Week 7 Progress Report


What I wanted to do was to send an array from CUDA to Mathematica using a socket. The following are some concept images that I sketched in my notebook on Friday$

My plan was to place the D3Q19 CUDA drawing into the CAVE using this method, but because I have yet to implement D3Q19 on the CUDA chip and because I did not know if it would work, I started by working with fluidzDy which I already understand well.

Placing the fluidzDy client in Mathematica also allows us to have more examples to demonstrate how to create clients for CUDA. It would also give us, by transitivity, a way to view this CUDA program in the CAVE. A few questions crossed my mind while I was planning this, and I asked Chase about them on Friday:

I then proceeded to create a mathlink. First, I downloaded the SDK on the macs. After downloading, I tried to compile the examples they provide and it filed giving me the following error:

beltrami:MathLinkExamples dakkak\$ make
cc -c -I/Users/dakkak/Desktop/Darwin/CompilerAdditions addtwotm.c
In file included from addtwotm.c:15:
/Users/dakkak/Desktop/Darwin/CompilerAdditions/mathlink.h:88: error: syntax error before 'yet'
/Users/dakkak/Desktop/Darwin/CompilerAdditions/mathlink.h:387: error: syntax error before 'enum'
make: *** [addtwotm.o] Error 1

Not wanting to deal with issue at this point, and because Chase might know a fix for this issue since he compiled CM2, I decided to develop on my Linux machine where the examples do compile.

I started by reading the examples provided in the SDK and figuring out how to load and unload the external mathlink programs. I then started programming and everything worked. There are a few catches, however:

  1. Mathlink does not like 32 bit float (versus double s), and since everything is passed in as float, we had to unpack all float arrays into a double array.
  2. Mathlink does not return a RealList, rather you have to use the MLPutRealList function provided in mathlink. Also, there is no such thing (at least in my SDK) relating to MLPutReal32List or MLPutReal64List this contradicts with the documentation.
  3. A function that returns nothing; i.e. void behaves strangely in mathlink. All functions will thus return 1 if they complete correctly .

The fluidzMathlink.tm was then written, although it is pretty much explanatory if you read the documentation. Finally the notebook fluidz.nb was created that includes all useful functions.

NOTE: I have yet to test whether any part of this is viewable in CM22

How to Run



Cube Mathematica, the part that I wrote today


Cave Mathematica, the part that Mimi and Ulises wrote last summer


The use of Mathematica as a drawing platform for CUDA




A very productive day. I first looked at D2Q9 on the CUDA (I think I figured out the problem, but have yet to fix it). Then, I got D3Q19 to work on my laptop (still need to work on the drawing portion). Got the mathlink interface for fluidz to compile on the Macs. Realized that Mandelbrot needed to be done for the demonstration at Wolfram, so spent 6 hours at night debugging and getting it to work. Everything worked at the end and I wrote the mathlink interface to it.





NOTE: Presentation at Wolfram.


  1. The mathlink program that interacts with CUDA.

  2. CaveMathematica