Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numba-dpex doesn't allow range multiplications inside NdRange #1159

Open
roxx30198 opened this issue Oct 5, 2023 · 3 comments
Open

numba-dpex doesn't allow range multiplications inside NdRange #1159

roxx30198 opened this issue Oct 5, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@roxx30198
Copy link
Contributor

roxx30198 commented Oct 5, 2023

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'

@chudur-budur
Copy link
Contributor

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:

gemm[ndpx.NdRange(griddim, blockdim)](a, b, c)

pairwise_distance[ndpx.NdRange(global_size, local_size)](

kernel_polynomial[ndpx.NdRange(global_range, local_range)](

@chudur-budur chudur-budur self-assigned this Dec 19, 2023
@chudur-budur chudur-budur added user User submitted issue documentation Improvements or additions to documentation feature-change labels Dec 19, 2023
@chudur-budur
Copy link
Contributor

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.

@roxx30198
Copy link
Contributor Author

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.

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.

@diptorupd diptorupd added enhancement New feature or request and removed feature-change user User submitted issue documentation Improvements or additions to documentation labels Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants