arrayfire / arrayfire/arrayfire-rust

[BUG] `Array::get_backend()` can never return `OPENCL`

Open Beginner friendly
#387 0 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
Rust
Stars
827
Forks
59
PR merge metrics
No merged PRs in 30d

Description

[`src/core/array.rs:392-404`](https://github.com/arrayfire/arrayfire-rust/blob/master/src/core/array.rs#L392-L404):

```rust
match (err_val, ret_val) {
(0, 1) => Backend::CPU,
(0, 2) => Backend::CUDA,
(0, 3) => Backend::OPENCL,
_ => Backend::DEFAULT,
}
```

`af_backend` is a bit-flag enum, not sequential (`include/af/defines.h:414-417`, v3.8.0):

```c
AF_BACKEND_DEFAULT = 0,
AF_BACKEND_CPU = 1,
AF_BACKEND_CUDA = 2,
AF_BACKEND_OPENCL = 4
```

There is no backend with value 3. An OpenCL-created array returns 4, falls through to the wildcard, and is reported as `Backend::DEFAULT`.

**Fix:** `(0, 4) => Backend::OPENCL`.

---

Found by Claude Opus 5

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/core/array.rs:392-404 and compare the backend values in include/af/defines.h:414-417. Update the mapping so an OpenCL-created array is reported as Backend::OPENCL, then run the existing test suite or backend-related tests to verify the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.