Skip to content
Snippets Groups Projects
Commit 0025151f authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

make sorting more memory-efficient.

Former-commit-id: 0b8d1b961353602dc0ec66a399cd1c4a7efb8f4c
parent fa60b920
Branches
Tags
No related merge requests found
...@@ -882,7 +882,7 @@ void runner_dosort ( struct runner_thread *rt , struct cell *c , int flags ) { ...@@ -882,7 +882,7 @@ void runner_dosort ( struct runner_thread *rt , struct cell *c , int flags ) {
int j, k, count = c->count; int j, k, count = c->count;
int cone, ctwo; int cone, ctwo;
int i, ind, off[8], inds[8], temp_i; int i, ind, off[8], inds[8], temp_i;
float shift[3]; // float shift[3];
float buff[8]; float buff[8];
struct cell *temp_c; struct cell *temp_c;
TIMER_TIC TIMER_TIC
...@@ -997,36 +997,57 @@ void runner_dosort ( struct runner_thread *rt , struct cell *c , int flags ) { ...@@ -997,36 +997,57 @@ void runner_dosort ( struct runner_thread *rt , struct cell *c , int flags ) {
} /* progeny? */ } /* progeny? */
/* Otherwise, just sort. */
// else {
//
// /* Loop over the different cell axes. */
// for ( j = 0 ; j < 13 ; j++ ) {
//
// /* Has this sort array been flagged? */
// if ( !( flags & (1 << j) ) )
// continue;
//
// /* Get the shift vector. */
// shift[0] = runner_shift[ 3*j + 0 ];
// shift[1] = runner_shift[ 3*j + 1 ];
// shift[2] = runner_shift[ 3*j + 2 ];
//
// /* Fill the sort array. */
// finger = &c->sort[ j*(count + 1) ];
// for ( k = 0 ; k < count ; k++ ) {
// finger[k].i = k;
// finger[k].d = parts[k].x[0]*shift[0] + parts[k].x[1]*shift[1] + parts[k].x[2]*shift[2];
// }
//
// /* Add the sentinel. */
// finger[ c->count ].d = FLT_MAX;
// finger[ c->count ].i = 0;
//
// /* Sort descending. */
// runner_dosort_ascending( finger , c->count );
//
// }
//
// }
/* Otherwise, just sort. */ /* Otherwise, just sort. */
else { else {
/* Loop over the different cell axes. */ /* Fill the sort array. */
for ( j = 0 ; j < 13 ; j++ ) { for ( k = 0 ; k < count ; k++ )
for ( j = 0 ; j < 13 ; j++ )
/* Has this sort array been flagged? */ if ( flags & (1 << j) ) {
if ( !( flags & (1 << j) ) ) c->sort[ j*(count + 1) + k].i = k;
continue; c->sort[ j*(count + 1) + k].d = parts[k].x[0]*runner_shift[ 3*j + 0 ] + parts[k].x[1]*runner_shift[ 3*j + 1 ] + parts[k].x[2]*runner_shift[ 3*j + 2 ];
}
/* Get the shift vector. */
shift[0] = runner_shift[ 3*j + 0 ]; /* Add the sentinel and sort. */
shift[1] = runner_shift[ 3*j + 1 ]; for ( j = 0 ; j < 13 ; j++ )
shift[2] = runner_shift[ 3*j + 2 ]; if ( flags & (1 << j) ) {
c->sort[ j*(count + 1) + c->count ].d = FLT_MAX;
/* Fill the sort array. */ c->sort[ j*(count + 1) + c->count ].i = 0;
finger = &c->sort[ j*(count + 1) ]; runner_dosort_ascending( &c->sort[ j*(count + 1) ] , c->count );
for ( k = 0 ; k < count ; k++ ) {
finger[k].i = k;
finger[k].d = parts[k].x[0]*shift[0] + parts[k].x[1]*shift[1] + parts[k].x[2]*shift[2];
} }
/* Add the sentinel. */
finger[ c->count ].d = FLT_MAX;
finger[ c->count ].i = 0;
/* Sort descending. */
runner_dosort_ascending( finger , c->count );
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment