From e4fe9fc77c724d57a703598e715d3b092493d2cb Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Thu, 23 May 2019 17:39:38 +0100 Subject: [PATCH] Rename struct entry to struct sort_entry entry is a very generic name and it clashes with a struct in the search.h header --- src/cache.h | 14 ++++++++------ src/cell.h | 12 ++++++------ src/runner.c | 16 ++++++++-------- src/runner_doiact.h | 25 +++++++++++++------------ src/runner_doiact_stars.h | 12 ++++++------ src/runner_doiact_vec.c | 34 ++++++++++++++++++---------------- src/sort_part.h | 2 +- 7 files changed, 60 insertions(+), 55 deletions(-) diff --git a/src/cache.h b/src/cache.h index e5a62f33b3..e2e5185d5a 100644 --- a/src/cache.h +++ b/src/cache.h @@ -346,7 +346,7 @@ __attribute__((always_inline)) INLINE int cache_read_particles_subset_self( */ __attribute__((always_inline)) INLINE void cache_read_particles_subset_pair( const struct cell *restrict const ci, struct cache *restrict const ci_cache, - const struct entry *restrict sort_i, int *first_pi, int *last_pi, + const struct sort_entry *restrict sort_i, int *first_pi, int *last_pi, const double *loc, const int flipped) { #if defined(GADGET2_SPH) @@ -608,9 +608,10 @@ __attribute__((always_inline)) INLINE int cache_read_force_particles( __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted( const struct cell *restrict const ci, const struct cell *restrict const cj, struct cache *restrict const ci_cache, - struct cache *restrict const cj_cache, const struct entry *restrict sort_i, - const struct entry *restrict sort_j, const double *restrict const shift, - int *first_pi, int *last_pj) { + struct cache *restrict const cj_cache, + const struct sort_entry *restrict sort_i, + const struct sort_entry *restrict sort_j, + const double *restrict const shift, int *first_pi, int *last_pj) { /* Make the number of particles to be read a multiple of the vector size. * This eliminates serial remainder loops where possible when populating the @@ -860,8 +861,9 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted_force( const struct cell *const ci, const struct cell *const cj, struct cache *const ci_cache, struct cache *const cj_cache, - const struct entry *restrict sort_i, const struct entry *restrict sort_j, - const double *const shift, int *first_pi, int *last_pj) { + const struct sort_entry *restrict sort_i, + const struct sort_entry *restrict sort_j, const double *const shift, + int *first_pi, int *last_pj) { /* Make the number of particles to be read a multiple of the vector size. * This eliminates serial remainder loops where possible when populating the diff --git a/src/cell.h b/src/cell.h index 6fcd073610..00d9b2d5a8 100644 --- a/src/cell.h +++ b/src/cell.h @@ -332,7 +332,7 @@ struct cell { struct xpart *xparts; /*! Pointer for the sorted indices. */ - struct entry *sort[13]; + struct sort_entry *sort[13]; /*! Super cell, i.e. the highest-level parent cell that has a hydro * pair/self tasks */ @@ -600,7 +600,7 @@ struct cell { float dx_max_sort_old; /*! Pointer for the sorted indices. */ - struct entry *sort[13]; + struct sort_entry *sort[13]; /*! Bit mask of sort directions that will be needed in the next timestep. */ uint16_t requires_sorts; @@ -1247,8 +1247,8 @@ __attribute__((always_inline)) INLINE static void cell_malloc_hydro_sorts( * on the same dimensions), so we need separate allocations per dimension. */ for (int j = 0; j < 13; j++) { if ((flags & (1 << j)) && c->hydro.sort[j] == NULL) { - if ((c->hydro.sort[j] = (struct entry *)swift_malloc( - "hydro.sort", sizeof(struct entry) * (count + 1))) == NULL) + if ((c->hydro.sort[j] = (struct sort_entry *)swift_malloc( + "hydro.sort", sizeof(struct sort_entry) * (count + 1))) == NULL) error("Failed to allocate sort memory."); } } @@ -1285,8 +1285,8 @@ __attribute__((always_inline)) INLINE static void cell_malloc_stars_sorts( * on the same dimensions), so we need separate allocations per dimension. */ for (int j = 0; j < 13; j++) { if ((flags & (1 << j)) && c->stars.sort[j] == NULL) { - if ((c->stars.sort[j] = (struct entry *)swift_malloc( - "stars.sort", sizeof(struct entry) * (count + 1))) == NULL) + if ((c->stars.sort[j] = (struct sort_entry *)swift_malloc( + "stars.sort", sizeof(struct sort_entry) * (count + 1))) == NULL) error("Failed to allocate sort memory."); } } diff --git a/src/runner.c b/src/runner.c index 3694e9dc53..a8deac018a 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1149,13 +1149,13 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { * @param sort The entries * @param N The number of entries. */ -void runner_do_sort_ascending(struct entry *sort, int N) { +void runner_do_sort_ascending(struct sort_entry *sort, int N) { struct { short int lo, hi; } qstack[10]; int qpos, i, j, lo, hi, imin; - struct entry temp; + struct sort_entry temp; float pivot; /* Sort parts in cell_i in decreasing order with quicksort */ @@ -1260,7 +1260,7 @@ RUNNER_CHECK_SORTS(stars) void runner_do_hydro_sort(struct runner *r, struct cell *c, int flags, int cleanup, int clock) { - struct entry *fingers[8]; + struct sort_entry *fingers[8]; const int count = c->hydro.count; const struct part *parts = c->hydro.parts; struct xpart *xparts = c->hydro.xparts; @@ -1372,7 +1372,7 @@ void runner_do_hydro_sort(struct runner *r, struct cell *c, int flags, } /* For each entry in the new sort list. */ - struct entry *finger = c->hydro.sort[j]; + struct sort_entry *finger = c->hydro.sort[j]; for (int ind = 0; ind < count; ind++) { /* Copy the minimum into the new sort array. */ @@ -1451,7 +1451,7 @@ void runner_do_hydro_sort(struct runner *r, struct cell *c, int flags, /* Verify the sorting. */ for (int j = 0; j < 13; j++) { if (!(flags & (1 << j))) continue; - struct entry *finger = c->hydro.sort[j]; + struct sort_entry *finger = c->hydro.sort[j]; for (int k = 1; k < count; k++) { if (finger[k].d < finger[k - 1].d) error("Sorting failed, ascending array."); @@ -1493,7 +1493,7 @@ void runner_do_hydro_sort(struct runner *r, struct cell *c, int flags, void runner_do_stars_sort(struct runner *r, struct cell *c, int flags, int cleanup, int clock) { - struct entry *fingers[8]; + struct sort_entry *fingers[8]; const int count = c->stars.count; struct spart *sparts = c->stars.parts; float buff[8]; @@ -1604,7 +1604,7 @@ void runner_do_stars_sort(struct runner *r, struct cell *c, int flags, } /* For each entry in the new sort list. */ - struct entry *finger = c->stars.sort[j]; + struct sort_entry *finger = c->stars.sort[j]; for (int ind = 0; ind < count; ind++) { /* Copy the minimum into the new sort array. */ @@ -1677,7 +1677,7 @@ void runner_do_stars_sort(struct runner *r, struct cell *c, int flags, /* Verify the sorting. */ for (int j = 0; j < 13; j++) { if (!(flags & (1 << j))) continue; - struct entry *finger = c->stars.sort[j]; + struct sort_entry *finger = c->stars.sort[j]; for (int k = 1; k < count; k++) { if (finger[k].d < finger[k - 1].d) error("Sorting failed, ascending array."); diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 635d41a95d..a69489ed29 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -681,7 +681,7 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, const float H = cosmo->H; /* Pick-out the sorted lists. */ - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; const float dxj = cj->hydro.dx_max_sort; /* Parts are on the left? */ @@ -984,8 +984,8 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, for (int k = 0; k < 3; k++) rshift += shift[k] * runner_shift[sid][k]; /* Pick-out the sorted lists. */ - const struct entry *restrict sort_i = ci->hydro.sort[sid]; - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_i = ci->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; #ifdef SWIFT_DEBUG_CHECKS /* Some constants used to checks that the parts are in the right frame */ @@ -1231,8 +1231,8 @@ void DOPAIR1_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) { #ifdef SWIFT_DEBUG_CHECKS /* Pick-out the sorted lists. */ - const struct entry *restrict sort_i = ci->hydro.sort[sid]; - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_i = ci->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; /* Check that the dx_max_sort values in the cell are indeed an upper bound on particle movement. */ @@ -1309,8 +1309,8 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, for (int k = 0; k < 3; k++) rshift += shift[k] * runner_shift[sid][k]; /* Pick-out the sorted lists. */ - struct entry *restrict sort_i = ci->hydro.sort[sid]; - struct entry *restrict sort_j = cj->hydro.sort[sid]; + struct sort_entry *restrict sort_i = ci->hydro.sort[sid]; + struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; #ifdef SWIFT_DEBUG_CHECKS /* Some constants used to checks that the parts are in the right frame */ @@ -1350,7 +1350,8 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, const double shift_j[3] = {cj->loc[0], cj->loc[1], cj->loc[2]}; int count_active_i = 0, count_active_j = 0; - struct entry *restrict sort_active_i = NULL, *restrict sort_active_j = NULL; + struct sort_entry *restrict sort_active_i = NULL, + *restrict sort_active_j = NULL; if (cell_is_all_active_hydro(ci, e)) { /* If everybody is active don't bother copying */ @@ -1358,7 +1359,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, count_active_i = count_i; } else if (cell_is_active_hydro(ci, e)) { if (posix_memalign((void **)&sort_active_i, SWIFT_CACHE_ALIGNMENT, - sizeof(struct entry) * count_i) != 0) + sizeof(struct sort_entry) * count_i) != 0) error("Failed to allocate active sortlists."); /* Collect the active particles in ci */ @@ -1376,7 +1377,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, count_active_j = count_j; } else if (cell_is_active_hydro(cj, e)) { if (posix_memalign((void **)&sort_active_j, SWIFT_CACHE_ALIGNMENT, - sizeof(struct entry) * count_j) != 0) + sizeof(struct sort_entry) * count_j) != 0) error("Failed to allocate active sortlists."); /* Collect the active particles in cj */ @@ -1778,8 +1779,8 @@ void DOPAIR2_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) { #ifdef SWIFT_DEBUG_CHECKS /* Pick-out the sorted lists. */ - const struct entry *restrict sort_i = ci->hydro.sort[sid]; - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_i = ci->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; /* Check that the dx_max_sort values in the cell are indeed an upper bound on particle movement. */ diff --git a/src/runner_doiact_stars.h b/src/runner_doiact_stars.h index be4f83f813..9074f13293 100644 --- a/src/runner_doiact_stars.h +++ b/src/runner_doiact_stars.h @@ -324,8 +324,8 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, if (do_ci_stars) { /* Pick-out the sorted lists. */ - const struct entry *restrict sort_j = cj->hydro.sort[sid]; - const struct entry *restrict sort_i = ci->stars.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_i = ci->stars.sort[sid]; #ifdef SWIFT_DEBUG_CHECKS /* Some constants used to checks that the parts are in the right frame */ @@ -452,8 +452,8 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, if (do_cj_stars) { /* Pick-out the sorted lists. */ - const struct entry *restrict sort_i = ci->hydro.sort[sid]; - const struct entry *restrict sort_j = cj->stars.sort[sid]; + const struct sort_entry *restrict sort_i = ci->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->stars.sort[sid]; #ifdef SWIFT_DEBUG_CHECKS /* Some constants used to checks that the parts are in the right frame */ @@ -640,7 +640,7 @@ void DOPAIR1_SUBSET_STARS(struct runner *r, struct cell *restrict ci, if (count_j == 0) return; /* Pick-out the sorted lists. */ - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; const float dxj = cj->hydro.dx_max_sort; /* Sparts are on the left? */ @@ -1129,7 +1129,7 @@ void DOSELF1_BRANCH_STARS(struct runner *r, struct cell *c) { #define RUNNER_CHECK_SORT(TYPE, PART, cj, ci, sid) \ ({ \ - const struct entry *restrict sort_j = cj->TYPE.sort[sid]; \ + const struct sort_entry *restrict sort_j = cj->TYPE.sort[sid]; \ \ for (int pjd = 0; pjd < cj->TYPE.count; pjd++) { \ const struct PART *p = &cj->TYPE.parts[sort_j[pjd].i]; \ diff --git a/src/runner_doiact_vec.c b/src/runner_doiact_vec.c index 182e81e99c..f7d07e6b62 100644 --- a/src/runner_doiact_vec.c +++ b/src/runner_doiact_vec.c @@ -260,10 +260,11 @@ __attribute__((always_inline)) INLINE static void storeInteractions( */ __attribute__((always_inline)) INLINE static void populate_max_index_density( const struct cell *ci, const struct cell *cj, - const struct entry *restrict sort_i, const struct entry *restrict sort_j, - const float dx_max, const float rshift, const double hi_max, - const double hj_max, const double di_max, const double dj_min, - int *max_index_i, int *max_index_j, int *init_pi, int *init_pj, + const struct sort_entry *restrict sort_i, + const struct sort_entry *restrict sort_j, const float dx_max, + const float rshift, const double hi_max, const double hj_max, + const double di_max, const double dj_min, int *max_index_i, + int *max_index_j, int *init_pi, int *init_pj, const timebin_t max_active_bin, const int active_ci, const int active_cj) { const struct part *restrict parts_i = ci->hydro.parts; @@ -419,12 +420,12 @@ __attribute__((always_inline)) INLINE static void populate_max_index_density( */ __attribute__((always_inline)) INLINE static void populate_max_index_force( const struct cell *ci, const struct cell *cj, - const struct entry *restrict sort_i, const struct entry *restrict sort_j, - const float dx_max, const float rshift, const double hi_max_raw, - const double hj_max_raw, const double h_max, const double di_max, - const double dj_min, int *max_index_i, int *max_index_j, int *init_pi, - int *init_pj, const timebin_t max_active_bin, const int active_ci, - const int active_cj) { + const struct sort_entry *restrict sort_i, + const struct sort_entry *restrict sort_j, const float dx_max, + const float rshift, const double hi_max_raw, const double hj_max_raw, + const double h_max, const double di_max, const double dj_min, + int *max_index_i, int *max_index_j, int *init_pi, int *init_pj, + const timebin_t max_active_bin, const int active_ci, const int active_cj) { const struct part *restrict parts_i = ci->hydro.parts; const struct part *restrict parts_j = cj->hydro.parts; @@ -582,7 +583,8 @@ __attribute__((always_inline)) INLINE static int populate_max_index_subset( int *restrict ind, const double *total_ci_shift, const float dxj, const double di_shift_correction, const double runner_shift_x, const double runner_shift_y, const double runner_shift_z, - const struct entry *restrict sort_j, int *max_index_i, const int flipped) { + const struct sort_entry *restrict sort_j, int *max_index_i, + const int flipped) { /* The cell is on the right so read the particles * into the cache from the start of the cell. */ @@ -1320,8 +1322,8 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci, for (int k = 0; k < 3; k++) rshift += shift[k] * runner_shift[sid][k]; /* Pick-out the sorted lists. */ - const struct entry *restrict sort_i = ci->hydro.sort[sid]; - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_i = ci->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; /* Get some other useful values. */ const int count_i = ci->hydro.count; @@ -1726,7 +1728,7 @@ void runner_dopair_subset_density_vec(struct runner *r, const int count_j = cj->hydro.count; /* Pick-out the sorted lists. */ - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; const float dxj = cj->hydro.dx_max_sort; /* Get both particle caches from the runner and re-allocate @@ -2075,8 +2077,8 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci, for (int k = 0; k < 3; k++) rshift += shift[k] * runner_shift[sid][k]; /* Pick-out the sorted lists. */ - const struct entry *restrict sort_i = ci->hydro.sort[sid]; - const struct entry *restrict sort_j = cj->hydro.sort[sid]; + const struct sort_entry *restrict sort_i = ci->hydro.sort[sid]; + const struct sort_entry *restrict sort_j = cj->hydro.sort[sid]; /* Get some other useful values. */ const int count_i = ci->hydro.count; diff --git a/src/sort_part.h b/src/sort_part.h index 74116d7a8c..4da81215fc 100644 --- a/src/sort_part.h +++ b/src/sort_part.h @@ -23,7 +23,7 @@ /** * @brief Entry in a list of sorted indices. */ -struct entry { +struct sort_entry { /*! Distance on the axis */ float d; -- GitLab