Problem: 'printf' within OpenCL kernel doesn't work (Linux, Intel OpenCL SDK 1.5)

Problem: 'printf' within OpenCL kernel doesn't work (Linux, Intel OpenCL SDK 1.5)

Hi there,
I've read following statement of Intel:

I tried 'printf' for debugging my stuff on a Intel Core i7 2600k and a Core i7 2620m with Arch Linux (Intel OpenCL SDK 1.5 and the latest Nvidia OpenCL headers).
I've set following within my OpenCL kernel file:

#pragma OPENCL EXTENSION cl_intel_printf : enable

Following within the OpenCL kernel works fine:

printf("hello world n");

Using printf with specifiers breaks Intel OpenCL with a bad segmentation fault.

printf("hello world %i n", 10 );     // doesn't work

printf("hello world %s n", "test" ); // doesn't work

printf("hello world %f n", 1.0f);    // doesn't work

printf("hello world %d n", 1.0 );    // doesn't work

GDB shows following for each single example:

(gdb) backtrace
#0  0x00007ffff7042d68 in vfprintf () from /lib/
#1  0x00007ffff7069582 in vsnprintf () from /lib/
#2  0x00007ffff3342357 in ?? () from /opt/intel/opencl-sdk/
#3  0x00007ffff3342509 in ?? () from /opt/intel/opencl-sdk/
#4  0x00007ffff3342787 in ?? () from /opt/intel/opencl-sdk/
#5  0x00007ffff3342d65 in ?? () from /opt/intel/opencl-sdk/
#6  0x00007ffff7ed034d in ?? ()
#7  0x3ff0000000000000 in ?? ()
#8  0x0000000000000000 in ?? ()

I'm not really sure if it is a Intel OpenCL SDK Bug ... is somebody using 'printf' within Intel OpenCL and can say if it works fine or not?

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Patrick,

The printf implementation is a stable feature that has been part of the SDK for a few releases now.
I suspect your problem may have to do with the Linux distribution you're using. According to the SDK release notes, the only officially supported Linux distributions are:

  • Novell* SUSE* Linux Enterprise Server 11 Service Pack 1 (64-bit version)
  • Red Hat* Enterprise Linux 6 (64-bit version).

So Arch Linux is not supported. Specifically, there may be libc differences in Arch Linux which cause this problem. Please try your program on one of the supported distributions listed above, and see if you have the crashes.

Hi Eli,
thanks for your feedback. I haven't seen the officially supported Linux before you mentioned them.Because of the fact, that those commercial Linux distributions are a little bit expensive for a student like me, I'm not interested in buying one of them.I know that you guys don't want to here: Can we have the following feature within the next release.So I can only hope that there will a chance to get the source code or at least support for a linux distribution like debian at a later time. (I know that you will not explizitly support Arch ;-) )

Hi Eli,We currently use different OS's in addition to the supported ones without much trouble. I can't speak for Arch Linux but we use Ubuntu and have not had any signifigant problems with the printf command. I know I wouldn't want to switch distros to run OpenCL commands but I thought I would mention my experience and I hope it helps.On a second note to Patrick. Do you really think this is the issue?Regards,Jim


While the SDK might work on non-officially suported OSes, it's impossible for us to guarantee that all features will be supported as expected.

Login to leave a comment.