match_dtype_to_c_struct does not work if struct has arrays as fields
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 247
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 6
Description
E.g. say that a kernel has this struct as an argument, with 2 arrays:
```C
typedef struct {
uint x[2];
float y;
uint z[3];
} my_struct;
```
I can not find a way to turn this definition into a proper type for `PyOpenCL` to work with it. My attempt:
```
>>> type = np.dtype([('x', cltypes.uint, (2,)), ('y', cltypes.float), ('z', cltypes.uint, (3,))])
>>> type
dtype([('x', '>> my_type, my_struct_c_decl = cl.tools.match_dtype_to_c_struct(device, 't', my_type)
Traceback (most recent call last):
File ".../lib/python3.7/site-packages/pytools/__init__.py", line 536, in _deco
return func._memoize_dic[args] # pylint: disable=protected-access
AttributeError: 'function' object has no attribute '_memoize_dic'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../lib/python3.7/site-packages/pyopencl/compyte/dtypes.py", line 105, in dtype_to_ctype
return self.dtype_to_name[dtype]
KeyError: dtype(('", line 1, in
File "<.../lib/python3.7/site-packages/decorator.py:decorator-gen-3>", line 2, in match_dtype_to_c_struct
File ".../lib/python3.7/site-packages/pytools/__init__.py", line 539, in _deco
result = func(*args)
File ".../lib/python3.7/site-packages/pyopencl/tools.py", line 550, in match_dtype_to_c_struct
c_fields.append(" %s %s;" % (dtype_to_ctype(field_dtype), field_name))
File ".../lib/python3.7/site-packages/pyopencl/compyte/dtypes.py", line 107, in dtype_to_ctype
raise ValueError("unable to map dtype '%s'" % dtype)
ValueError: unable to map dtype '('>> t = np.dtype([('x', '>> t
dtype([('x', '>> t_c, t_c_decl = pyopencl.tools.match_dtype_to_c_struct(device, 't', t)
Traceback (most recent call last):
...
File "/home/sotiris/.local/lib/python3.7/site-packages/pyopencl/compyte/dtypes.py", line 107, in dtype_to_ctype
raise ValueError("unable to map dtype '%s'" % dtype)
ValueError: unable to map dtype '('
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.