Skip to content

Commit 1c0769f

Browse files
committed
Fix test
1 parent 02e0a83 commit 1c0769f

1 file changed

Lines changed: 25 additions & 21 deletions

File tree

check/TestHighsParallel.cpp

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -324,30 +324,34 @@ TEST_CASE("ParallelCApi", "[parallel]") {
324324
double actual_obj;
325325
double total = 0;
326326

327-
highs::parallel::TaskGroup tg;
328-
329-
tg.spawn([&]() {
330-
void* highs = Highs_create();
331-
Highs_setBoolOptionValue(highs, "output_flag", dev_run);
332-
Highs_setStringOptionValue(highs, "parallel", "on");
333-
Highs_readModel(highs, model.c_str());
334-
Highs_run(highs);
335-
Highs_getDoubleInfoValue(highs, "objective_function_value", &actual_obj);
336-
Highs_destroy(highs);
337-
});
327+
{
328+
highs::parallel::TaskGroup tg;
338329

339-
tg.spawn([&]() {
340-
void* highs = Highs_create();
341-
for (int i = 0; i < 1e6; ++i) {
342-
total += (double)i * i * i;
343-
}
344-
Highs_destroy(highs);
345-
});
330+
tg.spawn([&]() {
331+
void* highs = Highs_create();
332+
Highs_setBoolOptionValue(highs, "output_flag", dev_run);
333+
Highs_setStringOptionValue(highs, "parallel", "on");
334+
Highs_readModel(highs, model.c_str());
335+
Highs_run(highs);
336+
Highs_getDoubleInfoValue(highs, "objective_function_value", &actual_obj);
337+
Highs_destroy(highs);
338+
});
339+
340+
tg.spawn([&]() {
341+
void* highs = Highs_create();
342+
for (int i = 0; i < 1e6; ++i) {
343+
total += (double)i * i * i;
344+
}
345+
Highs_destroy(highs);
346+
});
346347

347-
tg.taskWait();
348+
tg.taskWait();
348349

349-
REQUIRE(total > 1e18);
350-
REQUIRE(std::abs(actual_obj - expected_obj) / std::abs(expected_obj) < 1e-4);
350+
REQUIRE(total > 1e18);
351+
REQUIRE(std::abs(actual_obj - expected_obj) / std::abs(expected_obj) <
352+
1e-4);
353+
}
354+
// TaskGroup destructor must be called before scheduler is killed
351355

352356
HighsTaskExecutor::shutdown(true);
353357
}

0 commit comments

Comments
 (0)