Skip to content

Commit

Permalink
shows how to use omp's timer
Browse files Browse the repository at this point in the history
  • Loading branch information
srinathv committed Apr 1, 2015
1 parent 42282c1 commit e38891c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions codingTests/cplusplus/testVec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ int main(){
#ifdef USE_TAU
TAU_START("std::vector.push_back loop");
#endif
#pragma omp parallel for
for (int i = 0; i < N; ++i)
{
v1.push_back(float(i));
}

#ifdef USE_TAU
TAU_STOP("std::vector.push_back loop");
#endif
Expand Down
20 changes: 20 additions & 0 deletions codingTests/openmp/omp_get_wtime.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// omp_get_wtime.cpp
// compile with: /openmp
#include <omp.h>
#include <stdio.h>
#include <chrono>
#include <thread>

int main() {
double start = omp_get_wtime( );
// sleep(1000);
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
double end = omp_get_wtime( );
double wtick = omp_get_wtick( );

printf("start = %.16g\nend = %.16g\ndiff = %.16g\n",
start, end, end - start);

printf("wtick = %.16g\n1/wtick = %.16g\n",
wtick, 1.0 / wtick);
}

0 comments on commit e38891c

Please sign in to comment.