Skip to content
fomics edited this page Sep 15, 2013 · 3 revisions

Preliminaries

ViennaCL is a template library analogous to Boost uBLAS template library, but providing extended functionality. ViennaCL provides backends for OpenMP (on CPUs or on Intel Xeon Phi), CUDA (for NVIDIA GPUs) and OpenCL (for CPUs or Intel Xeon Phi). With the CUDA backend (used in this exercise) ViennaCL's routines are included 'on-the-fly' during compilation with NVIDIA's nvcc compiler.

By this time, you should have logged into the course platform, and have loaded the CUDA 5.0 toolkit by loading the craype-accel-nvidia35 module (see instructions on main page). In addition, you need to load the Boost library for this exercise.

module load boost

The simplest compilation is

nvcc -o myprog.exe -I/apps/todi/ViennaCL -I/apps/todi/boost/1.48/gnu_461/include myprog.cu

In this exercise, you are provided with a Boost uBLAS program to read in a matrix and a vector, calculate the matrix-vector product a number of times, and then output the execution time of the benchmark.

mat_vec_prod.cu

In addition, you will need the following two include files:

io.hpp

benchmark-utils.hpp

A solution is:

mat_vec_prod_sol.cu