EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalculateNdRange.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CalculateNdRange.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 // SYCL plugin include(s)
11 
12 namespace Acts::Sycl {
13 cl::sycl::nd_range<1> calculate1DimNDRange(const uint32_t numThreads,
14  const uint32_t workGroupSize) {
15  auto q = (numThreads + workGroupSize - 1) / workGroupSize;
16  return cl::sycl::nd_range<1>{cl::sycl::range<1>(q * workGroupSize),
17  cl::sycl::range<1>(workGroupSize)};
18 }
19 
20 cl::sycl::nd_range<2> calculate2DimNDRange(const uint32_t numThreadsDim0,
21  const uint32_t numThreadsDim1,
22  const uint32_t workGroupSize) {
23  uint32_t wgSizeDim0 = 1;
24  uint32_t wgSizeDim1 = workGroupSize;
25 
26  while (numThreadsDim1 < wgSizeDim1 && 1 < wgSizeDim1 && wgSizeDim1 % 2 == 0) {
27  wgSizeDim1 /= 2;
28  wgSizeDim0 *= 2;
29  }
30  auto q1 = (numThreadsDim0 + wgSizeDim0 + 1) / wgSizeDim0;
31  auto q2 = (numThreadsDim1 + wgSizeDim1 + 1) / wgSizeDim1;
32  return cl::sycl::nd_range<2>{
33  cl::sycl::range<2>(q1 * wgSizeDim0, q2 * wgSizeDim1),
34  cl::sycl::range<2>(wgSizeDim0, wgSizeDim1)};
35 }
36 } // namespace Acts::Sycl