Skip to content
Oluwatosin Odubanjo edited this page Dec 15, 2022 · 26 revisions

1.0. Hello World! DPC++

Hello!

The aim of this material is to explore the basic concepts of DPC++ with the most simple example!

DPC++ is based on C++, however, this material can be studied by anyone who is familiar with C/C++ and is interested in getting started with heterogeneous application development. (If you are familiar with only C, get ready to look up some C++ concepts, also after this study material, get ready to study C++ to program in DPC++).

😃 Happy Learning! 😃

1.1. Pre-requisite knowledge:

Basic - Intermediate understanding of C/C++.

1.2. Task

To print out Hello World! using a 1D-array copy.

Printing out Hello World! with a programming model as DPC++ might seem pretty basic. This may make some of the concepts shown here seem too much. However, keep in mind that these concepts are designed to be used for computational and data intensive as well as more complex programs, and will be of much use in such a context.

Quotes for motivation:

✔️ "Little drops of water make a might ocean." - Julia A. F. Carney.

✔️ “If you can’t explain it simply, you don’t understand it well enough.” - Albert Einstein.

✔️ "Wisdom is the principal thing; therefore get wisdom: and with all thy getting, get understanding." - King Solomon

1.3. Tools for following this material

git logo

⚫ A Computer

⚫ Reliable Internet Connection

⚫ Intel® oneAPI Base Toolkit on Intel® DevCloud

To access the Intel® oneAPI Base Toolkit on Intel® DevCloud, sign up for a free Intel DevCloud Account here (Free access for 120 days with the possibility of an extension).

The DevCloud is a free remote development environment for learning about and programming oneAPI cross-architecture applications; it is equipped with the latest Intel CPUs, GPUs, FPGAs, and Intel oneAPI tools.

Please note that: You can also set up the Intel® oneAPI Base Toolkit on your computer by downloading the installer from here

1.4. Following the material

Having signed up for a free devcloud account: please do the following:

(To know how to configure the DevCloud to use HTTPS and SSH for git clone, please check this article: Cloning a git repository hosted on github.com or gitlab.com in Intel® DevCloud).

1.4.1. With git clone - DevCloud

NOTE: I am sorry I talk more about windows / linux and not macOS, this is because I am more familiar with the former. But I believe you would not have any issues if you are using macOS as long as there is a terminal with which to access Devcloud / if you use the JupyterLab* access.

     >> On your local terminal (linux, cygwin, mingw64, e.t.c), communicate with your remote Devcloud account (terminal - programming and runtime environment) :

     local-terminal $ ssh devcloud
     
     >> git clone repository

     login-node     $ git clone https://github.com/olutosinbanjo/Hello_World_dpcpp.git 
      
      ***OR***
      
     login-node     $ git clone [email protected]:olutosinbanjo/Hello_World_dpcpp.git
     
     >> change directory to repository folder
      
     login-node     $ cd Hello_World_dpcpp
      
     >> Request for a gpu computational node to access the Intel® Xeon® E-2176G CPU and its integrated graphics - Intel® UHD Graphics P630 [0x3e96]embedded P360 GPU
     
     login-node     $ pbsnodes | grep -B4 "e-2176g"         [ for a list of e-2176g nodes; choose a node that is free and running ]

     login-node     $ qsub -I -l nodes=s**-n**:gpu:ppn=2 -d .
     
     [ You can also decide to use the gen9 or gen11 processor; in this case replace e-2176g with gen9 or gen11 and do
       qsub -I -l nodes=s**-n**:gen9:ppn=2 -d or qsub -I -l nodes=s**-n**:gen11:ppn=2]

     >> Clean directory
     
     compute-node   $ ./clean.sh
     
     >> build source files
      
     compute-node   $ ./build.sh
     
     >> execute object files
      
     compute-node   $ cd bin
      
     compute-node   $ ./executable
     
     >> clean directory
      
     compute-node   $ cd ..
     
     compute-node   $ ./clean.sh

Read about the Intel® Xeon® E-2176G CPU here.

