Download User Manual - Support
Transcript
8.5 Available Tools 8.5.3 CUDA Utility Library CUTIL is a simple utility library designed for use in the CUDA SDK samples. There are 2 parts for CUDA and OpenCL. The locations are: • $CUDA_SDK/C/lib • $CUDA_SDK/OpenCL/common/lib Other applications may also refer to them, and the toolkit libraries have already been pre-configured accordingly. However, they need to be compiled prior to use. Depending on the cluster, this might have already have been done. [fred@demo [fred@demo [fred@demo [fred@demo [fred@demo [fred@demo ~] cd ~] cp -r $CUDA_SDK ~] cd $(basename $CUDA_SDK); cd C C] make C] cd $(basename $CUDA_SDK); cd OpenCL OpenCL] make CUTIL provides functions for: • parsing command line arguments • read and writing binary files and PPM format images • comparing data arrays (typically used for comparing GPU results with CPU results) • timers • macros for checking error codes • checking for shared memory bank conflicts 8.5.4 CUDA “Hello world” Example A hello world example code using CUDA is: Example /* CUDA example "Hello World" using shift13, a rot13-like function. Encoded on CPU, decoded on GPU. rot13 cycles between 26 normal alphabet characters. shift13 shifts 13 steps along the normal alphabet characters So it translates half the alphabet into non-alphabet characters shift13 is used because it is simpler than rot13 in c so we can focus on the point (c) Bright Computing Taras Shapovalov <taras.shapovalov@brightcomputing.com> */ © Bright Computing, Inc. 61