calebwin / emu

The write-once-run-anywhere GPGPU library for Rust
https://calebwin.github.io/emu
MIT License
1.59k stars 53 forks source link

OS X example build failed #27

Closed MrRobb closed 4 years ago

MrRobb commented 4 years ago

Hello, I am trying the example:

#[macro_use]
extern crate em;
use em::*;

#[gpu_use]
fn main() {
    let mut x = vec![0.0; 1000];

    gpu_do!(load(x)); // move data to the GPU

    gpu_do!(launch()); // off-load to run on the GPU

    for i in 0..1000 {
        x[i] = x[i] * 10.0;
    }

    gpu_do!(read(x)); // move data back from the GPU

    println!("{:?}", x);
}

Here's the error.

   ...
   Compiling emu_macro v0.1.0
error[E0277]: the trait bound `syn::Expr: std::convert::From<quote::__rt::TokenStream>` is not satisfied
   --> /Users/mrrobb/.cargo/registry/src/github.com-1ecc6299db9ec823/emu_macro-0.1.0/src/passing.rs:337:50
    |
337 |                     let gpu_ident = quote! {gpu}.into();
    |                                                  ^^^^ the trait `std::convert::From<quote::__rt::TokenStream>` is not implemented for `syn::Expr`
    |
    = help: the following implementations were found:
              <syn::Expr as std::convert::From<syn::ExprArray>>
              <syn::Expr as std::convert::From<syn::ExprAssign>>
              <syn::Expr as std::convert::From<syn::ExprAssignOp>>
              <syn::Expr as std::convert::From<syn::ExprAsync>>
            and 35 others
    = note: required because of the requirements on the impl of `std::convert::Into<syn::Expr>` for `quote::__rt::TokenStream`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `emu_macro`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Am I doing something wrong? Thank you.

calebwin commented 4 years ago

Hi,

This is similar to the issue described here on the Gitter chat. The solution was updating Rust to latest version.

Let me know if that works for you!

Micael106 commented 4 years ago

the latest version of rust is 1.38.0? doens't work here, in macos high sierra.

Compiling emu_macro v0.1.0
error[E0277]: the trait bound `syn::Expr: std::convert::From<quote::__rt::TokenStream>` is not satisfied
   --> /Users/labmint2/.cargo/registry/src/github.com-1ecc6299db9ec823/emu_macro-0.1.0/src/passing.rs:337:50
    |
337 |                     let gpu_ident = quote! {gpu}.into();
    |                                                  ^^^^ the trait `std::convert::From<quote::__rt::TokenStream>` is not implemented for `syn::Expr`
    |
    = help: the following implementations were found:
              <syn::Expr as std::convert::From<syn::ExprArray>>
              <syn::Expr as std::convert::From<syn::ExprAssign>>
              <syn::Expr as std::convert::From<syn::ExprAssignOp>>
              <syn::Expr as std::convert::From<syn::ExprAsync>>
            and 35 others
    = note: required because of the requirements on the impl of `std::convert::Into<syn::Expr>` for `quote::__rt::TokenStream`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
calebwin commented 4 years ago

I've tried compiling on Windows and Linux on Rust 1.38.0 and build has been successful.

stable-x86_64-pc-windows-msvc unchanged - rustc 1.38.0 (625451e37 2019-09-23) stable-x86_64-unknown-linux-gnu updated - rustc 1.38.0 (625451e37 2019-09-23)

@MrRobb are you also on MacOS?

However, interestingly, when I look at the docs the error message seems correct. From<proc_macro2::TokenStream> is implemented but not From<quote::__rt::TokenStream>.

I'll try to switch to proc_macro2::TokenStream and see if that can be done without regression when I get a chance.

Micael106 commented 4 years ago

I tried several versions of rust and got the same error, older versions and nightly

calebwin commented 4 years ago

I've replicated the issue and I'm really not sure how to resolve it. Digging into quote source code, it seems like there is a runtime.rs module that makes a pub use proc_macro2::*. So somehow that seems to be creating 2 copies of proc_macro2 and that's causing type mismatch errors which the .into() then fails to convert into the correct type.

I don't actually have that much experience with Rust so it would be great if someone could git clone this, change em/Cargo.toml's emu_macro = 0.1.0 to emu_macro = { path = "../emu_macro" }, and try to fix the type mismatch error.

Or, if anyone has ideas for how to fix this, please let me know.

MrRobb commented 4 years ago

@calebwin I am using MacOS Catalina and Rust 1.38.0.

Micael106 commented 4 years ago

unfortunately I also know very little about rust to help solve, I started learning this week for a college GPU job. I will use version 0.2.0, which compiled here.

This version uses quote 0.6.13

calebwin commented 4 years ago

@MrRobb @Micael106 I think I fixed the issue; the fix is pushed to the dev branch.

Would you mind cloning it and testing it out? If it works fine, I will probably pull it into the master branch and then publish the fix.

Micael106 commented 4 years ago

it's working now. thank you! Screen Shot 2019-11-02 at 22 38 09

calebwin commented 4 years ago

Yay! I'll pull into master and publish an update when I get a chance.

jkelleyrtp commented 4 years ago

Not sure if you've had a chance to pull it in yet, just reporting in that the dev branch works but not master for me

calebwin commented 4 years ago

Yeah. The dev branch works but not the master. I haven't pulled in dev yet.

On Sun, Feb 2, 2020 at 8:07 PM Jonathan Kelley notifications@github.com wrote:

Not sure if you've had a chance to pull it in yet, just reporting in that the dev branch works but not master for me

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/calebwin/emu/issues/27?email_source=notifications&email_token=AE6H6FLECPHZIUBDQM5FH6DRA6KBLA5CNFSM4JF6BXN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKSNMUA#issuecomment-581228112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6H6FPUMLVIJVANW4QUWNTRA6KBLANCNFSM4JF6BXNQ .