Hi.
I’m new to OpenCL and so I tried to implement the AMD Image Convolution tutorial using the code and style from the nVidia SDK samples.
(AMD Image Convolution Tutorial)
I started out by copying one of the sample projects, so the project settings should be okay.
When running the project I get the CL_MEM_OBJECT_ALLOCATION_FAILURE in clEnqueueWriteBuffer and I have no idea how to fix it or why it happens.
now the important code excerpts (full code at link below):
struct hostBufferStruct
{
float * pInput;
} hostBuffers;
struct oclBufferStruct
{
cl_mem inputCL;
} oclBuffers;
struct paramStruct
{
int nInWidth; //Input image width
int nInHeight; //Input image height
} params;
host buffer:
int sizeInBytes = params.nInWidth * params.nInHeight * sizeof(cl_float);
hostBuffers.pInput = (float *) malloc(sizeInBytes);
for (int i = 0; i < params.nInWidth * params.nInHeight; i++)
{
hostBuffers.pInput[i] = float(rand());
}
cl buffer:
oclBuffers.inputCL = clCreateBuffer(cxGPUContext,
CL_MEM_READ_ONLY,
sizeof(cl_float) * params.nInWidth*params.nInHeight,
hostBuffers.pInput,
&ciErr1);
enqueueWrite
ciErr1 = clEnqueueWriteBuffer(cqCommandQue, oclBuffers.inputCL, CL_TRUE, 0,
sizeof(cl_float) * params.nInWidth*params.nInHeight,
hostBuffers.pInput, 0, NULL, NULL);
if (ciErr1 != CL_SUCCESS)
{
shrLog(LOGBOTH, 0.0, "Error in clEnqueueWriteBuffer, Line %u in file %s !!!\n\n", __LINE__, __FILE__);
if(ciErr1 == CL_MEM_OBJECT_ALLOCATION_FAILURE)
shrLog(LOGBOTH, 0.0, "=> CL_MEM_OBJECT_ALLOCATION_FAILURE\n\n");
Cleanup(EXIT_FAILURE);
}
The full code:
.cpp
.cl (taken directly from AMD tutorial)
I really hope one of you knows what I did wrong here.
My system:
Windows 7, 64 bit version
Visual Studio 2008
SDK and driver from here: http://developer.nvidia.com/object/opencl-download.html
(190.89 driver, 2.3 SDK, both 64 bit)
The nVidia samples run without errors.
PS: just in case, I’ve attached a .zip of my full Visual Studio project
EDIT: download doesn’t work. I have uploaded it again, but I don’t know if that will help.
oclConvolution.zip (4.38 MB)