Dynamic arrays in .cu code not supported on Mac, despite not in __device__ code

I am seeing this linker error message

“___vla_alloc”, referenced from:
_main in channelmodeling.cu_o
_main in channelmodeling.cu_o
_main in channelmodeling.cu_o
fading_cpu_values(float*, float*, int, int, int, int)in channelmodeling.cu_o
fading_cpu_values(float*, float*, int, int, int, int)in channelmodeling.cu_o

main() is clearly not a device function, however for convenience it is part of a .cu file.

Yet constructs such as this

cuComplex localR[no_processes][no_freq_samples];

where no_processes and no_freq_samples are variables

do not compile on a Mac using CUDA SDK 2.0. This works on Linux by the way.

Is there any linker command that I can add to satisfy the ___vla_alloc/___vla_dealloc requirement?

Christian

Could you please post a small repro?

Makefile to be used in projects subfolder of MAC OS X CUDA SDK 2.0

############################################################

#

# Build script for project

#

############################################################

# Add source files here

EXECUTABLE	  := repro1  

# CUDA source files (compiled with cudacc)

CUFILES		 := repro1.cu  

############################################################

# Rules and targets

include ../../common/common.mk

Code for repro1.cu

#include <cuComplex.h>

#include <stdio.h>

int main(int argc, char **argv)

{

	int max_index= 7;

	cuComplex test[max_index];

	for (int i=0; i < max_index; i++)

		test[i] = make_cuComplex(i, i+1);

	for (int i=0; i < max_index; i++)

		printf("%f, %f\n", test[i].x, test[i].y);

	return 0;

}

Note: this compiles when using nvcc on the command line.

This does not compile (actually: link) using make, no matter what dbg or emu flag is given.

Error is as follows:

Macintosh-2:repro1 buchner$ make

Undefined symbols:

  "___vla_alloc", referenced from:

	  _main in repro1.cu_o

  "___vla_dealloc", referenced from:

	  _main in repro1.cu_o

ld: symbol(s) not found

collect2: ld returned 1 exit status

make: *** [../../bin/darwin/release/repro1] Error 1

Macintosh-2:repro1 buchner$

So it’s probably not an issue with the CUDA toolchain, but rather with the build environment that is created in common.mk of the SDK 2.0 for MAC

Christian

I’ve been having a similar issue, where the Mac OS X linker can’t find the ___vla_alloc/___vla_dealloc, but it will not have a problem under linux.

In my case I was passing an array by reference to a subfunction that dereferenced the array, memcpy’ed its elements and then called a stream of cuda kernels.

Has there been any progress with this issue (FYI: I’m using CUDA 2.0).