\documentclass{article}
\usepackage{amsmath}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\usepackage{graphics}
\usepackage[ps,dvips,xdvi,arrow,frame,matrix,graph,curve,cmtip]{xy}
\usepackage[pdftex]{graphicx}

\usepackage[breaklinks=true]{hyperref}
\usepackage{enumerate}

\setcounter{secnumdepth}{0}
\title{Week 7 Progress Report}
\author{Abdulmajed Dakkak}
\date{July 26th, 2008}
\begin{document}
\maketitle

\section{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 \verb!D3Q19! CUDA drawing into the CAVE
using this method, but because I have yet to implement \verb!D3Q19!
on the CUDA chip and because I did not know if it would work, I
started by working with \verb!fluidzDy! which I already understand
well.

Placing the \verb!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:

\begin{itemize}
\item 
  Does CaveMathematica support animation? There is limited support
  for animations, and the only way of interacting with the animation
  is by using sliders.
\item 
  How much control does Mathlink give you? Glancing over the mathlink
\item 
  documentation, apparently you can do anything.
\item 
  A more interesting idea is to write \verb!CM1!%
  \footnote{The mathlink program that interacts with CUDA.}
  using Java and use J/Link rather than mathlink? This idea was
  quickly discarded when I realized that some types (namely
  \verb!float!) might not be the same size between the languages.
\end{itemize}
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:

\begin{verbatim}
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
\end{verbatim}
Not wanting to deal with issue at this point, and because Chase
might know a fix for this issue since he compiled \verb!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:

\begin{enumerate}[1.]
\item 
  Mathlink does not like 32 bit \verb!float! (versus \verb!double!
  s), and since everything is passed in as \verb!float!, we had to
  unpack all \verb!float! arrays into a \verb!double! array.
\item 
  Mathlink does not return a \verb!RealList!, rather you have to use
  the \verb!MLPutRealList! function provided in mathlink. Also, there
  is no such thing (at least in my SDK) relating to
  \verb!MLPutReal32List! or \verb!MLPutReal64List! this contradicts
  with the documentation.
\item 
  A function that returns nothing; i.e. \verb!void! behaves strangely
  in mathlink. All functions will thus return 1 if they complete
  correctly .
\end{enumerate}
The \verb!fluidzMathlink.tm! was then written, although it is
pretty much explanatory if you read the documentation. Finally the
notebook \verb!fluidz.nb! was created that includes all useful
functions.

NOTE: I have yet to test whether any part of this is viewable in
\verb!CM2!%
\footnote{CaveMathematica}

\subsection{How to Run}

\begin{itemize}
\item 
  Start \verb!fluidzDy! on the CUDA computer
  \begin{itemize}
  \item 
    \verb!ssh ah130-15.math.uiuc.edu!
  \item 
    \verb!cd NVIDIA_CUDA_SDK/bin/linux/release/!
  \item 
    \verb!./fluidzDy <port_number>!
  \end{itemize}
\item 
  Starting Mathematica on another \verb!*.nix! computer
  \begin{itemize}
  \item 
    Make sure that your system path is set so that Mathematica will
    find fluidzMathlink \textbf{(you probably need to modify this)}
  \item 
    Run each cell
  \end{itemize}
\end{itemize}
\subsection{Notation}

\begin{description}
\item[CM1]
Cube Mathematica, the part that I wrote today

\item[CM2]
Cave Mathematica, the part that Mimi and Ulises wrote last summer

\item[$CM^2$]
The use of Mathematica as a drawing platform for CUDA

\end{description}
\subsection{Code}

\begin{itemize}
\item 
  \href{code/mathlink-s7}{CUDA Mathlink (\texttt{CM1})}(\href{code/mathlink-s7.tar.gz}{.tar.gz})
\end{itemize}
\section{Sunday}

\includegraphics[scale=0.1]{graphics/head.png}

\section{Monday}

A very productive day. I first looked at \verb!D2Q9! on the CUDA (I
think I figured out the problem, but have yet to fix it). Then, I
got \verb!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.

\subsection{Code}

\begin{itemize}
\item 
  \href{code/MandelbrotDy-m7}{MandelbrotDy}(\href{code/MandelbrotDy-m7.tar.gz}{.tar.gz})
\item 
  \href{code/mathlink-m7}{CUDA Mathlink Fluidz and Mandelbrot (\texttt{CM1})}(\href{code/mathlink-m7.tar.gz}{.tar.gz})
\end{itemize}
\section{Tuesday}

\section{Wednesday}

\section{Thursday}

NOTE: Presentation at Wolfram.

\section{Friday}

\end{document}
