diff --git a/examples/unified.rs b/examples/unified.rs index e70aa5d6..5fa69b87 100644 --- a/examples/unified.rs +++ b/examples/unified.rs @@ -47,6 +47,13 @@ fn main() { test_backend(); } + if available.contains(&Backend::ONEAPI) { + println!("Evaluating OneAPI Backend..."); + set_backend(Backend::ONEAPI); + println!("There are {} OneAPI compute devices", device_count()); + test_backend(); + } + if available.contains(&Backend::OPENCL) { println!("Evaluating OpenCL Backend..."); set_backend(Backend::OPENCL); diff --git a/src/core/array.rs b/src/core/array.rs index 7ee6579b..a444c0cd 100644 --- a/src/core/array.rs +++ b/src/core/array.rs @@ -398,7 +398,8 @@ where match (err_val, ret_val) { (0, 1) => Backend::CPU, (0, 2) => Backend::CUDA, - (0, 3) => Backend::OPENCL, + (0, 4) => Backend::OPENCL, + (0, 8) => Backend::ONEAPI, _ => Backend::DEFAULT, } } diff --git a/src/core/backend.rs b/src/core/backend.rs index 2cc3749f..eb1fbb62 100644 --- a/src/core/backend.rs +++ b/src/core/backend.rs @@ -35,6 +35,9 @@ pub fn get_available_backends() -> Vec { HANDLE_ERROR(AfError::from(err_val)); let mut b = Vec::new(); + if temp & 0b1000 == 0b1000 { + b.push(Backend::ONEAPI); + } if temp & 0b0100 == 0b0100 { b.push(Backend::OPENCL); } @@ -58,6 +61,7 @@ pub fn get_active_backend() -> Backend { (0, 1) => Backend::CPU, (0, 2) => Backend::CUDA, (0, 4) => Backend::OPENCL, + (0, 8) => Backend::ONEAPI, _ => panic!("Invalid backend retrieved, undefined behavior."), } } diff --git a/src/core/defines.rs b/src/core/defines.rs index b1166279..ffe27dc5 100644 --- a/src/core/defines.rs +++ b/src/core/defines.rs @@ -66,11 +66,14 @@ pub enum Backend { CUDA = 2, /// OpenCL Compute Backend OPENCL = 4, + /// OneAPI Compute Backend + ONEAPI = 8, } impl Display for Backend { fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> { let text = match *self { + Backend::ONEAPI => "OneAPI", Backend::OPENCL => "OpenCL", Backend::CUDA => "Cuda", Backend::CPU => "CPU",