CUDA

If you want to test CUDA on the math computers you can use the installation under /chalmers/sw/sup64/cuda_6.5.14 .
To use the package add
  /chalmers/sw/unsup64/cuda_6.5.14/bin
to your path and
  /chalmers/sw/unsup64/cuda_6.5.14/lib64
to your LD_LIBRARY_PATH.

If you want to know more, have a look in /chalmers/sw/unsup64/cuda_6.5.14/doc and /chalmers/sw/unsup64/cuda_6.5.14/samples . Some of the examples, in samples, are quite nice.

Note that long runs (> 5 s) will crash, since the GPU is used to uppdate the display as well. See the handouts for more details.

Here are some lab-suggestions:

Hints for the Monte Carlo problem:
start by reading the first part of the Overview in http://en.wikipedia.org/wiki/Monte_Carlo_integration .
There is a separate library, that comes with the CUDA SDK, for generating random numbers, but since it is rather complex to use I suggest that you use a simple random number generator, for a uniform distribution on (0, 1). This piece of code will produce a single precison random number in the interval ]0, 1[. The code is based on the following page.

const double r_max = 2.328306435454494e-10;
uint         m_z, m_w, u;
float        x;

// m_z and m_w are seeds. Pick any pair of positive integers.
m_z = ?
m_w = ?

// This part can be repeated in a loop to generate a sequence of random numbers.
m_z = 36969 * (m_z & 65535) + (m_z >> 16);
m_w = 18000 * (m_w & 65535) + (m_w >> 16);
u   = (m_z << 16) + m_w;
x   = (u + 1.0) * r_max;  // the random number

Do not forget the arch-flag when compiling, so nvcc -arch=sm_30 ....

Back