\documentclass[twocolumn]{article} 
% \documentclass{article}

\setlength{\oddsidemargin}{-0.5in}
\setlength{\evensidemargin}{-0.5in}
\setlength{\topmargin}{0.0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\textwidth}{7.0in}
\setlength{\textheight}{9.5in}
\setlength{\parindent}{0in}
\setlength{\parskip}{0.05in}
\setlength{\columnseprule}{0.3pt}

\setlength\columnsep{25pt}

\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\usepackage{listings}
\usepackage{amsmath}

\begin{document}

\lstset{xleftmargin=5mm,framexleftmargin=10mm,basicstyle=\footnotesize}

Name: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

% Directions: MAKE SURE TO COPY YOUR ANSWERS TO A SEPARATE SHEET FOR SENDING
% ME AN ELECTRONIC COPY LATER.

{\bf 1.} This problem concerns the CUDA code for Gaussian elimination,
Sec.\ 11.5.2.  Assume that the code that calls the kernel will have
quantities $A$, $b$ and $n$ at the beginning of Sec.\ 11.5 stored in
the variables {\bf a}, {\bf b} and {\bf n}, respectively.  The array
{\bf a} is one-dimensional, length $n^2$.  We have another array {\bf
ab}, one-dimensional, length $n(n+1)$, corresponding to the argument of
the same name in the kernel.

\begin{itemize}

\item [(a)] (20) Fill in the blank in the following statement:

\begin{lstlisting}
dim3 dimBlock( blank ,1,1);
\end{lstlisting}

\item [(b)] (20) The code preparing {\bf ab} will include the following,
in which you will fill in the blank:

\begin{lstlisting}
for (j = 0; j < n; j++) ab[ blank ] = b[j];
\end{lstlisting}

\end{itemize}

{\bf 2.} (20) Consider applying the smoothing idea, Sec.\ 13.5.1, to audio, in
the time domain. We could adapt the code in Sec.\ 4.14 for this.  
The argument {\bf k} now will be the number of neighbors to smooth with,
using {\bf k/2} data points before and after the given point.  We
would delete much of the code.  In particular, replace line 48 by

\begin{lstlisting}
perlen = k;
\end{lstlisting}

deleting line 62.

We would have to add a crucial line.  State the line number after which
the new statement would be added, and state what single line should be
added; don't worry about ``corner cases,'' say what happens near the
ends of the array.

{\bf 3.} (40) Use ``Snow '' (the portion of the R library {\bf parallel}
that was derived from the old {\bf snow} library) to implement the
run-length coding decompression algorithm in Sections 10.5 and 10.6.
The ``declaration'' of your function will be

\begin{lstlisting}
decomp <- function(x,cls)
\end{lstlisting}

where {\bf x} is the compressed vector, and {\bf cls} is a Snow cluster.

Your code need not be optimal, just parallel and correct.  Submit just the
function itself in the end, but you may wish to temporarily put in a
test case so you can try your code through OMSI.

\onecolumn

\newpage

{\bf Solutions:}

{\bf 1.a} {\bf n}

{\bf 1.b} {\bf (j+1) * (n+1) }

{\bf 2.} After line 56, insert

\begin{lstlisting}
x[perstart + k/2] = xbar;
\end{lstlisting}

{\bf 3.}  Outline:

\begin{lstlisting}
split x into chunks for the workers
each worker does a straightforward decompression of its chunk
apply Reduc(c, ) to what is returned from the workers
\end{lstlisting}


\end{document}

