cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

opencl_JEDI
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

0 Likes
15 Replies
omkaranathan
Adept I

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 Likes

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 Likes

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 Likes

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 Likes

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 Likes

Thank you all,

it really helped

0 Likes

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 Likes

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 Likes

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

0 Likes

I thought about that and here what I already tried

I put the file in a directory without a space, but in this case it doesn't build the program at all. I really don't know what to do, I can't move forward if I can't include my headers.

ciErrNum = clBuildProgram(cpProgram, 0, NULL, "-I C:/Users/localcontrol/internship/OpenCV/cv/include", NULL, NULL);

0 Likes

Are you using the AMD implementation?  We do not use clang in our stack so our implementation cannot generate clang error messages...

0 Likes

No, I'm using nvidia implementation

0 Likes

This should be -I "C:/Users/localcontrol/internship/OpenCV/cv/include"

0 Likes

It doesn't work,

I get error : 'I' : undeclared identifier

0 Likes

Originally posted by: opencl_JEDI It doesn't work,

 

I get error : 'I' : undeclared identifier

 

you try like this

 

"-I/"C:/Users/localcontrol/internship/OpenCV/cv/include/""

0 Likes