From a7c8ce1162ad54de3bbde278f5b731987fbd52a1 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Fri, 17 Jun 2016 12:44:09 +0100 Subject: [PATCH] Moved the debugging code between #define guards --- src/cell.c | 105 +++++++++++++++++++++++------------------- src/const.h | 3 ++ src/engine.c | 109 ++++++++++++++++++++++++-------------------- src/runner.c | 22 ++++----- src/scheduler.c | 8 ++-- src/space.c | 118 ++++++++++++++++++++++++++++-------------------- 6 files changed, 205 insertions(+), 160 deletions(-) diff --git a/src/cell.c b/src/cell.c index 6f74f63fd9..e152cd6136 100644 --- a/src/cell.c +++ b/src/cell.c @@ -406,12 +406,14 @@ void cell_split(struct cell *c) { xparts[j] = xtemp; } } - /* for ( k = 0 ; k <= j ; k++ ) - if ( parts[k].x[0] > pivot[0] ) - error( "cell_split: sorting failed." ); - for ( k = i ; k < count ; k++ ) - if ( parts[k].x[0] < pivot[0] ) - error( "cell_split: sorting failed." ); */ + +#ifdef SWIFT_DEBUG_CHECKS + for (int k = 0; k <= j; k++) + if (parts[k].x[0] > pivot[0]) error("cell_split: sorting failed."); + for (int k = i; k < count; k++) + if (parts[k].x[0] < pivot[0]) error("cell_split: sorting failed."); +#endif + left[1] = i; right[1] = count - 1; left[0] = 0; @@ -433,14 +435,17 @@ void cell_split(struct cell *c) { xparts[j] = xtemp; } } - /* for ( int kk = left[k] ; kk <= j ; kk++ ) - if ( parts[kk].x[1] > pivot[1] ) { - message( "ival=[%i,%i], i=%i, j=%i." , left[k] , right[k] , i , j ); - error( "sorting failed (left)." ); - } - for ( int kk = i ; kk <= right[k] ; kk++ ) - if ( parts[kk].x[1] < pivot[1] ) - error( "sorting failed (right)." ); */ + +#ifdef SWIFT_DEBUG_CHECKS + for (int kk = left[k]; kk <= j; kk++) + if (parts[kk].x[1] > pivot[1]) { + message("ival=[%i,%i], i=%i, j=%i.", left[k], right[k], i, j); + error("sorting failed (left)."); + } + for (int kk = i; kk <= right[k]; kk++) + if (parts[kk].x[1] < pivot[1]) error("sorting failed (right)."); +#endif + left[2 * k + 1] = i; right[2 * k + 1] = right[k]; left[2 * k] = left[k]; @@ -463,16 +468,20 @@ void cell_split(struct cell *c) { xparts[j] = xtemp; } } - /* for ( int kk = left[k] ; kk <= j ; kk++ ) - if ( parts[kk].x[2] > pivot[2] ) { - message( "ival=[%i,%i], i=%i, j=%i." , left[k] , right[k] , i , j ); - error( "sorting failed (left)." ); - } - for ( int kk = i ; kk <= right[k] ; kk++ ) - if ( parts[kk].x[2] < pivot[2] ) { - message( "ival=[%i,%i], i=%i, j=%i." , left[k] , right[k] , i , j ); - error( "sorting failed (right)." ); - } */ + +#ifdef SWIFT_DEBUG_CHECKS + for (int kk = left[k]; kk <= j; kk++) + if (parts[kk].x[2] > pivot[2]) { + message("ival=[%i,%i], i=%i, j=%i.", left[k], right[k], i, j); + error("sorting failed (left)."); + } + for (int kk = i; kk <= right[k]; kk++) + if (parts[kk].x[2] < pivot[2]) { + message("ival=[%i,%i], i=%i, j=%i.", left[k], right[k], i, j); + error("sorting failed (right)."); + } +#endif + left[2 * k + 1] = i; right[2 * k + 1] = right[k]; left[2 * k] = left[k]; @@ -490,32 +499,34 @@ void cell_split(struct cell *c) { for (int k = 0; k < count; k++) if (parts[k].gpart != NULL) parts[k].gpart->part = &parts[k]; +#ifdef SWIFT_DEBUG_CHECKS /* Verify that _all_ the parts have been assigned to a cell. */ - /* for ( k = 1 ; k < 8 ; k++ ) - if ( &c->progeny[k-1]->parts[ c->progeny[k-1]->count ] != - c->progeny[k]->parts ) - error( "Particle sorting failed (internal consistency)." ); - if ( c->progeny[0]->parts != c->parts ) - error( "Particle sorting failed (left edge)." ); - if ( &c->progeny[7]->parts[ c->progeny[7]->count ] != &c->parts[ count ] ) - error( "Particle sorting failed (right edge)." ); */ + for (int k = 1; k < 8; k++) + if (&c->progeny[k - 1]->parts[c->progeny[k - 1]->count] != + c->progeny[k]->parts) + error("Particle sorting failed (internal consistency)."); + if (c->progeny[0]->parts != c->parts) + error("Particle sorting failed (left edge)."); + if (&c->progeny[7]->parts[c->progeny[7]->count] != &c->parts[count]) + error("Particle sorting failed (right edge)."); /* Verify a few sub-cells. */ - /* for (int k = 0 ; k < c->progeny[0]->count ; k++ ) - if ( c->progeny[0]->parts[k].x[0] > pivot[0] || - c->progeny[0]->parts[k].x[1] > pivot[1] || - c->progeny[0]->parts[k].x[2] > pivot[2] ) - error( "Sorting failed (progeny=0)." ); - for (int k = 0 ; k < c->progeny[1]->count ; k++ ) - if ( c->progeny[1]->parts[k].x[0] > pivot[0] || - c->progeny[1]->parts[k].x[1] > pivot[1] || - c->progeny[1]->parts[k].x[2] <= pivot[2] ) - error( "Sorting failed (progeny=1)." ); - for (int k = 0 ; k < c->progeny[2]->count ; k++ ) - if ( c->progeny[2]->parts[k].x[0] > pivot[0] || - c->progeny[2]->parts[k].x[1] <= pivot[1] || - c->progeny[2]->parts[k].x[2] > pivot[2] ) - error( "Sorting failed (progeny=2)." ); */ + for (int k = 0; k < c->progeny[0]->count; k++) + if (c->progeny[0]->parts[k].x[0] > pivot[0] || + c->progeny[0]->parts[k].x[1] > pivot[1] || + c->progeny[0]->parts[k].x[2] > pivot[2]) + error("Sorting failed (progeny=0)."); + for (int k = 0; k < c->progeny[1]->count; k++) + if (c->progeny[1]->parts[k].x[0] > pivot[0] || + c->progeny[1]->parts[k].x[1] > pivot[1] || + c->progeny[1]->parts[k].x[2] <= pivot[2]) + error("Sorting failed (progeny=1)."); + for (int k = 0; k < c->progeny[2]->count; k++) + if (c->progeny[2]->parts[k].x[0] > pivot[0] || + c->progeny[2]->parts[k].x[1] <= pivot[1] || + c->progeny[2]->parts[k].x[2] > pivot[2]) + error("Sorting failed (progeny=2)."); +#endif /* Now do the same song and dance for the gparts. */ diff --git a/src/const.h b/src/const.h index 6432ef6a9e..673aa3bf00 100644 --- a/src/const.h +++ b/src/const.h @@ -60,4 +60,7 @@ /* Gravity properties */ #define EXTERNAL_POTENTIAL_POINTMASS +/* Are we debugging ? */ +//#define SWIFT_DEBUG_CHECKS + #endif /* SWIFT_CONST_H */ diff --git a/src/engine.c b/src/engine.c index 26459148b1..04337bbc15 100644 --- a/src/engine.c +++ b/src/engine.c @@ -224,7 +224,7 @@ void engine_redistribute(struct engine *e) { bzero(counts, sizeof(int) * nr_nodes * nr_nodes); bzero(g_counts, sizeof(int) * nr_nodes * nr_nodes); - // Allocate the destination index arrays. + /* Allocate the destination index arrays. */ int *dest, *g_dest; if ((dest = (int *)malloc(sizeof(int) * s->nr_parts)) == NULL) error("Failed to allocate dest temporary buffer."); @@ -243,9 +243,12 @@ void engine_redistribute(struct engine *e) { } const int cid = cell_getid(cdim, parts[k].x[0] * ih[0], parts[k].x[1] * ih[1], parts[k].x[2] * ih[2]); - /* if (cid < 0 || cid >= s->nr_cells) - error("Bad cell id %i for part %i at [%.3e,%.3e,%.3e].", - cid, k, parts[k].x[0], parts[k].x[1], parts[k].x[2]); */ +#ifdef SWIFT_DEBUG_CHECKS + if (cid < 0 || cid >= s->nr_cells) + error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, + parts[k].x[0], parts[k].x[1], parts[k].x[2]); +#endif + dest[k] = cells[cid].nodeID; /* The counts array is indexed as count[from * nr_nodes + to]. */ @@ -272,9 +275,10 @@ void engine_redistribute(struct engine *e) { count_this_dest = 0; } - /* Debug */ - /* if(s->parts[k].gpart->id < 0) */ - /* error("Trying to link a partnerless gpart !"); */ +#ifdef SWIFT_DEBUG_CHECKS + if (s->parts[k].gpart->id < 0) + error("Trying to link a partnerless gpart !"); +#endif s->parts[k].gpart->id = count_this_dest; count_this_dest++; @@ -294,9 +298,12 @@ void engine_redistribute(struct engine *e) { } const int cid = cell_getid(cdim, gparts[k].x[0] * ih[0], gparts[k].x[1] * ih[1], gparts[k].x[2] * ih[2]); - /* if (cid < 0 || cid >= s->nr_cells) - error("Bad cell id %i for part %i at [%.3e,%.3e,%.3e].", - cid, k, g_parts[k].x[0], g_parts[k].x[1], g_parts[k].x[2]); */ +#ifdef SWIFT_DEBUG_CHECKS + if (cid < 0 || cid >= s->nr_cells) + error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, + gparts[k].x[0], gparts[k].x[1], gparts[k].x[2]); +#endif + g_dest[k] = cells[cid].nodeID; /* The counts array is indexed as count[from * nr_nodes + to]. */ @@ -471,36 +478,38 @@ void engine_redistribute(struct engine *e) { offset_gparts += count_gparts; } +#ifdef SWIFT_DEBUG_CHECKS /* Verify that all parts are in the right place. */ - /* for ( int k = 0 ; k < nr_parts ; k++ ) { - int cid = cell_getid( cdim , parts_new[k].x[0]*ih[0], - parts_new[k].x[1]*ih[1], parts_new[k].x[2]*ih[2] ); - if ( cells[ cid ].nodeID != nodeID ) - error( "Received particle (%i) that does not belong here - (nodeID=%i).", k , cells[ cid ].nodeID ); - } */ + for (int k = 0; k < nr_parts; k++) { + int cid = cell_getid(cdim, parts_new[k].x[0] * ih[0], + parts_new[k].x[1] * ih[1], parts_new[k].x[2] * ih[2]); + if (cells[cid].nodeID != nodeID) + error("Received particle (%i) that does not belong here (nodeID=%i).", k, + cells[cid].nodeID); + } /* Verify that the links are correct */ - /* for (size_t k = 0; k < nr_gparts; ++k) { */ + for (size_t k = 0; k < nr_gparts; ++k) { - /* if (gparts_new[k].id > 0) { */ + if (gparts_new[k].id > 0) { - /* if (gparts_new[k].part->gpart != &gparts_new[k]) */ - /* error("Linking problem !"); */ + if (gparts_new[k].part->gpart != &gparts_new[k]) + error("Linking problem !"); - /* if (gparts_new[k].x[0] != gparts_new[k].part->x[0] || */ - /* gparts_new[k].x[1] != gparts_new[k].part->x[1] || */ - /* gparts_new[k].x[2] != gparts_new[k].part->x[2]) */ - /* error("Linked particles are not at the same position !"); */ - /* } */ - /* } */ - /* for (size_t k = 0; k < nr_parts; ++k) { */ + if (gparts_new[k].x[0] != gparts_new[k].part->x[0] || + gparts_new[k].x[1] != gparts_new[k].part->x[1] || + gparts_new[k].x[2] != gparts_new[k].part->x[2]) + error("Linked particles are not at the same position !"); + } + } + for (size_t k = 0; k < nr_parts; ++k) { - /* if (parts_new[k].gpart != NULL) { */ + if (parts_new[k].gpart != NULL) { - /* if (parts_new[k].gpart->part != &parts_new[k]) error("Linking problem !"); */ - /* } */ - /* } */ + if (parts_new[k].gpart->part != &parts_new[k]) error("Linking problem !"); + } + } +#endif /* Set the new part data, free the old. */ free(parts); @@ -717,8 +726,7 @@ void engine_exchange_cells(struct engine *e) { MPI_Status status; ticks tic = getticks(); - /* Run through the cells and get the size of the ones that will be sent off. - */ + /* Run through the cells and get the size of the ones that will be sent */ int count_out = 0; for (int k = 0; k < nr_cells; k++) { offset[k] = count_out; @@ -2445,26 +2453,29 @@ void engine_split(struct engine *e, struct partition *initial_partition) { for (size_t k = 0; k < s->nr_gparts; k++) if (s->gparts[k].id > 0) s->gparts[k].part->gpart = &s->gparts[k]; +#ifdef SWIFT_DEBUG_CHECKS + /* Verify that the links are correct */ - /* for (size_t k = 0; k < s->nr_gparts; ++k) { */ + for (size_t k = 0; k < s->nr_gparts; ++k) { - /* if (s->gparts[k].id > 0) { */ + if (s->gparts[k].id > 0) { - /* if (s->gparts[k].part->gpart != &s->gparts[k]) error("Linking problem !"); */ + if (s->gparts[k].part->gpart != &s->gparts[k]) error("Linking problem !"); - /* if (s->gparts[k].x[0] != s->gparts[k].part->x[0] || */ - /* s->gparts[k].x[1] != s->gparts[k].part->x[1] || */ - /* s->gparts[k].x[2] != s->gparts[k].part->x[2]) */ - /* error("Linked particles are not at the same position !"); */ - /* } */ - /* } */ - /* for (size_t k = 0; k < s->nr_parts; ++k) { */ + if (s->gparts[k].x[0] != s->gparts[k].part->x[0] || + s->gparts[k].x[1] != s->gparts[k].part->x[1] || + s->gparts[k].x[2] != s->gparts[k].part->x[2]) + error("Linked particles are not at the same position !"); + } + } + for (size_t k = 0; k < s->nr_parts; ++k) { - /* if (s->parts[k].gpart != NULL) { */ + if (s->parts[k].gpart != NULL) { + if (s->parts[k].gpart->part != &s->parts[k]) error("Linking problem !"); + } + } - /* if (s->parts[k].gpart->part != &s->parts[k]) error("Linking problem !"); */ - /* } */ - /* } */ +#endif #else error("SWIFT was not compiled with MPI support."); @@ -2483,7 +2494,7 @@ void engine_dump_snapshot(struct engine *e) { if (e->verbose) message("writing snapshot at t=%f.", e->time); - /* Dump... */ +/* Dump... */ #if defined(WITH_MPI) #if defined(HAVE_PARALLEL_HDF5) write_output_parallel(e, e->snapshotBaseName, e->snapshotUnits, e->nodeID, diff --git a/src/runner.c b/src/runner.c index d38b52ce38..0db16a7a20 100644 --- a/src/runner.c +++ b/src/runner.c @@ -346,18 +346,18 @@ void runner_do_sort(struct runner *r, struct cell *c, int flags, int clock) { } } +#ifdef SWIFT_DEBUG_CHECKS /* Verify the sorting. */ - /* for ( j = 0 ; j < 13 ; j++ ) { - if ( !( flags & (1 << j) ) ) - continue; - finger = &sort[ j*(count + 1) ]; - for ( k = 1 ; k < count ; k++ ) { - if ( finger[k].d < finger[k-1].d ) - error( "Sorting failed, ascending array." ); - if ( finger[k].i >= count ) - error( "Sorting failed, indices borked." ); - } - } */ + for (j = 0; j < 13; j++) { + if (!(flags & (1 << j))) continue; + finger = &sort[j * (count + 1)]; + for (k = 1; k < count; k++) { + if (finger[k].d < finger[k - 1].d) + error("Sorting failed, ascending array."); + if (finger[k].i >= count) error("Sorting failed, indices borked."); + } + } +#endif if (clock) TIMER_TOC(timer_dosort); } diff --git a/src/scheduler.c b/src/scheduler.c index 8f833dad50..39dab82a41 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -685,10 +685,12 @@ void scheduler_ranktasks(struct scheduler *s) { left = j; } +#ifdef SWIFT_DEBUG_CHECKS /* Verify that the tasks were ranked correctly. */ - /* for ( k = 1 ; k < s->nr_tasks ; k++ ) - if ( tasks[ tid[k-1] ].rank > tasks[ tid[k-1] ].rank ) - error( "Task ranking failed." ); */ + for (int k = 1; k < s->nr_tasks; k++) + if (tasks[tid[k - 1]].rank > tasks[tid[k - 1]].rank) + error("Task ranking failed."); +#endif } /** diff --git a/src/space.c b/src/space.c index 8181971fa8..c4173a5889 100644 --- a/src/space.c +++ b/src/space.c @@ -431,6 +431,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { // clocks_from_ticks(getticks() - tic), clocks_getunit()); #ifdef WITH_MPI + /* Move non-local parts to the end of the list. */ const int local_nodeID = s->e->nodeID; for (size_t k = 0; k < nr_parts;) { @@ -458,8 +459,9 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { } } +#ifdef SWIFT_DEBUG_CHECKS /* Check that all parts are in the correct places. */ - /* for (size_t k = 0; k < nr_parts; k++) { + for (size_t k = 0; k < nr_parts; k++) { if (cells[ind[k]].nodeID != local_nodeID) { error("Failed to move all non-local parts to send list"); } @@ -468,7 +470,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { if (cells[ind[k]].nodeID == local_nodeID) { error("Failed to remove local parts from send list"); } - }*/ + } +#endif /* Move non-local gparts to the end of the list. */ for (int k = 0; k < nr_gparts;) { @@ -493,8 +496,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { } } +#ifdef SWIFT_DEBUG_CHECKS /* Check that all gparts are in the correct place (untested). */ - /* for (size_t k = 0; k < nr_gparts; k++) { if (cells[gind[k]].nodeID != local_nodeID) { error("Failed to move all non-local gparts to send list"); @@ -504,7 +507,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { if (cells[gind[k]].nodeID == local_nodeID) { error("Failed to remove local gparts from send list"); } - }*/ + } +#endif /* Exchange the strays, note that this potentially re-allocates the parts arrays. */ @@ -533,12 +537,15 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ind[k] = cell_getid(cdim, p->x[0] * ih[0], p->x[1] * ih[1], p->x[2] * ih[2]); cells[ind[k]].count += 1; - /* if ( cells[ ind[k] ].nodeID != nodeID ) - error( "Received part that does not belong to me (nodeID=%i)." , cells[ - ind[k] ].nodeID ); */ +#ifdef SWIFT_DEBUG_CHECKS + if (cells[ind[k]].nodeID != local_nodeID) + error("Received part that does not belong to me (nodeID=%i).", + cells[ind[k]].nodeID); +#endif } nr_parts = s->nr_parts; -#endif + +#endif /* WITH_MPI */ /* Sort the parts according to their cells. */ space_parts_sort(s, ind, nr_parts, 0, s->nr_cells - 1, verbose); @@ -547,15 +554,18 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { for (size_t k = 0; k < nr_parts; k++) if (s->parts[k].gpart != NULL) s->parts[k].gpart->part = &s->parts[k]; +#ifdef SWIFT_DEBUG_CHECKS /* Verify space_sort_struct. */ - /* for ( k = 1 ; k < nr_parts ; k++ ) { - if ( ind[k-1] > ind[k] ) { - error( "Sort failed!" ); - } - else if ( ind[k] != cell_getid( cdim , parts[k].x[0]*ih[0] , - parts[k].x[1]*ih[1] , parts[k].x[2]*ih[2] ) ) - error( "Incorrect indices!" ); - } */ + for (size_t k = 1; k < nr_parts; k++) { + if (ind[k - 1] > ind[k]) { + error("Sort failed!"); + } else if (ind[k] != cell_getid(cdim, s->parts[k].x[0] * ih[0], + s->parts[k].x[1] * ih[1], + s->parts[k].x[2] * ih[2])) { + error("Incorrect indices!"); + } + } +#endif /* We no longer need the indices as of here. */ free(ind); @@ -596,26 +606,28 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { /* We no longer need the indices as of here. */ free(gind); +#ifdef SWIFT_DEBUG_CHECKS /* Verify that the links are correct */ - /* for (size_t k = 0; k < nr_gparts; ++k) { */ + for (size_t k = 0; k < nr_gparts; ++k) { - /* if (s->gparts[k].id > 0) { */ + if (s->gparts[k].id > 0) { - /* if (s->gparts[k].part->gpart != &s->gparts[k]) error("Linking problem !"); */ + if (s->gparts[k].part->gpart != &s->gparts[k]) error("Linking problem !"); - /* if (s->gparts[k].x[0] != s->gparts[k].part->x[0] || */ - /* s->gparts[k].x[1] != s->gparts[k].part->x[1] || */ - /* s->gparts[k].x[2] != s->gparts[k].part->x[2]) */ - /* error("Linked particles are not at the same position !"); */ - /* } */ - /* } */ - /* for (size_t k = 0; k < nr_parts; ++k) { */ + if (s->gparts[k].x[0] != s->gparts[k].part->x[0] || + s->gparts[k].x[1] != s->gparts[k].part->x[1] || + s->gparts[k].x[2] != s->gparts[k].part->x[2]) + error("Linked particles are not at the same position !"); + } + } + for (size_t k = 0; k < nr_parts; ++k) { - /* if (s->parts[k].gpart != NULL) { */ + if (s->parts[k].gpart != NULL) { - /* if (s->parts[k].gpart->part != &s->parts[k]) error("Linking problem !"); */ - /* } */ - /* } */ + if (s->parts[k].gpart->part != &s->parts[k]) error("Linking problem !"); + } + } +#endif /* Hook the cells up to the parts. */ // tic = getticks(); @@ -705,13 +717,14 @@ void space_parts_sort(struct space *s, int *ind, size_t N, int min, int max, /* Launch the sorting tasks. */ engine_launch(s->e, s->e->nr_threads, (1 << task_type_part_sort), 0); +#ifdef SWIFT_DEBUG_CHECKS /* Verify space_sort_struct. */ - /* for (int i = 1; i < N; i++) + for (int i = 1; i < N; i++) if (ind[i - 1] > ind[i]) error("Sorting failed (ind[%i]=%i,ind[%i]=%i), min=%i, max=%i.", i - 1, - ind[i - 1], i, - ind[i], min, max); - message("Sorting succeeded."); */ + ind[i - 1], i, ind[i], min, max); + message("Sorting succeeded."); +#endif /* Clean up. */ free(space_sort_struct.stack); @@ -773,19 +786,21 @@ void space_do_parts_sort() { } } +#ifdef SWIFT_DEBUG_CHECKS /* Verify space_sort_struct. */ - /* for (int k = i; k <= jj; k++) + for (int k = i; k <= jj; k++) if (ind[k] > pivot) { - message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%i, j=%i.", k, - ind[k], pivot, i, j); + message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", + k, ind[k], pivot, i, j); error("Partition failed (<=pivot)."); } for (int k = jj + 1; k <= j; k++) if (ind[k] <= pivot) { - message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%i, j=%i.", k, - ind[k], pivot, i, j); + message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", + k, ind[k], pivot, i, j); error("Partition failed (>pivot)."); - } */ + } +#endif /* Split-off largest interval. */ if (jj - i > j - jj + 1) { @@ -885,13 +900,14 @@ void space_gparts_sort(struct space *s, int *ind, size_t N, int min, int max, /* Launch the sorting tasks. */ engine_launch(s->e, s->e->nr_threads, (1 << task_type_gpart_sort), 0); +#ifdef SWIFT_DEBUG_CHECKS /* Verify space_sort_struct. */ - /* for (int i = 1; i < N; i++) + for (int i = 1; i < N; i++) if (ind[i - 1] > ind[i]) error("Sorting failed (ind[%i]=%i,ind[%i]=%i), min=%i, max=%i.", i - 1, - ind[i - 1], i, - ind[i], min, max); - message("Sorting succeeded."); */ + ind[i - 1], i, ind[i], min, max); + message("Sorting succeeded."); +#endif /* Clean up. */ free(space_sort_struct.stack); @@ -949,19 +965,21 @@ void space_do_gparts_sort() { } } +#ifdef SWIFT_DEBUG_CHECKS /* Verify space_sort_struct. */ - /* for (int k = i; k <= jj; k++) + for (int k = i; k <= jj; k++) if (ind[k] > pivot) { - message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%i, j=%i.", k, - ind[k], pivot, i, j); + message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", + k, ind[k], pivot, i, j); error("Partition failed (<=pivot)."); } for (int k = jj + 1; k <= j; k++) if (ind[k] <= pivot) { - message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%i, j=%i.", k, - ind[k], pivot, i, j); + message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", + k, ind[k], pivot, i, j); error("Partition failed (>pivot)."); - } */ + } +#endif /* Split-off largest interval. */ if (jj - i > j - jj + 1) { -- GitLab