Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

CUDALink is properly installed and up to date, all built-in functions work fine, and all little functions I did worked fine... Until I tried using shared memory. The only example I found on the help doesn't work for more than one reason. It declares the memory without a type and my compiler complains. So that's a bad start. Anyway, I'm trying the most basic function I can, and I can't make it work.

I would appreciate if anyone could tell me what's wrong, or if it works (or doesn't) for you, or give me an example that does work... Sample code I'm trying

    testf = CUDAFunctionLoad["__global__ void test(int* out)
    extern __shared__ int smem[];
      }", "test", {{_Integer, "Output"}}, 16];

When I run it I get a CUDAFunction::internal: CUDALink experienced an internal error. >> and then I need to restart the kernel to make CUDALink work again

testf[Range[16], 16]

Just commenting out the line with the smem[threadIdx.x]=7 assignment makes it work. The compiler issues no warnings

share|improve this question

This Mathematica 8 documentation should answer your question.

share|improve this answer
+1 I can't believe I didn't see that section of "Scope" that looks helpful... Thanks... Edit your answer that I had to add "Shared" at the end of the list of arguments in CUDAFunctionLoad and you get an accept – Rojo Feb 9 '12 at 8:41
Can you please summarize the answer or at least, address the "I would appreciate if anyone could tell me what's wrong..." part of the question? Mere link only answers are not encouraged here :) – R. M. Mar 23 '12 at 3:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.