get_global_id not working

get_global_id not working

The attached simple program simply prints out the result of get_local_id(0) and get_global_id(0). The former works but the latter returns 0 every time. Here is the output:

Device name:        Intel(R) Core(TM) i5-2430M CPU @ 2.40GHz
Driver version:
local_id = 0 global_id = 0
local_id = 1 global_id = 0
local_id = 2 global_id = 0
local_id = 0 global_id = 0
local_id = 1 global_id = 0
local_id = 2 global_id = 0


I'm using Ubuntu 13.10 on Sandy Bridge and I installed from intel_sdk_for_ocl_applications_xe_2013_r2_runtime_3.1.1.11385_x64.tgz. I realise this is probably not a supported platform, but perhaps someone from Intel could run the code and see whether the problem is reproducible (g++ -Wall -g -o printf-test printf-test.cpp -lOpenCL).

Downloadtext/x-c++src printf-test.cpp936 bytes
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Bruce,

I was able to reproduce your results. Thanks for reporting it!

But I think it's an issue with printf function rather than get_global_id.

I switched get_global_id and get_local_id calls and get the correct results for get_global_id:

global_id = 0 local_id = 0
global_id = 1 local_id = 0
global_id = 2 local_id = 0
global_id = 3 local_id = 0
global_id = 4 local_id = 0
global_id = 5 local_id = 0

It looks like there is a problem with printing a second value.

Thanks, Aleksey

Best Reply

Ok. I realized what is the problem.

get_global_id and get_local_id return size_t which is I support 64-bit values on your device.

If you replace %d in your string with %ul, you should get correct output.

You're right, using the correct size modifier made it work. I'll go back to the original code I was trying to debug and see if I can make progress there. Thanks for the help.

It might be nice if future versions of the compiler gave a warning when the specifier and argument don't match, similar to the way GCC does.

Leave a Comment

Please sign in to add a comment. Not a member? Join today