aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fosphor/cl.c
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2013-10-26 17:48:25 +0200
committerSylvain Munaut <tnt@246tNt.com>2013-10-26 17:48:25 +0200
commite828e7faffb635ce0600a90e6e194f6c30a9c7fe (patch)
tree5dc97d907c79f3f0ffe8b1f0df12e5925db4e476 /lib/fosphor/cl.c
parent95f8775ce21a467a31011ae7525b3895f34a6c31 (diff)
fosphor/cl: Add a debug block allowing to save compile CL binary for debug
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'lib/fosphor/cl.c')
-rw-r--r--lib/fosphor/cl.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/fosphor/cl.c b/lib/fosphor/cl.c
index 1769166..7a119b7 100644
--- a/lib/fosphor/cl.c
+++ b/lib/fosphor/cl.c
@@ -313,6 +313,30 @@ cl_load_program(cl_device_id dev_id, cl_context ctx,
CL_ERR_CHECK(err, "Failed to build program");
+#ifdef DEBUG_CL
+ {
+ size_t bin_len;
+ char name_buf[256];
+ char *bin_buf;
+
+ snprintf(name_buf, 256, "prog_%s.bin", resource_name);
+
+ clGetProgramInfo(prog, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &bin_len, NULL);
+ fprintf(stderr, "Binary length for '%s': %d\n\n", resource_name, (int)bin_len);
+
+ bin_buf = malloc(bin_len);
+
+ clGetProgramInfo(prog, CL_PROGRAM_BINARIES, bin_len, &bin_buf, NULL );
+
+ FILE *fh = fopen(name_buf, "wb");
+ if (fwrite(bin_buf, bin_len, 1, fh) != 1)
+ fprintf(stderr, "[w] Binary write failed\n");
+ fclose(fh);
+
+ free(bin_buf);
+ }
+#endif
+
/* All good */
return prog;