1.4.2. Without git clone - DevCloud

      >> download zip folder from github.com
      
      local-terminal  $ download zip folder of this repository to your local computer (Hello_World_dpcpp-main.zip)
      
      >> open terminal (for Windows / Linux)
      
      >> change directory to where you have downloaded the zipped folder for the repository. Using WSL for example
      
      local-terminal  $ cd /mnt/c/users/username/downloads/ 
      
      >> send local file (downloaded zip file) to remote devcloud account
      
      local-terminal  $ scp Hello_World_dpcpp-main.zip devcloud:~/
      
      >> login to devcloud account 
      
      local-terminal  $ ssh devcloud
      
      >> unzip zipped file 
      
      login-node      $ unzip Hello_World_dpcpp-main.zip
      
      >> change directory to extracted folder of zipped file
      
      login-node      $ cd Hello_World_dpcpp-main
      
      >> Request for a gpu computational node to access the Intel® Xeon® E-2176G CPU and its integrated graphics - Intel® UHD Graphics P630 [0x3e96]embedded P360 GPU
      
      login-node     $ pbsnodes | grep -B4 "e-2176g"         [ for a list of e-2176g nodes; choose a node that is free and running ]

      login-node     $ qsub -I -l nodes=s**-n**:gpu:ppn=2 -d .

      [ You can also decide to use the gen9 or gen11 processor; in this case replace e-2176g with gen9 or gen11 and do
       qsub -I -l nodes=s**-n**:gen9:ppn=2 -d or qsub -I -l nodes=s**-n**:gen11:ppn=2]
      
      >> Clean directory
     
      compute-node   $ ./clean-main.sh
     
      >> build source files
      
      compute-node   $ ./build-main.sh
     
      >> execute object files
      
      compute-node   $ cd bin
      
      compute-node   $ ./executable
     
      >> clean directory
      
      compute-node   $ cd ..
     
      compute-node   $ ./clean-main.sh

1.4.3. With JupyterLab*

      You can also decide to connect to the Intel DevCloud JupyterLab* rather than use a windows / linux / macOS terminal.

      To use the JupyterLab*:

      >> Login to your account via [https://devcloud.intel.com/oneapi/get_started/](https://devcloud.intel.com/oneapi/get_started/)

      >> Scroll the bar to the bottom of the page, to find the Connect with JupyterLab* section; then click on Launch JupyterLab*

      >> As soon as you get connected, navigate to File -> New -> Terminal 

      >> You should see a window with your login node `usename@s**-n**:-$`

      >> git clone repository

     login-node     $ git clone https://github.com/olutosinbanjo/Hello_World_dpcpp.git 
      
      ***OR***
      
     login-node     $ git clone [email protected]:olutosinbanjo/Hello_World_dpcpp.git
     
     >> change directory to repository folder
      
     login-node     $ cd Hello_World_dpcpp-main
      
     >> Request for a gpu computational node to access the Intel® Xeon® E-2176G CPU and its integrated graphics - Intel® UHD Graphics P630 [0x3e96]embedded P360 GPU
     
     login-node     $ pbsnodes | grep -B4 "e-2176g"         [ for a list of e-2176g nodes; choose a node that is free and running ]

     login-node     $ qsub -I -l nodes=s**-n**:gpu:ppn=2 -d .
     
     [ You can also decide to use the gen9 or gen11 processor; in this case replace e-2176g with gen9 or gen11 and do
       qsub -I -l nodes=s**-n**:gen9:ppn=2 -d or qsub -I -l nodes=s**-n**:gen11:ppn=2]

     >> Clean directory
     
     compute-node   $ ./clean.sh
     
     >> build source files
      
     compute-node   $ ./build.sh
     
     >> execute object files
      
     compute-node   $ cd bin
      
     compute-node   $ ./executable
     
     >> clean directory
      
     compute-node   $ cd ..
     
     compute-node   $ ./clean.sh

1.5. Following the Source Code Explanations

To follow the source code explanations, it is advisable to have another window linking the source codes opened, as shown in the image below:

source code explanation

Thank you!