From Code to Performance

Exercise 6: Profiling and Optimization Challenge

Objectives:Apply profiling tools to identify bottlenecks and optimize an HPC application.

Tasks

  1. Take your OpenMP or MPI program,
  1. Compile with debugging/profiling flags: mpicc -g -pg -fopenmp app.c -o app
  1. Run the program and generate a profile: mpirun -n 4 ./app --> produces gmon.out.
  1. Analyze with gprof: gprof ./app gmon.out > report.txt.
  1. Identify the function consuming the most time.
  1. Optimize it (e.g., reduce redundant loops or add cache blocking).
  1. Re-profile and compare improvements.

Optional: Try perf stat ./app or Intel Vtune if available.