source: CIVL/examples/omp/nas-dc/common/c_timers.c@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#include "wtime.h"
2#include <stdlib.h>
3#ifdef _OPENMP
4#include <omp.h>
5#endif
6
7/* Prototype */
8void wtime( double * );
9
10
11/*****************************************************************/
12/****** E L A P S E D _ T I M E ******/
13/*****************************************************************/
14double elapsed_time( void )
15{
16 double t;
17
18#ifdef _OPENMP
19/* Use the OpenMP timer if we can */
20 t = omp_get_wtime();
21#else
22 wtime( &t );
23#endif
24 return( t );
25}
26
27
28static double start[64], elapsed[64];
29#ifdef _OPENMP
30#pragma omp threadprivate(start, elapsed)
31#endif
32
33/*****************************************************************/
34/****** T I M E R _ C L E A R ******/
35/*****************************************************************/
36void timer_clear( int n )
37{
38 elapsed[n] = 0.0;
39}
40
41
42/*****************************************************************/
43/****** T I M E R _ S T A R T ******/
44/*****************************************************************/
45void timer_start( int n )
46{
47 start[n] = elapsed_time();
48}
49
50
51/*****************************************************************/
52/****** T I M E R _ S T O P ******/
53/*****************************************************************/
54void timer_stop( int n )
55{
56 double t, now;
57
58 now = elapsed_time();
59 t = now - start[n];
60 elapsed[n] += t;
61
62}
63
64
65/*****************************************************************/
66/****** T I M E R _ R E A D ******/
67/*****************************************************************/
68double timer_read( int n )
69{
70 return( elapsed[n] );
71}
72
Note: See TracBrowser for help on using the repository browser.