Results 1 to 8 of 8

Thread: invalid address space for argument to _kernel function

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    18

    invalid address space for argument to _kernel function

    Hi,

    I wrote a kernel that takes a vector<int> type as an argument,
    but when I run it the compiler seems not to recognize this type,
    vector<int> is defined in "c:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector"

    my Kernel is defined in a .cl file.

    How can I include header files to a .cl file to allow kernels to take structures defined in those files as arguments?

    Code :
    __kernel void findPairs( __global const CvSeq* objectKeypoints, __global const CvSeq* objectDescriptors,
               __global const CvSeq* imageKeypoints, __global const CvSeq* imageDescriptors, __global vector<int>& ptpairs )
    {

    Actually it's an Opencv code I'm trying to run on GPU using Opencl.

    Thanks in advancs, I really need help with this
    I can give more details if needed

  2. #2
    Junior Member
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    21

    Re: invalid address space for argument to _kernel function

    the vector class is part of the STL of C++. The CL compiler do not know any STL stuff (cause it is an OpenCL compiler, not C++)

    A extra warning : Each compiling of any structure or class in different compilers could lead into data missalignment.

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    18

    Re: invalid address space for argument to _kernel function

    Thanks for your reply,

    - is there a type that I can replace vector with, and that is opencl compliant ?

    I also have another question:
    does structures must be defined in .cl file before using it in kernels,
    when I use structures defined in .h I got errors, when I copy them to .cl file it works.


    Thanks.

  4. #4
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: invalid address space for argument to _kernel function

    OpenCL just provides buffers. You can put whatever you'd like in them. So if you want a long list of ints just make it the right size and copy them in. You can then access it as an array. You won't have any of the nice OO features of STL, though.

    OpenCL will compile your .h files if you include them either from the compile command or with a #include in your kernel and they are in the right location. Otherwise it will not include anything other than the actual string you use to create a program.

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    18

    Re: invalid address space for argument to _kernel function

    I added the path to include files to my program like this:
    Code :
    ciErrNum = clBuildProgram(cpProgram, 0, NULL, "-Ic:\Program Files\OpenCV\cv\include", NULL, NULL);

    like it's described in the opencl spec but when I run it I got:

    - clang: Unknown command line argument 'FilesOpencvinclude'. Try 'clang --help'

    does anyone knows what's could be the problem ?
    Go to the top of the pageReport Post

  6. #6
    Junior Member
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    21

    Re: invalid address space for argument to _kernel function

    Seem like it couldn't handle spaces in the include path.
    Better use / (windows this is valid too, could help when develop multiplatform).
    So you need an include path without any spaces in the name.

  7. #7
    Junior Member
    Join Date
    Mar 2010
    Posts
    18

    Re: invalid address space for argument to _kernel function

    I did change the path and use / like this
    Code :
    ciErrNum = clBuildProgram(cpProgram, 0, NULL, "-I C:/Users/localcontrol/internship/OpenCV/cv/include", NULL, NULL);
    but this time it doesn't run my kernels, I don't get 'cv.h' file not found like before,
    it just run the program until clBuildProgram, and then nothing

  8. #8
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: invalid address space for argument to _kernel function

    Try directly copy-and-pasting your header into the cl code you're passing to clCreateProgram and see if that works. If it does, then it sounds like a driver bug accessing the header file. If not, then there's a problem with your header file.

Similar Threads

  1. address space qualifiers and pointers to arrays
    By romein in forum Interoperability issues
    Replies: 4
    Last Post: 11-14-2012, 08:27 PM
  2. address space on multiple chips
    By wilbur in forum OpenCL
    Replies: 2
    Last Post: 07-03-2009, 12:09 PM

Posting Permissions

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