@@ -86,12 +86,16 @@ struct KernelAttributesReqGroupSizeTest : public BasicCommandBufferTest
8686 " clGetDeviceInfo for CL_DEVICE_MAX_WORK_GROUP_SIZE failed" );
8787
8888
89- std::vector<std::pair<std::string, std:: uint16_t >> attribs = {
90- { " __attribute__((reqd_work_group_size(2,1,1))) " , 1 },
91- { " __attribute__((reqd_work_group_size(2,3,1))) " , 2 },
92- { " __attribute__((reqd_work_group_size(2,3,4))) " , 3 }
89+ struct KernelAttribInfo
90+ {
91+ cl_int wgs[ 3 ];
92+ cl_uint min_dim;
9393 };
9494
95+ std::vector<KernelAttribInfo> attribs = { { { 2 , 1 , 1 }, 1 },
96+ { { 2 , 3 , 1 }, 2 },
97+ { { 2 , 3 , 4 }, 3 } };
98+
9599 const std::string body_str = R"(
96100 __kernel void wg_size(__global int* dst)
97101 {
@@ -108,7 +112,12 @@ struct KernelAttributesReqGroupSizeTest : public BasicCommandBufferTest
108112
109113 for (auto & attrib : attribs)
110114 {
111- const std::string source_str = attrib.first + body_str;
115+ const std::string attrib_str =
116+ " __attribute__((reqd_work_group_size("
117+ + std::to_string (attrib.wgs [0 ]) + " ,"
118+ + std::to_string (attrib.wgs [1 ]) + " ,"
119+ + std::to_string (attrib.wgs [2 ]) + " )))" ;
120+ const std::string source_str = attrib_str + body_str;
112121 const char * source = source_str.c_str ();
113122
114123 clProgramWrapper program;
@@ -120,22 +129,20 @@ struct KernelAttributesReqGroupSizeTest : public BasicCommandBufferTest
120129 error = clSetKernelArg (kernel, 0 , sizeof (cl_mem), &dst);
121130 test_error (error, " clSetKernelArg failed" );
122131
123- for (cl_uint work_dim = 1 ; work_dim <= attrib. second ; work_dim++)
132+ for (cl_uint work_dim = attrib. min_dim ; work_dim <= 3 ; work_dim++)
124133 {
125- const cl_int expected[3 ] = { 2 , work_dim >= 2 ? 3 : 1 ,
126- work_dim >= 3 ? 4 : 1 };
127134 const size_t test_work_group_size =
128- expected [0 ] * expected [1 ] * expected [2 ];
129- if ((size_t )expected [0 ] > device_max_work_item_sizes[0 ]
130- || (size_t )expected [1 ] > device_max_work_item_sizes[1 ]
131- || (size_t )expected [2 ] > device_max_work_item_sizes[2 ]
135+ attrib. wgs [0 ] * attrib. wgs [1 ] * attrib. wgs [2 ];
136+ if ((size_t )attrib. wgs [0 ] > device_max_work_item_sizes[0 ]
137+ || (size_t )attrib. wgs [1 ] > device_max_work_item_sizes[1 ]
138+ || (size_t )attrib. wgs [2 ] > device_max_work_item_sizes[2 ]
132139 || test_work_group_size > device_max_work_group_size)
133140 {
134141 log_info (
135142 " Skipping test for work_dim = %u: required work group "
136143 " size (%i, %i, %i) (total %zu) exceeds device max "
137144 " work group size (%zu, %zu, %zu) (total %zu)\n " ,
138- work_dim, expected [0 ], expected [1 ], expected [2 ],
145+ work_dim, attrib. wgs [0 ], attrib. wgs [1 ], attrib. wgs [2 ],
139146 test_work_group_size, device_max_work_item_sizes[0 ],
140147 device_max_work_item_sizes[1 ],
141148 device_max_work_item_sizes[2 ],
@@ -146,7 +153,7 @@ struct KernelAttributesReqGroupSizeTest : public BasicCommandBufferTest
146153 const cl_int zero = 0 ;
147154 error = clCommandFillBufferKHR (
148155 command_buffer, nullptr , nullptr , dst, &zero, sizeof (zero),
149- 0 , sizeof (expected ), 0 , nullptr , nullptr , nullptr );
156+ 0 , sizeof (attrib. wgs ), 0 , nullptr , nullptr , nullptr );
150157 test_error (error, " clCommandFillBufferKHR failed" );
151158
152159 const size_t global_work_size[3 ] = { 2 * 32 , 3 * 32 , 4 * 32 };
@@ -169,13 +176,13 @@ struct KernelAttributesReqGroupSizeTest : public BasicCommandBufferTest
169176 test_error (error, " clEnqueueReadBuffer failed" );
170177
171178 // Verify the result
172- if (results[0 ] != expected [0 ] || results[1 ] != expected [1 ]
173- || results[2 ] != expected [2 ])
179+ if (results[0 ] != attrib. wgs [0 ] || results[1 ] != attrib. wgs [1 ]
180+ || results[2 ] != attrib. wgs [2 ])
174181 {
175182 log_error (
176183 " Executed local size mismatch with work_dim = %u: "
177184 " Expected (%d,%d,%d) got (%d,%d,%d)\n " ,
178- work_dim, expected [0 ], expected [1 ], expected [2 ],
185+ work_dim, attrib. wgs [0 ], attrib. wgs [1 ], attrib. wgs [2 ],
179186 results[0 ], results[1 ], results[2 ]);
180187 return TEST_FAIL ;
181188 }
@@ -189,16 +196,16 @@ struct KernelAttributesReqGroupSizeTest : public BasicCommandBufferTest
189196 test_error (error,
190197 " clGetKernelSuggestedLocalWorkSizeKHR failed" );
191198
192- if ((cl_int) suggested[0 ] != expected [0 ]
193- || (cl_int) suggested[1 ] != expected [1 ]
194- || (cl_int) suggested[2 ] != expected [2 ])
199+ if (suggested[0 ] != ( size_t )attrib. wgs [0 ]
200+ || suggested[1 ] != ( size_t )attrib. wgs [1 ]
201+ || suggested[2 ] != ( size_t )attrib. wgs [2 ])
195202 {
196203 log_error (
197204 " Suggested local size mismatch with work_dim = "
198- " %u: Expected (%d,%d,%d) got (%d,%d,%d )\n " ,
199- work_dim, expected [0 ], expected[ 1 ], expected[ 2 ],
200- (cl_int) suggested[0 ], (cl_int) suggested[1 ],
201- (cl_int) suggested[2 ]);
205+ " %u: Expected (%d,%d,%d) got (%zu,%zu,%zu )\n " ,
206+ work_dim, attrib. wgs [0 ], attrib. wgs [ 1 ],
207+ attrib. wgs [ 2 ], suggested[0 ], suggested[1 ],
208+ suggested[2 ]);
202209 return TEST_FAIL ;
203210 }
204211 }
0 commit comments