Results 1 to 9 of 9

Thread: Problem maybe in clBuildProgram

  1. #1

    Problem maybe in clBuildProgram

    Hi,

    I initially build, compile and execute my openCL program in my AMD notebook. But, now i need to execute in GPU card, and our GPU Card is in a machine that have NVIDA CArd. When i compile my program in a GPU NVDIA, don't show the error message, in true show the set of chars that i show bellow: ================================================== ================================================== ================================================== ==============================================

    The code bellow work in my AMD, but i think that don't work well in NVDIA CARD.

    cl_int erro_compila_kernel = clBuildProgram(program, 1, &device, NULL, NULL, NULL);

    //Verifica se houve erro na compila艫o de todos os Kernels atribuidos a Program.
    if( erro_compila_kernel != CL_SUCCESS )
    {
    char buff_erro[0x10000];
    clGetProgramBuildInfo( program,
    device,
    CL_PROGRAM_BUILD_LOG,
    0x10000,
    buff_erro,
    NULL);
    printf("\n%s\n",buff_erro);
    }
    else
    printf("\nKernel compilado com sucesso.\n");


    A other strange thing is that, when i configured the NVDIA SDK, accused that only one OPenCL source is avaliable, GPU works with opencl, but MultiCore don't.

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Problem maybe in clBuildProgram

    printf("\n%s\n",buff_erro);
    What is the value of erro_compila_kernel? What build log is printed above? Can you show it? If you don't see a build log, try doing this instead:

    Code :
    char *buff_erro;
    cl_int errcode;
    size_t build_log_len;
    errcode = clGetProgramBuildInfo( program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_len);
    if(errcode) { printf("clGetProgramBuildInfo failed at line %d\n", __LINE__); exit(-1); }
     
    buf_erro = malloc(build_log_len);
    if(!buf_erro) { printf("malloc failed at line %d\n", __LINE__); exit(-2);}
     
    errcode = clGetProgramBuildInfo( program, device, CL_PROGRAM_BUILD_LOG, build_log_len, buf_erro, NULL);
    if(errcode) { printf("clGetProgramBuildInfo failed at line %d\n", __LINE__); exit(-3); }
     
    printf("Build log: \n%s\n", buf_erro);
    free(buf_erro);
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3

    Re: Problem maybe in clBuildProgram

    Hi,

    The value of erro_compila_kernel is 0 (false), entering in if clausule.
    It ends up printing the build log, but the content of build log, is a lot of '=' chars.
    Don't displays any decipherable error message.

    And, a thing that i think is very strange is that my code work well in my AMD note when it's run in CPU, but when i run in a other machine that have a GPU, this occurs.

    Do you know what can is happening?

    Very Thanks,

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Problem maybe in clBuildProgram

    If erro_compila_kernel was zero then it's equal to CL_SUCCESS. That doesn't make sense. Can you check again the value returned by clBuildProgram()?

    Also, copy the code I showed earlier and run it instead. Maybe the build log will look correctly now.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  5. #5

    Re: Problem maybe in clBuildProgram

    Hi,

    I used your code and the errors showed better than my code, thanks.
    But, i got what's going.
    The buffer of command don't showed all errors.
    So, i put the errors messages in a file and checked what was happening.
    In a research that i did a person had a same problem that i have currently, but the people that answer the question don't showed how solve only what's going.

    The problem dont occurs when i run my code in CPU, only in GPU.
    When i load my .h and .cpp files in a array of chars , i put manualy the '\0' char in the end of vector to certify that there is the final of file, for later be compiled in kernel.

    But, even with '\0' the rest of vector ( trash of memory ) going to be compiled in kernel, and so, generating error.

    Do you know how can i send only what's in the file for be compiled?

    The error log shows that is:

    :1: error: expected identifier or '('
    様様様様様様様様様様様様様様様様様様様様様様様様様 様様様様様様様様様様様様様様様様様様様様様様様様様 #include <C:/Documents and Settings/All Users/Dados de aplicativos/NVIDIA Corporation/NVIDIA GPU Computing SDK/OpenCL/src/Intervalar/intervalar_metodos.h>


    Very Thanks,

    Luiz Drumond

  6. #6
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Problem maybe in clBuildProgram

    So the problem is that the source code you pass to clCreateProgramWithSource() contains some garbage? How are you reading that source code from a file?
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  7. #7

    Re: Problem maybe in clBuildProgram

    Yes,

    But the problem don't is in load the file, but in file in a vector. Whether i'm allocating a vector with 10000 of chars and my code use only 8000 with '\0' in the end, the compilation processo is ignoring '\0' at the end of vector and send whole of vector, including the 2000 positions that don't was used, that have garbage of memory.
    This problem don't occurs in CPU, but when i set to run in GPU occurs.

    Sorry my english, don't is very good.

    And, very thanks for whole help that you give me in this and others posts.

  8. #8

    Re: Problem maybe in clBuildProgram

    I forgot to put the code that i load my .cpp, .h and kernel to be compiled.

    The code as follow bellow:


    ifstream arquivo;
    char *intervalar_metodos_arquivo = (char *) malloc(10000 * sizeof(char));
    int i = 0;
    //------ intervalar_metodos.cpp
    arquivo.open("intervalar_metodos.cpp");
    while(arquivo.good())
    {

    intervalar_metodos_arquivo[i] = arquivo.get();
    i++;

    }
    i--;


    intervalar_metodos_arquivo[i] = '\0';
    arquivo.close();

  9. #9
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Problem maybe in clBuildProgram

    The way you are reading the file looks mostly okay, except it won't work well for long files.


    Just in case the problem is in how you read the file, here's a quick way to do it:

    Code :
    size_t length;
    char* source;
    ifstream arquivo("intervalar_metodos.cpp");
     
    if(!arquivo)
    {
         // Error message here: could not open file
         exit(-1);
    }
     
    // get length of file
    arquivo.seekg(0, ios::end);
    length = length.tellg();
    length.seekg(0, ios::beg);
     
    // allocate memory
    source = new char[length + 1];
     
    // read file
    arquivo.read(source, length);
    arquivo.close();
     
    // add null termination to string
    source[length] = 0;
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. clbuildprogram
    By evk8888 in forum OpenCL
    Replies: 0
    Last Post: 01-11-2012, 09:52 AM
  2. clBuildProgram Problem?
    By RobanyBigjobz in forum OpenCL
    Replies: 1
    Last Post: 08-11-2011, 09:00 AM

Posting Permissions

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