|  | 
| 21 | 21 | #include <sycl/kernel_bundle.hpp> // for kernel_bundle_impl | 
| 22 | 22 | 
 | 
| 23 | 23 | #include <detail/device_kernel_info.hpp> | 
|  | 24 | +#include <detail/kernel_arg_desc.hpp> | 
|  | 25 | +#include <detail/ndrange_desc.hpp> | 
| 24 | 26 | 
 | 
| 25 | 27 | #include <assert.h> // for assert | 
| 26 | 28 | #include <memory>   // for shared_ptr, unique_ptr | 
| @@ -49,114 +51,6 @@ class stream_impl; | 
| 49 | 51 | class queue_impl; | 
| 50 | 52 | class kernel_bundle_impl; | 
| 51 | 53 | 
 | 
| 52 |  | -// The structure represents kernel argument. | 
| 53 |  | -class ArgDesc { | 
| 54 |  | -public: | 
| 55 |  | -  ArgDesc(sycl::detail::kernel_param_kind_t Type, void *Ptr, int Size, | 
| 56 |  | -          int Index) | 
| 57 |  | -      : MType(Type), MPtr(Ptr), MSize(Size), MIndex(Index) {} | 
| 58 |  | - | 
| 59 |  | -  sycl::detail::kernel_param_kind_t MType; | 
| 60 |  | -  void *MPtr; | 
| 61 |  | -  int MSize; | 
| 62 |  | -  int MIndex; | 
| 63 |  | -}; | 
| 64 |  | - | 
| 65 |  | -// The structure represents NDRange - global, local sizes, global offset and | 
| 66 |  | -// number of dimensions. | 
| 67 |  | - | 
| 68 |  | -// TODO: A lot of tests rely on particular values to be set for dimensions that | 
| 69 |  | -// are not used. To clarify, for example, if a 2D kernel is invoked, in | 
| 70 |  | -// NDRDescT, the value of index 2 in GlobalSize must be set to either 1 or 0 | 
| 71 |  | -// depending on which constructor is used for no clear reason. | 
| 72 |  | -// Instead, only sensible defaults should be used and tests should be updated | 
| 73 |  | -// to reflect this. | 
| 74 |  | -class NDRDescT { | 
| 75 |  | - | 
| 76 |  | -public: | 
| 77 |  | -  NDRDescT() = default; | 
| 78 |  | -  NDRDescT(const NDRDescT &Desc) = default; | 
| 79 |  | -  NDRDescT(NDRDescT &&Desc) = default; | 
| 80 |  | - | 
| 81 |  | -  template <int Dims_> | 
| 82 |  | -  NDRDescT(sycl::range<Dims_> N, bool SetNumWorkGroups) : Dims{size_t(Dims_)} { | 
| 83 |  | -    if (SetNumWorkGroups) { | 
| 84 |  | -      for (size_t I = 0; I < Dims_; ++I) { | 
| 85 |  | -        NumWorkGroups[I] = N[I]; | 
| 86 |  | -      } | 
| 87 |  | -    } else { | 
| 88 |  | -      for (size_t I = 0; I < Dims_; ++I) { | 
| 89 |  | -        GlobalSize[I] = N[I]; | 
| 90 |  | -      } | 
| 91 |  | - | 
| 92 |  | -      for (int I = Dims_; I < 3; ++I) { | 
| 93 |  | -        GlobalSize[I] = 1; | 
| 94 |  | -      } | 
| 95 |  | -    } | 
| 96 |  | -  } | 
| 97 |  | - | 
| 98 |  | -  template <int Dims_> | 
| 99 |  | -  NDRDescT(sycl::range<Dims_> NumWorkItems, sycl::range<Dims_> LocalSizes, | 
| 100 |  | -           sycl::id<Dims_> Offset) | 
| 101 |  | -      : Dims{size_t(Dims_)} { | 
| 102 |  | -    for (size_t I = 0; I < Dims_; ++I) { | 
| 103 |  | -      GlobalSize[I] = NumWorkItems[I]; | 
| 104 |  | -      LocalSize[I] = LocalSizes[I]; | 
| 105 |  | -      GlobalOffset[I] = Offset[I]; | 
| 106 |  | -    } | 
| 107 |  | - | 
| 108 |  | -    for (int I = Dims_; I < 3; ++I) { | 
| 109 |  | -      LocalSize[I] = LocalSizes[0] ? 1 : 0; | 
| 110 |  | -    } | 
| 111 |  | - | 
| 112 |  | -    for (int I = Dims_; I < 3; ++I) { | 
| 113 |  | -      GlobalSize[I] = 1; | 
| 114 |  | -    } | 
| 115 |  | -  } | 
| 116 |  | - | 
| 117 |  | -  template <int Dims_> | 
| 118 |  | -  NDRDescT(sycl::range<Dims_> NumWorkItems, sycl::id<Dims_> Offset) | 
| 119 |  | -      : Dims{size_t(Dims_)} { | 
| 120 |  | -    for (size_t I = 0; I < Dims_; ++I) { | 
| 121 |  | -      GlobalSize[I] = NumWorkItems[I]; | 
| 122 |  | -      GlobalOffset[I] = Offset[I]; | 
| 123 |  | -    } | 
| 124 |  | -  } | 
| 125 |  | - | 
| 126 |  | -  template <int Dims_> | 
| 127 |  | -  NDRDescT(sycl::nd_range<Dims_> ExecutionRange) | 
| 128 |  | -      : NDRDescT(ExecutionRange.get_global_range(), | 
| 129 |  | -                 ExecutionRange.get_local_range(), | 
| 130 |  | -                 ExecutionRange.get_offset()) {} | 
| 131 |  | - | 
| 132 |  | -  template <int Dims_> | 
| 133 |  | -  NDRDescT(sycl::range<Dims_> Range) | 
| 134 |  | -      : NDRDescT(Range, /*SetNumWorkGroups=*/false) {} | 
| 135 |  | - | 
| 136 |  | -  template <int Dims_> void setClusterDimensions(sycl::range<Dims_> N) { | 
| 137 |  | -    if (this->Dims != size_t(Dims_)) { | 
| 138 |  | -      throw std::runtime_error( | 
| 139 |  | -          "Dimensionality of cluster, global and local ranges must be same"); | 
| 140 |  | -    } | 
| 141 |  | - | 
| 142 |  | -    for (int I = 0; I < Dims_; ++I) | 
| 143 |  | -      ClusterDimensions[I] = N[I]; | 
| 144 |  | -  } | 
| 145 |  | - | 
| 146 |  | -  NDRDescT &operator=(const NDRDescT &Desc) = default; | 
| 147 |  | -  NDRDescT &operator=(NDRDescT &&Desc) = default; | 
| 148 |  | - | 
| 149 |  | -  std::array<size_t, 3> GlobalSize{0, 0, 0}; | 
| 150 |  | -  std::array<size_t, 3> LocalSize{0, 0, 0}; | 
| 151 |  | -  std::array<size_t, 3> GlobalOffset{0, 0, 0}; | 
| 152 |  | -  /// Number of workgroups, used to record the number of workgroups from the | 
| 153 |  | -  /// simplest form of parallel_for_work_group. If set, all other fields must be | 
| 154 |  | -  /// zero | 
| 155 |  | -  std::array<size_t, 3> NumWorkGroups{0, 0, 0}; | 
| 156 |  | -  std::array<size_t, 3> ClusterDimensions{1, 1, 1}; | 
| 157 |  | -  size_t Dims = 0; | 
| 158 |  | -}; | 
| 159 |  | - | 
| 160 | 54 | /// Base class for all types of command groups. | 
| 161 | 55 | class CG { | 
| 162 | 56 | public: | 
|  | 
0 commit comments