cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

shankha
Journeyman III

Emulation mode

Hi,
Is there a way I can run OpenCL programs in emulation mode on CPU itself without having to install driver or graphics card.

Thanks

 

0 Likes
12 Replies
Steveyoungs
Journeyman III

AMD provide a CPU based OpenCL implementation (certainly for Windows) as do the other well known chip maker.

However in both cases, you will need to install the driver (OpenCL runtime), just as you need to install the c/c++ runtime libraries.

 

Steve.

0 Likes

Actually there is no need to install the driver. OpenCL runtime is shipped with both driver and SDK as AMD's opencl implementation is meant for both CPU & GPU. 

0 Likes

Hi,

So is the code generated by the OpenCL compiler same when it runs in emulation mode or it is diffirent.

Thanks

0 Likes

No, the code is not the same. OpenCL compiler creates architecture (x86, x86_64) dependant SSE binary on the CPU, and ISA code for the GPUs. However, is by "same" you meant same functionality, then sort of.

First of all one clarification: compiling OpenCL onto the CPU is NOT emulation. It does not emulate anything. It is paralell code being compiled onto a multi-core HW, namely a CPU.

As for being the "same", well written code will work the same on CPU and GPU. Not-well written code will work on one, but fail on the other. Such cases are born when synchronization bugs are left in the code, but it accidently works on one of the two, but fails on the other. These are 99% of the times due to faulty programming. This is the reason why running on CPU is not fully the same as running on a GPU, since architectures differ greatly, and sync issues arise differently.

0 Likes

Originally posted by: himanshu.gautam Actually there is no need to install the driver. OpenCL runtime is shipped with both driver and SDK as AMD's opencl implementation is meant for both CPU & GPU. 

Hi,
Could you please tell me the additional linker options or against which library I should link in my code so that I am able to use the emulation mode.

I had a side question. I couldn't find the appropriate forum so I am posting it here.

I tried to download the driver for ATI R5770 Hawk. The webppage
(http://www.driverspro.org/lp.php?bid=ATI&coid=11&muid=11&slid=11&srcid=rdn101) takes me to a scanner software which looks for the list of devices installed and sugegsts the appropriate driver. I do not have the hardware right now but wished to install the software before hand. Could you please let me know where can I get hold of the drivers for the above mentioned card.

Thanks

0 Likes

Hi shankha,

As meteorhead already told, running on CPU is not an emulation.OpenCL compiler creates binaries for all devices you want to. 

You don't need any specific library other than opencl.lib to run opencl programs.

 

I think you should be able to find driver for any AMD device on AMD site. But AFAIK, it would not be possible  to install a driver without the hardware. And why would you need to do that. You can run opencl on CPU without installing the driver at all.

0 Likes

Hi Himanshu,

I tried compiling my OpenCL code. My program fails when I call clGetPlatformIDs.

My copying my code and command line. Please do let me know if you find the options incorrect or I should be using any additional options.

 ====================================================================================================

SRC :

I have attached code to this message.

Compilation Comamnd :

 Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

cl /Feexample.exe  -I"C:\Program Files (x86)\AMD APP"\include  -I"C:\Users\shankhab\Documents\AMD APP"\include  example.c  -DATI_OS_WIN  /link /LIBPATH:"C:\Program Files (x86)\AMD APP"\lib\x86  /LIBPATH:"C:\Users\shankhab\Documents\AMD APP"\lib\x86  OpenCl.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

example.c
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:example.exe
"/LIBPATH:C:\Program Files (x86)\AMD APP\lib\x86"
"/LIBPATH:C:\Users\shankhab\Documents\AMD APP\lib\x86"
OpenCl.lib
example.obj    

Please note, I am not trying to run the Kernel.

====================================================================================================

I do understand the call to clGetPlatformIDs( 1, &platform, NULL ) and clGetDeviceIDs would fail since I do not have the card installed.
The question is then how I make these calls succed so that the correct set of parametres are passed to clCreateProgramWithSource and
the call succeds.

Thanks for your help.

Thanks
Shankha 

#include <CL/cl.h> #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <winbase.h> #include <time.h> #define NWITEMS 512 const char *source = "__kernel void memset( __global uint *dst ) \n" "{ \n" " dst[get_global_id(0)] = get_global_id(0); \n" "} \n"; #define CL_ERROR(func) \ do { \ if (cl_ret != CL_SUCCESS) \ { \ printf ("%s Failed\n", \ func); \ exit (EXIT_FAILURE); \ } \ cl_ret = CL_SUCCESS; \ } while(0) int main(int argc, const char ** argv) { cl_platform_id platform; cl_device_id device; cl_context context; cl_command_queue queue; cl_program program; cl_int cl_ret; cl_ret = clGetPlatformIDs( 1, &platform, NULL ); CL_ERROR("clGetPlatformIDs"); // 2. Find a gpu device. cl_ret = clGetDeviceIDs( platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL); CL_ERROR("clGetDeviceIDs"); // 3. Create a context and command queue on that device. context = clCreateContext(NULL, 1, &device, NULL, NULL, &cl_ret); CL_ERROR("clCreateContext"); queue = clCreateCommandQueue(context, device, 0, &cl_ret); CL_ERROR("clCreateCommandQueue"); program = clCreateProgramWithSource( context, 1, &source, NULL, &cl_ret); CL_ERROR("clCreateProgramWithSource"); cl_ret = clBuildProgram( program, 1, &device, NULL, NULL, NULL ); CL_ERROR("clBuildProgram"); printf ("Done...\n"); return 0; }

0 Likes

You should use CL_DEVICE_TYPE_CPU to run on the CPU device.

Jeff

0 Likes

Thanks for the tip!.

Please correct me if I am wrong. This will generate code which will run on CPU.  I wish to generate code for a particular GPU (say R5700) without installing the card. I do not wish  to run the kernel. Just wish to compile the OpenCL code and dump hthe assembly.

Thanks

 

0 Likes

Originally posted by: shankha Thanks for the tip!.

 

Please correct me if I am wrong. This will generate code which will run on CPU.  I wish to generate code for a particular GPU (say R5700) without installing the card. I do not wish  to run the kernel. Just wish to compile the OpenCL code and dump hthe assembly.



To clarify some.  The same application can use the CPU and GPU devices.  So the code generation is the same *until you call clBuildProgram*.  clBuildProgram is when the driver compiles the OpenCL kernel for the particular device(s) you pass in.  All the host code is identical, really.

That said, you may wish to change the flow of your application depending on whether you are running on a CPU or GPU device.  For example, GPU devices might work more efficiently by moving data to the device, but the CPU doesn't have this issue.

Jeff

0 Likes

Originally posted by: MicahVillmow Shanka, Please use the --offline-devices platform extension. This will allow you to do so.


Thanks.

Found a excellent example  here (http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=115).

 

0 Likes

Shanka,
Please use the --offline-devices platform extension. This will allow you to do so.
0 Likes