1. Examples
The hello.cu contains the CUDA implementation of HelloWorld.
- Login to HPC
- Setup MPI toolchain:
- Compile
nvcc -O3 -arch=sm_20 hello.cu
- Run
The option -t specifies the limit of run time. Setting it as a small number will get your program scheduled earlier. For more information on srun options, you can use man srun to find out.
- Profile (optional)
srun -n1 –gres=gpu:p100:1 –partition=debug nvprof ./a.out
- Allocate a machine
module purge
module load gcc /8.3.0 cuda /10.1.243
srun -n1 –gres=gpu:1 -t1 ./a.out
salloc -n1 –gres=gpu:1 –mem=16G -t10
// After the allocation, you will log on the machine and have 10 minutes to perform multiple operations
./a.out
// edit , compile , and run again without waiting for a new allocation
./a.out ./a.out
2. (15 points) Refer to the kernel test_shfl_up in the file simpleShfl.cu. Invoke it with a negative delta as follows:
test_shfl_up<<<1, BDIMX>>>(d_outData, d_inData, -2);
Check the results.
- (15 points) Refer to the kernel test_shfl_wrap in the file simpleShfl.cu.Make a new kernel that can generate the following result:
Initial: 0123456789101112131415 Result: 246810121416182022242628300
- (15 points) Refer to the kernel test_shfl_xor in the file simpleShfl.cu.Make a new kernel that can generate the following result:
Initial: 0123456789101112131415 Result: 11559913131717212125252929
- (15 points) Refer to the kernel test_shfl_xor_array in the file simpleShfl.cu. Make a new kernel that just performs one operation as follows:
value[3] = __shfl_xor(value[0], mask, BDIMX);
Check the results.
- (20 points) Refer to the kernel test_shfl_wrap in the file simpleShfl.cu. Make a new kernel that can shift double-precision variables in a wrap-around wrap approach.
- (20 points) Refer to the kernel warpReduce in the file reduceIntegerShfl.cu. Write an equivalent function that uses the __shfl_down instruction instead.





