0

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!

Matlab and CUDA (C++)

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.

2
  • Can you post the error you are receiving? Commented Feb 17, 2014 at 11:08
  • 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/Local/Temp/tmpxft_00000c44_00000000-8_kernel.cpp1.ii". Commented Feb 17, 2014 at 11:10

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

When I tried your solution I got the error: "kernel.cu(55): error: expression must have pointer-to-object type" I think this is because he doesn't accept the Pointer as an multidimensional Array!
You cannot use [][] style indexing inside CUDA kernels for an array passed by pointer. This error is effectively a different question - "How can I index a Matlab array inside a kernel". Please update your question with some real code.....
Ok so it was the way I wanted to access the data! Thank you for your help! I think I'll open a new Question for that :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.