% Week 7 Progress Report % Abdulmajed Dakkak % July 26th, 2008 Saturday ======== 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\$
\includegraphics[scale=0.1]{graphics/cm.png}
\includegraphics[scale=0.1]{graphics/machine-layout.png} 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: * Does CaveMathematica support animation? There is limited support for animations, and the only way of interacting with the animation is by using sliders. * How much control does Mathlink give you? Glancing over the mathlink * documentation, apparently you can do anything. * A more interesting idea is to write `CM1`[^CM1] using Java and use J/Link rather than mathlink? This idea was quickly discarded when I realized that some types (namely `float`) might not be the same size between the languages. 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 `CM2`[^CM2] [^CM1]: The mathlink program that interacts with CUDA. [^CM2]: CaveMathematica How to Run ---------- * Start `fluidzDy` on the CUDA computer - `ssh ah130-15.math.uiuc.edu` - `cd NVIDIA_CUDA_SDK/bin/linux/release/` - `./fluidzDy ` * Starting Mathematica on another `*.nix` computer - Make sure that your system path is set so that Mathematica will find fluidzMathlink **(you probably need to modify this)** - Run each cell Notation -------- CM1 : Cube Mathematica, the part that I wrote today CM2 : Cave Mathematica, the part that Mimi and Ulises wrote last summer $CM^2$ : The use of Mathematica as a drawing platform for CUDA Code ---- * [CUDA Mathlink (`CM1`)][CM.s7]([.tar.gz][CM.s7.tar.gz]) [CM.s7]: code/mathlink-s7 [CM.s7.tar.gz]: code/mathlink-s7.tar.gz Sunday ======
\includegraphics[scale=0.1]{graphics/head.png} Monday ====== 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. Code ---- * [MandelbrotDy][MandelbrotDy.m7]([.tar.gz][MandelbrotDy.m7.tar.gz]) * [CUDA Mathlink Fluidz and Mandelbrot (`CM1`)][CM.m7]([.tar.gz][CM.m7.tar.gz]) [MandelbrotDy.m7]: code/MandelbrotDy-m7 [MandelbrotDy.m7.tar.gz]: code/MandelbrotDy-m7.tar.gz [CM.m7]: code/mathlink-m7 [CM.m7.tar.gz]: code/mathlink-m7.tar.gz Tuesday ======= Wednesday ========= Thursday ======== NOTE: Presentation at Wolfram. Friday ======