File CalculateNdRange.hpp

namespace Acts::Sycl

Functions

cl::sycl::nd_range<1> calculate1DimNDRange(const uint32_t numThreads, const uint32_t workGroupSize)

Calculate global range of 1 dimensional nd_range for kernel execution.

Calculates the global dimension of the nd_range, which is the smallest multiple of workGroupSize that is not smaller than numThreads.

Parameters
  • numThreads[in] is the number of threads globally

  • workGroupSize[in] is the number of threads in one work group

Returns

a one dimensional nd_range of threads

cl::sycl::nd_range<2> calculate2DimNDRange(const uint32_t numThreadsDim0, const uint32_t numThreadsDim1, const uint32_t workGroupSize)

Calculate global and local range of 2 dimensional nd_range for kernel execution.

Local range is calculated the following way:

  • local range dimensions multiplied together should be equal to workGroupSize

  • if workGroupSize > numThreadsDim1: set local range in the second dimension to be equal to the smallest factor of 2, that is not smaller that the number of threads globally in the second dimension

  • else: local range is {1, workGroupSize}

Global range is calculated the following way:

  • set the number of threads in both dimensions to the smallest multiple of the work group size in that dimension

Parameters
  • numThreadsDim0[in] is the number of threads globally in the first dimension

  • numThreadsDim1[in] is the number of threads globally in the second dimension

  • workGroupSize[in] is the number of threads in one work group

Returns

a two dimensional nd_range of threads