1 #include "sort_profiler.h"
2 
3 #ifdef HAVE_PAPI
4 #include <papi.h>
5 #endif
6 
7 #include <omp.h>
8 
9 sort_profiler_t 				total_sort;
10 
11 sort_profiler_t 				sample_get_splitters;
12 sort_profiler_t 				sample_sort_splitters;
13 sort_profiler_t 				sample_prepare_scatter;
14 sort_profiler_t 				sample_do_all2all;
15 
16 sort_profiler_t					hyper_compute_splitters;
17 sort_profiler_t					hyper_communicate;
18 sort_profiler_t					hyper_merge;
19 sort_profiler_t 				hyper_comm_split;
20 
21 sort_profiler_t 				seq_sort;
22 sort_profiler_t					sort_partitionw;
23 
24 long                    total_bytes;
25 
sort_profiler_t()26 sort_profiler_t::sort_profiler_t () {
27 	seconds  = 0.0;   // openmp wall time
28 	p_flpops =   0;   // papi floating point operations
29 
30 	_pri_seconds  = 0.0;
31 	_pri_p_flpops =   0;
32 }
33 
~sort_profiler_t()34 sort_profiler_t::~sort_profiler_t () {
35 
36 }
37 
38 void
start()39 sort_profiler_t::start() {
40 	_pri_seconds = omp_get_wtime();
41 	flops_papi();
42 }
43 
44 void
stop()45 sort_profiler_t::stop() {
46 	seconds -= _pri_seconds;
47 	p_flpops -= _pri_p_flpops;
48 
49 	_pri_seconds = omp_get_wtime();
50 	flops_papi();
51 
52 	seconds  += _pri_seconds;
53 	p_flpops += _pri_p_flpops;
54 }
55 
56 void
clear()57 sort_profiler_t::clear() {
58 	seconds  = 0.0;
59 	p_flpops =   0;
60 
61 	_pri_seconds  = 0.0;
62 	_pri_p_flpops =   0;
63 }
64 
65 void
flops_papi()66 sort_profiler_t::flops_papi() {
67 #ifdef HAVE_PAPI
68 	int 		retval;
69 	float rtime, ptime, mflops;
70 	retval  = PAPI_flops(&rtime, &ptime, &_pri_p_flpops, &mflops);
71 	// assert (retval == PAPI_OK);
72 #else
73 	_pri_p_flpops =   0;
74 #endif
75 }
76