Kartikay Bhuchar, Amar Puri, Abhishek Thapa, Benson Muite and David Bunde <dbunde@knox.edu>
This module introduces SYCL programming using an image processing application. It is a translation of the CUDA code in the module "Introduction to CUDA Programming". It begins with a lecture that introduces General Purpose Graphics Processing Unit (GPU) programming and SYCL specifically. SYCL code can also be run on a Central Processing Unit (CPU). The image processing application is then given as a lab or homework assignment.
This module is intended as a first introduction to GPU programming. Students are shown some basic examples ("Hello world" and adding vectors) before tackling the image processing application. I gave the later as a lab assignment, though it could also be phrased as a homework assignment.
The given code is in C and C++. The architectural aspects of SYCL are treated very lightly. I am using this module in my Introduction to Systems course, which has parallelism as a major topic.
My students have found it easier to use Google Colab to run the code in this module than to use ssh to access departmental computing resources. Colab provides an interactive computing environment running Jupyter notebooks with access to GPUs. Using GPUs does require installing a SYCL compiler, for portability hipSYCL is used. As an added wrinkle, the GPU students run on changes (thus, changing its number of cores and architecture) when they restart the notebook, which can lead to different results. See the setup resource below for additional information on using Google Colab.
I typically teach using the Peer Instruction pedagogy, in which lectures feature multiple choice questions that the students answer and discuss. (See [1] for more information.) Because of this, my slides have some multiple choice questions. Since not everyone teaches this way, the module includes 2 sets of slides, one with questions and one for a more conventional lecture class. (Even the slides with questions only have a couple of questions at the end. Thus, they don't fully implement the Peer Instruction pedagogy; something else to work on...)
HC topics covered in this module are listed below. Bloom's classification is shown in brackets
- GPU Acceleration [A]
- SIMD parallelism [A]
Having completed this module, students should be able to
- Write simple programs in SYCL
- Translate between 1D and 2D coordinates by arranging the 2D points in row-major order
The teaching material included with this module are the following:
- Slides with embedded questions (.pptx, .pdf)
- Slides for a traditional lecture (.pptx, .pdf)
- SYCL programs discussed during lecture: hello.cpp, addVectors.cpp
- Information on using Google Colab (The instructions are largely duplicated in the Colab notebook below.)
- Files for lab:
- Colab notebook (open it and then click "open in colab")
- Lab handout: .pdf or .tex
- stb_image.h, stb_image_write.h: libraries files for dealing with image files
- 640x426.bmp: sample image file (can also use your own)
- noRed.cpp: kernel that removes red from the image; this file is included in the Colab notebook so you don't need this file unless you are running the lab outside the notebook
All material available for download from the ToUCH git repository
- Peer Instruction for CS. http://peerinstruction4cs.com/