I compile this kernel code is that…
shrLog(LOGBOTH, 0.0, "Initializing OpenCL
");
oclHandles.context = clCreateContextFromType(0, CL_DEVICE_TYPE_GPU, NULL, NULL, &err);
shrCheckError(err, CL_SUCCESS);
err = clGetContextInfo(oclHandles.context, CL_CONTEXT_DEVICES, 0, NULL, &dataByte);
oclHandles.devices = (cl_device_id*)malloc(dataByte);
err |= clGetContextInfo(oclHandles.context, CL_CONTEXT_DEVICES, dataByte, oclHandles.devices, NULL);
shrCheckError(err, CL_SUCCESS);
GetAndLogDevice(oclHandles.devices, argc, &argv, &oclHandles.context); // print device data
//Create a command-queue
oclHandles.queue = clCreateCommandQueue(oclHandles.context, oclHandles.devices[0], 0, &err);
shrCheckError(err, CL_SUCCESS);
// device Info
size_t returned_size = 0;
size_t max_workgroup_size = 0;
err = clGetDeviceInfo(*oclHandles.devices, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &max_workgroup_size, &returned_size);
if (err != CL_SUCCESS)
{
printf("Error: Failed to retrieve device info!
");
return EXIT_FAILURE;
}
// 3. allocating inputCL buffer..
shrLog(LOGBOTH, 0.0, "...allocating inputCL buffers
");
// if you use CL_MEM_COPY_HOST_PTR attibute, you must write 4 parameter(void*) data.
// Another attribute - you choose that 4 parameter write or NULL.
clBuffers.inputCL = clCreateBuffer(oclHandles.context, CL_MEM_READ_WRITE, compressedSize, NULL, &err);
if(!clBuffers.inputCL)
{
printf("ERROR : Failed to allocating inputCL buffer!
");
return EXIT_FAILURE;
}
// Hextile ??? ?? ?? raw ??? ? ??? ??? size? image? ???? ??
clBuffers.outputCL = clCreateBuffer(oclHandles.context, CL_MEM_WRITE_ONLY, compressedSize, NULL, &err);
if(!clBuffers.outputCL)
{
printf("ERROR : Failed to allocating OutputCL buffer!
");
return EXIT_FAILURE;
}
//4. Program Setup
//
shrLog(LOGBOTH, 0.0, "Initializing OpenCL Hextile...
");
// ret = InitOpenCL(clGPUContext, clCommandQueue, argv);
size_t program_length;
cl_device_id device_id;
// kernel.cl loading
shrLog(LOGBOTH, 0.0, "..loading Kernel.cl
");
char* source_path = shrFindFilePath("SubRectEncode.cl", argv[0]);
shrCheckError(source_path != NULL, shrTRUE);
// const char* filename = "SubRectEncode.cl";
// char *source_path = load_program_source(filename);
char *kernel_source = oclLoadProgSource(source_path, "", &program_length);
//shrCheckError(kernel_source != NULL, shrTRUE);
// Connect to a GPU computing device
err = clGetDeviceIDs(NULL, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
if(err != CL_SUCCESS)
{
printf("ERROR : Failed to create a device group!
");
return EXIT_FAILURE;
}
// create kernel program
shrLog(LOGBOTH, 0.0, "..creating kernel program
");
oclHandles.program = clCreateProgramWithSource(oclHandles.context, 1, (const char **)&kernel_source, &program_length, &err);
if(!oclHandles.program || err != CL_SUCCESS)
{
printf("ERROR : Failed to create computing program!!
");
return EXIT_FAILURE;
}
// build kernel program
shrLog(LOGBOTH, 0.0, "...building kernel program
");
err = clBuildProgram(oclHandles.program, 0, NULL, NULL, NULL, NULL); // this erro!
if(err != CL_SUCCESS)
{
size_t len;
char buffer[4096];
printf("ERROR : Failed to build program executable!
");
clGetProgramBuildInfo(oclHandles.program, device_id, CL_PROGRAM_BUILD_LOG,
sizeof(buffer), buffer, &len);
printf("%s
", buffer);
return EXIT_FAILURE;
}
I write the error statement up to the code.
Oh, I have one question…
The sample source code at NVIDIA are not include the clGetDeviceIDs() function.
But another sample at web-stie is included the clGetDeviceIDs() function.
Is it important to me??