Hi, All
I have installed both coprthr and pocl on Parallella, a zynq(cortex-A9) base
device.
My question is how do I know which OpenCL platform do I used when I compile my
program
There is a strange output coprthr-1.6.2 (Freewill) at the very beginning of my
program
but in fact, I do want to use pocl as my opencl platform. Here is output of my
program
------------------------------------------------------------------
coprthr-1.6.2 (Freewill)
Finding platforms
Found 2 platforms
Getting platforms
Secure a OCL device
Found platform Portable Computing Language
Get Portable Computing Language, that is it
Printing device output
Device is pthread
non CPU or GPU processor from 0x41 with a max of 2 compute units
Creating context
Creating command queue
Creating program
Building program
------------------------------------------------------------------
my compile command is
gcc main.c -O3 -lm -D DEVICE=CL_DEVICE_TYPE_CPU -lOpenCL -fopenmp -I . -o main
------------------------------------------------------------------
my program is below
void main(){
printf("Finding platforms\n");
err = clGetPlatformIDs(0, NULL, &numPlatforms);
checkError(err, "Finding platforms");
if (numPlatforms == 0){
printf("Found 0 platforms!\n");
return EXIT_FAILURE;
}
printf("Found %d platforms\n", numPlatforms);
// Get all platforms
printf("Getting platforms\n");
cl_platform_id Platform[numPlatforms];
err = clGetPlatformIDs(numPlatforms, Platform, NULL);
checkError(err, "Getting platforms");
uint32_t i, j, k;
// Secure a OCL device
printf("Secure a OCL device\n");
for(i = 0; i < numPlatforms; i++){
err = clGetPlatformInfo(Platform[i], CL_PLATFORM_NAME,
sizeof(platformName), &platformName, NULL);
printf("Found platform %s\n", platformName);
if(!strcmp(platformName, "Portable Computing Language")){
{ printf("Get %s, that is it\n", platformName);
err = clGetDeviceIDs(Platform[i], DEVICE, 1, &device_id, NULL);
if (err == CL_SUCCESS){
break;
}
}
}
if (device_id == NULL)
checkError(err, "Finding a device");
printf("Printing device output\n");
err = output_device_info(device_id);
checkError(err, "Printing device output");
printf("Printing device output\n");
err = output_device_info(device_id);
checkError(err, "Printing device output");
// Create a compute context
printf("Creating context\n");
context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
checkError(err, "Creating context");
// Create a command queue
printf("Creating command queue\n");
commands = clCreateCommandQueue(context, device_id, 0, &err);
checkError(err, "Creating command queue");
// Read kernel source file
int pl;
char *source = file_contents("kernell.cl", &pl);
size_t sourceSize[] = {(size_t)pl};
// Create the compute program from the source buffer
printf("Creating program\n");
program = clCreateProgramWithSource(context, 1, (const char **)&source,
sourceSize, &err);
checkError(err, "Creating program");
printf("Building program\n");
char *compiler_options = "-I \".\" -I \"/usr/local/bin\"";
err = clBuildProgram(program, 1, &device_id, compiler_options, NULL, NULL);
// Do somthing with OpenCL
}------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
pocl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pocl-devel