skip to content
Ivan's wiki
Site Tools
Search
Tools
Show pagesource
Backlinks
Recent Changes
Media Manager
Sitemap
>
Recent Changes
Media Manager
Sitemap
openmp-time-measurement
This page is read only. You can view the source, but not change it.
# OpenMP time measurement **[Time measurement](https://hpc-tutorials.llnl.gov/openmp/omp_get_wtime/)** in OpenMP is done with `omp_get_wtime()`, which returns elapsed wall-clock time in seconds as a `double`. Calling it before and after a parallel region gives the actual time the user waited, which is what matters for speedup measurement. CPU time is not useful here: it sums across all threads and grows with thread count rather than shrinking. ```c double t0 = omp_get_wtime(); #pragma omp parallel for for (int i = 0; i < N; i++) a[i] = foo(i); printf("%.4f s\n", omp_get_wtime() - t0); ``` Speedup is the serial wall time divided by the parallel wall time. To get a meaningful serial baseline, either run the same binary with `OMP_NUM_THREADS=1` or time the region before adding any pragmas.
Page Tools
Show pagesource
Backlinks
Back to top