COMP528-JAN21 University of Liverpool
COMP528-JAN21 – Lab 1
Coordinator: Fabio Papacchini
1 Login to the lab-based PC (Windows system)
The PCs in the lab run the “MWS” (CSD’s “managed Windows system”) from which we use “mobaXterm”
(or similar app such as PuTTy or a UNIX/Linux host on a Virtual Machine) to login to the remote UoL
HPC system.
1. Login to MWS
2. Find the mobaXterm icon and double click to open. If asked, select the “start local terminal”. (There
are many ways to use mobaXterm, and you will get familiar with these during the labs.)
3. This gives you a basic Linux environment from which you can “ssh” to a remote UNIX/Linux machine.
mobaXterm also provides “X11” (an X Window Manager) which means that any GUI/apps you start
on the remote machine actually appear on your local machine.
2 Accessing UoL HPC System “Barkla”
4. Having started mobaXterm’s local terminal, you need to connect to the remote HPC facility. The
command is “ssh” and to find out what it does and the syntax you enter the following at your prompt:
man ssh
This gives the “manual page” (a page of a manual – i.e. the “help”) for the command “ssh”. You will
note that you see just one page at a time: you can use the spacebar to move to the next page, or enter
the letter “q” to quit the help.
You should record your answers to all questions highlighted in bold
5. What flag (a parameter passed to a linux command) do you need to forward the X11?
6. In a moment you will login using ssh, enabling X11 forwarding. First, we note there are several login
nodes on Barkla (see “Barkla – system architecture” slide in CANVAS, and the email you received
when your account was set up). Take a moment to read these and understand when to use which login
node and what the full name is. Today we wish to use GUIs and use the more powerful login nodes,
so for example we login via ssh -X .ac.uk where username would be your
central username and the password on Barkla is the same as your central credentials (that you used to
login to Windows).
7. Nothing much will change when you login, but you should see something like the following image in
your terminal window (e.g. see if the prompt has your username, the local name for the host, and the
name “barkla”).
Fabio Papacchini: Fabio. .uk 1
COMP528-JAN21 University of Liverpool
3 Editing a File on Barkla
8. Whilst still LOGGED IN TO BARKLA, we will edit a simple “C” program. There are a number of
different editors available, and commonly used ones are gedit and nano. You can use their relevant
“manual page” to find out more. Note that
(a) “gedit” will open a new window that you can type into, but until you close that window you
cannot type in the original terminal window. You can circumvent this annoyance by starting the
editor in the background such that it keeps running via: gedit &
(b) “nano” just starts in the same terminal window. You have to save and exit to return to the
terminal window
9. To see what files are in a directory (=folder) use the “ls” command. To view a file (without editing it)
you can use the “cat” command. Using these you should look at the file
∼papacchf/COMP528-JAN21/labs/intro1/myHello.c
Fabio Papacchini: Fabio. .uk 2
COMP528-JAN21 University of Liverpool
10. Have a read of this code to ensure you can follow what it is doing, and the key “C” programming
constructs illustrated.
11. Now open an editor (see point 8) and re-create this file in your home directory – you can use copy/paste
to do this quickly.
12. To run this program we need to “compile” it. This converts the human-reading “C” program into
machine code. There are several compilers for “C” and today you should use the compiler: gcc
13. Take a look at the manual page for the compiler, compile the code and (if it compiles successfully) you
will have a new executable file that you can run. For example
gcc myHello.c
ls
./a.out
14. What output do you see? Can you explain this by looking at the code? Can you amend
this command to get more meaningful output?
4 Compile and Run a Timed “C” Example
15. Obtain files by:
cd
tar -xzf ∼papacchf/COMP528-JAN21/labs/lab01.tgz
cd intro1
(The above commands mean “change directory to my ‘home’ directory”, “extract compressed files from
∼papacchf/COMP528-JAN21/labs/lab01.tgz into the current directory”, and “change directory into
the directory named intro1”.)
16. If you now list the directory (using “ls”) you should see: func1.c myHello.c omp quad.c quad.c
quad.sh
17. Look at the “quad.c” code and determine what it does.
Fabio Papacchini: Fabio. .uk 3
COMP528-JAN21 University of Liverpool
(a) Can you see which statements relate to timing a section of the code? And where it
is output?
(b) Note that we want to measure the wallclock time. This involves using the gettimeofday function
(whereas the clock function returns CPU time) – what do you think is the difference
between wallclock and CPU times?
18. You will also see a batch script file “quad.sh” which you should examine and ensure you understand
what is going on.
(a) Can you see where the GNU compiler is used, and where the Intel compiler is used?
(b) Note the “-O0” and “-O3” flags to each compiler – view the relevant manual page to
see what these are expected to do
(c) What do you think the “module” command is for?
19. On an HPC system, there are login nodes (for small tasks) and compute nodes (for running jobs). To
compile and then run the executables we submit the batch script to the “SLURM” batch system:
sbatch quad.sh
(We will cover SLURM in more detail in next week’s lab)
20. You can use the “squeue” command to examine if your job is running. Please see “man squeue” for
more information.
21. Once a job has completed (it disappears from “squeue” output) you will obtain a job output file, named
after the batch script used. Today, you will see the job standard output in a file called something like
slurm-NNNN.out where the NNNN will be replaced by the actual job number. Note that (frequently)
there may be a few seconds between a job finished and the output file being visible in your home filestore
22. Example your job output.
(a) What can you say about the different optimisation levels for each of the GNU and
the Intel compilers?
(b) How would you compare the performance of the GNU compiler to the Intel compiler?
23. Have you checked the results?!
24. You will see there are 2 sets of results at the bottom of the slurm output file with labels about “OpenMP
parallelisation”. If you look closely at the quad.sh file you will see these are from compiling the source
file “omp quad.c” which is one example of a parallel C code such that you will learn to write yourself.
Compare this with “omp.c” to see there is a little more in the parallel code. You may notice we compile
it slightly differently (which we cover later in the term) but for now look at the timings and compare
with the timings for the serial codes.
5 SUMMARY
Today you have experienced and learned about
� Using a typical university HPC system
� How to run batch jobs and examine their output
� Editing, compiling and running a serial C code, with timings, and compared compilers
� compiling and running a parallel C code
Fabio Papacchini: Fabio. .uk 4
Login to the lab-based PC (Windows system)
Accessing UoL HPC System “Barkla”
Editing a File on Barkla
Compile and Run a Timed “C” Example
SUMMARY