I'm trying to pass a 2D array to a C function in a CUDA code, and nvcc
won't compile it, but gcc
works fine. Here's the code:
#include<stdio.h>
void f(int row, int col, int[row][col]) {
printf("LOL\n");
}
int main(void) {
int mat[2][3];
f(2, 3, mat);
}
If I put this code in test.c
and run gcc test.c
, it works as expected.
If I put this code in test.cu
and run nvcc test.cu
, it throws the following error:
test.cu(3): error: a parameter is not allowed
Why is it not working with nvcc
? It it's not supported, what's the best way to give a 2D array as parameter in CUDA ? A pointer to the first element of the first row ?
Thanks in advance for help on this.