- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to pass some compile time constants in as build options:
eg: "-D BUFFER_SIZE=512"
and then I would like to declare the following variable in my kernel:
local buffer[BUFFER_SIZE];
When I try this, (visual studio 2012) I get errors. Is there a way of doing this with the intel SDK and
visual studio integration?
Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
THanks, Yuri. Visual Studio does static checking on opencl file
when compiling C/C++ code. And it doesn't know about the compiler option passed to clBuildProgram.
So it flags
local buffer[BUFFER_SIZE];
as an error.
I would like the visual studio plugin to somehow know about the clBuildProgram complier options.
Is this clearer?
THanks,
Aaron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Yuri. Unfortunately, that will not work.
I would like to build different programs using the same kernel code, but with different configurations of #defines.
For example:
Program 1: kernel1 with BUFFER_SIZE=512
Program2: kernel1 with BUFFER_SIZE=1028
Also, when I tried your suggestion, I got CL_INVALID_KERNEL errors. So, it doesn't actually work :(
Thanks again,
Aaron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Any ideas on how to resolve this? Any workarounds?
Thanks,
Aaron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could consider your kernel source as a string and build it from values defined in the host program.
That is,
char *kernelSource2 =" ... local buffer[%d]; \n ..."; sprintf(kernelSource,kernelSource2,BUFFER_SIZE); program = clCreateProgramWithSource(context, 1, (const char **) & kernelSource, NULL, &err);
Will this work for what you are trying to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, ok, my bad here. Yuri's suggestion does work.
1) Right click on .cl file and add a command line parameter D BUFFER_SIZE=512
2) pass the same parameter in when calling clBuildProgram
Now, the compiler is happy, and the visual studio plugin is happy.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page