Compilation error

Hello.

Why the code below return error at compile time? Am I violating some constraint?

[codebox]#include <stdlib.h>

#include <stdio.h>

global void parcimoniosoKernel(int *zd);

device int viavel(int m, int nos, int *zd);

int main( int argc, char** argv) {

int *zd; cudaMalloc((void **)&zd, sizeof(int) * 10);

parcimoniosoKernel<<<1, 1>>>(zd);

return 0;

}

global void parcimoniosoKernel(int *zd) {

    viavel(60, 60, zd);

}

device int viavel(int m, int nos, int *zd) {

int i=0;

int w[nos+1];

for (i=1; i<=nos-1; i++) {

    int x = zd[i];

    w[x] = w[x] + 1;

}

return 0;

}[/codebox]

error:

[codebox]Signal: Segmentation fault in Code_Expansion phase.

(0): Error: Signal Segmentation fault in phase Code_Expansion – processing aborted

*** Internal stack backtrace:

/usr/local/cuda/open64/lib//be [0x82edd22]

/usr/local/cuda/open64/lib//be [0x82ee700]

/usr/local/cuda/open64/lib//be [0x82eea8c]

/usr/local/cuda/open64/lib//be [0x82edf73]

/usr/local/cuda/open64/lib//be [0x82eed32]

[0x4001e400]

/usr/local/cuda/open64/lib//be [0x81a1dc3]

/usr/local/cuda/open64/lib//be [0x819ea8c]

/usr/local/cuda/open64/lib//be [0x819fd4b]

/usr/local/cuda/open64/lib//be [0x819edb3]

/usr/local/cuda/open64/lib//be [0x81a35a5]

/usr/local/cuda/open64/lib//be [0x81a41cc]

/usr/local/cuda/open64/lib//be [0x81a4735]

/usr/local/cuda/open64/lib//be [0x8180fa5]

/usr/local/cuda/open64/lib//be [0x804c501]

/usr/local/cuda/open64/lib//be [0x804d297]

/usr/local/cuda/open64/lib//be [0x804e5ff]

/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0x40172775]

/usr/local/cuda/open64/lib//be [0x804aa81]

nvopencc INTERNAL ERROR: /usr/local/cuda/open64/lib//be died due to signal 4

[/codebox]

nvcc version:

[codebox]nvcc: NVIDIA ® Cuda compiler driver

Copyright © 2005-2009 NVIDIA Corporation

Built on Thu_Jul__2_10:56:25_PDT_2009

Cuda compilation tools, release 2.3, V0.2.1221[/codebox]

nvcc version:

[codebox]nvcc: NVIDIA ® Cuda compiler driver

Copyright © 2005-2009 NVIDIA Corporation

Built on Thu_Jul__2_10:56:25_PDT_2009

Cuda compilation tools, release 2.3, V0.2.1221[/codebox]

Try upgrading to CUDA 3.0.

You have:

int w[nos+1];

where nos is a variable, in your code. This is non-standard C that will result in a dynamic memory allocation. Dynamic memory allocations are not possible on the GPU.

Try upgrading to CUDA 3.0.

You have:

int w[nos+1];

where nos is a variable, in your code. This is non-standard C that will result in a dynamic memory allocation. Dynamic memory allocations are not possible on the GPU.