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

Open
#382 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
hpc

Research direction

Start at the get_device_type function shown in the issue and compare its return mapping with the AFCL_DEVICE_TYPE_UNKNOWN value and cl-sys DeviceType definitions linked in the report. Confirm the intended handling of the ArrayFire unknown value and verify that it no longer reports DeviceType::ALL.

Written by the indexing model from the issue text.

Description

Bug

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

Dominant language
Rust
Stars
827
Forks
59
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from arrayfire/arrayfire-rust

All issues in arrayfire/arrayfire-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.