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

Intel® SDK for OpenCL* for 2013 manual and clCreateProgramWithBinary

Steven_M_3
Beginner
666 Views

I'm using your MedianFilter sample with VS2010 amd trying to create a

c following the user manual..  First, a minor not, theres a typo in the manual where you refer to

clCreateProgramFromBinary.  I assume you mean

clCreateProgramWithBinary.

More importantly,  I set in MedianFilter properties-Intel SDK for OpenCL Applications-General options the option to gnerate asm, llvm and ir options.

The "Command Line" shows that the options were set; but no .ir file is emmitted, and in the output window showing the output from Build I get

1>------ Rebuild All started: Project: MedianFilter, Configuration: Debug Win32 ------

1>Build started 9/16/2013 3:35:17 PM.

1>_PrepareForClean:

1>  Deleting file "Win32\Debug\MedianFilter.lastbuildstate".

1>InitializeBuildStatus:

1>  Creating "Win32\Debug\MedianFilter.unsuccessfulbuild" because "AlwaysCreate" was specified.

1>_Intel_OpenCL_Build_Rules:

1>  Preprocessing: MedianFilter.cl

1>ClCompile:

1>  utils.cpp

1>  stdafx.cpp

1>  MedianFilter.cpp

1>c:\users\sm\desktop\intel-ocl-median-filter\medianfilter\medianfilter.cpp(146): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'

1>c:\users\sm\desktop\intel-ocl-median-filter\medianfilter\medianfilter.cpp(165): warning C4101: 'lSize1' : unreferenced local variable

1>  Generating Code...

1>Manifest:

1>  Deleting file "Win32\Debug\MedianFilter.exe.embed.manifest".

1>LinkEmbedManifest:

1>  MedianFilter_SA.vcxproj -> C:\Users\sm\Desktop\intel-ocl-median-filter\MedianFilter\\..\Win32\Debug\MedianFilter.exe

1>PostBuildEvent:

1>          1 file(s) copied.

1>FinalizeBuildStatus:

1>  Deleting file "Win32\Debug\MedianFilter.unsuccessfulbuild".

1>  Touching "Win32\Debug\MedianFilter.lastbuildstate".

1>

1>Build succeeded.

1>

1>Time Elapsed 00:00:02.74

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

with none of the entries your manual shows to click on to view the asm or llvm outputs.

 

Furthermore if I create the binary using the Intel Kernel builder, and then trying to use it in clCreateProgramWithBinary as follows,

FILE* fp = fopen("c:\\Users\\sm\\Desktop\\intel-ocl-median-filter\\MedianFilter\\Win32\\Debug\\MedianFilterlib.ir","r");

fseek (fp , 0 , SEEK_END);

constsize_t lSize = ftell(fp);

rewind(fp);

unsignedchar* buffer;

buffer = (unsignedchar*) malloc (lSize);

fread(buffer, 1, lSize, fp);

fclose(fp);

cl_int status;

cl_int ciErr1;

g_program =clCreateProgramWithBinary(g_context, 1, (constcl_device_id *)devices,&lSize,(constunsignedchar**)&buffer,&status,&ciErr1);

constchar* error_string2 = OCL_GetErrorString(ciErr1);

size_t lSize1;

ciErr1 = clGetProgramInfo (g_program,CL_PROGRAM_KERNEL_NAMES,100,buffer,NULL);

constchar* error_string1 = OCL_GetErrorString(ciErr1);

then g_program looks legitmate, error string show CL_Success,  BUT clGetProgramInfo or any other attempt to use  g_program returns an

CL_INVALID_PROGRAM_EXECUTABLE!!

I'm running on CPU (Sandy Bridge, VS2010 and Windows 7.   What am I doing wrong, and why does the output from build not create the .ir file and not match the infro displayed in the manual???

 

0 Kudos
4 Replies
Steven_M_3
Beginner
666 Views

Sorry there is a typo in the firs 2 lines, they should read:

I'm using your MedianFilter sample with VS2010 and trying to create a

clCreateProgramFromBinary following the user manual..  First, a minor note, there is a typo in the manual where you refer to

0 Kudos
Yuri_K_Intel
Employee
666 Views
Hi Steven, 1) We will fix clCreateProgramFromBinary -> clCreateProgramWithBinary typo. Thank you for noticing. 2) I was able to reproduce the behavior when there are no output files (IR, LLVM) produced during the build in Visual Studio. I will submit a ticket for that. 3) Regarding creating program with binary. There are two issues in your code. - When you open a file with IR you should do that in binary mode, so pass "rb" to fopen. Otherwise, if it's not specified the file could be opened in text mode and the file content might not be read fully. - After the call to clCreateProgramWithBinary, you should call clBuildProgram before the calls to clGetProgramInfo, etc. Thanks, Yuri
0 Kudos
Steven_M_3
Beginner
666 Views

Hi Yuri:

  Thanks for the "rb" tip.  It worked.

   One additional note on the Plug in.  When I right click on the Project, it shows the "convert to Intel sdk etc.",; selecting it then sets up the sdk.

   When I right click again to change back to C++, the message remain the same, i.e. it never says conver to C++  as the Docs indicate.  The project does however go back to the C++ style.  So the only error is that the message is not changed. 

     Steve

0 Kudos
Yuri_K_Intel
Employee
666 Views
Steve, I see the message 'Convert to and from an Intel SDK for OpenCL Project'. So it's obviously intended to stay the same. And this is another bug of the user guide. Thanks, Yuri
0 Kudos
Reply