Reputation: 70
I'm trying to figure out how to pass a matrix from Matlab to a C++ CUDA file (*.ptx). I want to process the matrix differently in every thread! I definitely don't want to split the matrix up in different threads! I want each thread to have the same matrix!
I've tried something like:
_global_ void radialAverage(int* image[][]) {
...
}
but it didn't work. I am getting the following error:
kernel.cu(8): error: an array may not have elements of this type
1 error detected in the compilation of "C:/Users/ADMINI~1/AppData/Loca/Temp/tmpxft_00000c44_00000000-8_kernel.cpp1.ii".
Can you think of any way to do this? Or is it possible?
Btw: I'm not using any libraries for C++, only the CUDA-Api.
Upvotes: 0
Views: 86
Reputation: 72348
The correct way of defining the kernel to pass a matrix from Matlab is clearly shown (several times) on the page you linked to in your question.
In summary, define the kernel like this (the Matlab gpuArray
is passed automagically as a device pointer to the kernel):
__global__ void radialAverage(int* image) {
...
}
After you retrieve the kernel using CUDAKernel
from the toolbox, create an integer gpuArray
from your Matlab matrix, and pass that to the kernel function.
Upvotes: 1