From 5588ba4721c4cfdf703aa5289096fb3e998fe47f Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 25 Jun 2022 15:55:24 +0200 Subject: [PATCH 1/3] cargo: Create workspace and add all crates to it By creating a workspace various cargo commands go over every crate in this workspace instead of only looking at, linting, or formatting the root `ispc` crate (and any local crate that happens to be in its `[dependencies]`). --- Cargo.toml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6dd1f6b56..db50670ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ description = """ A build-time dependency for Cargo build scripts to help with compiling and linking to ISPC code and generating Rust bindings for the resulting library. This crate is a meta-crate for the ispc_compile and ispc_rt crates, which provide -the actual functionality for building ISPC code and generating bindgs, and +the actual functionality for building ISPC code and generating bindings, and importing those bindings into Rust. """ keywords = ["build-dependencies", "ispc", "simd"] @@ -20,12 +20,18 @@ exclude = [ ".travis.yml", "*.png", ".gitignore", - ".github", - "scripts/*", - "examples/*" + ".github", + "scripts/*", + "examples/*", ] [dependencies] ispc_compile = { path = "./compile/", version = "1.0.14" } ispc_rt = { path = "./runtime/", version = "1.0.7" } +[workspace] +members = [ + "compile", + "runtime", + "examples/*", +] From a3c4466d1d84de17b0b336a349173230026c318c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 25 Jun 2022 16:00:37 +0200 Subject: [PATCH 2/3] Run `cargo fmt` over the entire workspace --- runtime/src/exec.rs | 90 ++++++++++++++++++++++++--------- runtime/src/instrument.rs | 11 +++-- runtime/src/lib.rs | 101 +++++++++++++++++++++++--------------- runtime/src/task.rs | 97 +++++++++++++++++++++++++++--------- 4 files changed, 211 insertions(+), 88 deletions(-) diff --git a/runtime/src/exec.rs b/runtime/src/exec.rs index 4021be070..ac11db54b 100644 --- a/runtime/src/exec.rs +++ b/runtime/src/exec.rs @@ -4,13 +4,13 @@ use libc; use num_cpus; -use std::time::Duration; use std::cell::RefCell; -use std::sync::{Arc, RwLock, Mutex}; use std::sync::atomic::{self, AtomicUsize}; +use std::sync::{Arc, Mutex, RwLock}; use std::thread::{self, JoinHandle}; +use std::time::Duration; -use task::{ISPCTaskFn, Context}; +use task::{Context, ISPCTaskFn}; /// Trait to be implemented to provide ISPC task execution functionality. /// @@ -26,7 +26,12 @@ pub trait TaskSystem { /// The `handle_ptr` should be set to some context tracking facility so that you can later /// track task groups launched in the context and perform finer grained synchronization in /// `sync`. - unsafe fn alloc(&self, handle_ptr: *mut *mut libc::c_void, size: i64, align: i32) -> *mut libc::c_void; + unsafe fn alloc( + &self, + handle_ptr: *mut *mut libc::c_void, + size: i64, + align: i32, + ) -> *mut libc::c_void; /// Launch is called when a new group of tasks is being launched and should schedule them to /// be executed in some way. /// @@ -50,8 +55,15 @@ pub trait TaskSystem { /// } /// } /// ``` - unsafe fn launch(&self, handle_ptr: *mut *mut libc::c_void, f: ISPCTaskFn, data: *mut libc::c_void, - count0: i32, count1: i32, count2: i32); + unsafe fn launch( + &self, + handle_ptr: *mut *mut libc::c_void, + f: ISPCTaskFn, + data: *mut libc::c_void, + count0: i32, + count1: i32, + count2: i32, + ); /// Synchronize an execution context with the tasks it's launched. Use `handle` to determine /// the task context that's being synchronized. /// @@ -77,15 +89,19 @@ pub struct Parallel { impl Parallel { /// Create a parallel task execution environment that will use `num_cpus` threads /// to run tasks. - pub fn new() -> Arc { Parallel::oversubscribed(1.0) } + pub fn new() -> Arc { + Parallel::oversubscribed(1.0) + } /// Create an oversubscribued parallel task execution environment that will use /// `oversubscribe * num_cpus` threads to run tasks. pub fn oversubscribed(oversubscribe: f32) -> Arc { assert!(oversubscribe >= 1.0); - let par = Arc::new(Parallel { context_list: RwLock::new(Vec::new()), - next_context_id: AtomicUsize::new(0), - threads: Mutex::new(Vec::new()), - chunk_size: 8 }); + let par = Arc::new(Parallel { + context_list: RwLock::new(Vec::new()), + next_context_id: AtomicUsize::new(0), + threads: Mutex::new(Vec::new()), + chunk_size: 8, + }); { let mut threads = par.threads.lock().unwrap(); let num_threads = (oversubscribe * num_cpus::get() as f32) as usize; @@ -93,8 +109,9 @@ impl Parallel { for i in 0..num_threads { let task_sys = Arc::clone(&par); // Note that the spawned thread ids start at 1 since the main thread is 0 - threads.push(thread::spawn(move || Parallel::worker_thread(task_sys, i + 1, num_threads + 1, - chunk_size))); + threads.push(thread::spawn(move || { + Parallel::worker_thread(task_sys, i + 1, num_threads + 1, chunk_size) + })); } } par @@ -105,9 +122,19 @@ impl Parallel { /// Note that due to threading issues you shouldn't assume the context returned actually has /// outstanding tasks by the time it's returned to the caller and a chunk is requested. fn get_context(&self) -> Option> { - self.context_list.read().unwrap().iter().find(|c| !c.current_tasks_done()).cloned() + self.context_list + .read() + .unwrap() + .iter() + .find(|c| !c.current_tasks_done()) + .cloned() } - fn worker_thread(task_sys: Arc, thread: usize, total_threads: usize, chunk_size: usize) { + fn worker_thread( + task_sys: Arc, + thread: usize, + total_threads: usize, + chunk_size: usize, + ) { THREAD_ID.with(|f| *f.borrow_mut() = thread); loop { // Get a task group to run @@ -129,7 +156,12 @@ impl Parallel { } impl TaskSystem for Parallel { - unsafe fn alloc(&self, handle_ptr: *mut *mut libc::c_void, size: i64, align: i32) -> *mut libc::c_void { + unsafe fn alloc( + &self, + handle_ptr: *mut *mut libc::c_void, + size: i64, + align: i32, + ) -> *mut libc::c_void { // If the handle is null this is the first time this function has spawned tasks // and we should create a new Context structure in the TASK_LIST for it, otherwise // it's the pointer to where we should append the new Group @@ -139,7 +171,9 @@ impl TaskSystem for Parallel { // unbox it into a raw ptr to get a ptr we can pass back to ISPC through // the handle_ptr and then re-box it into our TASK_LIST so it will // be free'd properly when we erase it from the vector in ISPCSync - let c = Arc::new(Context::new(self.next_context_id.fetch_add(1, atomic::Ordering::SeqCst))); + let c = Arc::new(Context::new( + self.next_context_id.fetch_add(1, atomic::Ordering::SeqCst), + )); { let h = &*c; *handle_ptr = h as *const Context as *mut libc::c_void; @@ -150,12 +184,22 @@ impl TaskSystem for Parallel { } else { let context_list = self.context_list.read().unwrap(); let handle_ctx = *handle_ptr as *mut Context; - let ctx = context_list.iter().find(|c| (*handle_ctx).id == c.id).unwrap(); + let ctx = context_list + .iter() + .find(|c| (*handle_ctx).id == c.id) + .unwrap(); ctx.alloc(size as usize, align as usize) } } - unsafe fn launch(&self, handle_ptr: *mut *mut libc::c_void, f: ISPCTaskFn, data: *mut libc::c_void, - count0: i32, count1: i32, count2: i32) { + unsafe fn launch( + &self, + handle_ptr: *mut *mut libc::c_void, + f: ISPCTaskFn, + data: *mut libc::c_void, + count0: i32, + count1: i32, + count2: i32, + ) { // Push the tasks being launched on to the list of task groups for this function let context: &mut Context = &mut *(*handle_ptr as *mut Context); context.launch((count0, count1, count2), data, f); @@ -209,8 +253,10 @@ impl TaskSystem for Parallel { } // Now erase this context from our vector let mut context_list = self.context_list.write().unwrap(); - let pos = context_list.iter().position(|c| context.id == c.id).unwrap(); + let pos = context_list + .iter() + .position(|c| context.id == c.id) + .unwrap(); context_list.remove(pos); } } - diff --git a/runtime/src/instrument.rs b/runtime/src/instrument.rs index ab419cb60..6987f150b 100644 --- a/runtime/src/instrument.rs +++ b/runtime/src/instrument.rs @@ -22,9 +22,14 @@ pub struct SimpleInstrument; impl Instrument for SimpleInstrument { fn instrument(&self, file: &CStr, note: &CStr, line: i32, mask: u64, active_count: u32) { - println!("SimpleInstrument:\n\tFile: {}\n\tNote: {}\ + println!( + "SimpleInstrument:\n\tFile: {}\n\tNote: {}\ \n\tLine: {}\n\tActive: {}\nt\tMask: 0x{:x}", - file.to_str().unwrap(), note.to_str().unwrap(), line, active_count, mask); + file.to_str().unwrap(), + note.to_str().unwrap(), + line, + active_count, + mask + ); } } - diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index db29ed91f..da7da64b9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -13,19 +13,19 @@ extern crate libc; extern crate num_cpus; -pub mod task; pub mod exec; pub mod instrument; +pub mod task; -use std::mem; use std::env; -use std::sync::{Once, Arc}; use std::ffi::CStr; +use std::mem; use std::path::{Path, PathBuf}; +use std::sync::{Arc, Once}; -pub use task::ISPCTaskFn; -pub use exec::{TaskSystem, Parallel}; +pub use exec::{Parallel, TaskSystem}; pub use instrument::{Instrument, SimpleInstrument}; +pub use task::ISPCTaskFn; /// Convenience macro for generating the module to hold the raw/unsafe ISPC bindings. /// @@ -44,9 +44,9 @@ pub use instrument::{Instrument, SimpleInstrument}; /// ``` #[macro_export] macro_rules! ispc_module { - ($lib:ident) => ( + ($lib:ident) => { include!(concat!(env!("ISPC_OUT_DIR"), "/", stringify!($lib), ".rs")); - ) + }; } /// A `PackagedModule` refers to an ISPC module which was previously @@ -63,7 +63,10 @@ impl PackagedModule { /// have any prefix or suffix. For example, instead of `libexample.a` or /// `example.lib`, simple pass `example` pub fn new(lib: &str) -> PackagedModule { - PackagedModule {path: None, lib: lib.to_owned()} + PackagedModule { + path: None, + lib: lib.to_owned(), + } } /// Specify the path to search for the packaged ISPC libraries and bindings pub fn lib_path>(&mut self, path: P) -> &mut PackagedModule { @@ -75,19 +78,26 @@ impl PackagedModule { let path = self.get_lib_path(); let libfile = self.lib.clone() + &env::var("TARGET").unwrap(); let bindgen_file = self.lib.clone() + ".rs"; - + println!("cargo:rustc-link-lib=static={}", libfile); - println!("cargo:rerun-if-changed={}", path.join(get_lib_filename(&libfile)).display()); - println!("cargo:rerun-if-changed={}", path.join(bindgen_file).display()); + println!( + "cargo:rerun-if-changed={}", + path.join(get_lib_filename(&libfile)).display() + ); + println!( + "cargo:rerun-if-changed={}", + path.join(bindgen_file).display() + ); println!("cargo:rustc-link-search=native={}", path.display()); println!("cargo:rustc-env=ISPC_OUT_DIR={}", path.display()); } /// Returns the user-set output directory if they've set one, otherwise /// returns env("OUT_DIR") fn get_lib_path(&self) -> PathBuf { - let p = self.path.clone().unwrap_or_else(|| { - env::var_os("OUT_DIR").map(PathBuf::from).unwrap() - }); + let p = self + .path + .clone() + .unwrap_or_else(|| env::var_os("OUT_DIR").map(PathBuf::from).unwrap()); if p.is_relative() { env::current_dir().unwrap().join(p) } else { @@ -133,13 +143,11 @@ fn get_task_system() -> &'static dyn TaskSystem { // TODO: This is a bit nasty, but I'm not sure on a nicer solution. Maybe something that // would let the user register the desired (or default) task system? But if // mutable statics can't have destructors we still couldn't have an Arc or Box to something? - TASK_INIT.call_once(|| { - unsafe { - let task_sys = Parallel::new() as Arc; - let s = &*task_sys as *const (dyn TaskSystem + 'static); - mem::forget(task_sys); - TASK_SYSTEM = Some(&*s); - } + TASK_INIT.call_once(|| unsafe { + let task_sys = Parallel::new() as Arc; + let s = &*task_sys as *const (dyn TaskSystem + 'static); + mem::forget(task_sys); + TASK_SYSTEM = Some(&*s); }); unsafe { TASK_SYSTEM.unwrap() } } @@ -168,13 +176,11 @@ pub fn print_instrumenting_summary() { fn get_instrument() -> &'static dyn Instrument { // TODO: This is a bit nasty, like above - INSTRUMENT_INIT.call_once(|| { - unsafe { - let instrument = Arc::new(SimpleInstrument) as Arc; - let s = &*instrument as *const (dyn Instrument + 'static); - mem::forget(instrument); - INSTRUMENT = Some(&*s); - } + INSTRUMENT_INIT.call_once(|| unsafe { + let instrument = Arc::new(SimpleInstrument) as Arc; + let s = &*instrument as *const (dyn Instrument + 'static); + mem::forget(instrument); + INSTRUMENT = Some(&*s); }); unsafe { INSTRUMENT.unwrap() } } @@ -182,37 +188,54 @@ fn get_instrument() -> &'static dyn Instrument { #[allow(non_snake_case)] #[doc(hidden)] #[no_mangle] -pub unsafe extern "C" fn ISPCAlloc(handle_ptr: *mut *mut libc::c_void, size: i64, - align: i32) -> *mut libc::c_void { +pub unsafe extern "C" fn ISPCAlloc( + handle_ptr: *mut *mut libc::c_void, + size: i64, + align: i32, +) -> *mut libc::c_void { get_task_system().alloc(handle_ptr, size, align) } #[allow(non_snake_case)] #[doc(hidden)] #[no_mangle] -pub unsafe extern "C" fn ISPCLaunch(handle_ptr: *mut *mut libc::c_void, f: *mut libc::c_void, - data: *mut libc::c_void, count0: libc::c_int, - count1: libc::c_int, count2: libc::c_int) { +pub unsafe extern "C" fn ISPCLaunch( + handle_ptr: *mut *mut libc::c_void, + f: *mut libc::c_void, + data: *mut libc::c_void, + count0: libc::c_int, + count1: libc::c_int, + count2: libc::c_int, +) { let task_fn: ISPCTaskFn = mem::transmute(f); - get_task_system().launch(handle_ptr, task_fn, data, count0 as i32, count1 as i32, count2 as i32); + get_task_system().launch( + handle_ptr, + task_fn, + data, + count0 as i32, + count1 as i32, + count2 as i32, + ); } #[allow(non_snake_case)] #[doc(hidden)] #[no_mangle] -pub unsafe extern "C" fn ISPCSync(handle: *mut libc::c_void){ +pub unsafe extern "C" fn ISPCSync(handle: *mut libc::c_void) { get_task_system().sync(handle); } #[allow(non_snake_case)] #[doc(hidden)] #[no_mangle] -pub unsafe extern "C" fn ISPCInstrument(cfile: *const libc::c_char, cnote: *const libc::c_char, - line: libc::c_int, mask: u64) { - +pub unsafe extern "C" fn ISPCInstrument( + cfile: *const libc::c_char, + cnote: *const libc::c_char, + line: libc::c_int, + mask: u64, +) { let file_name = CStr::from_ptr(cfile); let note = CStr::from_ptr(cnote); let active_count = (mask as u64).count_ones(); get_instrument().instrument(file_name, note, line as i32, mask as u64, active_count); } - diff --git a/runtime/src/task.rs b/runtime/src/task.rs index 6b63f0ef4..476edd517 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -5,8 +5,8 @@ use libc; use std::cmp; use std::iter::Iterator; -use std::sync::{Mutex, RwLock, Arc}; -use std::sync::atomic::{self, AtomicUsize, AtomicPtr}; +use std::sync::atomic::{self, AtomicPtr, AtomicUsize}; +use std::sync::{Arc, Mutex, RwLock}; /// A pointer to an ISPC task function. /// @@ -17,10 +17,19 @@ use std::sync::atomic::{self, AtomicUsize, AtomicPtr}; /// int taskIndex0, int taskIndex1, int taskIndex2, /// int taskCount0, int taskCount1, int taskCount2); /// ``` -pub type ISPCTaskFn = extern "C" fn(data: *mut libc::c_void, thread_idx: libc::c_int, thread_cnt: libc::c_int, - task_idx: libc::c_int, task_cnt: libc::c_int, task_idx0: libc::c_int, - task_idx1: libc::c_int, task_idx2: libc::c_int, task_cnt0: libc::c_int, - task_cnt1: libc::c_int, task_cnt2: libc::c_int); +pub type ISPCTaskFn = extern "C" fn( + data: *mut libc::c_void, + thread_idx: libc::c_int, + thread_cnt: libc::c_int, + task_idx: libc::c_int, + task_cnt: libc::c_int, + task_idx0: libc::c_int, + task_idx1: libc::c_int, + task_idx2: libc::c_int, + task_cnt0: libc::c_int, + task_cnt1: libc::c_int, + task_cnt2: libc::c_int, +); /// A list of all task groups spawned by a function in some launch context which /// will be sync'd at an explicit `sync` call or function exit. @@ -53,11 +62,18 @@ pub struct Context { impl Context { /// Create a new list of tasks for some function with id `id` pub fn new(id: usize) -> Context { - Context { tasks: RwLock::new(Vec::new()), mem: Mutex::new(Vec::new()), id } + Context { + tasks: RwLock::new(Vec::new()), + mem: Mutex::new(Vec::new()), + id, + } } /// Add a task group for execution that was launched in this context pub fn launch(&self, total: (i32, i32, i32), data: *mut libc::c_void, fcn: ISPCTaskFn) { - self.tasks.write().unwrap().push(Arc::new(Group::new(total, AtomicPtr::new(data), fcn))); + self.tasks + .write() + .unwrap() + .push(Arc::new(Group::new(total, AtomicPtr::new(data), fcn))); } /// Check if all tasks currently in the task list are completed /// @@ -177,13 +193,22 @@ pub struct Group { impl Group { /// Create a new task group for execution of the function pub fn new(total: (i32, i32, i32), data: AtomicPtr, fcn: ISPCTaskFn) -> Group { - Group { start: AtomicUsize::new(0), end: (total.0 * total.1 * total.2) as usize, - total, data, fcn, - chunks_launched: AtomicUsize::new(0), chunks_finished: AtomicUsize::new(0) } + Group { + start: AtomicUsize::new(0), + end: (total.0 * total.1 * total.2) as usize, + total, + data, + fcn, + chunks_launched: AtomicUsize::new(0), + chunks_finished: AtomicUsize::new(0), + } } /// Get an iterator over `chunk_size` chunks of tasks to be executed for this group pub fn chunks(&self, chunk_size: usize) -> GroupChunks { - GroupChunks { group: self, chunk_size } + GroupChunks { + group: self, + chunk_size, + } } /// Check if all tasks for this group have been completed pub fn is_finished(&self) -> bool { @@ -206,10 +231,16 @@ impl Group { /// you get is the last chunk to be executed (`chunk.end == total.0 * total.1 * total.2`) /// you must mark this group as finished upon completing execution of the chunk fn get_chunk(&self, desired_tasks: usize) -> Option { - let start = self.start.fetch_add(desired_tasks, atomic::Ordering::SeqCst); + let start = self + .start + .fetch_add(desired_tasks, atomic::Ordering::SeqCst); if start < self.end { // Give the chunk 4 tasks or whatever remain - let c = Some(Chunk::new(self, start, cmp::min(start + desired_tasks, self.end))); + let c = Some(Chunk::new( + self, + start, + cmp::min(start + desired_tasks, self.end), + )); self.chunks_launched.fetch_add(1, atomic::Ordering::SeqCst); c } else { @@ -256,8 +287,13 @@ impl<'a> Chunk<'a> { /// Create a new chunk to execute tasks in the group from [start, end) pub fn new(group: &'a Group, start: usize, end: usize) -> Chunk { let d = AtomicPtr::new(group.data.load(atomic::Ordering::SeqCst)); - Chunk { start: start as i32, end: end as i32, total: group.total, - fcn: group.fcn, data: d, group + Chunk { + start: start as i32, + end: end as i32, + total: group.total, + fcn: group.fcn, + data: d, + group, } } /// Execute all tasks in this chunk @@ -266,18 +302,31 @@ impl<'a> Chunk<'a> { let data = self.data.load(atomic::Ordering::SeqCst); for t in self.start..self.end { let id = self.task_indices(t); - (self.fcn)(data, thread_id as libc::c_int, total_threads as libc::c_int, - t as libc::c_int, total_tasks as libc::c_int, - id.0 as libc::c_int, id.1 as libc::c_int, id.2 as libc::c_int, - self.total.0 as libc::c_int, self.total.1 as libc::c_int, - self.total.2 as libc::c_int); + (self.fcn)( + data, + thread_id as libc::c_int, + total_threads as libc::c_int, + t as libc::c_int, + total_tasks as libc::c_int, + id.0 as libc::c_int, + id.1 as libc::c_int, + id.2 as libc::c_int, + self.total.0 as libc::c_int, + self.total.1 as libc::c_int, + self.total.2 as libc::c_int, + ); } // Tell the group this chunk is done - self.group.chunks_finished.fetch_add(1, atomic::Ordering::SeqCst); + self.group + .chunks_finished + .fetch_add(1, atomic::Ordering::SeqCst); } /// Get the global task id for the task index fn task_indices(&self, id: i32) -> (i32, i32, i32) { - (id % self.total.0, (id / self.total.0) % self.total.1, id / (self.total.0 * self.total.1)) + ( + id % self.total.0, + (id / self.total.0) % self.total.1, + id / (self.total.0 * self.total.1), + ) } } - From 67dd87335d62d3682c30c06fdc31f0a48d611f7c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 27 Jun 2022 22:36:07 +0200 Subject: [PATCH 3/3] Remove unneeded CI scripts now that all crates reside in the workspace Note that these script didn't include the `compile` and `runtime` subcrates, which were also missing from the workspace hence never checked for formatting either. --- .github/workflows/main.yml | 34 ++++++++++++---------------- Cargo.toml | 1 + compile/Cargo.toml | 4 ++-- runtime/Cargo.toml | 4 ++-- scripts/build-examples-linux.sh | 18 --------------- scripts/build-test-windows.ps1 | 33 --------------------------- scripts/check-examples-formatting.sh | 14 ------------ 7 files changed, 20 insertions(+), 88 deletions(-) delete mode 100755 scripts/build-examples-linux.sh delete mode 100644 scripts/build-test-windows.ps1 delete mode 100755 scripts/check-examples-formatting.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6a4b6fe51..85cfc137e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,17 +11,15 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable - - run: wget -O ispc.tar.gz https://github.com/ispc/ispc/releases/download/v${ISPC_VERSION}/ispc-v${ISPC_VERSION}-linux.tar.gz - - run: tar -xf ispc.tar.gz - - run: echo "PATH=$PATH:`pwd`/ispc-v${ISPC_VERSION}-linux/bin/" >> $GITHUB_ENV - - run: cargo build - - run: cargo test - - run: cargo doc - - run: scripts/build-examples-linux.sh + - run: curl -L https://github.com/ispc/ispc/releases/download/v${{ env.ISPC_VERSION }}/ispc-v${{ env.ISPC_VERSION }}-linux.tar.gz | tar xzv ispc-v${{ env.ISPC_VERSION }}-linux/bin/ispc + - run: realpath "ispc-v${{ env.ISPC_VERSION }}-linux/bin/" >> $GITHUB_PATH + - run: cargo build --all --all-targets --features ispc + - run: cargo test --all + - run: cargo doc --all --no-deps --document-private-items --all-features + env: + RUSTDOCFLAGS: -Dwarnings - name: Format Core run: cargo fmt -- --check - - name: Format Examples - run: scripts/check-examples-formatting.sh build_mac: runs-on: macos-latest steps: @@ -30,9 +28,8 @@ jobs: with: toolchain: stable - run: brew install ispc - - run: cargo build - - run: cargo test - - run: scripts/build-examples-linux.sh + - run: cargo build --all --all-targets --features ispc + - run: cargo test --all build_windows: runs-on: windows-latest steps: @@ -40,10 +37,9 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable - - run: choco install wget - - run: wget -O LLVM-11.0.0.7z https://www.dl.dropboxusercontent.com/s/vontvxjexyk417e/LLVM-11.0.0.7z - - run: 7z x LLVM-11.0.0.7z -y; - - run: wget -O ispc.zip https://github.com/ispc/ispc/releases/download/v${env:ISPC_VERSION}/ispc-v${env:ISPC_VERSION}-windows.zip - - run: 7z x ispc.zip -y -o"ispc" - - run: scripts/build-test-windows.ps1 - + - run: | + curl -LO https://github.com/ispc/ispc/releases/download/v${{ env.ISPC_VERSION }}/ispc-v${{ env.ISPC_VERSION }}-windows.zip + unzip ispc-v${{ env.ISPC_VERSION }}-windows.zip bin/ispc.exe + Resolve-Path "./bin" | Add-Content -Path $env:GITHUB_PATH + - run: cargo build --all --all-targets --features ispc + - run: cargo test --all diff --git a/Cargo.toml b/Cargo.toml index db50670ca..3262e2ff9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ ispc_compile = { path = "./compile/", version = "1.0.14" } ispc_rt = { path = "./runtime/", version = "1.0.7" } [workspace] +resolver = "2" members = [ "compile", "runtime", diff --git a/compile/Cargo.toml b/compile/Cargo.toml index faaf16eff..ce1603826 100644 --- a/compile/Cargo.toml +++ b/compile/Cargo.toml @@ -21,8 +21,8 @@ exclude = [ ".travis.yml", "*.png", ".gitignore", - ".github", - "scripts/*", + ".github", + "scripts/*", "examples/*" ] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index a3bf02997..fe18088fd 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -18,8 +18,8 @@ exclude = [ ".travis.yml", "*.png", ".gitignore", - ".github", - "scripts/*", + ".github", + "scripts/*", "examples/*" ] diff --git a/scripts/build-examples-linux.sh b/scripts/build-examples-linux.sh deleted file mode 100755 index 17f6588b5..000000000 --- a/scripts/build-examples-linux.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# build the examples -cd examples -for d in `ls ./`; do - cd $d - pwd - if [[ "$d" == "simple" ]]; then - cargo build --features ispc - fi - - cargo build - if [[ "$?" != "0" ]]; then - exit 1 - fi - cd ../ -done - diff --git a/scripts/build-test-windows.ps1 b/scripts/build-test-windows.ps1 deleted file mode 100644 index 08c6e6081..000000000 --- a/scripts/build-test-windows.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -$env:WORK_DIR=(get-location) -$env:LIBCLANG_PATH="${env:WORK_DIR}\LLVM-11.0.0\" -$env:PATH+=";${env:WORK_DIR}\ispc\bin\;${env:LIBCLANG_PATH}" - -Write-Output "Building ispc-rs" -cargo build -if (!$?) { - exit 1 -} - -Write-Output "Running ispc-rs Tests" -cargo test -if (!$?) { - exit 1 -} - -# build the examples -cd examples -Get-ChildItem .\ -Directory | ForEach-Object { - cd $_ - Write-Output $_ - $dirname = $_ | Split-Path -Leaf - if ($dirname -eq "simple") { - cargo build --features ispc - } - - cargo build - if (!$?) { - exit 1 - } - cd .. -} - diff --git a/scripts/check-examples-formatting.sh b/scripts/check-examples-formatting.sh deleted file mode 100755 index c623168b0..000000000 --- a/scripts/check-examples-formatting.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# build the examples -cd examples -for d in `ls ./`; do - cd $d - pwd - cargo fmt -- --check - if [[ "$?" != "0" ]]; then - exit 1 - fi - cd ../ -done -