Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Error using my .h files in Kernel OpenCL

  1. #1

    Error using my .h files in Kernel OpenCL

    Hi,

    I successfully include my .h file in kernel, no erros in compile process
    in VS 2010 occurs.
    However, when kernel is compiled a error occour.
    I guess that error is because of the link process.

    I put the full path in #include statment.
    Add path in VS2010 Linker option and copy .o file in all possible
    directories.

    The error is:
    C:\DOCUME~1\A\CONFIG~1\Temp\OCL256.tmp.obj:fake.text+0x29): undefined
    reference to `i_imprime'
    C:\DOCUME~1\A\CONFIG~1\Temp\OCL256.tmp.obj:fake.text+0x92): undefined
    refer
    ence to `i_imprime'

    i_imprime is a function in my .h file.

    Please help me, i don't know more what i can do.

    Very Thanks,
    Luiz.

  2. #2

    Re: Error using my .h files in Kernel OpenCL

    It sounds like you are mixing host code with kernel code. A few things are unclear to me after reading your question. What is the content of the header file? Where is it included? What is i_imprime? What object file are you placing in all possible directories? What does the kernel source look like?

  3. #3

    Re: Error using my .h files in Kernel OpenCL

    Hi,

    I had a sequential algorithm and i want paralelize with openCL.

    Almost of the functions that i need to use in kernel, is in my .h file. So, i
    put the sentence #include inside of kernel to use these functions.
    When compile kernel no error occours in the #include sentence, but occours in
    calling of functions described in my .h file.

    i_imprime is one function present in my .h file.

    The object file is .obj file compiled by VS2010, as i thought that in
    kernel compile process was not find the .obj file to incorporate in .exe
    file, i copy this .obj file in all directories of my project and includes
    this paths in linker and include options of project.

    The Kernel at first don't do anything, because i need to make this
    working first.

    Very Thanks for help,

  4. #4
    Member
    Join Date
    Mar 2010
    Location
    Raleigh, NC
    Posts
    55

    Re: Error using my .h files in Kernel OpenCL

    I too am having trouble identifying the problem. However, if you are mixing host and kernel code, you could have some issues from my past experience. Without seeing your code, I can only take a stab at what is wrong (if you want to post it here, more eyes can see it; otherwise you could email the solution to me and I could try to replicate and solve the issue). The following thoughts are random ideas that popped into my mind:

    From what I understand, you have a bunch of functions from your sequential algorithm. Those are in a .h file. You have converted these functions to kernels, and they are also in the .h file.

    Are you checking the error code when you build the OpenCL program, identify kernels, etc? That would be a great place to start. If you have a typo in the program, you'd probably get an error message, allowing you to track that down.

    I have found that, when I compile OpenCL programs with the NVIDIA drivers, the kernel is stored in the temporary files location on your computer. That could be what it is trying to find, but can't.

    I've gotta head to class...should finish this post in about 3-4 hours.

  5. #5

    Re: Error using my .h files in Kernel OpenCL

    Note that the compilation of the kernels is completely separate from the compilation of the host application. Kernel compilation normally happens during runtime and has nothing to do with the .obj-files created by Visual Studio.

  6. #6

    Re: Error using my .h files in Kernel OpenCL

    Thanks for everyone that help me.

    I know that the compilation of kernel is in run time.

    Here is my problem, i put this example to help you to understand me.
    The code descript below is my kernel
    ____________
    #include <D:/Meus Documentos/Programação/2010/OpenCL/Testes de Códigos/PrjTeste1/PrjTeste1/intervalar.h> //Here is my .h file that i create with functions that i need to work in my kernel

    __kernel void soma_de_vetores( __global uint *vetor1,
    __global uint *vetor2,
    __global uint *vetor_resultante){
    i_imprime(vetor[0]); //This function is inside of intervalar.h

    }

    The problem is, no error occur in #include sentence, but when i call the function i_imprime a error below happen:

    O erro é:
    C: \ DOCUME ~ 1 \ A CONFIG \ ~ 1 \ Temp \ OCL256.tmp.obj: (text +0
    x29).:: fake indefinido
    referência a «i_imprime '
    C: \ DOCUME ~ 1 \ A CONFIG \ ~ 1 \ Temp \ OCL256.tmp.obj: (text +0
    x92).:: fake indefinido
    referem-se
    referência à «i_imprime '

  7. #7

    Re: Error using my .h files in Kernel OpenCL

    I guess that i found the problem, altough i don't know how solve this.

    When i put inside the Kernel #include with my .h file, all functions described in my .h file don't were to for .obj file of kernel.

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

    Re: Error using my .h files in Kernel OpenCL

    You can pass the definition (implementation) of your functions to clBuildProgramWithSource().

    That is, your header file contains this:
    Code :
    void foo(__global float* bar);

    Then your "library" string contains this:
    Code :
    #include <myheader.h>
    void foo(__global float* bar)
    {
        // Example implementation
        bar[get_global_id(0)] = get_global_id(0);
    }

    Your main program could look like this:
    Code :
    #include <myheader.h>
     
    __kernel void mykernel(__global float* a, __global float* b)
    {
        // ... do some stuff here...
        // ...then call into the "library"
        foo(a);
    }


    Finally, your host code would do something like this:
    Code :
    cl_char* mysources[2] = {mylibrary, mykernel};
    cl_program program = clCreateProgramWithSource(context, 2, &mysources[0], NULL, &errcode);
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  9. #9

    Re: Error using my .h files in Kernel OpenCL

    Hi david.garcia,

    Very Thanks, it is exactly what i needed.

    Already that you help me, i want to ask something more.

    I did exactly you sent, but a error happened in compilation of kernel.

    "_intervalo" has already been declared in the current scope
    struct _intervalo

    _intervalo is a struct that i declared in my .h file.

    Thanks,

    Luiz Drumond.

  10. #10

    Re: Error using my .h files in Kernel OpenCL

    sounds like you included the .h file from several sources. try this:

    Code :
    #ifndef INTERVALO
    #define INTERVALO
    struct _intervalo
    {
    // your struct here
    };
     
    #endif

    or alternatively (and i'm not sure if this will work in OCL, it does in c/c++), put this line at the top of your .h file.
    Code :
    #pragma once

    These preprocessor directives simply tell the compiler not to define the same struct (or function/global variable/other shared resources) more than once.

Page 1 of 2 12 LastLast

Similar Threads

  1. OpenCL kernel crashes with -5 Error
    By Gopal_HC in forum OpenCL
    Replies: 0
    Last Post: 08-09-2012, 03:12 AM
  2. OpenCL error on multiple kernel runs
    By xargon in forum OpenCL
    Replies: 2
    Last Post: 05-17-2012, 07:47 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
  •