3838
3939using namespace sycl ;
4040
41+ #define SET_LOCAL_ACCESSOR_ARG (CGH, NDIM, ARGTY, R, IDX ) \
42+ do { \
43+ switch ((ARGTY)) { \
44+ case DPCTL_INT8_T: \
45+ { \
46+ auto la = local_accessor<int8_t , NDIM>(R, CGH); \
47+ CGH.set_arg (IDX, la); \
48+ return true ; \
49+ } \
50+ case DPCTL_UINT8_T: \
51+ { \
52+ auto la = local_accessor<uint8_t , NDIM>(R, CGH); \
53+ CGH.set_arg (IDX, la); \
54+ return true ; \
55+ } \
56+ case DPCTL_INT16_T: \
57+ { \
58+ auto la = local_accessor<int16_t , NDIM>(R, CGH); \
59+ CGH.set_arg (IDX, la); \
60+ return true ; \
61+ } \
62+ case DPCTL_UINT16_T: \
63+ { \
64+ auto la = local_accessor<uint16_t , NDIM>(R, CGH); \
65+ CGH.set_arg (IDX, la); \
66+ return true ; \
67+ } \
68+ case DPCTL_INT32_T: \
69+ { \
70+ auto la = local_accessor<int32_t , NDIM>(R, CGH); \
71+ CGH.set_arg (IDX, la); \
72+ return true ; \
73+ } \
74+ case DPCTL_UINT32_T: \
75+ { \
76+ auto la = local_accessor<uint32_t , NDIM>(R, CGH); \
77+ CGH.set_arg (IDX, la); \
78+ return true ; \
79+ } \
80+ case DPCTL_INT64_T: \
81+ { \
82+ auto la = local_accessor<int64_t , NDIM>(R, CGH); \
83+ CGH.set_arg (IDX, la); \
84+ return true ; \
85+ } \
86+ case DPCTL_UINT64_T: \
87+ { \
88+ auto la = local_accessor<uint64_t , NDIM>(R, CGH); \
89+ CGH.set_arg (IDX, la); \
90+ return true ; \
91+ } \
92+ case DPCTL_FLOAT32_T: \
93+ { \
94+ auto la = local_accessor<float , NDIM>(R, CGH); \
95+ CGH.set_arg (IDX, la); \
96+ return true ; \
97+ } \
98+ case DPCTL_FLOAT64_T: \
99+ { \
100+ auto la = local_accessor<double , NDIM>(R, CGH); \
101+ CGH.set_arg (IDX, la); \
102+ return true ; \
103+ } \
104+ default : \
105+ error_handler (" Kernel argument could not be created." , __FILE__, \
106+ __func__, __LINE__, error_level::error); \
107+ return false ; \
108+ } \
109+ } while (0 );
110+
41111namespace
42112{
43113static_assert (__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_VERSION_REQUIRED,
@@ -62,11 +132,39 @@ void set_dependent_events(handler &cgh,
62132 }
63133}
64134
135+ bool set_local_accessor_arg (handler &cgh,
136+ size_t idx,
137+ const MDLocalAccessor *mdstruct)
138+ {
139+ switch (mdstruct->ndim ) {
140+ case 1 :
141+ {
142+ auto r = range<1 >(mdstruct->dim0 );
143+ SET_LOCAL_ACCESSOR_ARG (cgh, 1 , mdstruct->dpctl_type_id , r, idx);
144+ }
145+ case 2 :
146+ {
147+ auto r = range<2 >(mdstruct->dim0 , mdstruct->dim1 );
148+ SET_LOCAL_ACCESSOR_ARG (cgh, 2 , mdstruct->dpctl_type_id , r, idx);
149+ }
150+ case 3 :
151+ {
152+ auto r = range<3 >(mdstruct->dim0 , mdstruct->dim1 , mdstruct->dim2 );
153+ SET_LOCAL_ACCESSOR_ARG (cgh, 3 , mdstruct->dpctl_type_id , r, idx);
154+ }
155+ default :
156+ return false ;
157+ }
158+ }
65159/* !
66160 * @brief Set the kernel arg object
67161 *
68- * @param cgh My Param doc
69- * @param Arg My Param doc
162+ * @param cgh SYCL command group handler using which a kernel is going to
163+ * be submitted.
164+ * @param idx The position of the argument in the list of arguments passed
165+ * to a kernel.
166+ * @param Arg A void* representing a kernel argument.
167+ * @param Argty A typeid specifying the C++ type of the Arg parameter.
70168 */
71169bool set_kernel_arg (handler &cgh,
72170 size_t idx,
@@ -109,10 +207,11 @@ bool set_kernel_arg(handler &cgh,
109207 case DPCTL_VOID_PTR:
110208 cgh.set_arg (idx, Arg);
111209 break ;
210+ case DPCTL_LOCAL_ACCESSOR:
211+ arg_set = set_local_accessor_arg (cgh, idx, (MDLocalAccessor *)Arg);
212+ break ;
112213 default :
113214 arg_set = false ;
114- error_handler (" Kernel argument could not be created." , __FILE__,
115- __func__, __LINE__);
116215 break ;
117216 }
118217 return arg_set;
0 commit comments