8000 First set of changes to enable OneAPI backend by 9prady9 · Pull Request #379 · arrayfire/arrayfire-rust · GitHub
[go: up one dir, main page]

Skip to content

First set of changes to enable OneAPI backend #379

New issue
Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/unified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Dow 10000 n
3 changes: 2 additions & 1 deletion src/core/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ pub fn get_available_backends() -> Vec<Backend> {
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);
}
Expand All @@ -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."),
}
}
3 changes: 3 additions & 0 deletions src/core/defines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
0