Skip to content
Browse files

Check that CL_INVALID_KERNEL_DEFINITION is caused

  • Loading branch information...
1 parent 411868a commit cd925155f00ec92a359cf9d221a6afbb4448119e @matze committed Jul 20, 2012
Showing with 35 additions and 0 deletions.
  1. +35 −0 check.c
View
35 check.c
@@ -86,6 +86,7 @@ int main(int argc, char *argv[])
return 1;
}
+ /* Check bug with mixed GPUs and more than two __constant parameters */
kernels = read_kernel_names ("programs.cl");
ocl = ocl_new (first_device, last_device, &errcode);
@@ -101,6 +102,40 @@ int main(int argc, char *argv[])
print_check ("Creating kernel `%s`", errcode, name);
}
+ clReleaseProgram (program);
+
+ /* Check that two different kernel programs can be built if the arguments
+ * stay the same */
+ if (ocl->num_devices > 1) {
+ static const char *source = "\
+#ifdef FIRST\n \
+ __kernel void foo(__global float *arg) { arg[0] = 0.0; }\n\
+ __kernel void bar(__global float *arg) { arg[0] = 1.0; }\n\
+#else\n \
+ __kernel void foo(__global float *arg) { arg[0] = 1.0; }\n\
+ __kernel void bar(__constant float *arg) { }\n\
+#endif";
+
+ cl_kernel kernel;
+
+ program = clCreateProgramWithSource (ocl->context, 1, (const char **) &source, NULL, &errcode);
+
+ print_check ("Creating program `kernel-definition`", errcode);
+
+ errcode = clBuildProgram (program, 1, &ocl->devices[0], "-D FIRST", NULL, NULL);
+ print_check ("Build program `kernel-definition` for GPU 1", errcode);
+
+ errcode = clBuildProgram (program, 1, &ocl->devices[1], "", NULL, NULL);
+ print_check ("Build program `kernel-definition` for GPU 2", errcode);
+
+ kernel = clCreateKernel (program, "foo", &errcode);
+ print_check ("Created kernel `foo` with same signature", errcode);
+ clReleaseKernel (kernel);
+
+ kernel = clCreateKernel (program, "bar", &errcode);
+ print_check ("Created kernel `bar` with different signature [expect CL_INVALID_KERNEL_DEFINITION]", errcode);
+ }
+
ocl_free (ocl);
g_list_foreach (kernels, (GFunc) g_free, NULL);

0 comments on commit cd92515

Please sign in to comment.
Something went wrong with that request. Please try again.