diff --git a/examples/test_fmm.c b/examples/test_fmm.c index 5aa7e191883b8e7e7dac2bb4ccb2c357c01ade7e..26e8c6a3046bb6df85428f66ad5e45773fbcb615 100644 --- a/examples/test_fmm.c +++ b/examples/test_fmm.c @@ -362,21 +362,11 @@ void cell_split(struct cell *c, struct qsched *s) { qsched_addunlock(s, progenitors[k]->com_tid, c->com_tid); #endif -/* /\* Otherwise, we're at a leaf, so create the cell's particle-cell task. *\/ */ -/* } else { */ -/* struct cell *data[2] = {root, c}; */ -/* int tid = qsched_addtask(s, task_type_self_pc, task_flag_none, data, */ -/* 2 * sizeof(struct cell *), 1); */ -/* qsched_addlock(s, tid, c->res); */ -/* #ifdef COM_AS_TASK */ -/* qsched_addunlock(s, root->com_tid, tid); */ -/* #endif */ - - } /* does the cell need to be split? */ -/* Compute the cell's center of mass. */ + #ifndef COM_AS_TASK + /* Compute the cell's center of mass. */ comp_com(c); #endif @@ -438,33 +428,6 @@ static inline void make_interact_pc(struct part *parts, int count, } /* loop over every particle. */ } -/** - * @brief Checks whether the cell leaf is a subvolume of the cell c - */ -static inline int is_inside(struct cell *leaf, struct cell *c) { - return (leaf->parts >= c->parts) && (leaf->parts < c->parts + c->count); -} - -/** - * @brief Checks whether the cells are direct neighbours ot not - */ -static inline int are_neighbours_different_size(struct cell *ci, - struct cell *cj) { - - double cih = ci->h, cjh = cj->h; - - /* Maximum allowed distance */ - float min_dist = 0.5 * (cih + cjh); - - /* (Manhattan) Distance between the cells */ - for (int k = 0; k < 3; k++) { - float center_i = ci->loc[k] + 0.5 * cih; - float center_j = cj->loc[k] + 0.5 * cjh; - if (fabsf(center_i - center_j) > min_dist) return 0; - } - - return 1; -} /** * @brief Checks whether the cells are direct neighbours ot not. Both cells have @@ -490,150 +453,14 @@ static inline int are_neighbours(struct cell *ci, struct cell *cj) { return 1; } -/* /\** */ -/* * @brief Compute the interactions between all particles in a cell leaf */ -/* * and the center of mass of all the cells in a part of the tree */ -/* * described by ci and cj */ -/* * */ -/* * @param ci The #cell containing the particle */ -/* * @param cj The #cell containing the center of mass. */ -/* *\/ */ -/* static inline void iact_pair_pc(struct cell *ci, struct cell *cj, */ -/* struct cell *leaf, struct part_local *parts, */ -/* int count, double *loc) { */ - -/* struct cell *cp, *cps; */ - -/* #ifdef SANITY_CHECKS */ - -/* /\* Early abort? *\/ */ -/* if (ci->count == 0 || cj->count == 0) error("Empty cell !"); */ - -/* /\* Sanity check *\/ */ -/* if (ci == cj) */ -/* error("The impossible has happened: pair interaction between a cell and " */ -/* "itself."); */ - -/* /\* Sanity check *\/ */ -/* if (!is_inside(leaf, ci)) */ -/* error("The impossible has happened: The leaf is not within ci"); */ - -/* /\* Are the cells direct neighbours? *\/ */ -/* if (!are_neighbours(ci, cj)) error("Cells are not neighours"); */ - -/* /\* Are both cells split ? *\/ */ -/* if (!ci->split || !cj->split) error("One of the cells is not split !"); */ -/* #endif */ - -/* /\* Let's find in which subcell of ci the leaf is *\/ */ -/* for (cp = ci->firstchild; cp != ci->sibling; cp = cp->sibling) { */ - -/* if (is_inside(leaf, cp)) break; */ -/* } */ - -/* if (are_neighbours_different_size(cp, cj)) { */ - -/* /\* Now interact this subcell with all subcells of cj *\/ */ -/* for (cps = cj->firstchild; cps != cj->sibling; cps = cps->sibling) { */ - -/* /\* Check whether we have to recurse or can directly jump to the multipole */ -/* * calculation *\/ */ -/* if (are_neighbours(cp, cps)) { */ - -/* /\* We only recurse if the children are split *\/ */ -/* if (cp->split && cps->split) { */ -/* iact_pair_pc(cp, cps, leaf, parts, count, loc); */ -/* } */ - -/* } else { */ -/* make_interact_pc(parts, count, loc, cps); */ -/* } */ -/* } */ -/* } else { */ - -/* /\* If cp is not a neoghbour of cj, we can directly interact with the */ -/* * multipoles *\/ */ -/* for (cps = cj->firstchild; cps != cj->sibling; cps = cps->sibling) { */ - -/* make_interact_pc(parts, count, loc, cps); */ -/* } */ -/* } */ -/* } */ - -/* /\** */ -/* * @brief Compute the interactions between all particles in a leaf and */ -/* * and all the monopoles in the cell c */ -/* * */ -/* * @param c The #cell containing the monopoles */ -/* * @param leaf The #cell containing the particles */ -/* *\/ */ -/* static inline void iact_self_pc(struct cell *c, struct cell *leaf, */ -/* struct part_local *parts) { */ - -/* struct cell *cp, *cps; */ -/* int collect_part_data = 0; */ - -/* #ifdef SANITY_CHECKS */ - -/* /\* Early abort? *\/ */ -/* if (c->count == 0) error("Empty cell !"); */ - -/* if (!c->split) error("Cell is not split !"); */ - -/* #endif */ - -/* /\* Get local copies of the particle data. *\/ */ -/* if (parts == NULL) { */ -/* int count = leaf->count; */ -/* if ((parts = */ -/* (struct part_local *)malloc(sizeof(struct part_local) * count)) == */ -/* NULL) */ -/* error("Failed to allocate local parts."); */ -/* for (int k = 0; k < count; k++) { */ -/* for (int j = 0; j < 3; j++) { */ -/* parts[k].x[j] = leaf->parts[k].x[j] - leaf->loc[j]; */ -/* parts[k].a[j] = 0.0f; */ -/* } */ -/* parts[k].mass = leaf->parts[k].mass; */ -/* } */ -/* collect_part_data = 1; */ -/* } */ - -/* /\* Find in which subcell of c the leaf is *\/ */ -/* for (cp = c->firstchild; cp != c->sibling; cp = cp->sibling) { */ - -/* /\* Only recurse if the leaf is in this part of the tree *\/ */ -/* if (is_inside(leaf, cp)) break; */ -/* } */ - -/* if (cp->split) { */ - -/* /\* Recurse if the cell can be split *\/ */ -/* iact_self_pc(cp, leaf, parts); */ - -/* /\* Now, interact with every other subcell *\/ */ -/* for (cps = c->firstchild; cps != c->sibling; cps = cps->sibling) { */ - -/* /\* Since cp and cps will be direct neighbours it is only worth recursing */ -/* *\/ */ -/* /\* if the cells can both be split *\/ */ -/* if (cp != cps && cps->split) */ -/* iact_pair_pc(cp, cps, leaf, parts, leaf->count, leaf->loc); */ -/* } */ -/* } */ - -/* /\* Clean up local parts? *\/ */ -/* if (collect_part_data) { */ -/* for (int k = 0; k < leaf->count; k++) { */ -/* for (int j = 0; j < 3; j++) leaf->parts[k].a[j] += parts[k].a[j]; */ -/* } */ -/* free(parts); */ -/* } */ -/* } */ - static inline void iact_pair_pc(struct cell *ci, struct cell *cj) { +#ifdef SANITY_CHECKS + if (ci->h != cj->h) + error(" Cells of different size in distance calculation."); +#endif + make_interact_pc(ci->parts, ci->count, ci->loc, cj); make_interact_pc(cj->parts, cj->count, cj->loc, ci); @@ -956,18 +783,6 @@ void create_tasks(struct qsched *s, struct cell *ci, struct cell *cj) { #endif -/* /\* Create the other task. *\/ */ -/* data[1] = ci; */ -/* data[0] = cj; */ -/* tid = qsched_addtask(s, task_type_pair_pc, task_flag_none, data, */ -/* sizeof(struct cell *) * 2, cj->count); */ - -/* /\* Add the resource and dependance *\/ */ -/* qsched_addlock(s, tid, cj->res); */ -/* #ifdef COM_AS_TASK */ -/* qsched_addunlock(s, ci->com_tid, tid); */ -/* #endif */ - } else {/* Cells are direct neighbours */ /* Are both cells split and we are above the task limit ? */ @@ -1414,13 +1229,8 @@ void test_bh(int N, int nr_threads, int runs, char *fileName) { // fprintf(fileTime, "%lli %e\n", toc_run - tic, (float)(toc_run - tic)); } -// fclose(fileTime); + // fclose(fileTime); -/* #if ICHECK >= 0 */ -/* message("[check] accel of part %i is [%.3e,%.3e,%.3e]", ICHECK, */ -/* root->parts[ICHECK].a_legacy[0], root->parts[ICHECK].a_legacy[1], */ -/* root->parts[ICHECK].a_legacy[2]); */ -/* #endif */ printf("task counts: [ %10s %10s %10s %10s %10s ]\n", "self", "pair", "m-poles", "direct", "CoMs"); printf("task counts: [ %10i %10i %10i %10i %10i ] (legacy).\n", 0, 0,