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.
1721 Discussions

Problem with MACROS added with clBuildProgram

Edgardo_Doerner
1,003 Views

Hi to everyone,

I have a problem with the SDK plugin for Visual Studio 2010. In my kernel I add several MACROS using the -D flag inside the options argument of the clBuildProgram function. However, this is not recognized by the Intel OpenCL SDK plugin, therefore it throws several "use of undeclared identifier" errors and I am not able to run my program.

I am able to run the Kernel if I disable the plugin, but it would be nice to be able to use it, so is there a way to fix this, or I should explicitly declare this macros inside my kernel to be able to debug it using the VS plugin?

Thanks for your help!

PS: As a small example, I have defined in my .cl file the following struct:

 

typedef struct{
	double zbound[MXREG];
	int nzb;
} Geom;

Therefore, I define MXREG using the -D flag when calling clBuildProgram:

 

char options[64];
sprintf(options, "-DMXREG=%d, geom.nzb);
cl_program program;
program = oclBuildProgram(device, context, PROGRAM_FILE, options);

This works perfectly when the OpenCL plugin is not used.

0 Kudos
1 Solution
Robert_I_Intel
Employee
1,003 Views

Edgardo,

Have you added these options to OpenCL Options line on the Build Options tab?BuildOptions.png

 

I am using the latest version of the INDE tools (https://software.intel.com/en-us/intel-inde ) and this option works for me (try to upgrade to the latest version of INDE and see if you still have an issue):

Using build options: -DMXREG=1024

OpenCL Intel(R) Graphics device was found!

Device name: Intel(R) Iris(TM) Pro Graphics 5200

Device version: OpenCL 1.2

Device vendor: Intel(R) Corporation

Device profile: FULL_PROFILE

fcl build 1 succeeded.

fcl build 2 succeeded.

bcl build succeeded.

Build succeeded!

 

View solution in original post

0 Kudos
4 Replies
Robert_I_Intel
Employee
1,004 Views

Edgardo,

Have you added these options to OpenCL Options line on the Build Options tab?BuildOptions.png

 

I am using the latest version of the INDE tools (https://software.intel.com/en-us/intel-inde ) and this option works for me (try to upgrade to the latest version of INDE and see if you still have an issue):

Using build options: -DMXREG=1024

OpenCL Intel(R) Graphics device was found!

Device name: Intel(R) Iris(TM) Pro Graphics 5200

Device version: OpenCL 1.2

Device vendor: Intel(R) Corporation

Device profile: FULL_PROFILE

fcl build 1 succeeded.

fcl build 2 succeeded.

bcl build succeeded.

Build succeeded!

 

0 Kudos
Edgardo_Doerner
1,003 Views

Hi Robert, your suggestion worked!... thanks for your help!

0 Kudos
Omar_I_
Beginner
1,003 Views

Greetings, 

I have the same problem , however, the value of the passed option is only known at runtime, (i.e. the 1024 in the above example is unknown at compile time) , how can I handle this ?   

0 Kudos
Jeffrey_M_Intel1
Employee
1,003 Views

If you need the application to update the value then you'll need a combination of the two:

1) Set -DMXREG in the Code Builder properties.  This is to help with the Code Builder compilation so you won't see errors for missing symbols at compile time.

2) Set the runtime value in the build options.

char options[64];
sprintf(options, "-g -s \"./source.cl\" -DMXREG=%d, geom.nzb);
cl_program program;
program = oclBuildProgram(device, context, PROGRAM_FILE, options);

 

In my tests the value in #1 was overwritten when the code was recompiled at runtime.  When a breakpoint was applied in in the kernel I coudl see the value from step2. 

0 Kudos
Reply