Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] opencl-interop get_device_type always returns DeviceType::ALL #382

Open
nikhilr612 opened this issue Jan 27, 2025 · 0 comments
Open
Labels

Comments

@nikhilr612
Copy link

Description

The get_device_type function transmutes the value -1 into DeviceType or returns DeviceType::ALL; however, the enum variant that corresponds to the value (-1i32 as u64) is DeviceType::ALL. This does not seem to be the intended behaviour.

///// Fetch Active ArrayFire device's type i.e. CPU/GPU/Accelerator etc.
pub fn get_device_type() -> DeviceType {
    let mut out: i32 = 0;
    let err_val = unsafe { afcl_get_device_type(&mut out as *mut c_int) };
    handle_error_general(AfError::from(err_val));
    match out {
        -1 => unsafe { mem::transmute(out as u64) },
        _ => DeviceType::ALL,
    }
}

The value of -1 corresponds to AFCL_DEVICE_TYPE_UNKNOWN in arrayfire, whilst -1 corresponds to CL_DEVICE_TYPE_ALL in cl-sys

@nikhilr612 nikhilr612 added the Bug label Jan 27, 2025
nikhilr612 added a commit to nikhilr612/arrayfire-rust that referenced this issue Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant