Permalink
Browse files

Read kernel names directly from file

  • Loading branch information...
1 parent 379c6ed commit 411868af7bba94f434073ea2ca8d1241a977f7d2 @matze committed Jul 19, 2012
Showing with 53 additions and 22 deletions.
  1. +14 −3 README.md
  2. +39 −19 check.c
View
@@ -1,8 +1,7 @@
-General information
--------------------
+## General information
This small utility checks if an installed OpenCL platform is working according
-to the specifications.
+to the specifications in a multi GPU environment.
Right now it checks if
- platforms and devices can be initialized
@@ -11,3 +10,15 @@ Right now it checks if
The latter is currently _not_ working with NVIDIA driver 302.06.03 and a multi
GPU setup with a GTX 680 and a GTX 590 in the same OpenCL context.
+
+
+### Building
+
+An OpenCL installation should be present, if so you can build with
+
+ $ ./waf configure
+ $ ./waf
+
+and run the suite over a range of GPUs with
+
+ $ ./build/check --first=0 --last=4
View
58 check.c
@@ -31,11 +31,40 @@ print_check (const gchar *format, int errcode, ...)
g_print (": Error: %s\n", ocl_error (errcode));
}
+static GList *
+read_kernel_names (const gchar *filename)
+{
+ GList *names = NULL;
+ FILE *fp;
+ gchar *line;
+ GRegex *regex;
+ GMatchInfo *match_info;
+
+ regex = g_regex_new ("__kernel void ([_A-Za-z][_A-Za-z0-9]*)", 0, 0, NULL);
+ line = g_malloc0 (1024);
+ fp = fopen (filename, "r");
+
+ while (fgets (line, 1024, fp) != NULL) {
+ if (g_regex_match (regex, line, 0, &match_info)) {
+ gchar *kernel_name = g_match_info_fetch (match_info, 1);
+ names = g_list_append (names, kernel_name);
+ }
+ }
+
+ fclose (fp);
+ g_free (line);
+
+
+ g_regex_unref (regex);
+ return names;
+}
+
int main(int argc, char *argv[])
{
OCL *ocl;
GOptionContext *context;
GError *error = NULL;
+ GList *kernels;
int errcode = CL_SUCCESS;
cl_program program;
@@ -49,40 +78,31 @@ int main(int argc, char *argv[])
{ NULL }
};
- static const gchar *kernels[] =
- {
- "assign",
- "two_global_params",
- "three_global_params",
- "four_global_params",
- "two_const_params",
- "three_const_params",
- "four_const_params",
- "two_local_params",
- "three_local_params",
- "four_local_params",
- NULL
- };
-
context = g_option_context_new ("");
g_option_context_add_main_entries (context, entries, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_print ("Option parsing failed: %s\n", error->message);
return 1;
}
+
+ kernels = read_kernel_names ("programs.cl");
ocl = ocl_new (first_device, last_device, &errcode);
print_check ("Initialization", errcode);
program = ocl_program_new_from_file (ocl, "programs.cl", "", &errcode);
- print_check ("Creating backproject program", errcode);
+ print_check ("Creating `programs.cl`", errcode);
+
+ for (GList *it = g_list_first (kernels); it != NULL; it = g_list_next (it)) {
+ gchar *name = (gchar *) it->data;
- for (guint i = 0; kernels[i] != NULL; i++) {
- check_kernel (program, kernels[i], &errcode);
- print_check ("Creating kernel `%s`", errcode, kernels[i]);
+ check_kernel (program, name, &errcode);
+ print_check ("Creating kernel `%s`", errcode, name);
}
ocl_free (ocl);
+ g_list_foreach (kernels, (GFunc) g_free, NULL);
+
return 0;
}

0 comments on commit 411868a

Please sign in to comment.