Skip to content

Commit

Permalink
Fix segfault in density test: cannot do BOOST_TEST inside an openmp loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sbird committed Dec 26, 2024
1 parent 758af41 commit 0dcf75b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions libgadget/slotsmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ void
slots_free(struct slots_manager_type * sman)
{
myfree(sman->Base);
sman->Base = NULL;
}

/* mark the i-th base particle as a garbage. */
Expand Down
4 changes: 2 additions & 2 deletions libgadget/tests/test_density.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ static void free_domain(DomainDecomp * ddecomp) {
myfree(ddecomp->Tasks);
myfree(ddecomp->TopLeaves);
myfree(ddecomp->TopNodes);
slots_free(SlotsManager);
myfree(PartManager->Base);
}

static struct density_testdata setup_density(void)
Expand Down Expand Up @@ -99,7 +101,6 @@ static void check_densities(double MinGasHsml)
{
int i;
double maxHsml=P[0].Hsml, minHsml= P[0].Hsml;
#pragma omp parallel for reduction(min:minHsml) reduction(max:maxHsml)
for(i=0; i<PartManager->NumPart; i++) {
BOOST_TEST(std::isfinite(PartManager->Base[i].Hsml));
BOOST_TEST(std::isfinite(SPHP(i).Density));
Expand Down Expand Up @@ -201,7 +202,6 @@ static void do_density_test(struct density_testdata * data, const int numpart, d
/* Free tree before checks so that we still recover if checks fail*/
force_tree_free(&tree);

#pragma omp parallel for reduction(max:diff)
for(i=0; i<numpart; i++) {
BOOST_TEST(fabs(Hsml[i]/PartManager->Base[i].Hsml-1) < data->dp.MaxNumNgbDeviation / DesNumNgb);
if(fabs(Hsml[i] - PartManager->Base[i].Hsml) > diff)
Expand Down

0 comments on commit 0dcf75b

Please sign in to comment.