OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1718 Discussions

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

p_siegl
Beginner
1,150 Views
Hi there,

I've read following statement of Intel:
[plain]http://software.intel.com/en-us/articles/debugging-opencl-kernels-using-printf/[/plain]
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:
[cpp]#pragma OPENCL EXTENSION cl_intel_printf : enable[/cpp]
Following within the OpenCL kernel works fine:
[cpp]printf("hello world \n");[/cpp]
Using printf with specifiers breaks Intel OpenCL with a bad segmentation fault.

Examples:
[cpp]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[/cpp]
GDB shows following for each single example:
[bash](gdb) backtrace
#0  0x00007ffff7042d68 in vfprintf () from /lib/libc.so.6
#1  0x00007ffff7069582 in vsnprintf () from /lib/libc.so.6
#2  0x00007ffff3342357 in ?? () from /opt/intel/opencl-sdk/libOclCpuBackEnd.so
#3  0x00007ffff3342509 in ?? () from /opt/intel/opencl-sdk/libOclCpuBackEnd.so
#4  0x00007ffff3342787 in ?? () from /opt/intel/opencl-sdk/libOclCpuBackEnd.so
#5  0x00007ffff3342d65 in ?? () from /opt/intel/opencl-sdk/libOclCpuBackEnd.so
#6  0x00007ffff7ed034d in ?? ()
#7  0x3ff0000000000000 in ?? ()
#8  0x0000000000000000 in ?? ()[/bash]
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?

Regards
Patrick
0 Kudos
4 Replies
Eli_Bendersky__Intel
1,150 Views
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.

0 Kudos
p_siegl
Beginner
1,150 Views
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 ;-) )

Regards
Patrick
0 Kudos
Jim_Vaughn
Beginner
1,149 Views
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
0 Kudos
Eli_Bendersky__Intel
1,149 Views
Hi,

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.


0 Kudos
Reply