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 )
{
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
when you use #include "" in kernel then you must also pass include directory path into clBuildProgram() for example like this "-Ic:\path\to\files\"
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
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.
Thank you all,
it really helped
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);
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; } } } }
Could you try putting the path in quotes and see? The space in the path could be causing issues.
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);
Are you using the AMD implementation? We do not use clang in our stack so our implementation cannot generate clang error messages...
No, I'm using nvidia implementation
This should be -I "C:/Users/localcontrol/internship/OpenCV/cv/include"
It doesn't work,
I get error : 'I' : undeclared identifier
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/""