Preparation

The content of this page was obsolete. Therefore, it is replaced by the version in year 2013.

This assignment requires that you have access to a CUDA-enabled (OpenCL-enabled) GPU. There are three access options. We only provide official support for the first option.

  1. Officially supported option: using the server. You can obtain an account to access the server, which is equipped with an NVIDIA GPU (GTX 460) that supports CUDA.
  2. On-your-own option: running CUDA on your own computer. If your computer has a CUDA-enabled GPU, you can perform the assignment on your own computer. If you are not sure whether your GPU supports CUDA, you can read below the Section 2.1 check whether your GPU supports CUDA.
  3. Advanced (hardest) option: running OpenCL on your own computer. If your computer has an OpenCL-enabled GPU, you can perform the assignment on your own computer. If you are not sure whether your GPU supports OpenCL, you can read below the Section 3.1 check whether your GPU supports OpenCL.

Important notes, please read them first:

If you are already familiar with CUDA or OpenCL, you can skip the remaining parts of this page and jump to the examples. Otherwise you can continue reading some of the remaining parts of this page, depending on which access option you choose.

Contents

  1. Option 1: Using the Server
    1. Setting Up the Tools
    2. Testing basic samples
    3. Additional Tools (Optional)
  2. Option 2: Running CUDA on Your Own Computer
    1. Check whether your GPU supports CUDA
    2. Install Development Tools
    3. Testing with Sample Programs
  3. Option 3: Running OpenCL on Your Own Computer
    1. Check whether your GPU supports OpenCL
    2. Install Development Tools
    3. Testing with Sample Programs

Option 1: Using the Server

You can log on to the machine (IP: ics-pc011.ele.tue.nl) via ssh, with the user name and password provided with the course.

An NVIDIA GPU (GTX 460) is equipped on the server, which runs the x86_64 Linux. The CUDA 5.5 development tools have already been installed on the server. Yet you need to set up a few things before starting using CUDA, as described below.

Setting Up the Tools

The CUDA 5.5 is already installed at /usr/local/cuda-5.5. However, there are a few things to be set up before using CUDA.

Setting Environment Variables

You need to set the environment variables. It is recommended to permanently add them to you start-up script. To do that, you can add the lines below to your (~/.bashrc) file.


# User specific aliases and functions
export PATH=/usr/local/cuda-5.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-5.5/lib64:/lib:$LD_LIBRARY_PATH

The modification of the (~/.bashrc) file will not take effect until the next log in session. You can either log out and then log in again or, alternatively, type the "bash" command that let the modification take effect.

Copy code samples to your local directory

NVIDIA provides a lot of CUDA examples, for both testing and learning purposes. It is recommended to try out some of them. You can copy them from the installation directory to your local directory (e.g., ~/cuda-5.5), as shown below.


mkdir ~/cuda-5.5
cd ~/cuda-5.5/
cp -r /usr/local/cuda-5.5/samples ./

Testing basic samples

To test whether the tools are set up properly, you can try to compile and run a few examples. Two representative examples are the deviceQuery and the matrixMul.

DeviceQuery

To compile and run the deviceQuery, you can issue the commands below:


cd ~/cuda-5.5/samples/1_Utilities/deviceQuery
make
./deviceQuery

If the deviceQuery compiles and runs properly, you should be able to see the information of the detected GPU, as shown below.


./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 460"
  CUDA Driver Version / Runtime Version          5.5 / 5.5
  CUDA Capability Major/Minor version number:    2.1
  Total amount of global memory:                 768 MBytes (804847616 bytes)
  ( 7) Multiprocessors, ( 48) CUDA Cores/MP:     336 CUDA Cores
  GPU Clock rate:                                1400 MHz (1.40 GHz)
  Memory Clock rate:                             1840 Mhz
  Memory Bus Width:                              192-bit
  L2 Cache Size:                                 393216 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65535), 3D=(2048, 2048, 2048)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 32768
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1536
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (65535, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Bus ID / PCI location ID:           1 / 0
  Compute Mode:
     < Exclusive (only one host thread in one process is able to use ::cudaSetDevice() with this device) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 5.5, CUDA Runtime Version = 5.5, NumDevs = 1, Device0 = GeForce GTX 460
Result = PASS

MatrixMul

To compile and run the matrixMul, you can issue the commands below:


cd ~/cuda-5.5/samples/0_Simple/matrixMul
make
./matrixMul

If the matrixMul compiles and runs correctly, it should print out the message like this:


[Matrix Multiply Using CUDA] - Starting...
GPU Device 0: "GeForce GTX 460" with compute capability 2.1

MatrixA(320,320), MatrixB(640,320)
Computing result using CUDA Kernel...
done
Performance= 109.05 GFlop/s, Time= 1.202 msec, Size= 131072000 Ops, WorkgroupSize= 1024 threads/block
Checking computed result for correctness: Result = PASS

Note: For peak performance, please refer to the matrixMulCUBLAS example.

Additional Tools (Optional)

Besides the compiler (nvcc), CUDA 5 contains several other tools in /usr/local/cuda-5.5/bin. You can do the assignment without these tools, but some of them could be helpful. You can choose to use them or not depending on your own needs.

Option 2: Running CUDA on Your Own Computer

Check whether your GPU supports CUDA

If you have an NVIDIA GPU, you can check a list of CUDA GPUs from NVIDIA.

Install Development Tools

You can download and install the tools following the official instruction. You can download CUDA 5.5 installers from NVIDIA.

Testing with Sample Programs

Please verify the installation of the development tools with some examples. You can test with the installed examples.

Option 3: Running OpenCL on Your Own Computer

Check whether your GPU supports OpenCL

If you have an AMD GPU, you can check the system requirements from AMD, which also states the driver conformance at the bottom. Note that you need to first update your Catalyst driver to a recent version before installing the development tools.

Install Development Tools

You can download and install the tools following the official instruction. If you have the proper driver installed (check driver conformance at the bottom of this page), you can install the Accelerated Parallel Processing (APP) SDK from AMD.

Testing with Sample Programs

Please verify the installation of the development tools with some examples. You can test with the installed examples (installed location: AMDAPP/samples). Alternatively, you can download individual samples. If the driver or the development tool is not properly installed, the MatrixMultiplication example will print out "GPU not found. Falling back to CPU device".