HPC / CFD Deep Question Bank¶
All exam-style questions with answers, organised by chapter and difficulty. Use as an active drill: cover the answer, write your own, then check.
Chapter 1 — Course Introduction & HPC Overview¶
Beginner¶
- What does HPC stand for? High-Performance Computing.
- Name two supercomputers. El Capitan, Frontier, JUWELS, Aurora.
- OS on every Top500 cluster? Linux.
- What is a "core"? One processing unit (ALU + registers) inside a CPU.
- Top500 ranks by which benchmark? LINPACK (HPL) in FLOPS.
Intermediate¶
- Define FLOPS and convert 1 PFLOPS to FLOPS. Floating-point operations per second; 1 PFLOPS = \(10^{15}\) FLOPS.
- Node vs core? Node = whole computer; core = one processing unit inside its CPU.
- State three reasons Linux dominates HPC. Open-source kernel, scriptable shells, modular distributions, POSIX portability.
- Difference between simulation and experiment in CFD? Experiments give limited but ground-truth data; simulations give all variables but need validation.
- Role of the interconnect in a cluster? Fast inter-node communication for MPI; latency limits strong scaling.
Hard¶
- LES of 5e8 cells × 5e4 steps × 200 ops → total FLOPS? \(5 \times 10^{15}\).
- Why do more cores not always help? Amdahl's law: serial fraction limits speed-up to 1/f.
- Why are GPUs becoming dominant? Higher FLOPS/W, dense vector compute.
- What limits strong scaling? Communication latency vs computation; sub-domain shrinks while messages stay.
- Power as Top500 metric? Cooling cost ∝ power; targets push GFLOPS/W.
Very Hard¶
- Algebra of Amdahl plateau. S(N) = 1/(f + (1-f)/N) → 1/f as N → ∞.
- 5% serial → max speed-up. 1/0.05 = 20×.
- Communication ∝ √N, compute ∝ N — when does communication dominate? When √N × c_comm \(\gtrsim\) N × c_compute, i.e. small per-node work.
Deep Integration¶
- Trace a CFD job from edit to plot. Vim → Git → SSH → SLURM → MPI → rsync → gnuplot.
- Why is "scriptability" of Linux more important than "free"? Reproducibility & automation.
Coding/Command¶
- One-liner to print core count.
nproc. - Time a program.
time ./a.out.
Debugging¶
- Why does parallel program produce different result each run? Race conditions; non-deterministic FP reduction order.
- Speed-up decreases beyond 16 cores on a laptop? Hyperthreads share ALUs; cache contention.
Long Written¶
- Discuss IFAS HPC research and sustainable aviation in 250 words. (See Ch. 1 §9.3.)
Chapter 2 — Unix / Linux Basics¶
Beginner¶
- Who released the Linux kernel? Linus Torvalds, 1991.
- What does GNU stand for? GNU is Not Unix.
- Licence of Linux kernel? GPLv2.
- Two Unix-derived OSes. macOS, Solaris.
- Tux? Linux's penguin mascot.
Intermediate¶
- Why was Unix portable? Rewritten in C in 1973.
- Who maintains POSIX? IEEE.
- Role of
init? First user-space process; starts services. - Why clusters use RHEL/Rocky? Long support, ISV certification.
- Why is
bashthe "Bourne-Again Shell"? Successor to Stephen Bourne'ssh.
Hard¶
- Two POSIX features. Function API (e.g.
fork); shell utilities (grep). - Why
Linux ≠ Unixlegally? Linux is Unix-like; not derived from AT&T code. - What is
glibc? GNU C library; user-side POSIX implementation. - Why does
lswork on macOS? Both POSIX-compliant; both shipls. - Monolithic vs micro-kernel? Linux: drivers in kernel space; Mach: drivers in user space.
Very Hard¶
- How does syscall change privilege (x86_64)?
syscallinstr → MSR-defined entry → kernel mode. - "Everything is a file" — why useful? Generic syscalls work on devices, sockets, pipes.
- Linux vs Hurd? Hurd never finished; GNU userland uses Linux kernel.
Deep Integration¶
- How does Unix philosophy map to Ch. 7? Pipes compose grep/awk/sed.
- Why is POSIX still relevant in 2026? Containers, WSL, embedded depend on it.
Coding/Command¶
- Print kernel version.
uname -r. - Print current shell.
echo $SHELL.
Debugging¶
ls: command not founddespite/bin/lsexists. PATH cleared.- System still boots old kernel after update. GRUB default not updated.
Long Written¶
- Discuss why HPC chooses Linux over BSD/Windows in 250 words. (Ch. 1 §4.4 + Ch. 2 §4.7.)
Chapter 3 — Linux Commands & File Permissions¶
Beginner¶
- Numeric for
rw-r--r--. 644. - Symbolic for 700.
rwx------. - Count words in file.
wc -w f. - Copy directory.
cp -r src dst. - Symbol for home.
~.
Intermediate¶
- Numeric for
rwsr-xr-x. 4755. - Numeric for
rwxrwxrwt. 1777. - Why
chmod 644cannot run a script. No execute bit. cpvsmvon same FS.mvjust renames inode;cpduplicates data.ls -ld /tmpoutput.drwxrwxrwt root root ....
Hard¶
umask 027onmkdir. 0777 - 027 = 0750.- List only files.
ls -lp \| grep -v '/$'orfind . -maxdepth 1 -type f. - Hard link, delete one name. Other still works; ref-count > 0.
cp -r dir1 dir2if dir2 missing. dir2 created as copy of dir1.- Why
rm -ion cluster. Adds confirmation; prevents catastrophic deletes.
Very Hard¶
-rwsrwsr-Tnumeric. 7766 (setuid+setgid+sticky+no other-x).umaskdiffers login vs non-login — why? Different rc files.rm -rf $undef_var/danger. Empty var →rm -rf /.
Deep Integration¶
- Why is
chmod -R 777bad on a shared cluster? Anyone can edit; reproducibility lost; security risk. - Why does SLURM need setuid? Helper bins elevate briefly to enforce policy.
Coding/Command¶
- Recursive group-write.
chmod -R g+w data/. - Count
.cpp.find . -type f -name "*.cpp" \| wc -l.
Debugging¶
Permission deniedrunning script.chmod +x.ls > log; ls /missing > log— what's in log? Only stderr appears; merge with2>&1.
Long Written¶
- Discuss permissions on multi-user HPC in 200 words. (Ch. 3 §9.3.)
Chapter 4 — bashrc, SSH, Remote Workflows¶
Beginner¶
- Default SSH port. 22.
- File listing your authorized public keys.
~/.ssh/authorized_keys. - One-shot file copy command.
scp. - Incremental sync command.
rsync. &at end of command. Run in background.
Intermediate¶
- Why ed25519 over RSA? Smaller, faster, modern.
- Permission for
~/.ssh/id_ed25519. 600. - Where do aliases go for persistence?
~/.bashrc. sourcevs run.sourcemodifies current shell.2>&1plain English. Send stderr where stdout points.
Hard¶
ssh -L 8888:cn01:8888 user@gw. Local-port forward localhost:8888 ↔ gateway tunnel ↔ cn01:8888.- Why does
tmuxsurvive disconnection? Server process owns the pty. - Mode 777 on
~/.ssh. SSH refuses keys for safety. ~/.ssh/known_hosts. Stores trusted server fingerprints; detects MITM.rsync src/ dst/vsrsync src dst/. Trailing slash = contents only.
Very Hard¶
- Why TOFU weakness for SSH host keys? First-contact MITM possible; mitigate via SSHFP DNS or CA.
- Agent forwarding (
ssh -A) trade-off. Convenience vs forwarding-host compromise. - Why
scpblocks butrsyncresumes? scp has no chunking/state; rsync rebuilds via checksums.
Deep Integration¶
- Map SSH ops to CFD workflow. ssh login → tmux → rsync push → sbatch → tmux detach → rsync pull.
- Why disable password auth on cluster? Stops brute-force; key-based audit-friendly.
Coding/Command¶
- Mirror with delete.
rsync -avzP --delete ~/work/ cluster:~/work/. - Bash function tunneling Jupyter.
jup(){ ssh -L 8888:$1:8888 cluster; }.
Debugging¶
Permission denied (publickey)despite key. Wrong perms / key not in agent / not in authorized_keys.scp: not foundon cluster. OpenSSH ≥9 disabled scp; usescp -Oor rsync/sftp.
Long Written¶
-
Daily CFD workflow with SSH/rsync/tmux/SLURM in 250 words.
A CFD researcher's day starts locally: edit the case (Vim), commit (Git), push. Then
ssh hpc— public-key authentication, configured once viassh-keygen,ssh-copy-id, and a~/.ssh/configHost block, makes this a two-second, password-free step. On the login node,tmux new -s workcreates a session that will survive any disconnection; inside it,git pullfetches today's changes andmodule load gcc/12 openmpi/4.1restores the toolchain. Input data moves withrsync -avzP laptop:case_A/ $WORK/case_A/— incremental, compressed, resumable, so re-syncing a 50 GB case after a small change transfers only the changed blocks. The job itself is never run on the login node:sbatch run.sbatchhands it to SLURM,squeue -u $USERshows PENDING→RUNNING, and the script's#SBATCHlines fix nodes, tasks, walltime and partition. While the solver runs, the researcher detaches (Ctrl-b d), closes the laptop, and later re-attaches withtmux a -t work— the shell, history and monitoring loops are exactly where they were left. Whensacctreports COMPLETED, results return withrsync -avzP $WORK/case_A/results/ laptop:results/— again incremental, so daily harvesting stays cheap. Post-processing (awk → gnuplot) can run remotely, sending back only PNGs. The pattern to stress in the exam: SSH provides the secure channel everything else rides on; rsync minimises data motion; tmux decouples session lifetime from connection lifetime; SLURM decouples computation from the login node. Four tools, one principle each — together they make remote HPC feel local.¶
Chapter 5 — Vim & Command-Line Editing¶
Beginner¶
- Save and quit.
:wq(orZZ). - Discard.
:q!. - Copy line.
yy. - Delete 5 lines.
5dd. - Undo.
u.
Intermediate¶
ci". Change inside quotes.>aP. Indent a paragraph.- Replace foo→bar lines 5–10.
:5,10s/foo/bar/g. - Search backwards.
?Re. - Open Makefile in vsplit.
:vsp Makefile.
Hard¶
- Whole-word replace.
:%s/\<Re\>/Reynolds/g. - Repeat last
:s.&. - Yank function body. Cursor in body,
ya{. - Append
;to every line.:%s/$/;/. - Comment out lines 5–20.
:5,20s/^/\/\//.
Very Hard¶
- Edit on 200 buffers.
:bufdo %s/foo/bar/ge \| update. - Sort selected lines numerically. Select
V,:'<,'>!sort -n. - Reformat paragraph to 80 cols.
gq(withset textwidth=80).
Deep Integration¶
- Batch-edit 50 SLURM scripts.
vim *.sbatch; :argdo %s/--time=2/--time=4/ge \| update. - Why Vim over VS Code on HPC? Works over SSH; pre-installed; low memory.
Coding/Command¶
- Macro to wrap line in
if(true){…}.qa I if(true) { <Esc>A } <Esc>qthen@a. <F5>mapping to compile + run C++. See Ch. 5 §6.4.
Debugging¶
:s/foo/bar/gonly 1 match. Need%::%s/foo/bar/g.:wread-only.:w!or:w !sudo tee %.
Long Written¶
-
Discuss Vim grammar's productivity in 250 words.
Vim's productivity comes from treating editing as a language, not a menu. Commands compose as [count][operator][motion]:
d(delete),c(change),y(yank),>(indent) are verbs;w,e,$,},G,i",a{are motions and text objects. Learning m operators and n motions yields m·n commands — 8 verbs × 10 motions = 80 edits from 18 memorised pieces.d2wdeletes two words,ci"changes inside quotes,y}yanks a paragraph: each reads like a sentence, and once one new motion is learned it instantly works with every verb. Three multipliers sit on top. The dot command.repeats the last change, turning a one-off fix into a keystroke-per-occurrence sweep. Registers give named clipboards ("ayy,"ap), with"_discarding deletions so a prepared yank survives. Macros record any keystroke sequence into a register (qa … q) and replay it (@a,5@a, or:g/pat/normal! @aacross a whole file) — a disposable program written by demonstration, ideal for reformatting hundreds of SLURM log lines or case-file entries. Ex commands scale the same grammar to file ranges::5,20s/^/# /comments a block,:argdo %s/Re=1000/Re=5000/ge | updateedits fifty buffers. On clusters this matters doubly: Vim is always installed, runs over SSH without a GUI, and starts instantly. The exam-worthy conclusion: modal editing spends keystrokes on structure rather than cursor travel, and its combinatorial grammar means capability grows multiplicatively while learning grows additively.¶
Chapter 6 — Regex & Globbing¶
Beginner¶
*.txtin shell. All files ending.txt.^abcregex. Lines startingabc.- Glob for one char.
?. - POSIX class for digits.
[[:digit:]]. - Regex for word + space.
[[:alpha:]]+.
Intermediate¶
- List
.h .cppin dir-1+dir-2.ls {dir-1,dir-2}/*.{h,cpp}. - Loose IPv4 regex.
([0-9]{1,3}\.){3}[0-9]{1,3}. - Replace tabs with 4 spaces (sed).
sed 's/\t/ /g'. - Whole-word
Re.\<Re\>(BRE/ERE) or\bRe\b(PCRE). - Glob hidden files.
.[!.]*.
Hard¶
- No-
foo-no-barlines (PCRE).^(?!.*(foo|bar)).*$. - Phone with optional country code.
(\+[0-9]+ )?[0-9]{3}-[0-9]{3}-[0-9]{4}. - Negate glob.
extglob!(pattern). - Replace SciNot by 0.0.
sed -E 's/[0-9]*\.[0-9]+[eE][+-]?[0-9]+/0.0/g'. - Date YYYY-MM-DD regex.
[0-9]{4}-[0-9]{2}-[0-9]{2}.
Very Hard¶
ls *.txtfaster thanfind . -name "*.txt". Glob expanded once via readdir; find recurses.- Strict IPv4 regex.
((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|...). - Negate glob.
shopt -s extglob; ls !(tmp*).
Deep Integration¶
- Pipeline to print files matching regex.
grep -lE 'PATTERN' *.log. - Why regex101.com first? Test before destructive
sed -i.
Coding/Command¶
- Find today's logs and grep ERROR.
find . -mtime -1 -type f -name '*.log' -exec grep -l ERROR {} +. - Vim whole-word replace all open buffers.
:bufdo %s/\<oldName\>/newName/ge \| update.
Debugging¶
grep "(foo|bar)" fno match. BRE: parens literal; use-E.ls *.[ch]empty. No matching files;shopt -s nullglob.
Long Written¶
-
Regex+glob in HPC log analysis pipeline (250 words).
Globs and regexes divide the labour in every HPC log pipeline: the shell's glob chooses which files, a tool's regex chooses which text inside them. They look similar but differ in meaning (
*= any string in a glob, but = zero-or-more of the previous atom in a regex) and in who expands them — the shell substitutes globs before the program ever runs, while grep/sed/awk apply regexes to file content. A realistic sweep: 200 cases live incase_*/;ls case_*/run.log(glob) enumerates the logs. Health check:grep -lE "diverg(ed|ing)|nan|inf" case_*/run.log— the glob fans out to 200 paths, the ERE alternation flags sick runs,-lprints only filenames for the rerun list. Extraction:grep -hoE "residual=[0-9.eE+-]+" case_042/run.logisolates numeric fields, orawk '/^Time =/ {print $3, $7}'converts a verbose log into two-column plot data. Bulk repair uses sed with a captured group:sed -i -E 's/^(Re *= *)1000\b/\15000/' case_*/in.dat— the glob selects the files, the backreference keeps the untouched part,-iedits in place (test without-ifirst). Recursive selection upgrades toshopt -s globstar; **/*.log, and stricter file choice can move intofind -name "*.log" -mtime -1when age or size matters. The trap to name: quoting —find . -name "*.log"must protect the pattern from shell expansion, the exact opposite of thelscase. One line of exam summary: globs name files, regexes match text; the pipelineglob → grep → sed/awkis HPC's standard log-analysis machine.¶
Chapter 7 — Linux Text Tools¶
Beginner¶
- All
.txtin~.find ~ -type f -name "*.txt". - Count lines with ERROR.
grep -c ERROR log. - Replace first foo→bar per line.
sed 's/foo/bar/' f. - Print 2nd CSV field.
awk -F, '{print $2}' f. - Diff two files.
diff a b.
Intermediate¶
- Files >100 MB.
find . -size +100M. - Replace all foo→bar in place.
sed -i 's/foo/bar/g' f. - Sum column 3.
awk '{s+=$3} END{print s}' f. - First match per file.
grep -m1 PAT *.log. - Unique departments.
awk -F, 'NR>1{print $3}' f \| sort -u.
Hard¶
- CSV with quoted commas — parsing?
awk -v FPAT='([^,]+)|("[^"]+")'. - Median of column.
awk '{a[NR]=$1} END{n=asort(a); ...}'. - Replace IPs with
[redacted].sed -E 's/[0-9]{1,3}(\.[0-9]{1,3}){3}/[redacted]/g'. - 5 longest lines.
awk '{print length, $0}' f \| sort -nr \| head -5. - Diff huge files: just summary.
diff -q a b.
Very Hard¶
- awk pivot by dept & gender.
awk -F, 'NR>1{c[$3,$5]++} END{for(k in c) print k,c[k]}'. - sed conditional.
sed -E '/^Re/s/=[0-9]+/=5000/'. - find avoiding
node_modules.find . -name node_modules -prune -o -type f -print.
Deep Integration¶
- Find
coutnot followed byendlin.cpp.grep -rEn 'cout[^;]*;[^l]*' --include='*.cpp' .. - Top-10 directories by size.
du -sk * \| sort -nr \| head -10.
Coding/Command¶
- awk: NR>1 && salary>50000.
awk -F, 'NR>1 && $4>50000 {print $1,$2,$3}' f. - sed swap Last_First → First_Last.
sed -E 's/([A-Za-z]+)_([A-Za-z]+)/\2_\1/'.
Debugging¶
- awk prints empty for CSV. Need
-F,. sed 's/(foo|bar)/X/g'literal. Need-E.
Long Written¶
-
sed vs awk discussion in 250 words.
sed and awk are both stream processors, but they answer different questions. sed is a stream editor: it reads one line into the pattern space, applies editing commands — overwhelmingly
s/pattern/replacement/— auto-prints, and moves on. It is the tool for mechanical text surgery: substitutions with backreferences (s/^(Re *= *)1000/\15000/), deletions (/^#/d), line-range edits (5,10s/^/# /), in-place bulk changes across case files with-i.bak. It has no arithmetic and no real variables; its power is regex-driven rewriting at pipeline speed. awk is a small programming language over structured text: each record (line) is auto-split into fields$1..$NF, patterns guard actions (pattern { action }), andBEGIN/ENDblocks frame the run. It owns every task involving columns or numbers:awk '{s+=$2} END{print s/NR}'for a mean,$5=="PD" {n++}for conditional counts, associative arrays (sum[$2]+=$3) for per-group totals,printffor formatted tables. Choosing between them is exam-simple: if the job is "change this text into that text", sed; if it is "select, compute or reformat by columns", awk; if both, chain them —grepnarrows,sedcleans,awkcomputes,sort|uniq -csummarises. In CFD practice sed rewritesin.datparameters for sweeps, while awk turns solver logs intoresiduals.datfor gnuplot. Mention the models to score theory marks: sed's pattern-space cycle versus awk's record/field model — one edits a stream, the other programs over it.¶
Chapter 8 — Shell Scripting¶
Beginner¶
- Make script executable.
chmod +x s.sh. - Print first arg.
echo $1. - Number of args.
$#. - Exit success.
exit 0. - Array length.
${#A[@]}.
Intermediate¶
- Test file exists.
[ -f f ]. - Loop
*.cpp.for f in *.cpp; do ...; done. - Read input.
read -p "?: " ans. - Subshell.
( cd dir; ls ). - Capture cmd output.
x=$(cmd).
Hard¶
cd dir; cmdvs(cd dir; cmd). Subshell scope.- Replace
.txtwith.bak.for f in *.txt; do mv -- "$f" "${f%.txt}.bak"; done. - getopts with combined flags. See Ch.8 §4.12.
- Predict
(( 0 )). Exit status 1. - Source vs run.
. file.shruns in current shell.
Very Hard¶
for f in $(ls)worse thanfor f in *. Word splitting on filenames with spaces.set -epitfalls in pipes. Needpipefailfor middle-of-pipe errors.- Memoization in bash. Associative arrays.
Deep Integration¶
- Combine awk + bash for failed cases.
awk '/FAIL/{print $1}' results \| xargs -n1 ./rerun.sh. - Trap to clean tmp on Ctrl-C.
trap 'rm -f "$tmp"' EXIT INT TERM.
Coding/Command¶
- Sum file sizes in dir.
du -sb "$1" \| cut -f1. - Squares 1..10.
for i in {1..10}; do echo $((i*i)); done.
Debugging¶
if [ $x = "yes" ]fails empty. Quote:[ "$x" = "yes" ].for f in *.cpp; do ...with no matches.shopt -s nullglobor guard.
Long Written¶
-
Walk through extended
backup-data.shin 250 words.The extended backup script is a template for defensive shell tooling. It begins with
#!/bin/bashand aUSAGEfunction that prints the call syntax and exits non-zero — errors are loud, not silent. Option parsing usesgetopts ":vs": the loop consumes-v(VERBOSE=1) and-s(SYNC=1), the leading colon selects silent error handling so an invalid flag lands in the?case, which calls USAGE. The essential line after the loop isshift $((OPTIND-1)): it discards the parsed options so$1/$2become the real positional arguments, SOURCE and DEST. Validation follows:[ -d "$SOURCE" ] && [ -d "$DEST" ]guarantees both directories exist before anything destructive; the quotes keep space-containing paths intact. The action block is a two-level branch. With SYNC=1 the transfer isrsync -aP(archive mode preserves permissions/timestamps,-Presumes and shows progress) — incremental, so repeated backups copy only changes; verbose adds-v. Without sync it falls back tocp -r, again with-vwhen requested. Each branch checks the command's exit status ($?) and reports success or failure, so the caller — a human or a cron job — gets a trustworthy return code. The design points to name in the exam: getopts+shift is the canonical CLI pattern; validation before action; rsync over cp for repeated data movement; quoting everywhere; explicit exit codes. In CFD daily life this exact skeleton ships results from$WORKto a project share — the exercise is a rehearsal for production cluster scripts.¶
Chapter 9 — Gnuplot¶
Beginner¶
- Plot sin(x).
plot sin(x). - Add title.
set title "..."; replot. - Save PNG.
set terminal png; set output 'x.png'; replot. - Plot col 1 vs 3.
using 1:3. - Legend top-right.
set key right top.
Intermediate¶
- Log y axis.
set logscale y. - Two curves on one plot.
plot 'a' u 1:2, 'b' u 1:2. - Red dashed thick.
lt 2 lw 3 lc rgb "red" dt 2. - Error bars.
using 1:2:3 with yerrorbars. - 2×2 multiplot.
set multiplot layout 2,2 ....
Hard¶
- Fit
a*exp(-b*x).f(x)=a*exp(-b*x); fit f(x) 'd' via a,b. - Twin y-axis.
set y2tics; plot ... axes x1y2. - Histogram.
smooth frequency with boxes. - Conditional colour.
lc variablebased on column. - 3-D surface.
splot 'mesh' u 1:2:3 with pm3d.
Very Hard¶
- awk → gnuplot in one script. See Ch. 9 §6.8.
- Animate frames into GIF. Bash loop +
convert -delay. - LaTeX-ready labels.
set terminal cairolatex eps.
Deep Integration¶
- Auto-plot every case. §7 + 6.7.
- gnuplot vs Excel for HPC. Reproducible, scriptable, terminal output.
Coding/Command¶
- Plot column 1 in ms.
plot 'd' using ($1*1000):2 with lines. - Horizontal line at 1e-6.
set arrow from graph 0,first 1e-6 to graph 1,first 1e-6 nohead lt 0.
Debugging¶
- Plot CSV nothing.
set datafile separator ",". - PNG empty. Forgot
replotafterset terminal png.
Long Written¶
-
gnuplot as HPC postprocessor in 250 words.
gnuplot fits HPC because it is text-driven, scriptable and headless — the same reasons Linux fits HPC. A plot is a short program: set terminal/output, titles, ranges,
set logscale yfor residuals spanning ten decades, thenplot 'residuals.dat' using 1:2 with linespoints. Because it is a program, it is reproducible: the.gpscript lives in Git next to the solver, and anyone can regenerate the figure from raw data — impossible to guarantee with GUI spreadsheets. It composes with the shell: awk extractsiter residualpairs from a noisy solver log, a heredoc orgnuplot -e "datafile='...'"parameterises the script, and a bash loop renders one PNG per case — two hundred convergence plots from an overnight sweep with no clicks. It runs on the cluster itself, so gigabyte logs never cross the network; only kilobyte PNGs come home (compute where the data lives). Beyond line plots it covers the scientific needs: multiplot grids for dashboards, error bars (using 1:2:3 with yerrorbars), 3-Dsplot ... with pm3d, and least-squares fitting —fit f(x) 'd' via a,b,cminimises the residual sum of squares with Levenberg–Marquardt and reports parameter errors infit.log, turning a grid-convergence study into a slope read straight off a log-log line. Terminals export raster PNG for slides and vector pdfcairo for papers. Note the 2026 caveat: the dedicated lecture was dropped, but the workflow — awk → gnuplot → PNG — remains the canonical, exam-quotable way HPC results become figures.¶
Chapter 10 — Git¶
Beginner¶
- Init.
git init. - Stage.
git add file. - Commit.
git commit -m "msg". - Log.
git log. - Clone.
git clone url.
Intermediate¶
- Create+switch branch.
git switch -c x. - Merge x into main.
git checkout main; git merge x. - Delete branch.
git branch -d x. - Add remote.
git remote add origin url. - First push.
git push -u origin main.
Hard¶
- Undo last commit, keep staged.
git reset --soft HEAD~1. - Squash 3 commits.
git rebase -i HEAD~3thenslower two. - Restore deleted file.
git restore -- file. - Cherry-pick commit.
git cherry-pick <hash>. - Log of file.
git log -- solver.cpp.
Very Hard¶
- FF vs 3-way merge. FF linear; 3-way merge commit with two parents.
- Recover deleted branch.
git reflog→git branch x <hash>. git bisect. Binary search through history for bad commit.
Deep Integration¶
- Tag + reproducibility on cluster.
git tag v1.0-paper; git push --tags. - Why rebase shared branch is bad. Rewrites history; teammates' fetches break.
Coding/Command¶
- Stage all
.cppand commit.git add '*.cpp'; git commit -m "...". - Show README changes last 5 commits.
git log -p -5 README.md.
Debugging¶
Updates were rejected.git pull --rebasethenpush.- PAT 401. Token expired or missing scope.
Long Written¶
-
GitFlow vs GitHub Flow for HPC team in 250 words.
GitFlow and GitHub Flow are two branching policies on the same Git machinery. GitFlow is ceremonial: a permanent
developbranch collects features;feature/*branches merge into develop; releases get their ownrelease/*stabilisation branches, tagged intomain; emergencies go throughhotfix/*. GitHub Flow is minimal:mainis always deployable; every change is a short-lived branch off main, pushed early, reviewed as a Merge/Pull Request with CI, merged, deleted. For a research CFD team, the trade-offs are concrete. GitFlow's release branches suit software that ships versioned artefacts to external users — a solver released as v2.1 to other institutes, needing long-term support branches and back-ported hotfixes. Its cost is bookkeeping: two long-lived branches, more merges, more conflict surface — heavy for a five-person group where "release" means "the tag used in the paper". GitHub Flow matches how research code actually evolves: small increments, continuous integration running the build plus regression cases on every MR,mainalways able to reproduce yesterday's results. Reproducibility comes not from release branches but from tags:git tag -a v1.0-paperpins the exact commit behind every figure, and the cluster job clones that tag. A sensible recommendation to defend in the exam: default to GitHub Flow (simplicity, CI-guarded main, tags for papers) and borrow GitFlow's release branch only when the group must maintain an old shipped version in parallel. The meta-point: branching models are policy, not technology — pick the lightest policy that protectsmainand preserves provenance.¶
Chapter 11 — C++ Basics¶
Beginner¶
- Compile hello.
g++ hello.cpp -o hello. - Print "hi".
std::cout << "hi" << std::endl;. - Declare int.
int a=5;. - Address of a.
&a. - Pointer to a.
int *p=&a;.
Intermediate¶
- Loop length 5.
for(int i=0;i<5;++i) .... - Pass by reference.
void f(int& a). - Class with public method. See Complex.
- Init list.
T():a(0){}. using namespace stdbad in headers. Name pollution.
Hard¶
- Why call-by-value doesn't modify caller? Copy.
int *p; *p=5;. Uninitialised pointer.deletevsdelete[]. Single object vs array.- Why
endlslow. Flushes buffer. - Returning class by value. Uses copy/move.
Very Hard¶
- Why
const Field&? Avoid expensive copies. - Stack vs heap. Auto vs
new/delete; lifetime. - Forgot
;after class. Cascading errors.
Deep Integration¶
- Pointer arithmetic ↔ SIMD vectorisation. Contiguous memory, stride 1.
- RAII vs
new/delete. Constructor acquires, destructor releases — exception-safe.
Coding/Command¶
- swap by reference.
void swap(int&a,int&b){int t=a;a=b;b=t;}. - Add
operator+to Complex. See Ch. 11 §9.7.
Debugging¶
puninit when reading.p=&afirst.c.x=5private. Use accessor or make public.
Long Written¶
-
Why HPC kernels avoid copying — by-ref vs ptr (250 words).
Copying is the silent performance killer in HPC, because moving bytes costs more than computing on them. A CFD field of 10⁸ cells with four doubles per cell is ≈3 GB; passing it by value copies 3 GB through a memory system delivering perhaps 400 GB/s — tens of milliseconds per call, repeated every time-step, plus doubled peak RAM that can push a node into OOM. Call-by-value also defeats caches: the copy evicts the hot working set. Hence kernels pass big objects by reference (
void update(Field& f)) or by pointer (void update(Field* f)), both costing eight bytes regardless of payload. References are the C++ default: they cannot be null, cannot be reseated, need no dereference syntax, andconst Field&documents read-only intent while letting the compiler optimise. Pointers remain necessary where nullability ("no boundary field attached"), reseating, raw arrays decayed from C interfaces, or MPI buffers (MPI_Send(&x, …)) are involved. The same economy drives the wider stack: swap-by-pointer exchanges array ownership instead of contents;std::vectormoves steal the internal pointer in O(1); range-for usesconst auto&to avoid per-element copies; MPI halo exchange ships only the ghost layer, never the sub-domain. The rule to state: copy scalars, reference aggregates; make read-only intentconst&; reach for pointers only when null/reseat/C-API semantics demand them. Then quantify once — 3 GB versus 8 bytes — and the exam answer writes itself: in HPC, data motion, not arithmetic, is the budget.¶
Chapter 12 — Build Process¶
Beginner¶
- Default executable name.
a.out. - Include path flag.
-I path. - Library path.
-L path. - Link math.
-lm. make cleantypically. Remove generated.
Intermediate¶
- Compile single to .o.
g++ -c file.cpp. - Link two .o.
g++ a.o b.o -o prog. - Build static lib.
ar rcs libx.a a.o b.o. - Build shared lib.
g++ -shared -fPIC -o libx.so a.cpp b.cpp. - List symbols.
nm libx.a.
Hard¶
- Why
-fPICfor shared. PIC: relative addressing for variable load addresses. - Why
makerebuilds only changed. Timestamp comparison. LD_LIBRARY_PATH. Runtime lib search dirs.-Lvs-l. Path vs library name.rpath. Embedded run-time lib paths.
Very Hard¶
lddshowsnot found. Missing .so in search paths.- Find heavy header.
g++ -H -c …. make -j$(nproc)faster. Parallel build.
Deep Integration¶
- Header guards + templates + inline. Templates/inline must be in headers; guards prevent dup non-inline non-template defs.
- CMake adoption in CFD. Portability + dependencies + tests + install.
Coding/Command¶
- Makefile rule for Complex.h-aware .cpp→.o. See Ch.12 §6.6.
- CMakeLists for same project. See harder version.
Debugging¶
Makefile:5: missing separator. Use TAB.undefined reference to add(int,int). Forgot to compile/linkadd.cpp.
Long Written¶
-
Make vs CMake for 100-file CFD project (250 words).
Make is a build runner: a Makefile declares targets, prerequisites and recipes, and rebuilds a target when it is older than any prerequisite. CMake is a build-system generator: CMakeLists.txt describes targets abstractly, and CMake emits Makefiles (or Ninja) for the platform. For 100 files the difference becomes decisive along five axes. Dependencies: hand-written Makefiles must encode header dependencies (
%.o: %.cpp defs.h) or silently ship stale objects when a header changes; CMake scans includes automatically and regenerates the graph. Portability: the same CMakeLists drives GCC on the cluster, Clang on laptops, and finds MPI/HDF5 viafind_package(MPI REQUIRED)— in Make, those become fragile hand-set variables. Structure:add_library(core src/…)plustarget_link_libraries(solver PRIVATE core)scales to modules cleanly;target_include_directories(... PUBLIC include)propagates usage requirements so consumers inherit paths. Hygiene: out-of-source builds (cmake -B build -S .) keep the tree clean, allow parallel Debug/Release trees (-DCMAKE_BUILD_TYPE=Release), and onerm -rf buildresets everything. Ecosystem: CTest wires regression cases into CI, install/export rules ship the solver. Make retains virtues — no extra tool, transparent recipes, perfect for small demos and for reading what actually runs (CMake generates Makefiles precisely because Make executes well). The defensible conclusion: for a 100-file, multi-library, MPI-linked CFD code, write CMake and let it generate Make; keep hand-written Make for toy projects and for understanding the timestamp mechanics that CMake automates. Modern HPC practice — and the lecture — land on exactly that split.¶
Chapter 13 — Debugging¶
Beginner¶
- Debug compile flag.
-g. - Start gdb.
gdb ./prog. - Set breakpoint.
break 10. - Run.
run. - Print var.
print x.
Intermediate¶
- Step into vs over.
step/next. - Print 5-element array.
p *arr@5. - Run to function end.
finish. - Show stack.
backtrace. - Detect leaks.
valgrind --leak-check=full.
Hard¶
<optimized out>. Compiled with-O2+.- Pause when i==100.
watch i; cond N i==100. - Inspect register.
info registers; p $rax. - Set var from gdb.
set var x = 5. - Attach to process.
gdb -p <pid>.
Very Hard¶
- Reverse-debug.
record full; reverse-step. - Debug optimized build.
-O2 -g -fno-omit-frame-pointer. - Debug MPI rank.
mpirun gdbor attach to PID.
Deep Integration¶
- Sanitizer in CI. Build with ASan; fail on errors.
- Why leaks bad in CFD jobs. OOM; growing per iteration.
Coding/Command¶
- One-liner with ASan.
g++ -O1 -g -fsanitize=address prog.cpp && ./a.out. - gdb finding debug03 NULL deref. See Ch.13 §6.3.
Debugging¶
- No core file.
ulimit -c unlimited. - valgrind "uninitialised value". Use
--track-origins=yes.
Long Written¶
-
gdb on debug05 step-by-step (250 words).
debug05.cpp wraps
is_primein a loop printing primes up to 31; the exercise is to verify the logic live rather than guess. Step 1: build for debugging —g++ -O0 -g debug05.cpp -o d5;-gembeds source mapping,-O0stops the optimiser from dissolving variables into<optimized out>. Step 2:gdb ./d5, thenbreak is_primeandrun— execution pauses at the first call. Step 3: inspect the call:print numshows the argument (first call: 1, since the loop passesi+1);info localsshowsprimeinitialised true. Step 4: trace the guard:nextoverif (num < 2)and watch the early return —finishruns to the end of the function and prints the return value, false for 1, confirming 1 is correctly excluded (and exposing the variant bugreturn prime;if it printed true). Step 5: probe a composite:condition 1 num==9,continue; inside,display ianddisplay prime, thennextrepeatedly — ati=3,9 % 3 == 0flips prime to false; note the loop still walks toi=8, a correctness-irrelevant inefficiency worth one comment (breakwould fix it). Step 6: check the boundary: the caller tests up toi+1 == 31, socondition 1 num==31,continue,finish→ true, 31 printed — the<=30loop is intentional, not off-by-one. Step 7:delete breakpoints; continueand compare the full output 2 3 5 7 … 31. The transcript — break, run, print, next/finish, conditional breakpoints, display — is exactly the reusable gdb vocabulary the written exam asks you to demonstrate.¶
Chapter 14 — Parallelization¶
Beginner¶
- OpenMP for? Shared-memory.
- MPI for? Distributed-memory.
- MPI compile.
mpic++ -O2 a.cpp -o a. - Run with 4 ranks.
mpirun -n 4 ./a. - Default communicator.
MPI_COMM_WORLD.
Intermediate¶
- Amdahl.
S=1/(f+(1-f)/N). - rank vs size. ID vs total.
- Why
reduction? Avoid race. - Datatype double.
MPI_DOUBLE. - Tag. Message label for matching.
Hard¶
- Send/Recv size mismatch. Error or hang.
- Blocking vs non-blocking. Returns when safe vs immediately + Wait.
MPI_Allreduce. Reduce + broadcast.- Why halo cells? Avoid per-cell communication.
schedule(dynamic)better when? Variable iteration cost.
Very Hard¶
- Why more ranks slow down beyond a point? Strong-scaling: communication > compute.
- Avoid load imbalance. ParMETIS partitioning by cost.
MPI_Sendrecvvs separate. Atomic exchange; deadlock-free for pairwise.
Deep Integration¶
- MPI + OpenMP + GPU. MPI between, OpenMP within node, OpenACC/CUDA on GPU.
- Why GPU CFD still needs MPI. Multi-GPU multi-node.
Coding/Command¶
-
OpenMP doubles array.
Each iteration touches a distinct element, so there is no shared write → no race and no reduction needed; compile with-fopenmpand control threads viaOMP_NUM_THREADS. -
Broadcast int.
MPI_Bcast(&x,1,MPI_INT,0,MPI_COMM_WORLD);.
Debugging¶
- Hang on 2 ranks. Both Recv first; reorder or
Sendrecv. - Race wrong sum. Add
reduction(+:sum).
Long Written¶
-
Why hybrid MPI+OpenMP dominates CFD (250 words).
Hybrid programming mirrors the hardware. A cluster is distributed memory between nodes and shared memory within a node; MPI matches the first, OpenMP the second. Pure MPI on a 128-core node means 128 ranks: each carries its own halo copies, buffers and runtime state, so memory per node balloons and the halo surface multiplies — communication grows with rank count even though the physics did not change. Hybrid runs a few ranks per node (often one per NUMA domain or per GPU) and lets OpenMP threads share that rank's arrays directly: intra-node "communication" becomes plain loads/stores, halos exist only at true node boundaries, and per-rank memory overhead drops by the thread count. Collectives also cheapen — MPI_Allreduce over 8 ranks × 16 threads synchronises 8 endpoints, not 128. The canonical CFD structure follows: domain decomposition assigns one sub-domain per rank (
--ntasks-per-node),#pragma omp parallel for(with reductions) spreads cell loops over--cpus-per-taskthreads, non-blocking Isend/Irecv overlap halo exchange with interior computation, andOMP_NUM_THREADS=$SLURM_CPUS_PER_TASKkeeps SLURM and the runtime consistent. Load balance improves too: threads self-balance inside a rank (schedule(dynamic)), softening partitioning imperfections that pure MPI freezes in. The model extends naturally to accelerators — MPI between nodes, OpenMP/offload or CUDA within — which is precisely JUPITER's Grace-Hopper design. Exam summary sentence: hybrid wins because it sends messages only where memory is actually distributed and shares memory wherever it truly is shared — matching the machine beats fighting it.¶
Chapter 15 — HPC Cluster¶
Beginner¶
- Where jobs run. Compute nodes.
- List software.
module avail. - Submit job.
sbatch script.sh. - See queue.
squeue. - Cancel job.
scancel ID.
Intermediate¶
- Reserve interactively.
srun --pty --nodes=1 bash. - Heavy I/O location.
$WORK. - OpenMP threads from SLURM.
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK. - Job 99 details.
scontrol show job 99. - Module file-search.
module spider <name>.
Hard¶
- Job dependencies.
sbatch --dependency=afterok:<id>. ntasksvscpus-per-task. MPI ranks vs OpenMP threads.- Pin processes to cores.
--cpu-bind=cores/OMP_PROC_BIND=true. - Why
module purgefirst. Reproducible environment. sinfoshows what. Partition names + limits.
Very Hard¶
sbatchovernohup. Scheduler accounting + isolation + restart.- Lustre stripes. File split across OSTs for parallel I/O.
- Why checkpoint long jobs. Walltime kill recovery.
Deep Integration¶
- Git + module + SLURM. Ch.15 §7.
- Why record
module list. Reproducibility.
Coding/Command¶
srunfor 4 ranks 1 hour gpu partition.srun --pty --partition=gpu --nodes=1 --ntasks=4 --gres=gpu:1 --time=1:00:00 bash.- Wait until own jobs end.
until [ -z "$(squeue -h -u $USER)" ]; do sleep 60; done.
Debugging¶
- "Permission denied" running job.
chmod +xor wrong path. - Pending forever. Too many nodes/walltime.
Long Written¶
-
sallocinteractive vssbatchbatch (250 words).sbatchandsallocrequest the same resources through the same scheduler but serve opposite phases of work.sbatch run.sbatchsubmits a script: SLURM queues the job, and when nodes free up it runs the script unattended — output to--outputfiles, environment rebuilt inside the script (module loads included), results collected viasacctafterwards. It is fire-and-forget: reproducible (the script is the record, versionable in Git), immune to your laptop sleeping, chainable via--dependency, and the only sane mode for 24-hour production runs or 100-task array sweeps.salloc --nodes=1 --time=1:00:00instead reserves resources and returns a shell holding the allocation; commands you type run throughsrunon the allocated node(s), andsrun --pty bashgives a live prompt on compute hardware. This is the debugging and experimentation mode: rebuild, run a 4-rank test under gdb, inspect a crashing case interactively, measure a kernel — with human latency in the loop but scheduler-managed fairness, unlike abusing the login node. The costs invert: interactive allocations waste core-hours whenever you think instead of compute, and they die with your connection (pair with tmux); batch jobs cost nothing while queued but debug slowly — each attempt is a queue round-trip. The professional workflow the exam wants: prototype undersalloc/srunon a small case in the short/test partition, freeze the commands into an sbatch script, then submit the real run withsbatchand monitor viasqueue. Same allocator, two doors: one for humans, one for jobs.¶
Mixed-Topic Integration Questions¶
- Edit→commit→push→build→submit→post-process pipeline. Combine Vim + Git + ssh + Makefile/CMake + sbatch + awk + gnuplot. Reference each chapter.
- Why does
rsync -avzmatter forgit cloneon a cluster? Not directly; butrsyncfor big result transfer +gitfor code. - Predict residuals time series for a CFD case based on the script in Ch.7 §7. Apply pipeline mentally.
- Why does compile + sanitizer + valgrind matter together? Sanitizers fast pass, valgrind deep audit; the build step decides.
- How many cores total in a SBATCH
nodes=4 ntasks-per-node=2 cpus-per-task=8? 64.
End of question bank.