How to use malloc and free inside the device version 3.2 using malloc and free inside the device ker

Hello all,

I am trying to test out the malloc() and free() commands inside the device. Unless I read the release notes wrong it said it should support dynamic memory allocation. However when I use the malloc command I still get the error: calling a host function from a device/global function is not allowed. Is there a specific header file I need to include? or is there a specific directory setup I need to include under my project properties?

Thanks

are you compiling with -arch sm_20?

are you compiling with -arch sm_20?

I am not sure. I am still new to the guts of compilers so I don’t know all the flags you can throw or how to change them. My compiler output is this though

[codebox]

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe" -gencode=arch=compute_10,code=“sm_10,compute_10” -gencode=arch=compute_20,code=“sm_20,compute_20” --machine 32 -ccbin “C:\Program Files\Microsoft Visual Studio 9.0\VC\bin” -Xcompiler “/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include” -maxrregcount=32 --compile -o “Debug/main.cu.obj” main.cu

[/codebox]

Does that help?

I am not sure. I am still new to the guts of compilers so I don’t know all the flags you can throw or how to change them. My compiler output is this though

[codebox]

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe" -gencode=arch=compute_10,code=“sm_10,compute_10” -gencode=arch=compute_20,code=“sm_20,compute_20” --machine 32 -ccbin “C:\Program Files\Microsoft Visual Studio 9.0\VC\bin” -Xcompiler “/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include” -maxrregcount=32 --compile -o “Debug/main.cu.obj” main.cu

[/codebox]

Does that help?

And is dynamic allocation possible only for cuda toolkit 3.2? Or can I use previous toolkits?

And is dynamic allocation possible only for cuda toolkit 3.2? Or can I use previous toolkits?