inducer / inducer/pyopencl

Difference in behavior between PYOPENCL_CTX and PYOPENCL_TEST

Open
#781 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.2k
Forks
247
Avg merge
7h 2m
Merged PRs (30d)
6

Description

**Describe the bug**
Parsing of `PYOPENCL_CTX` and `PYOPENCL_TEST` is implemented differently, leading to a different selection behavior. An example is given below. #780 is another example.

**To Reproduce**

```console
$ clinfo -l
Platform #0: AMD Accelerated Parallel Processing
`-- Device #0: gfx90a:sramecc+:xnack-

$ PYOPENCL_TEST=AMD:90 python -c "import pyopencl; pyopencl.choose_devices()"
Traceback (most recent call last):
File "", line 1, in
File "/p/lustre1/diener3/Work/enew/pyopencl/pyopencl/__init__.py", line 1561, in choose_devices
for _plat, devs in get_test_platforms_and_devices():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/p/lustre1/diener3/Work/enew/pyopencl/pyopencl/tools.py", line 646, in get_test_platforms_and_devices
[find_cl_obj(devs, dev_id)
File "/p/lustre1/diener3/Work/enew/pyopencl/pyopencl/tools.py", line 646, in
[find_cl_obj(devs, dev_id)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/p/lustre1/diener3/Work/enew/pyopencl/pyopencl/tools.py", line 618, in find_cl_obj
return objs[num]
~~~~^^^^^
IndexError: list index out of range

$ PYOPENCL_CTX=AMD:90 python -c "import pyopencl; pyopencl.choose_devices()"
$ # works fine
```

**Expected behavior**
Having the same selection logic may be beneficial.

**Environment (please complete the following information):**
- OS: [e.g. Linux] Any
- ICD Loader and version: [e.g. ocl-icd 2.3.1] ocl-icd 2.3.2
- ICD and version: [e.g. pocl 1.8] Any
- CPU/GPU: [e.g. Nvidia Titan V] Any
- Python version: [e.g. 3.10] 3.11
- PyOpenCL version: [e.g. 2021.1] 2024.2.7

**Additional context**
Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.