/[escript]/trunk/paso/src/performance.cpp
ViewVC logotype

Contents of /trunk/paso/src/performance.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6144 - (show annotations)
Wed Apr 6 05:25:13 2016 UTC (2 years, 7 months ago) by caltinay
File size: 7684 byte(s)
last round of namespacing defines.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************/
19
20 /* Paso: performance monitor interface using PAPI */
21
22 /****************************************************************************/
23
24 /* Copyrights by ACcESS Australia 2006 */
25 /* Author: Lutz Gross, l.gross@uq.edu.au */
26
27 /****************************************************************************/
28
29 #include "Paso.h"
30 #include "performance.h"
31
32 namespace paso {
33
34 /// sets up the monitoring process
35 void Performance_open(Performance* pp, int verbose)
36 {
37 #ifdef ESYS_HAVE_PAPI
38 #pragma omp single
39 {
40 pp->event_set = PAPI_NULL;
41 // Initialize the PAPI library
42 int retval = PAPI_library_init(PAPI_VER_CURRENT);
43 if (retval != PAPI_VER_CURRENT && retval > 0) {
44 throw PasoException("performance: PAPI library version mismatch.");
45 } else if (retval < 0) {
46 throw PasoException("performance: PAPI initialization error.");
47 } else {
48 if (PAPI_create_eventset(&(pp->event_set)) != PAPI_OK)
49 throw PasoException("performance: PAPI event set up failed.");
50 }
51 // try to add various monitors
52 pp->num_events=0;
53 if (PAPI_add_event(pp->event_set, PAPI_FP_OPS) == PAPI_OK) {
54 pp->events[pp->num_events]=PAPI_FP_OPS;
55 pp->num_events++;
56 }
57 if (PAPI_add_event(pp->event_set, PAPI_L1_DCM) == PAPI_OK) {
58 pp->events[pp->num_events]=PAPI_L1_DCM;
59 pp->num_events++;
60 }
61 if (PAPI_add_event(pp->event_set, PAPI_L2_DCM) == PAPI_OK) {
62 pp->events[pp->num_events]=PAPI_L2_DCM;
63 pp->num_events++;
64 }
65 if (PAPI_add_event(pp->event_set, PAPI_L3_DCM) == PAPI_OK) {
66 pp->events[pp->num_events]=PAPI_L3_DCM;
67 pp->num_events++;
68 }
69 for (int i=0; i<PERFORMANCE_NUM_MONITORS; ++i) {
70 pp->cycles[i] = 0;
71 pp->set[i] = PERFORMANCE_UNUSED;
72 for (int j=0; j<PERFORMANCE_NUM_EVENTS; ++j)
73 pp->values[i][j] = 0.;
74 }
75 PAPI_start(pp->event_set);
76 } // omp single
77 #endif // ESYS_HAVE_PAPI
78 }
79
80 /// find the index of an event in the list of monitored events
81 int Performance_getEventIndex(Performance* pp, int event_id)
82 {
83 #ifdef ESYS_HAVE_PAPI
84 for (int i=0; i<pp->num_events; ++i)
85 if (pp->events[i]==event_id)
86 return i;
87 #endif
88 return PERFORMANCE_UNMONITORED_EVENT;
89 }
90
91 /// shuts down the monitoring process
92 void Performance_close(Performance* pp, int verbose)
93 {
94 #ifdef ESYS_HAVE_PAPI
95 #pragma omp single
96 {
97 if (verbose) {
98 int i_ops = Performance_getEventIndex(pp, PAPI_FP_OPS);
99 int i_l1_miss = Performance_getEventIndex(pp, PAPI_L1_DCM);
100 int i_l2_miss = Performance_getEventIndex(pp, PAPI_L2_DCM);
101 int i_l3_miss = Performance_getEventIndex(pp, PAPI_L3_DCM);
102 printf(" monitor |");
103 if (i_ops != PERFORMANCE_UNMONITORED_EVENT)
104 printf(" flops/cycle |");
105 if (i_ops != PERFORMANCE_UNMONITORED_EVENT && i_l1_miss!=PERFORMANCE_UNMONITORED_EVENT)
106 printf(" L1 miss/flops |");
107 if (i_ops!=PERFORMANCE_UNMONITORED_EVENT && i_l2_miss!=PERFORMANCE_UNMONITORED_EVENT)
108 printf(" L2 miss/flops |");
109 if (i_ops!=PERFORMANCE_UNMONITORED_EVENT && i_l3_miss!=PERFORMANCE_UNMONITORED_EVENT)
110 printf(" L3 miss/flops |");
111 printf("\n");
112 for (int i=0; i<PERFORMANCE_NUM_MONITORS; ++i) {
113 if (pp->set[i] != PERFORMANCE_UNUSED) {
114 switch(i) {
115 case PERFORMANCE_ALL:
116 printf(" over all |");
117 break;
118 case PERFORMANCE_SOLVER:
119 printf(" solver |");
120 break;
121 case PERFORMANCE_PRECONDITIONER_INIT:
122 printf(" init. preconditioner |");
123 break;
124 case PERFORMANCE_PRECONDITIONER:
125 printf(" preconditioner |");
126 break;
127 case PERFORMANCE_MVM:
128 printf(" matrix-vector product |");
129 break;
130 case PERFORMANCE_ASSEMBLAGE:
131 printf(" assemblage |");
132 break;
133 default:
134 printf(" no name |");
135 break;
136 }
137 if (pp->set[i]==PERFORMANCE_CLOSED) {
138 if (i_ops != PERFORMANCE_UNMONITORED_EVENT)
139 printf(" %12.5e |",(((double)(pp->values[i][i_ops]))/((double)(pp->cycles[i]))));
140 if (i_ops!=PERFORMANCE_UNMONITORED_EVENT && i_l1_miss!=PERFORMANCE_UNMONITORED_EVENT)
141 printf(" %13.5e |",(((double)(pp->values[i][i_l1_miss]))/((double)(pp->values[i][i_ops]))));
142 if (i_ops!=PERFORMANCE_UNMONITORED_EVENT && i_l2_miss!=PERFORMANCE_UNMONITORED_EVENT)
143 printf(" %13.5e |",(((double)(pp->values[i][i_l2_miss]))/((double)(pp->values[i][i_ops]))));
144 if (i_ops!=PERFORMANCE_UNMONITORED_EVENT && i_l3_miss!=PERFORMANCE_UNMONITORED_EVENT)
145 printf(" %13.5e |",(((double)(pp->values[i][i_l3_miss]))/((double)(pp->values[i][i_ops]))));
146 } else {
147 printf("not closed!!!");
148 }
149 printf("\n");
150 }
151 }
152 }
153 long_long values[PERFORMANCE_NUM_EVENTS];
154 PAPI_stop(pp->event_set, values);
155 PAPI_cleanup_eventset(pp->event_set);
156 PAPI_destroy_eventset(&pp->event_set);
157 }
158 #endif
159 }
160
161 /// switches on a monitor
162 void Performance_startMonitor(Performance* pp, int monitor)
163 {
164 #ifdef ESYS_HAVE_PAPI
165 #pragma omp barrier
166 #pragma omp single
167 {
168 long_long values[PERFORMANCE_NUM_EVENTS];
169 // Start counting events in the Event Set
170 PAPI_read(pp->event_set, values);
171 for (int i=0; i<pp->num_events; ++i)
172 pp->values[monitor][i] -= values[i];
173 // set cycles
174 pp->cycles[monitor] -= PAPI_get_real_cyc();
175 pp->set[monitor] = PERFORMANCE_OPENED;
176 }
177 #endif
178 }
179
180 /// switches off a monitor
181 void Performance_stopMonitor(Performance* pp,int monitor)
182 {
183 #ifdef ESYS_HAVE_PAPI
184 #pragma omp barrier
185 #pragma omp single
186 {
187 long_long values[PERFORMANCE_NUM_EVENTS];
188 // Add the counters in the Event Set
189 PAPI_read(pp->event_set, values);
190 for (int i=0; i<pp->num_events; ++i)
191 pp->values[monitor][i] += values[i];
192 // set cycles
193 pp->cycles[monitor] += PAPI_get_real_cyc();
194 pp->set[monitor] = PERFORMANCE_CLOSED;
195 }
196 #endif
197 }
198
199 } // namespace paso
200

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/paso/src/performance.cpp:5567-5588 /branches/amg_from_3530/paso/src/performance.cpp:3531-3826 /branches/lapack2681/paso/src/performance.cpp:2682-2741 /branches/pasowrap/paso/src/performance.cpp:3661-3674 /branches/py3_attempt2/paso/src/performance.cpp:3871-3891 /branches/restext/paso/src/performance.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/performance.cpp:3669-3791 /branches/stage3.0/paso/src/performance.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/performance.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/performance.cpp:3517-3974 /branches/trilinos_from_5897/paso/src/performance.cpp:5898-6118 /release/3.0/paso/src/performance.cpp:2591-2601 /release/4.0/paso/src/performance.cpp:5380-5406 /trunk/paso/src/performance.cpp:4257-4344 /trunk/ripley/test/python/paso/src/performance.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26