diff --git a/Cargo.lock b/Cargo.lock index 59355a5c..f0567540 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -127,7 +127,7 @@ dependencies = [ name = "em" version = "0.3.0" dependencies = [ - "emu_macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "emu_macro 0.1.0", "ocl 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -141,16 +141,6 @@ dependencies = [ "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "emu_macro" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "emu_tests" version = "0.1.0" @@ -622,7 +612,6 @@ dependencies = [ "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -"checksum emu_macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6848641fc2fc74ae85123d7aa6eab124cbd7079f49dfd637d443263bc9d74b6d" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" diff --git a/em/Cargo.toml b/em/Cargo.toml index 2b4dde95..8ca71ee5 100644 --- a/em/Cargo.toml +++ b/em/Cargo.toml @@ -16,4 +16,4 @@ edition = "2018" [dependencies] ocl = "0.19.3" -emu_macro = "0.1.0" \ No newline at end of file +emu_macro = { path = "../emu_macro" } \ No newline at end of file diff --git a/em/src/lib.rs b/em/src/lib.rs index 2749fbb1..35fe9072 100644 --- a/em/src/lib.rs +++ b/em/src/lib.rs @@ -144,10 +144,10 @@ macro_rules! get_buffer_key { /// 3. Launching on the GPU with `gpu_do!(launch())` /// /// Note that data must be an identifier. The only hard requirement for data is -/// that it must have the 2 following methods. +/// that it must have the 2 following methods. /// - `fn as_slice(&self) -> &[f32]` /// - `fn as_mut_slice(&mut self) -> &mut [f32]` -/// +/// /// There is a soft requirement that the data should be representing a list of /// `f32`s and indexing it with `data[i]` should return an `f32`. But this is /// really just to ensure that when we lift code from CPU to GPU it is diff --git a/emu_examples/arithmetic/src/main.rs b/emu_examples/arithmetic/src/main.rs index 69c276d2..45e91d6a 100644 --- a/emu_examples/arithmetic/src/main.rs +++ b/emu_examples/arithmetic/src/main.rs @@ -25,9 +25,8 @@ fn main() { // for (i, chunk) in x.chunks(10).enumerate() { // let mut scratch = vec![0.0; 10]; // for (j, _) in chunk.enumerate() { - + // } // } - -// } \ No newline at end of file +// } diff --git a/emu_macro/Cargo.toml b/emu_macro/Cargo.toml index 74b314cb..97917a6d 100644 --- a/emu_macro/Cargo.toml +++ b/emu_macro/Cargo.toml @@ -16,11 +16,11 @@ edition = "2018" [dependencies] proc-macro2 = "0.4.30" -syn = { version = "1.0.5", features = ["full", "visit", "fold"] } -quote = "1.0.2" +syn = { version = "=1.0.5", features = ["full", "visit", "fold"] } +quote = "^1.0.3" [dev-dependencies] em = { path = "../em", version = "0.*" } [lib] -proc-macro = true \ No newline at end of file +proc-macro = true diff --git a/emu_macro/src/accelerating.rs b/emu_macro/src/accelerating.rs index 9b34956f..dd33b526 100644 --- a/emu_macro/src/accelerating.rs +++ b/emu_macro/src/accelerating.rs @@ -13,9 +13,9 @@ use syn::visit::Visit; use syn::*; // for etc.use crate::generator::Generator; +use crate::generator::Generator; use crate::identifier::get_global_work_size; use crate::identifier::Dim; -use crate::generator::Generator; // there is passing // then there is accelerating @@ -120,7 +120,7 @@ impl Fold for Accelerator { // is it load? read? launch? if path .path - .is_ident(&Ident::new("load", quote::__rt::Span::call_site())) + .is_ident(&Ident::new("load", quote::__private::Span::call_site())) { let new_code = quote! { { @@ -166,7 +166,7 @@ impl Fold for Accelerator { new_ast } else if path .path - .is_ident(&Ident::new("read", quote::__rt::Span::call_site())) + .is_ident(&Ident::new("read", quote::__private::Span::call_site())) { let new_code = quote! { { @@ -190,7 +190,7 @@ impl Fold for Accelerator { new_ast } else if path .path - .is_ident(&Ident::new("launch", quote::__rt::Span::call_site())) + .is_ident(&Ident::new("launch", quote::__private::Span::call_site())) { self.ready_to_launch = true; @@ -256,7 +256,7 @@ impl Fold for Accelerator { // (b) generate arguments let args = code_generator.params.iter().map(|param| { - let ident = Ident::new(¶m.name, quote::__rt::Span::call_site()); + let ident = Ident::new(¶m.name, quote::__private::Span::call_site()); let ident_literal = ident.to_string().clone(); if param.is_array { diff --git a/emu_macro/src/lib.rs b/emu_macro/src/lib.rs index 51e4cfa7..9dec30d5 100644 --- a/emu_macro/src/lib.rs +++ b/emu_macro/src/lib.rs @@ -16,11 +16,11 @@ use syn::fold::Fold; use syn::*; // THE TABLE OF CONTENTS -// +// // these modules are the main modules Emu uses mod accelerating; // for looking through code for gpu_do!() and using the GPU appropriately mod passing; // for passing around a reference to the GPU from function to function -// these modules are more linke utilities for Emu + // these modules are more linke utilities for Emu mod generator; // for generating OpenCL from Rust mod identifier; // for identifying a for loop as potentially something we can work with mod inspector; // for inspecting a function for more info diff --git a/emu_macro/src/passing.rs b/emu_macro/src/passing.rs index b2f0fa5c..de3b0c14 100644 --- a/emu_macro/src/passing.rs +++ b/emu_macro/src/passing.rs @@ -236,9 +236,7 @@ impl Fold for HelperFunctionReturnModifier { // modifies return statements // this mainly just creates an instance of the above "folder" that we defined // we then just invoke it's "fold_item_fn" method to fold on the function -pub fn modify_returns_for_helper_function( - input: TokenStream, -) -> Result> { +pub fn modify_returns_for_helper_function(input: TokenStream) -> Result> { // parse into function let maybe_ast = syn::parse::(input.clone()); @@ -340,8 +338,9 @@ impl Fold for HelperFunctionInvocationModifier { } if is_helper_function_invocation { - let gpu_ident = quote! {gpu}.into(); - i.args.insert(0, gpu_ident); + let gpu_ident = syn::Ident::new("gpu", syn::export::Span::call_site()); + i.args + .insert(0, syn::Expr::Verbatim(gpu_ident.to_token_stream())); let new_code = quote! { {