Exercise 6: Profiling and Optimization Challenge
Objectives:Apply profiling tools to identify bottlenecks and optimize an HPC application.
Tasks
- Take your OpenMP or MPI program,
- Compile with debugging/profiling flags:
mpicc -g -pg -fopenmp app.c -o app
- Run the program and generate a profile:
mpirun -n 4 ./app--> producesgmon.out.
- Analyze with
gprof:gprof ./app gmon.out > report.txt.
- Identify the function consuming the most time.
- Optimize it (e.g., reduce redundant loops or add cache blocking).
- Re-profile and compare improvements.
Optional: Try perf stat ./app or Intel Vtune if available.