Skip to content

Commit 03ff08d

Browse files
committed
Simplify time collection in DataCollector
1 parent 3af85a0 commit 03ff08d

File tree

8 files changed

+173
-300
lines changed

8 files changed

+173
-300
lines changed

highs/ipm/hipo/factorhighs/Analyse.cpp

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,70 +1255,41 @@ Int Analyse::run(Symbolic& S) {
12551255

12561256
if (!ready_) return kRetGeneric;
12571257

1258-
#if HIPO_TIMING_LEVEL >= 1
1259-
Clock clock_total;
1260-
#endif
1258+
HIPO_CLOCK_CREATE(1);
1259+
HIPO_CLOCK_CREATE(2);
12611260

1262-
#if HIPO_TIMING_LEVEL >= 2
1263-
Clock clock_items;
1264-
#endif
1261+
HIPO_CLOCK_START(2);
12651262
if (getPermutation(S.metisNo2hop())) return kRetMetisError;
1266-
#if HIPO_TIMING_LEVEL >= 2
1267-
data_.sumTime(kTimeAnalyseMetis, clock_items.stop());
1268-
#endif
1263+
HIPO_CLOCK_STOP(2, data_, kTimeAnalyseMetis);
12691264

1270-
#if HIPO_TIMING_LEVEL >= 2
1271-
clock_items.start();
1272-
#endif
1265+
HIPO_CLOCK_START(2);
12731266
permute(iperm_);
12741267
eTree();
12751268
postorder();
1276-
#if HIPO_TIMING_LEVEL >= 2
1277-
data_.sumTime(kTimeAnalyseTree, clock_items.stop());
1278-
#endif
1269+
HIPO_CLOCK_STOP(2, data_, kTimeAnalyseTree);
12791270

1280-
#if HIPO_TIMING_LEVEL >= 2
1281-
clock_items.start();
1282-
#endif
1271+
HIPO_CLOCK_START(2);
12831272
colCount();
1284-
#if HIPO_TIMING_LEVEL >= 2
1285-
data_.sumTime(kTimeAnalyseCount, clock_items.stop());
1286-
#endif
1273+
HIPO_CLOCK_STOP(2, data_, kTimeAnalyseCount);
12871274

1288-
#if HIPO_TIMING_LEVEL >= 2
1289-
clock_items.start();
1290-
#endif
1275+
HIPO_CLOCK_START(2);
12911276
fundamentalSupernodes();
12921277
relaxSupernodes();
12931278
afterRelaxSn();
1294-
#if HIPO_TIMING_LEVEL >= 2
1295-
data_.sumTime(kTimeAnalyseSn, clock_items.stop());
1296-
#endif
1279+
HIPO_CLOCK_STOP(2, data_, kTimeAnalyseSn);
12971280

1298-
#if HIPO_TIMING_LEVEL >= 2
1299-
clock_items.start();
1300-
#endif
1281+
HIPO_CLOCK_START(2);
13011282
reorderChildren();
1302-
#if HIPO_TIMING_LEVEL >= 2
1303-
data_.sumTime(kTimeAnalyseReorder, clock_items.stop());
1304-
#endif
1283+
HIPO_CLOCK_STOP(2, data_, kTimeAnalyseReorder);
13051284

1306-
#if HIPO_TIMING_LEVEL >= 2
1307-
clock_items.start();
1308-
#endif
1285+
HIPO_CLOCK_START(2);
13091286
snPattern();
1310-
#if HIPO_TIMING_LEVEL >= 2
1311-
data_.sumTime(kTimeAnalysePattern, clock_items.stop());
1312-
#endif
1287+
HIPO_CLOCK_STOP(2, data_, kTimeAnalysePattern);
13131288

1314-
#if HIPO_TIMING_LEVEL >= 2
1315-
clock_items.start();
1316-
#endif
1289+
HIPO_CLOCK_START(2);
13171290
relativeIndCols();
13181291
relativeIndClique();
1319-
#if HIPO_TIMING_LEVEL >= 2
1320-
data_.sumTime(kTimeAnalyseRelInd, clock_items.stop());
1321-
#endif
1292+
HIPO_CLOCK_STOP(2, data_, kTimeAnalyseRelInd);
13221293

13231294
computeBlockStart();
13241295
computeCriticalPath();
@@ -1370,11 +1341,7 @@ Int Analyse::run(Symbolic& S) {
13701341
S.consecutive_sums_ = std::move(consecutive_sums_);
13711342
S.clique_block_start_ = std::move(clique_block_start_);
13721343

1373-
#if HIPO_TIMING_LEVEL >= 1
1374-
data_.sumTime(kTimeAnalyse, clock_total.stop());
1375-
#else
1376-
(void)data_; // to avoid an unused-private-field warning
1377-
#endif
1344+
HIPO_CLOCK_STOP(1, data_, kTimeAnalyse);
13781345

13791346
return kRetOk;
13801347
}

highs/ipm/hipo/factorhighs/CallAndTimeBlas.cpp

Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,98 +19,66 @@ namespace hipo {
1919

2020
void callAndTime_daxpy(Int n, double da, const double* dx, Int incx, double* dy,
2121
Int incy, DataCollector& data) {
22-
#if HIPO_TIMING_LEVEL >= 3
23-
Clock clock;
24-
#endif
22+
HIPO_CLOCK_CREATE(3);
2523
cblas_daxpy(n, da, dx, incx, dy, incy);
26-
#if HIPO_TIMING_LEVEL >= 3
27-
data.sumTime(kTimeBlas_axpy, clock.stop());
28-
#endif
24+
HIPO_CLOCK_STOP(3, data, kTimeBlas_axpy);
2925
}
3026

3127
void callAndTime_dcopy(Int n, const double* dx, Int incx, double* dy, Int incy,
3228
DataCollector& data) {
33-
#if HIPO_TIMING_LEVEL >= 3
34-
Clock clock;
35-
#endif
29+
HIPO_CLOCK_CREATE(3);
3630
cblas_dcopy(n, dx, incx, dy, incy);
37-
#if HIPO_TIMING_LEVEL >= 3
38-
data.sumTime(kTimeBlas_copy, clock.stop());
39-
#endif
31+
HIPO_CLOCK_STOP(3, data, kTimeBlas_copy);
4032
}
4133

4234
void callAndTime_dscal(Int n, const double da, double* dx, Int incx,
4335
DataCollector& data) {
44-
#if HIPO_TIMING_LEVEL >= 3
45-
Clock clock;
46-
#endif
36+
HIPO_CLOCK_CREATE(3);
4737
cblas_dscal(n, da, dx, incx);
48-
#if HIPO_TIMING_LEVEL >= 3
49-
data.sumTime(kTimeBlas_scal, clock.stop());
50-
#endif
38+
HIPO_CLOCK_STOP(3, data, kTimeBlas_scal);
5139
}
5240

5341
void callAndTime_dswap(Int n, double* dx, Int incx, double* dy, Int incy,
5442
DataCollector& data) {
55-
#if HIPO_TIMING_LEVEL >= 3
56-
Clock clock;
57-
#endif
43+
HIPO_CLOCK_CREATE(3);
5844
cblas_dswap(n, dx, incx, dy, incy);
59-
#if HIPO_TIMING_LEVEL >= 3
60-
data.sumTime(kTimeBlas_swap, clock.stop());
61-
#endif
45+
HIPO_CLOCK_STOP(3, data, kTimeBlas_swap);
6246
}
6347

6448
// level 2
6549

6650
void callAndTime_dgemv(char trans, Int m, Int n, double alpha, const double* A,
6751
Int lda, const double* x, Int incx, double beta,
6852
double* y, Int incy, DataCollector& data) {
69-
#if HIPO_TIMING_LEVEL >= 3
70-
Clock clock;
71-
#endif
53+
HIPO_CLOCK_CREATE(3);
7254
cblas_dgemv(CblasColMajor, TRANS(trans), m, n, alpha, A, lda, x, incx, beta,
7355
y, incy);
74-
#if HIPO_TIMING_LEVEL >= 3
75-
data.sumTime(kTimeBlas_gemv, clock.stop());
76-
#endif
56+
HIPO_CLOCK_STOP(3, data, kTimeBlas_gemv);
7757
}
7858

7959
void callAndTime_dtpsv(char uplo, char trans, char diag, Int n,
8060
const double* ap, double* x, Int incx,
8161
DataCollector& data) {
82-
#if HIPO_TIMING_LEVEL >= 3
83-
Clock clock;
84-
#endif
62+
HIPO_CLOCK_CREATE(3);
8563
cblas_dtpsv(CblasColMajor, UPLO(uplo), TRANS(trans), DIAG(diag), n, ap, x,
8664
incx);
87-
#if HIPO_TIMING_LEVEL >= 3
88-
data.sumTime(kTimeBlas_tpsv, clock.stop());
89-
#endif
65+
HIPO_CLOCK_STOP(3, data, kTimeBlas_tpsv);
9066
}
9167

9268
void callAndTime_dtrsv(char uplo, char trans, char diag, Int n, const double* A,
9369
Int lda, double* x, Int incx, DataCollector& data) {
94-
#if HIPO_TIMING_LEVEL >= 3
95-
Clock clock;
96-
#endif
70+
HIPO_CLOCK_CREATE(3);
9771
cblas_dtrsv(CblasColMajor, UPLO(uplo), TRANS(trans), DIAG(diag), n, A, lda, x,
9872
incx);
99-
#if HIPO_TIMING_LEVEL >= 3
100-
data.sumTime(kTimeBlas_trsv, clock.stop());
101-
#endif
73+
HIPO_CLOCK_STOP(3, data, kTimeBlas_trsv);
10274
}
10375

10476
void callAndTime_dger(Int m, Int n, double alpha, const double* x, Int incx,
10577
const double* y, Int incy, double* A, Int lda,
10678
DataCollector& data) {
107-
#if HIPO_TIMING_LEVEL >= 3
108-
Clock clock;
109-
#endif
79+
HIPO_CLOCK_CREATE(3);
11080
cblas_dger(CblasColMajor, m, n, alpha, x, incx, y, incy, A, lda);
111-
#if HIPO_TIMING_LEVEL >= 3
112-
data.sumTime(kTimeBlas_ger, clock.stop());
113-
#endif
81+
HIPO_CLOCK_STOP(3, data, kTimeBlas_ger);
11482
}
11583

11684
// level 3
@@ -119,40 +87,28 @@ void callAndTime_dgemm(char transa, char transb, Int m, Int n, Int k,
11987
double alpha, const double* A, Int lda, const double* B,
12088
Int ldb, double beta, double* C, Int ldc,
12189
DataCollector& data) {
122-
#if HIPO_TIMING_LEVEL >= 3
123-
Clock clock;
124-
#endif
90+
HIPO_CLOCK_CREATE(3);
12591
cblas_dgemm(CblasColMajor, TRANS(transa), TRANS(transb), m, n, k, alpha, A,
12692
lda, B, ldb, beta, C, ldc);
127-
#if HIPO_TIMING_LEVEL >= 3
128-
data.sumTime(kTimeBlas_gemm, clock.stop());
129-
#endif
93+
HIPO_CLOCK_STOP(3, data, kTimeBlas_gemm);
13094
}
13195

13296
void callAndTime_dsyrk(char uplo, char trans, Int n, Int k, double alpha,
13397
const double* A, Int lda, double beta, double* C,
13498
Int ldc, DataCollector& data) {
135-
#if HIPO_TIMING_LEVEL >= 3
136-
Clock clock;
137-
#endif
99+
HIPO_CLOCK_CREATE(3);
138100
cblas_dsyrk(CblasColMajor, UPLO(uplo), TRANS(trans), n, k, alpha, A, lda,
139101
beta, C, ldc);
140-
#if HIPO_TIMING_LEVEL >= 3
141-
data.sumTime(kTimeBlas_syrk, clock.stop());
142-
#endif
102+
HIPO_CLOCK_STOP(3, data, kTimeBlas_syrk);
143103
}
144104

145105
void callAndTime_dtrsm(char side, char uplo, char trans, char diag, Int m,
146106
Int n, double alpha, const double* A, Int lda, double* B,
147107
Int ldb, DataCollector& data) {
148-
#if HIPO_TIMING_LEVEL >= 3
149-
Clock clock;
150-
#endif
108+
HIPO_CLOCK_CREATE(3);
151109
cblas_dtrsm(CblasColMajor, SIDE(side), UPLO(uplo), TRANS(trans), DIAG(diag),
152110
m, n, alpha, A, lda, B, ldb);
153-
#if HIPO_TIMING_LEVEL >= 3
154-
data.sumTime(kTimeBlas_trsm, clock.stop());
155-
#endif
111+
HIPO_CLOCK_STOP(3, data, kTimeBlas_trsm);
156112
}
157113

158114
} // namespace hipo

highs/ipm/hipo/factorhighs/DenseFactHybrid.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ Int denseFactFH(char format, Int n, Int k, Int nb, double* A, double* B,
2323
// BLAS calls: dcopy, dscal, daxpy, dgemm, dtrsm
2424
// ===========================================================================
2525

26-
#if HIPO_TIMING_LEVEL >= 2
27-
Clock clock;
28-
#endif
26+
HIPO_CLOCK_CREATE(2);
2927

3028
// check input
3129
if (n < 0 || k < 0 || !A || (k < n && !B)) return kRetInvalidInput;
@@ -63,6 +61,8 @@ Int denseFactFH(char format, Int n, Int k, Int nb, double* A, double* B,
6361
for (Int j = 0; j < n_blocks; ++j) {
6462
// j is the index of the block column
6563

64+
HIPO_CLOCK_START(2);
65+
6666
// jb is the number of columns
6767
const Int jb = std::min(nb, k - nb * j);
6868

@@ -182,15 +182,12 @@ Int denseFactFH(char format, Int n, Int k, Int nb, double* A, double* B,
182182

183183
offset += jb * col_jj;
184184
}
185-
186-
#if HIPO_TIMING_LEVEL >= 2
187-
data.sumTime(kTimeDenseFact_main, clock.stop());
188-
clock.start();
189-
#endif
190-
185+
HIPO_CLOCK_STOP(2, data, kTimeDenseFact_main);
186+
191187
// ===========================================================================
192188
// UPDATE SCHUR COMPLEMENT
193189
// ===========================================================================
190+
HIPO_CLOCK_START(2);
194191
if (k < n) {
195192
Int64 B_offset{};
196193

@@ -231,10 +228,7 @@ Int denseFactFH(char format, Int n, Int k, Int nb, double* A, double* B,
231228
offset += jb * ncol;
232229
}
233230
}
234-
#if HIPO_TIMING_LEVEL >= 2
235-
data.sumTime(kTimeDenseFact_schur, clock.stop());
236-
clock.start();
237-
#endif
231+
HIPO_CLOCK_STOP(2, data, kTimeDenseFact_schur);
238232
}
239233
}
240234

@@ -249,9 +243,7 @@ Int denseFactFP2FH(double* A, Int nrow, Int ncol, Int nb, DataCollector& data) {
249243
// BLAS calls: dcopy
250244
// ===========================================================================
251245

252-
#if HIPO_TIMING_LEVEL >= 2
253-
Clock clock;
254-
#endif
246+
HIPO_CLOCK_CREATE(2);
255247

256248
std::vector<double> buf(nrow * nb);
257249

@@ -279,9 +271,7 @@ Int denseFactFP2FH(double* A, Int nrow, Int ncol, Int nb, DataCollector& data) {
279271
}
280272
}
281273

282-
#if HIPO_TIMING_LEVEL >= 2
283-
data.sumTime(kTimeDenseFact_convert, clock.stop());
284-
#endif
274+
HIPO_CLOCK_STOP(2, data, kTimeDenseFact_convert);
285275

286276
return kRetOk;
287277
}

highs/ipm/hipo/factorhighs/DenseFactKernel.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ static bool blockBunchKaufman(Int j, Int n, double* A, Int lda, Int* swaps,
6161
// Swap of columns may be performed.
6262
// Regularisation of pivot may be performed.
6363

64-
#if HIPO_TIMING_LEVEL >= 2
65-
Clock clock;
66-
#endif
64+
HIPO_CLOCK_CREATE(2);
65+
6766
bool flag_2x2 = false;
6867

6968
// Find largest diagonal entry in the residual part of the block
@@ -144,9 +143,7 @@ static bool blockBunchKaufman(Int j, Int n, double* A, Int lda, Int* swaps,
144143
}
145144
}
146145

147-
#if HIPO_TIMING_LEVEL >= 2
148-
data.sumTime(kTimeDenseFact_pivoting, clock.stop());
149-
#endif
146+
HIPO_CLOCK_STOP(2, data, kTimeDenseFact_pivoting);
150147
return flag_2x2;
151148
}
152149

@@ -165,9 +162,7 @@ Int denseFactK(char uplo, Int n, double* A, Int lda, Int* pivot_sign,
165162
// quick return
166163
if (n == 0) return kRetOk;
167164

168-
#if HIPO_TIMING_LEVEL >= 2
169-
Clock clock;
170-
#endif
165+
HIPO_CLOCK_CREATE(2);
171166

172167
if (uplo == 'L') {
173168
assert(1 == 0);
@@ -282,10 +277,7 @@ Int denseFactK(char uplo, Int n, double* A, Int lda, Int* pivot_sign,
282277
}
283278
}
284279

285-
#if HIPO_TIMING_LEVEL >= 2
286-
data.sumTime(kTimeDenseFact_kernel, clock.stop());
287-
#endif
288-
280+
HIPO_CLOCK_STOP(2, data, kTimeDenseFact_kernel);
289281
return kRetOk;
290282
}
291283

0 commit comments

Comments
 (0)