Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

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

Description

@rohan11235813

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'

Activity

chudur-budur commented on Dec 11, 2023

@chudur-budur
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)](

self-assigned this
on Dec 19, 2023

chudur-budur commented on Dec 19, 2023

@chudur-budur
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.

rohan11235813 commented on Dec 20, 2023

@rohan11235813
ContributorAuthor

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.

added
enhancementNew feature or request
and removed
userUser submitted issue
documentationImprovements or additions to documentation
on Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions