Can we run NVidai OpenCL samples on CPU (AMD/Intel) Are the Nvidia opencl samples runs on CPU?
Are the Nvidia opencl samples runs on CPU?

Can some comment pls?
Are the Nvidia opencl samples runs on CPU?



Can some comment pls?

#1
Posted 05/07/2012 06:21 AM   
Yes, you would have to change the source to look for CPU type devices though
Yes, you would have to change the source to look for CPU type devices though

#2
Posted 05/07/2012 04:27 PM   
Thanks jam for the reply.

I am working on "OclScan" sample, i have modified the sample to run on CPU. (line#57 main.cpp).

I got the below error when i am running the sample:

oclScan.exe Starting...

Allocating and initializing host arrays...
Initializing OpenCL...
Error -1001 in clGetPlatformIDs Call !!!


!!! Error # -1000 (Unspecified Error) at line 51 , in file .\src\main.cpp !!!

Exiting...


Any help is appreciated.
Thanks jam for the reply.



I am working on "OclScan" sample, i have modified the sample to run on CPU. (line#57 main.cpp).



I got the below error when i am running the sample:



oclScan.exe Starting...



Allocating and initializing host arrays...

Initializing OpenCL...

Error -1001 in clGetPlatformIDs Call !!!





!!! Error # -1000 (Unspecified Error) at line 51 , in file .\src\main.cpp !!!



Exiting...





Any help is appreciated.

#3
Posted 05/08/2012 06:06 AM   
[quote name='scharupa' date='08 May 2012 - 09:06 AM' timestamp='1336457185' post='1405522']
Thanks jam for the reply.

I am working on "OclScan" sample, i have modified the sample to run on CPU. (line#57 main.cpp).

I got the below error when i am running the sample:

oclScan.exe Starting...

Allocating and initializing host arrays...
Initializing OpenCL...
Error -1001 in clGetPlatformIDs Call !!!


!!! Error # -1000 (Unspecified Error) at line 51 , in file .\src\main.cpp !!!

Exiting...


Any help is appreciated.
[/quote]

Let me help you because you are not loading the correct platform...

First thing is to change a bit the oclutils.h so as not search only for NVIDIA...

change in there :

extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID);

to

extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU=true);

Now go to oclutils.cpp to the declaration of : cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID)

and change it to :

cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU)

Now inside the function add this :
[code]

ciErrNum = clGetPlatformInfo (clPlatformIDs[i], CL_PLATFORM_NAME, 1024, &chBuffer, NULL);
if(ciErrNum == CL_SUCCESS)
{
if(strstr(chBuffer, "NVIDIA") != NULL && GPU)
{
*clSelectedPlatformID = clPlatformIDs[i];
break;
}

if(strstr(chBuffer, "Intel") != NULL && !GPU)
{
*clSelectedPlatformID = clPlatformIDs[i];
break;
}

}
[/code]


i.e we add to search for Intel, if you have an AMD processor replace Intel with AMD.

So we have hacked a bit oclutils.h and oclutils.cpp and all examples of NVIDIA will run normally.

Now in main.cpp

[code]

shrLog("Initializing OpenCL...\n");
//Get the Intel Platform
ciErrNum = oclGetPlatformID(&cpPlatform, false);
oclCheckError(ciErrNum, CL_SUCCESS);

//Get a GPU device
ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);
oclCheckError(ciErrNum, CL_SUCCESS);

//Create the context
cxGPUContext = clCreateContext(0, 1, &cdDevice, NULL, NULL, &ciErrNum);
oclCheckError(ciErrNum, CL_SUCCESS);

//Create a command-queue
cqCommandQueue = clCreateCommandQueue(cxGPUContext, cdDevice, 0, &ciErrNum);
oclCheckError(ciErrNum, CL_SUCCESS);
[/code]

I am not changing the variable cxGPUContext, you can change it to cxCPUContext if you like.

You are done. Enjoy :-) I see ./ so probably you are using Linux...you have to recompile oclutils.cpp a simple make clean and make again to save you from the fuss...also if your flavor of Linux has a TaskManager as Windows watch the CPU cores going all up. :-)
OpenCL is all wires in logic but it is for Software Engineers...with all respect to CUDA because I use it also but the latest is more to Software Developers.
[quote name='scharupa' date='08 May 2012 - 09:06 AM' timestamp='1336457185' post='1405522']

Thanks jam for the reply.



I am working on "OclScan" sample, i have modified the sample to run on CPU. (line#57 main.cpp).



I got the below error when i am running the sample:



oclScan.exe Starting...



Allocating and initializing host arrays...

Initializing OpenCL...

Error -1001 in clGetPlatformIDs Call !!!





!!! Error # -1000 (Unspecified Error) at line 51 , in file .\src\main.cpp !!!



Exiting...





Any help is appreciated.





Let me help you because you are not loading the correct platform...



First thing is to change a bit the oclutils.h so as not search only for NVIDIA...



change in there :



extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID);



to



extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU=true);



Now go to oclutils.cpp to the declaration of : cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID)



and change it to :



cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU)



Now inside the function add this :





ciErrNum = clGetPlatformInfo (clPlatformIDs[i], CL_PLATFORM_NAME, 1024, &chBuffer, NULL);

if(ciErrNum == CL_SUCCESS)

{

if(strstr(chBuffer, "NVIDIA") != NULL && GPU)

{

*clSelectedPlatformID = clPlatformIDs[i];

break;

}



if(strstr(chBuffer, "Intel") != NULL && !GPU)

{

*clSelectedPlatformID = clPlatformIDs[i];

break;

}



}






i.e we add to search for Intel, if you have an AMD processor replace Intel with AMD.



So we have hacked a bit oclutils.h and oclutils.cpp and all examples of NVIDIA will run normally.



Now in main.cpp







shrLog("Initializing OpenCL...\n");

//Get the Intel Platform

ciErrNum = oclGetPlatformID(&cpPlatform, false);

oclCheckError(ciErrNum, CL_SUCCESS);



//Get a GPU device

ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);

oclCheckError(ciErrNum, CL_SUCCESS);



//Create the context

cxGPUContext = clCreateContext(0, 1, &cdDevice, NULL, NULL, &ciErrNum);

oclCheckError(ciErrNum, CL_SUCCESS);



//Create a command-queue

cqCommandQueue = clCreateCommandQueue(cxGPUContext, cdDevice, 0, &ciErrNum);

oclCheckError(ciErrNum, CL_SUCCESS);




I am not changing the variable cxGPUContext, you can change it to cxCPUContext if you like.



You are done. Enjoy :-) I see ./ so probably you are using Linux...you have to recompile oclutils.cpp a simple make clean and make again to save you from the fuss...also if your flavor of Linux has a TaskManager as Windows watch the CPU cores going all up. :-)

OpenCL is all wires in logic but it is for Software Engineers...with all respect to CUDA because I use it also but the latest is more to Software Developers.

Dr. Alexander Agathos Degree in Maths, PhD in Computer Science (specialization in Computer Graphics)

Researcher in HPC, Department of Mathematics and Informatics, West University of Timisoara, Romania.

[email="agalex@iit.demokritos.gr"]Email[/email]

Website

--------------------
A famous researcher in parallelism said : Parallelism is a great problem. The basic question is though are you part of the solution or part of the problem?

The challenges of parallel computing are simple to enumerate : expose lots of parallelism and minimize communication (said another way : maximize locality)

The more complicated you present a subject the less you have really mastered it...Albert Einstein.

#4
Posted 05/09/2012 01:51 AM   
[quote name='AlexanderAgathos' date='09 May 2012 - 01:51 AM' timestamp='1336528315' post='1405878']
Let me help you because you are not loading the correct platform...

First thing is to change a bit the oclutils.h so as not search only for NVIDIA...

change in there :

extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID);

to

extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU=true);

Now go to oclutils.cpp to the declaration of : cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID)

and change it to :

cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU)

Now inside the function add this :
[code]

ciErrNum = clGetPlatformInfo (clPlatformIDs[i], CL_PLATFORM_NAME, 1024, &chBuffer, NULL);
if(ciErrNum == CL_SUCCESS)
{
if(strstr(chBuffer, "NVIDIA") != NULL && GPU)
{
*clSelectedPlatformID = clPlatformIDs[i];
break;
}

if(strstr(chBuffer, "Intel") != NULL && !GPU)
{
*clSelectedPlatformID = clPlatformIDs[i];
break;
}

}
[/code]


i.e we add to search for Intel, if you have an AMD processor replace Intel with AMD.

So we have hacked a bit oclutils.h and oclutils.cpp and all examples of NVIDIA will run normally.

Now in main.cpp

[code]

shrLog("Initializing OpenCL...\n");
//Get the Intel Platform
ciErrNum = oclGetPlatformID(&cpPlatform, false);
oclCheckError(ciErrNum, CL_SUCCESS);

//Get a GPU device
ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);
oclCheckError(ciErrNum, CL_SUCCESS);

//Create the context
cxGPUContext = clCreateContext(0, 1, &cdDevice, NULL, NULL, &ciErrNum);
oclCheckError(ciErrNum, CL_SUCCESS);

//Create a command-queue
cqCommandQueue = clCreateCommandQueue(cxGPUContext, cdDevice, 0, &ciErrNum);
oclCheckError(ciErrNum, CL_SUCCESS);
[/code]

I am not changing the variable cxGPUContext, you can change it to cxCPUContext if you like.

You are done. Enjoy :-) I see ./ so probably you are using Linux...you have to recompile oclutils.cpp a simple make clean and make again to save you from the fuss...also if your flavor of Linux has a TaskManager as Windows watch the CPU cores going all up. :-)
OpenCL is all wires in logic but it is for Software Engineers...with all respect to CUDA because I use it also but the latest is more to Software Developers.
[/quote]

You could just take the opencl file and write host code to run it on both and get used to creating a context with cpu devices in it.
[quote name='AlexanderAgathos' date='09 May 2012 - 01:51 AM' timestamp='1336528315' post='1405878']

Let me help you because you are not loading the correct platform...



First thing is to change a bit the oclutils.h so as not search only for NVIDIA...



change in there :



extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID);



to



extern "C" cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU=true);



Now go to oclutils.cpp to the declaration of : cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID)



and change it to :



cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID, bool GPU)



Now inside the function add this :





ciErrNum = clGetPlatformInfo (clPlatformIDs[i], CL_PLATFORM_NAME, 1024, &chBuffer, NULL);

if(ciErrNum == CL_SUCCESS)

{

if(strstr(chBuffer, "NVIDIA") != NULL && GPU)

{

*clSelectedPlatformID = clPlatformIDs[i];

break;

}



if(strstr(chBuffer, "Intel") != NULL && !GPU)

{

*clSelectedPlatformID = clPlatformIDs[i];

break;

}



}






i.e we add to search for Intel, if you have an AMD processor replace Intel with AMD.



So we have hacked a bit oclutils.h and oclutils.cpp and all examples of NVIDIA will run normally.



Now in main.cpp







shrLog("Initializing OpenCL...\n");

//Get the Intel Platform

ciErrNum = oclGetPlatformID(&cpPlatform, false);

oclCheckError(ciErrNum, CL_SUCCESS);



//Get a GPU device

ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);

oclCheckError(ciErrNum, CL_SUCCESS);



//Create the context

cxGPUContext = clCreateContext(0, 1, &cdDevice, NULL, NULL, &ciErrNum);

oclCheckError(ciErrNum, CL_SUCCESS);



//Create a command-queue

cqCommandQueue = clCreateCommandQueue(cxGPUContext, cdDevice, 0, &ciErrNum);

oclCheckError(ciErrNum, CL_SUCCESS);




I am not changing the variable cxGPUContext, you can change it to cxCPUContext if you like.



You are done. Enjoy :-) I see ./ so probably you are using Linux...you have to recompile oclutils.cpp a simple make clean and make again to save you from the fuss...also if your flavor of Linux has a TaskManager as Windows watch the CPU cores going all up. :-)

OpenCL is all wires in logic but it is for Software Engineers...with all respect to CUDA because I use it also but the latest is more to Software Developers.





You could just take the opencl file and write host code to run it on both and get used to creating a context with cpu devices in it.

#5
Posted 05/09/2012 04:59 AM   
Thanks Alexander for the inputs.

I have modified the code as you said, now i am getting DEVICE not found error:

oclScan.exe Starting...

Allocating and initializing host arrays...
Initializing OpenCL...

!!! Error # -1 (CL_DEVICE_NOT_FOUND) at line 59 , in file .\src\main.cpp !!!

Exiting...
-----------------------------------------------------------


main.cpp -> line 58,59

58: ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);
59: oclCheckError(ciErrNum, CL_SUCCESS);


Can you help for this.
Thanks Alexander for the inputs.



I have modified the code as you said, now i am getting DEVICE not found error:



oclScan.exe Starting...



Allocating and initializing host arrays...

Initializing OpenCL...



!!! Error # -1 (CL_DEVICE_NOT_FOUND) at line 59 , in file .\src\main.cpp !!!



Exiting...

-----------------------------------------------------------





main.cpp -> line 58,59



58: ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);

59: oclCheckError(ciErrNum, CL_SUCCESS);





Can you help for this.

#6
Posted 05/10/2012 09:37 AM   
[quote name='scharupa' date='10 May 2012 - 12:37 PM' timestamp='1336642671' post='1406409']
Thanks Alexander for the inputs.

I have modified the code as you said, now i am getting DEVICE not found error:

oclScan.exe Starting...

Allocating and initializing host arrays...
Initializing OpenCL...

!!! Error # -1 (CL_DEVICE_NOT_FOUND) at line 59 , in file .\src\main.cpp !!!

Exiting...
-----------------------------------------------------------


main.cpp -> line 58,59

58: ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);
59: oclCheckError(ciErrNum, CL_SUCCESS);


Can you help for this.
[/quote]

What processor do you have? Have you installed the Intel or AMD OpenCL SDK? If so which SDK?


[quote name='scharupa' date='10 May 2012 - 12:37 PM' timestamp='1336642671' post='1406409']

Thanks Alexander for the inputs.



I have modified the code as you said, now i am getting DEVICE not found error:



oclScan.exe Starting...



Allocating and initializing host arrays...

Initializing OpenCL...



!!! Error # -1 (CL_DEVICE_NOT_FOUND) at line 59 , in file .\src\main.cpp !!!



Exiting...

-----------------------------------------------------------





main.cpp -> line 58,59



58: ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_CPU, 1, &cdDevice, NULL);

59: oclCheckError(ciErrNum, CL_SUCCESS);





Can you help for this.





What processor do you have? Have you installed the Intel or AMD OpenCL SDK? If so which SDK?




Dr. Alexander Agathos Degree in Maths, PhD in Computer Science (specialization in Computer Graphics)

Researcher in HPC, Department of Mathematics and Informatics, West University of Timisoara, Romania.

[email="agalex@iit.demokritos.gr"]Email[/email]

Website

--------------------
A famous researcher in parallelism said : Parallelism is a great problem. The basic question is though are you part of the solution or part of the problem?

The challenges of parallel computing are simple to enumerate : expose lots of parallelism and minimize communication (said another way : maximize locality)

The more complicated you present a subject the less you have really mastered it...Albert Einstein.

#7
Posted 05/10/2012 10:09 AM   
[quote name='AlexanderAgathos' date='10 May 2012 - 10:09 AM' timestamp='1336644547' post='1406411']
What processor do you have? Have you installed the Intel or AMD OpenCL SDK? If so which SDK?
[/quote]


I am using Intel-Core-2-Duo
I have installed only Nvidia OpenCL/CUDA SDK-4.1.

Can't we run the sample using NVIDIA OPENCL SDK on CPU? Is the NVIDIA SDK does not supports CPU hardware?
[quote name='AlexanderAgathos' date='10 May 2012 - 10:09 AM' timestamp='1336644547' post='1406411']

What processor do you have? Have you installed the Intel or AMD OpenCL SDK? If so which SDK?







I am using Intel-Core-2-Duo

I have installed only Nvidia OpenCL/CUDA SDK-4.1.



Can't we run the sample using NVIDIA OPENCL SDK on CPU? Is the NVIDIA SDK does not supports CPU hardware?

