[PATCH 18/90] Fix tests/regression/test_alignment_with_dynamic_wg.cpp
authorMichal Babej <michal.babej@tuni.fi>
Mon, 20 Sep 2021 06:12:24 +0000 (09:12 +0300)
committerAndreas Beckmann <anbe@debian.org>
Fri, 7 Jan 2022 23:55:22 +0000 (23:55 +0000)
Don't rebuild the program inside loop iteration,
instead create a new one on each iteration.

Gbp-Pq: Name 0018-Fix-tests-regression-test_alignment_with_dynamic_wg..patch

tests/regression/test_alignment_with_dynamic_wg.cpp

index 281d66dd5101a82a081162d3dac3a8e0990e0b9d..f04918457415c0c2cd5e600ea7111225ef9274be 100644 (file)
@@ -48,8 +48,7 @@ __kernel void test(global uint *output, global const uint* trialValue){
 
 bool test_invocation(unsigned x, unsigned y, unsigned z,
                      const std::string &arg_x, const std::string &arg_y,
-                     const std::string &arg_z, cl::CommandQueue &queue,
-                     cl::Program &program) {
+                     const std::string &arg_z, cl::CommandQueue &queue) {
 
   unsigned expected_sum = x * y * z * 4;
 
@@ -57,6 +56,7 @@ bool test_invocation(unsigned x, unsigned y, unsigned z,
   assert(local_size > 0);
   assert(local_size <= 256);
 
+  cl::Program program(SOURCE);
   std::string options = "-cl-std=CL1.2";
   options += " -DX=" + arg_x + " -DY=" + arg_y + " -DZ=" + arg_z;
   program.build(options.c_str());
@@ -107,7 +107,6 @@ bool test_invocation(unsigned x, unsigned y, unsigned z,
 int main(int argc, char *argv[]) {
   cl::Device device = cl::Device::getDefault();
   cl::CommandQueue queue = cl::CommandQueue::getDefault();
-  cl::Program program(SOURCE);
 
   if (argc < 4) {
     std::cout << "USAGE: $0 X Y Z\n";
@@ -122,13 +121,13 @@ int main(int argc, char *argv[]) {
   unsigned y = std::stoi(argv[2]);
   unsigned z = std::stoi(argv[3]);
 
-  if (!test_invocation(x, y, z, arg_x, arg_y, arg_z, queue, program))
+  if (!test_invocation(x, y, z, arg_x, arg_y, arg_z, queue))
     return 1;
 
-  if (!test_invocation(y, z, x, arg_y, arg_z, arg_x, queue, program))
+  if (!test_invocation(y, z, x, arg_y, arg_z, arg_x, queue))
     return 1;
 
-  if (!test_invocation(z, x, y, arg_z, arg_x, arg_y, queue, program))
+  if (!test_invocation(z, x, y, arg_z, arg_x, arg_y, queue))
     return 1;
 
   return 0;