Commit 72017703 authored by Konstantin Kuck's avatar Konstantin Kuck 💬
Browse files

Add material for Coffee Lecture on HPC intro and bwHPC

parent 304ccd24
Loading
Loading
Loading
Loading
+5.05 MiB

File added.

No diff preview for this file type.

+32
Changes for 2026-10-28_Intro-HPC-bwHPC/README.md: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Coffee Lecture - Introduction to high-performance computing (HPC) and overview of bwHPC

This Coffee Lecture gives a short introduction to high-performance computing (HPC) and an overview of the bwHPC infrastructure in Baden-Württemberg.


High-performance computing typically means working on a compute cluster, a shared system of many interconnected computers. Working on a compute cluster differs from conventional computing in the sense that compute resources need to be explicitly requested and allocated.


Under the bwHPC initiative, five clusters are operated in Baden-Württemberg: one general-purpose cluster (bwUniCluster 3.0) and four discipline-specific clusters (bwForClusters). Researchers and students at universities in Baden-Württemberg can use them free of charge after registration.


Specifically, we discuss:
 - Architecture of a compute cluster
 - Use cases
 - Modes of working on a cluster computer
 - Overview of the bwHPC compute clusters
 - Registering for bwHPC
 

A short live demo shows how an R job is submitted, run, and monitored on the cluster.

No prior HPC experience required.
 
---

## Further information and support
 - **Detailed documentation** is available in the [bwHPC Wiki](https://wiki.bwhpc.de/e/Main_Page).
 - Do not hesitate to contact the bwHPC at the Office for Research Services (Stabsstelle Forschungsnahe Dienste) for questions or assistance: [kim-bw-projekt@uni-hohenheim.de](mailto:kim-bw-projekt@uni-hohenheim.de)
 - Alternatively, submit a ticket to the **bwSupport**: [https://bw-support.scc.kit.edu/](https://bw-support.scc.kit.edu/).
 
---
+48
Changes for 2026-10-28_Intro-HPC-bwHPC/code/boot.R: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
#==============================================================================
# Simple example to illustrate batch job computing in the context of a 
# parallelized bootstrap of a confidence interval
#===============================================================================


library(parallel)

# number of cores
n_cores <- as.integer(Sys.getenv("SLURM_NTASKS", unset = "1"))


# number of replications
R <- 50000

# initialize random number generator
RNGkind("L'Ecuyer-CMRG")
set.seed(1)

# simulate data
dat <- data.frame(x = rnorm(5000))
dat$y <- 2 * dat$x + rnorm(5000, sd = 3)

boot_fun <- function(i) {
  idx <- sample(nrow(dat), replace = TRUE)
  coef(lm(y ~ x, data = dat[idx, ]))[["x"]]
}

stime <- system.time({
    slopes <- unlist(lapply(1:R, boot_fun))
    })[3]

ptime <- system.time({
    slopes_par <- unlist(mclapply(1:R, boot_fun, mc.cores = n_cores))
    })[3]


cat("Bootstrap confidence interval (serial)\n")
print(quantile(slopes, c(0.025, 0.5, 0.975)))


cat("\n\nBootstrap confidence interval (parallel)\n")
print(quantile(slopes_par, c(0.025, 0.5, 0.975)))

cat("\n\n")
cat(sprintf('Sequential time: %f\n', stime))
cat(sprintf('Speed up for %d workers: %f\n',
            n_cores, round(stime / ptime, digits=2)))
+40
Changes for 2026-10-28_Intro-HPC-bwHPC/code/boot.slurm: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/sh 
########## Begin Slurm header ##########
#
# Give job a reasonable name
#SBATCH --job-name=parallel-bootstrap
#
# Request number of nodes for job
#SBATCH --nodes=1
#
# Number of program instances to be executed
#SBATCH --tasks-per-node=4
#
# Maximum run time of job
#SBATCH --time=00:10:00
#
# Write standard output and errors in same file
#SBATCH --output="%x.o%j"
#
# Send mail when job begins, aborts and ends
#SBATCH --mail-type=BEGIN,END,FAIL
#
########### End Slurm header ##########

echo "Working Directory:                    $PWD"
echo "Running on host                       `hostname`"
echo "Job id:                               $SLURM_JOB_ID"
echo "Job name:                             $SLURM_JOB_NAME"
echo "Number of nodes allocated to job:     $SLURM_NNODES"
echo "Number of cores allocated to job:     $SLURM_NTASKS"


# Setup R Environment
module load math/R/4.5.1

# Change to submission directory of this job (not needed)
cd "$SLURM_SUBMIT_DIR"

# Start program
R CMD BATCH --no-save --no-restore --slave boot2.R