#8
Posted 05/10/2012 10:23 AM   
[quote name='scharupa' date='10 May 2012 - 01:23 PM' timestamp='1336645420' post='1406413']
I am using Intel-Core-2-Duo
I have installed only Nvidia OpenCL/CUDA SDK-4.1.

Can't we run the sample using NVIDIA OPENCL SDK on CPU? Is the NVIDIA SDK does not supports CPU hardware?
[/quote]

No you can't. The SDK of NVIDIA is just for the GPU. Since you have an Intel-Core-2-Duo then your only solution is to go to :

[url="http://developer.amd.com/sdks/AMDAPPSDK/downloads/Pages/default.aspx"]http://developer.amd.com/sdks/AMDAPPSDK/downloads/Pages/default.aspx[/url]

and install the AMD SDK for Linux. I am assuming you are on a Linux platform.
You have to replace the "Intel" in oclutils.cpp to "AMD"
specifically : [color=#000088][size=2]if[/size][/color][color=#666600][size=2]([/size][/color][size=2]strstr[/size][color=#666600][size=2]([/size][/color][size=2]chBuffer[/size][color=#666600][size=2],[/size][/color][size=2] [/size][color=#008800][size=2]"AMD"[/size][/color][color=#666600][size=2])[/size][/color][size=2] [/size][color=#666600][size=2]!=[/size][/color][size=2] NULL [/size][color=#666600][size=2]&&[/size][/color][size=2] [/size][color=#666600][size=2]![/size][/color][size=2]GPU[/size][color=#666600][size=2])[/size][/color]
[color="#666600"][size=2]
[/size][/color]
[quote name='scharupa' date='10 May 2012 - 01:23 PM' timestamp='1336645420' post='1406413']

I am using Intel-Core-2-Duo

I have installed only Nvidia OpenCL/CUDA SDK-4.1.



Can't we run the sample using NVIDIA OPENCL SDK on CPU? Is the NVIDIA SDK does not supports CPU hardware?





No you can't. The SDK of NVIDIA is just for the GPU. Since you have an Intel-Core-2-Duo then your only solution is to go to :



http://developer.amd.com/sdks/AMDAPPSDK/downloads/Pages/default.aspx



and install the AMD SDK for Linux. I am assuming you are on a Linux platform.

You have to replace the "Intel" in oclutils.cpp to "AMD"

specifically : if(strstr(chBuffer, "AMD") != NULL && !GPU)


Dr. Alexander Agathos Degree in Maths, PhD in Computer Science (specialization in Computer Graphics)

Researcher in HPC, Department of Mathematics and Informatics, West University of Timisoara, Romania.

[email="agalex@iit.demokritos.gr"]Email[/email]

Website

--------------------
A famous researcher in parallelism said : Parallelism is a great problem. The basic question is though are you part of the solution or part of the problem?

The challenges of parallel computing are simple to enumerate : expose lots of parallelism and minimize communication (said another way : maximize locality)

The more complicated you present a subject the less you have really mastered it...Albert Einstein.

#9
Posted 05/10/2012 10:44 AM   
Thank you Alexander for all you support. I am able to runt the sample on CPU with AMD APP SDK.

Have a nice day.
Thank you Alexander for all you support. I am able to runt the sample on CPU with AMD APP SDK.



Have a nice day.

#10
Posted 05/10/2012 11:03 AM   
Cool. Enjoy your time with OpenCL, it is a magnificent API.

Cheers,
Alexander.
Cool. Enjoy your time with OpenCL, it is a magnificent API.



Cheers,

Alexander.

Dr. Alexander Agathos Degree in Maths, PhD in Computer Science (specialization in Computer Graphics)

Researcher in HPC, Department of Mathematics and Informatics, West University of Timisoara, Romania.

[email="agalex@iit.demokritos.gr"]Email[/email]

Website

--------------------
A famous researcher in parallelism said : Parallelism is a great problem. The basic question is though are you part of the solution or part of the problem?

The challenges of parallel computing are simple to enumerate : expose lots of parallelism and minimize communication (said another way : maximize locality)

The more complicated you present a subject the less you have really mastered it...Albert Einstein.

#11
Posted 05/10/2012 11:07 AM   
Scroll To Top