cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

Highlighted
Journeyman III
Journeyman III

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?

__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 advance, I really need help with this
I can give more details if needed

Tags (1)
0 Kudos
Reply
15 Replies
Highlighted
Journeyman III
Journeyman III

invalid address space for argument to _kernel function

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

OpenCL is C, C++ templates are not supported.

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? 

 

 

 

You can do a #include

0 Kudos
Reply
Highlighted
Exemplar
Exemplar

invalid address space for argument to _kernel function

when you use #include "" in kernel then you must also pass include directory path into clBuildProgram() for example like this "-Ic:\path\to\files\"

0 Kudos
Reply
Highlighted
Journeyman III
Journeyman III

invalid address space for argument to _kernel function

Thanks for your reply,

1- do you know with what can I replace vector type that is Opencl compliant?

2- actually I #include header files in .cl but it doesn't work

QUOTE

when you use #include "" in kernel then you must also pass include directory path into clBuildProgram() for example like this "-Ic:\path\to\files\"  

how can I add it to clBuildProgram(), here is my code

ciErrNum = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

I found nothing about it in opencl spec

 

 

 

0 Kudos
Reply
Highlighted
Journeyman III
Journeyman III

invalid address space for argument to _kernel function

The 4th argument in clBuildProgram() function takes build options as a char*.

OpenCL spec section 5.4.3 describes in detail about the build options.

0 Kudos
Reply
Highlighted

invalid address space for argument to _kernel function

opencl_JEDI,
A vector datatype is best represented as a pointer to a piece of memory. That piece of memory is setup as a sequence of int values.
0 Kudos
Reply
Highlighted
Journeyman III
Journeyman III

invalid address space for argument to _kernel function

Thank you all,

it really helped

0 Kudos
Reply
Highlighted
Journeyman III
Journeyman III

invalid address space for argument to _kernel function

I added the path to my program like this:

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 ?

ciErrNum = clBuildProgram(cpProgram, 0, NULL, "-Ic:\Program Files\OpenCV\cv\include", NULL, NULL);

0 Kudos
Reply
Highlighted
Journeyman III
Journeyman III

invalid address space for argument to _kernel function

I post more details of my problem

this is my kernel in .cl file

I got an error because it doesn't recognise CvSeq structure defined in header file

so I include the file .h and add teh path to clbuildprogram like this

 

const char* cvinclude = "cv.h";const char* cvinclude_path = shrFindFilePath(cvinclude, argv[0]);
    ciErrNum = clBuildProgram(cpProgram, 0, NULL, "-Icvinclude_path", NULL, NULL);

But I still get cv.h not found

please help, I hope I made my problem clear enough,

 

 

__kernel void findPairs( __global const CvSeq* objectKeypoints, __global const CvSeq* objectDescriptors, __global const CvSeq* imageKeypoints, __global const CvSeq* imageDescriptors, __global int* ptpairs ) { int i; int j; CvSeqReader reader, kreader; cvStartReadSeq( objectKeypoints, &kreader, 0); cvStartReadSeq( objectDescriptors, &reader, 0); //ptpairs.clear(); ptpairs = 0; // ptpairs.clear()? for( i = 0; i < objectDescriptors->total; i++ ) { const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr; const float* descriptor = (const float*)reader.ptr; CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader ); CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader ); int nearest_neighbor = naiveNearestNeighbor( descriptor, kp->laplacian, imageKeypoints, imageDescriptors ); if( nearest_neighbor >= 0 ) { for( j = 0; i < 2*objectDescriptors->total; j++ ) { //ptpairs.push_back(i); ptpairs = i; //ptpairs.push_back(i)? //ptpairs.push_back(nearest_neighbor); ptpairs[j+1] = nearest_neighbor; //ptpairs.push_back(nearest_neighbor); j=j+1; } } } }

0 Kudos
Reply
Highlighted
Journeyman III
Journeyman III

invalid address space for argument to _kernel function

Could you try putting the path in quotes and see? The space in the path could be causing issues.

0 Kudos
Reply