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

get_global_id not working

Bruce_M_
Beginner
620 Views

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: 1.2.0.76921
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).

0 Kudos
1 Solution
Alexey_B_Intel1
Employee
620 Views

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.

View solution in original post

0 Kudos
3 Replies
Alexey_B_Intel1
Employee
620 Views

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

0 Kudos
Alexey_B_Intel1
Employee
621 Views

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.

0 Kudos
Bruce_M_
Beginner
620 Views

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.

0 Kudos
Reply