numba-dpex
numba-dpex copied to clipboard
numba-dpex doesn't allow range multiplications inside NdRange
Below is a valid sycl code where we are allowed to multiply two sycl::range objects.
sycl::range<3> dimBlock(1, 1, BLOCK_SIZE);
sycl::range<3> dimGrid(1, 1, blockCols);
cgh.parallel_for(sycl::nd_range<3>(dimGrid * dimBlock, dimBlock), [=](sycl::nd_item<3> item_ct1) {}
dimBlock * dimGrid is expected to produce range object with dimensions (1, 1, blockCols* BLOCK_SIZE) in this case. However this isn't allowed in numba-dpex ndrange.
dimBlock = numba_dpex.Range(1,1,BLOCK_SIZE)
dimGrid = numba_dpex.Range(1,1,int(blockCols))
sample_kernel[numba_dpex.NdRange(dimGrid*dimBlock,dimBlock)]()
This throws an error:
TypeError: can't multiply sequence by non-int of type 'Range'
dimGrid and dimBlock are a Range objects, a Range is basically a tuple of ints., therefore you can't multiply two Ranges.
The Range and NdRange classes are defined here:
https://github.com/IntelPython/numba-dpex/blob/main/numba_dpex/core/kernel_interface/indexers.py
and to see how to use Range and NdRange, you can refer to these examples:
https://github.com/IntelPython/numba-dpex/blob/a92e9b37de455c21e6a0bf24aa3e03f0a839da82/numba_dpex/examples/kernel/matmul.py#L39
https://github.com/IntelPython/numba-dpex/blob/a92e9b37de455c21e6a0bf24aa3e03f0a839da82/numba_dpex/examples/kernel/pairwise_distance.py#L59
https://github.com/IntelPython/numba-dpex/blob/a92e9b37de455c21e6a0bf24aa3e03f0a839da82/numba_dpex/examples/kernel/interpolation.py#L123
In SYCL, two sycl::range objects can be multiplied. I think we can do something similar with Range/NdRange as well.
@roxx30198 could you please post a complete code?
Also what does the structure look like when you multiply two sycl::range objects?
It's a new feature that needs to be implemented.
In SYCL, two
sycl::rangeobjects can be multiplied. I think we can do something similar withRange/NdRangeas well.@roxx30198 could you please post a complete code? Also what does the structure look like when you multiply two
sycl::rangeobjects?It's a new feature that needs to be implemented.
Added the expected output. I couldn't get to exactly print the dimensions of final range object but I have verified it is the multiplication of corresponding elements in the tuple.