Results 1 to 2 of 2

Thread: I have a problem with opencl. please give me solution

  1. #1
    Newbie
    Join Date
    Apr 2014
    Posts
    1

    I have a problem with opencl. please give me solution

    I am using SDK opencl. but when debuging code belw, error is occured(error:fatal error LNK1207: there is the type of PDB which is not compatible. after removing, retry it)

    i don't konw why this is occured, could you give the solution to me?

    <CODE>
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <CL/opencl.h>

    void DisplayPlatformInfo(
    cl_platform_id id,
    cl_platform_info name,
    char *str);

    int main(){
    printf("\n------------ Platform & Device Information ------------\n\n");

    cl_int err,i,j;
    size_t size;
    cl_uint numPlatforms, numDevices;
    cl_platform_id *platformIDs;
    cl_device_id *deviceIDs;
    cl_context context =NULL;

    char dev_name[100];
    char dev_vendor_name[100];
    cl_int dev_max_wg;
    cl_int dev_max_cu;
    size_t dev_max_wi[3];

    //플랫폼의 수를 질의한다
    err=clGetPlatformIDs(0,NULL,&numPlatforms);
    if(err != CL_SUCCESS) {
    printf("##Error: clGetPlatformIDs\n");
    printf("##Failed to find any OpenCL platforms\n");
    exit(1);
    }else{
    printf(" (1) Number of OpenCL plarforms : %d\n",numPlatforms);
    }
    //플랫폼 목록들을 할당하고 ID를 질의한다.
    platformIDs=(cl_platform_id *)malloc(sizeof(cl_platform_id)*numPlatforms);

    err=clGetPlatformIDs(numPlatforms,platformIDs,NULL );
    if(err != CL_SUCCESS) {
    printf("##Error: clGetPlatformIDs\n");
    printf("##Failed to find any OpenCL platforms\n");
    exit(1);
    }else{
    printf(" (2) Infomation of each plarform \n");
    for(i=0;i<numPlatforms; i++){
    printf(" ------------------------\n");
    printf(" OpenCL platform[%d]\n",i);
    printf(" ------------------------\n");
    DisplayPlatformInfo(platformIDs[i],CL_PLATFORM_PROFILE,"CL_PLATFORM_PROFILE");

    DisplayPlatformInfo(platformIDs[i],CL_PLATFORM_VERSION,"CL_PLATFORM_VERSION");

    DisplayPlatformInfo(platformIDs[i],CL_PLATFORM_VENDOR,"CL_PLATFORM_VENDOR");
    }
    }
    printf(" ------------------------\n");
    //각 플랫폼 내부의 GPU 디바이스 수를 질의한다.
    for(i=0;i<numPlatforms; i++){
    err=clGetDeviceIDs(platformIDs[i],
    CL_DEVICE_TYPE_GPU,
    0,
    NULL,
    &numDevices);

    if(err != CL_SUCCESS||numDevices<1) {
    printf("##Error: clGetDeviceIDs%d\n",i);
    printf("##Failed to find GPU devices\n");
    exit(1);
    }else{
    printf(" (3) Number of OpenCL devices in platform[%d] : %d\n",i, numPlatforms);
    deviceIDs=(cl_device_id *)malloc(sizeof(cl_device_id)*numDevices);

    for(j=0;j<numDevices;j++){
    printf(" ------------------------\n");
    printf(" OpenCL device[%d]\n",i);
    printf(" ------------------------\n");
    err=clGetDeviceIDs(
    platformIDs[i],
    CL_DEVICE_TYPE_GPU,
    numDevices,
    deviceIDs,
    NULL);
    if(err != CL_SUCCESS) {
    printf("##Error: clGetDeviceIDs%d\n",i);
    printf("##Failed to find GPU devices\n");
    exit(1);
    }

    err=clGetDeviceInfo(
    deviceIDs[j],
    CL_DEVICE_NAME,
    sizeof(dev_name),
    dev_name,
    NULL);
    if(err != CL_SUCCESS) {
    printf("##Error: clGetDeviceInfo\n");
    exit(1);
    }else{
    printf(" DEVICE NAME: [%s]\n",dev_name);

    }
    err=clGetDeviceInfo(
    deviceIDs[j],
    CL_DEVICE_VENDOR,
    sizeof(dev_vendor_name),
    dev_vendor_name,
    NULL);
    if(err != CL_SUCCESS) {
    printf("##Error: clGetDeviceInfo\n");
    exit(1);
    }else{
    printf(" DEVICE NAME: [%s]\n",dev_vendor_name);

    }
    err=clGetDeviceInfo(
    deviceIDs[j],
    CL_DEVICE_MAX_WORK_GROUP_SIZE,
    sizeof(dev_max_wg),
    &dev_max_wg,
    NULL);
    if(err != CL_SUCCESS) {
    printf("##Error: clGetDeviceInfo\n");
    exit(1);
    }else{
    printf(" DEVICE MAX WORK GPOUP SIZE: [%d]\n",dev_max_wg);
    }
    err=clGetDeviceInfo(
    deviceIDs[j],
    CL_DEVICE_MAX_COMPUTE_UNITS,
    sizeof( dev_max_cu),
    & dev_max_cu,
    NULL);
    if(err != CL_SUCCESS) {
    printf("##Error: clGetDeviceInfo\n");
    exit(1);
    }else{
    printf(" DEVICE MAX WORK COMPUTE UNITS: [%d]\n",dev_max_cu);
    }
    err=clGetDeviceInfo(
    deviceIDs[j],
    CL_DEVICE_MAX_WORK_ITEM_SIZES,
    sizeof( dev_max_wi),
    dev_max_wi,
    NULL);
    if(err != CL_SUCCESS) {
    printf("##Error: clGetDeviceInfo\n");
    exit(1);
    }else{
    printf(" DEVICE MAX WORK ITEM SIZES: [%d,%d,%d]\n", dev_max_wi[0], dev_max_wi[1], dev_max_wi[2]);
    }
    }
    }
    }

    free(platformIDs);
    free(deviceIDs);

    }



    void DisplayPlatformInfo(
    cl_platform_id id,
    cl_platform_info name,
    char *str){

    cl_int err;
    size_t val_size;

    char *info;

    err=clGetPlatformInfo(
    id,
    name,
    0,
    NULL,
    &val_size);

    if(err != CL_SUCCESS) {
    printf("##Error: DisplayPlatformInfo\n");
    exit(1);
    }

    info=(char *)malloc(sizeof(char)*val_size);


    err=clGetPlatformInfo(
    id,
    name,
    val_size,
    info,
    NULL);

    if(err != CL_SUCCESS) {
    printf("##Error: DisplayPlatformInfo\n");
    exit(1);
    }else{
    printf(" %s: [%s]\n",str,info);

    }
    free(info);
    }

  2. #2
    Junior Member
    Join Date
    Dec 2010
    Posts
    4
    try #include <CL/cl.h>?

    It builds on my side after i remove the korean characters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •