arrayfire / arrayfire/arrayfire-rust

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

未关闭
#382 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Bug
主要语言
Rust
星标
827
派生
59
PR 合并指标
30 天内没有已合并 PR

描述

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_](https://docs.rs/cl-sys/latest/src/cl_sys/cl_h.rs.html#216) `DeviceType::ALL`. This does not seem to be the intended behaviour.
```rust
///// 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`

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。