Commit fa153c4c authored by James Willis's avatar James Willis
Browse files

Comments and formatting.

parent 4452cf5e
......@@ -273,7 +273,8 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
int first_pi = 0, last_pj = cj->count - 1;
int temp, active_id;
if(active_ci) {
/* Only populate max_index array for local actve cells. */
if (active_ci) {
/* Find the leftmost active particle in cell i that interacts with any
* particle in cell j. */
......@@ -289,7 +290,8 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
/* Set the first active pi in range of any particle in cell j. */
first_pi = active_id;
/* Find the maximum index into cell j for each particle in range in cell i. */
/* Find the maximum index into cell j for each particle in range in cell i.
*/
if (first_pi < ci->count) {
/* Start from the first particle in cell j. */
......@@ -297,7 +299,7 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
const struct part *pi = &parts_i[sort_i[first_pi].i];
const float first_di =
sort_i[first_pi].d + pi->h * kernel_gamma + dx_max - rshift;
sort_i[first_pi].d + pi->h * kernel_gamma + dx_max - rshift;
/* Loop through particles in cell j until they are not in range of pi.
* Make sure that temp stays between 0 and cj->count - 1.*/
......@@ -321,21 +323,22 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
/* Make sure that max index is set to first particle in cj.*/
max_index_i[ci->count - 1] = 0;
}
}
else {
/* Make sure that foreign cells are only read into the cache if the local cell requires it.
} else {
/* Make sure that foreign cells are only read into the cache if the local
* cell requires it.
* Also ensure that it does not require any particles from cj. */
first_pi = ci->count - 1;
first_pi = ci->count - 1;
max_index_i[ci->count - 1] = 0;
}
if(active_cj) {
/* Only populate max_index array for local actve cells. */
if (active_cj) {
/* Find the rightmost active particle in cell j that interacts with any
* particle in cell i. */
last_pj = -1;
active_id = last_pj;
while (last_pj < cj->count &&
sort_j[last_pj + 1].d - hj_max - dx_max < di_max) {
sort_j[last_pj + 1].d - hj_max - dx_max < di_max) {
last_pj++;
/* Store the index of the particle if it is active. */
if (part_is_active_no_debug(&parts_j[sort_j[last_pj].i], max_active_bin))
......@@ -345,7 +348,8 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
/* Set the last active pj in range of any particle in cell i. */
last_pj = active_id;
/* Find the maximum index into cell i for each particle in range in cell j. */
/* Find the maximum index into cell i for each particle in range in cell j.
*/
if (last_pj >= 0) {
/* Start from the last particle in cell i. */
......@@ -353,7 +357,7 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
const struct part *pj = &parts_j[sort_j[last_pj].i];
const float last_dj =
sort_j[last_pj].d - dx_max - pj->h * kernel_gamma + rshift;
sort_j[last_pj].d - dx_max - pj->h * kernel_gamma + rshift;
/* Loop through particles in cell i until they are not in range of pj. */
while (temp > 0 && last_dj < sort_i[temp].d) temp--;
......@@ -374,9 +378,9 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
/* Make sure that max index is set to last particle in ci.*/
max_index_j[0] = ci->count - 1;
}
}
else {
/* Make sure that foreign cells are only read into the cache if the local cell requires it.
} else {
/* Make sure that foreign cells are only read into the cache if the local
* cell requires it.
* Also ensure that it does not require any particles from ci. */
last_pj = 0;
max_index_j[0] = ci->count - 1;
......@@ -414,16 +418,14 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
* @param max_active_bin The largest time-bin active during this step.
*/
__attribute__((always_inline)) INLINE static void
populate_max_index_no_cache_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 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) {
populate_max_index_no_cache_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 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->parts;
const struct part *restrict parts_j = cj->parts;
......@@ -431,14 +433,15 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
int first_pi = 0, last_pj = cj->count - 1;
int temp, active_id;
if(active_ci) {
/* Only populate max_index array for local actve cells. */
if (active_ci) {
/* Find the leftmost active particle in cell i that interacts with any
* particle in cell j. */
first_pi = ci->count;
active_id = first_pi - 1;
while (first_pi > 0 &&
sort_i[first_pi - 1].d + dx_max + max(hi_max, hj_max) > dj_min) {
sort_i[first_pi - 1].d + dx_max + max(hi_max, hj_max) > dj_min) {
first_pi--;
/* Store the index of the particle if it is active. */
if (part_is_active_no_debug(&parts_i[sort_i[first_pi].i], max_active_bin))
......@@ -448,7 +451,8 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
/* Set the first active pi in range of any particle in cell j. */
first_pi = active_id;
/* Find the maximum index into cell j for each particle in range in cell i. */
/* Find the maximum index into cell j for each particle in range in cell i.
*/
if (first_pi < ci->count) {
/* Start from the first particle in cell j. */
......@@ -456,8 +460,8 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
const struct part *pi = &parts_i[sort_i[first_pi].i];
const float first_di = sort_i[first_pi].d +
max(pi->h, hj_max_raw) * kernel_gamma + dx_max -
rshift;
max(pi->h, hj_max_raw) * kernel_gamma + dx_max -
rshift;
/* Loop through particles in cell j until they are not in range of pi.
* Make sure that temp stays between 0 and cj->count - 1.*/
......@@ -470,8 +474,8 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
temp = max_index_i[i - 1];
pi = &parts_i[sort_i[i].i];
const float di =
sort_i[i].d + max(pi->h, hj_max_raw) * kernel_gamma + dx_max - rshift;
const float di = sort_i[i].d + max(pi->h, hj_max_raw) * kernel_gamma +
dx_max - rshift;
/* Make sure that temp stays between 0 and cj->count - 1.*/
while (temp < cj->count - 1 && di > sort_j[temp].d) temp++;
......@@ -482,21 +486,22 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
/* Make sure that max index is set to first particle in cj.*/
max_index_i[ci->count - 1] = 0;
}
}
else {
/* Make sure that foreign cells are only read into the cache if the local cell requires it.
} else {
/* Make sure that foreign cells are only read into the cache if the local
* cell requires it.
* Also ensure that it does not require any particles from cj. */
first_pi = ci->count - 1;
first_pi = ci->count - 1;
max_index_i[ci->count - 1] = 0;
}
if(active_cj) {
/* Only populate max_index array for local actve cells. */
if (active_cj) {
/* Find the rightmost active particle in cell j that interacts with any
* particle in cell i. */
last_pj = -1;
active_id = last_pj;
while (last_pj < cj->count &&
sort_j[last_pj + 1].d - max(hj_max, hi_max) - dx_max < di_max) {
sort_j[last_pj + 1].d - max(hj_max, hi_max) - dx_max < di_max) {
last_pj++;
/* Store the index of the particle if it is active. */
if (part_is_active_no_debug(&parts_j[sort_j[last_pj].i], max_active_bin))
......@@ -506,7 +511,8 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
/* Set the last active pj in range of any particle in cell i. */
last_pj = active_id;
/* Find the maximum index into cell i for each particle in range in cell j. */
/* Find the maximum index into cell i for each particle in range in cell j.
*/
if (last_pj >= 0) {
/* Start from the last particle in cell i. */
......@@ -514,7 +520,7 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
const struct part *pj = &parts_j[sort_j[last_pj].i];
const float last_dj = sort_j[last_pj].d - dx_max -
max(pj->h, hi_max_raw) * kernel_gamma + rshift;
max(pj->h, hi_max_raw) * kernel_gamma + rshift;
/* Loop through particles in cell i until they are not in range of pj. */
while (temp > 0 && last_dj < sort_i[temp].d) temp--;
......@@ -527,7 +533,7 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
pj = &parts_j[sort_j[i].i];
const float dj = sort_j[i].d - dx_max -
(max(pj->h, hi_max_raw) * kernel_gamma) + rshift;
(max(pj->h, hi_max_raw) * kernel_gamma) + rshift;
while (temp > 0 && dj < sort_i[temp].d) temp--;
......@@ -537,9 +543,9 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
/* Make sure that max index is set to last particle in ci.*/
max_index_j[0] = ci->count - 1;
}
}
else {
/* Make sure that foreign cells are only read into the cache if the local cell requires it.
} else {
/* Make sure that foreign cells are only read into the cache if the local
* cell requires it.
* Also ensure that it does not require any particles from ci. */
last_pj = 0;
max_index_j[0] = ci->count - 1;
......@@ -1157,12 +1163,13 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
TIMER_TIC;
/* Check whether cells are local to the node. */
#ifdef WITH_MPI
const int ci_local = (ci->nodeID == e->nodeID) ? 1 : 0;
const int cj_local = (cj->nodeID == e->nodeID) ? 1 : 0;
const int ci_local = (ci->nodeID == e->nodeID) ? 1 : 0;
const int cj_local = (cj->nodeID == e->nodeID) ? 1 : 0;
#else
const int ci_local = 1;
const int cj_local = 1;
const int ci_local = 1;
const int cj_local = 1;
#endif
/* Get the cutoff shift. */
......@@ -1238,7 +1245,8 @@ const int cj_local = 1;
* pj that interacts with any particle in ci. */
populate_max_index_no_cache(ci, cj, sort_i, sort_j, dx_max, rshift, hi_max,
hj_max, di_max, dj_min, max_index_i, max_index_j,
&first_pi, &last_pj, max_active_bin, active_ci, active_cj);
&first_pi, &last_pj, max_active_bin, active_ci,
active_cj);
/* Limits of the outer loops. */
int first_pi_loop = first_pi;
......@@ -1514,12 +1522,13 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
TIMER_TIC;
/* Check whether cells are local to the node. */
#ifdef WITH_MPI
const int ci_local = (ci->nodeID == e->nodeID) ? 1 : 0;
const int cj_local = (cj->nodeID == e->nodeID) ? 1 : 0;
const int ci_local = (ci->nodeID == e->nodeID) ? 1 : 0;
const int cj_local = (cj->nodeID == e->nodeID) ? 1 : 0;
#else
const int ci_local = 1;
const int cj_local = 1;
const int ci_local = 1;
const int cj_local = 1;
#endif
/* Get the cutoff shift. */
......@@ -1599,10 +1608,10 @@ const int cj_local = 1;
/* Find particles maximum distance into cj, max_di[] and ci, max_dj[]. */
/* Also find the first pi that interacts with any particle in cj and the last
* pj that interacts with any particle in ci. */
populate_max_index_no_cache_force(ci, cj, sort_i, sort_j, dx_max, rshift,
hi_max_raw, hj_max_raw, hi_max, hj_max,
di_max, dj_min, max_index_i, max_index_j,
&first_pi, &last_pj, max_active_bin, active_ci, active_cj);
populate_max_index_no_cache_force(
ci, cj, sort_i, sort_j, dx_max, rshift, hi_max_raw, hj_max_raw, hi_max,
hj_max, di_max, dj_min, max_index_i, max_index_j, &first_pi, &last_pj,
max_active_bin, active_ci, active_cj);
/* Limits of the outer loops. */
const int first_pi_loop = first_pi;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment