diff --git a/tests/test125cells.c b/tests/test125cells.c index affbdf306743f7d0f1b46eb0a05a93a0bcc6a3a1..128c36480fb36723b713a0b3e98e8bdd83fc9559 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -464,7 +464,6 @@ void runner_dopair1_branch_gradient(struct runner *r, struct cell *ci, int limit_h_max); void runner_doself1_branch_gradient(struct runner *r, struct cell *ci, int limit_h_min, int limit_h_max); - #endif /* EXTRA_HYDRO_LOOP_TYPE2 */ #endif /* EXTRA_HYDRO LOOP */ void runner_dopair2_branch_force(struct runner *r, struct cell *ci, @@ -692,7 +691,7 @@ int main(int argc, char *argv[]) { for (int j = 0; j < 125; ++j) runner_do_hydro_sort(&runner, cells[j], 0x1FFF, 0, 0, 0, 0); - /* Do the density calculation */ + /* Do the density calculation */ /* Initialise the particle cache. */ #ifdef WITH_VECTORIZATION @@ -783,246 +782,245 @@ int main(int argc, char *argv[]) { } } } + } - /* And now the self-interaction for the central cells */ - for (int j = 0; j < 27; ++j) { + /* And now the self-interaction for the central cells */ + for (int j = 0; j < 27; ++j) { #ifdef EXTRA_HYDRO_LOOP_TYPE2 - runner_doself2_branch_gradient(&runner, inner_cells[j], - /*limit_h_min=*/0, - /*limit_h_max=*/0); + runner_doself2_branch_gradient(&runner, inner_cells[j], /*limit_h_min=*/0, + /*limit_h_max=*/0); #else - runner_doself1_branch_gradient(&runner, inner_cells[j], - /*limit_h_min=*/0, - /*limit_h_max=*/0); + runner_doself1_branch_gradient(&runner, inner_cells[j], /*limit_h_min=*/0, + /*limit_h_max=*/0); #endif - } + } - /* Extra ghost to finish everything on the central cells */ - for (int j = 0; j < 27; ++j) - runner_do_extra_ghost(&runner, inner_cells[j], 0); + /* Extra ghost to finish everything on the central cells */ + for (int j = 0; j < 27; ++j) + runner_do_extra_ghost(&runner, inner_cells[j], 0); #endif /* EXTRA_HYDRO_LOOP */ /* Do the force calculation */ #ifdef WITH_VECTORIZATION - /* Initialise the cache. */ - cache_clean(&runner.ci_cache); - cache_clean(&runner.cj_cache); - cache_init(&runner.ci_cache, 512); - cache_init(&runner.cj_cache, 512); + /* Initialise the cache. */ + cache_clean(&runner.ci_cache); + cache_clean(&runner.cj_cache); + cache_init(&runner.ci_cache, 512); + cache_init(&runner.cj_cache, 512); #endif - int ctr = 0; - /* Do the pairs (for the central 27 cells) */ - for (int i = 1; i < 4; i++) { - for (int j = 1; j < 4; j++) { - for (int k = 1; k < 4; k++) { + int ctr = 0; + /* Do the pairs (for the central 27 cells) */ + for (int i = 1; i < 4; i++) { + for (int j = 1; j < 4; j++) { + for (int k = 1; k < 4; k++) { - struct cell *cj = cells[i * 25 + j * 5 + k]; + struct cell *cj = cells[i * 25 + j * 5 + k]; - if (main_cell != cj) { + if (main_cell != cj) { - const ticks sub_tic = getticks(); + const ticks sub_tic = getticks(); - runner_dopair2_branch_force(&runner, main_cell, cj, - /*limit_h_min=*/0, /*limit_h_max=*/0); + runner_dopair2_branch_force(&runner, main_cell, cj, + /*limit_h_min=*/0, /*limit_h_max=*/0); - timings[ctr++] += getticks() - sub_tic; - } + timings[ctr++] += getticks() - sub_tic; } } } + } - ticks self_tic = getticks(); + ticks self_tic = getticks(); - /* And now the self-interaction for the main cell */ - runner_doself2_branch_force(&runner, main_cell, /*limit_h_min=*/0, - /*limit_h_max=*/0); + /* And now the self-interaction for the main cell */ + runner_doself2_branch_force(&runner, main_cell, /*limit_h_min=*/0, + /*limit_h_max=*/0); - timings[26] += getticks() - self_tic; + timings[26] += getticks() - self_tic; - /* Finally, give a gentle kick */ - runner_do_end_hydro_force(&runner, main_cell, 0); - const ticks toc = getticks(); - time += toc - tic; + /* Finally, give a gentle kick */ + runner_do_end_hydro_force(&runner, main_cell, 0); + const ticks toc = getticks(); + time += toc - tic; - /* Dump if necessary */ - if (n == 0) { - sprintf(outputFileName, "swift_dopair_125_%.150s.dat", - outputFileNameExtension); - dump_particle_fields(outputFileName, main_cell, solution, 0); - } + /* Dump if necessary */ + if (n == 0) { + sprintf(outputFileName, "swift_dopair_125_%.150s.dat", + outputFileNameExtension); + dump_particle_fields(outputFileName, main_cell, solution, 0); + } - for (int i = 0; i < 125; ++i) { - for (int pid = 0; pid < cells[i]->hydro.count; ++pid) { - hydro_init_part(&cells[i]->hydro.parts[pid], &space.hs); - adaptive_softening_init_part(&cells[i]->hydro.parts[pid]); - mhd_init_part(&cells[i]->hydro.parts[pid]); - } + for (int i = 0; i < 125; ++i) { + for (int pid = 0; pid < cells[i]->hydro.count; ++pid) { + hydro_init_part(&cells[i]->hydro.parts[pid], &space.hs); + adaptive_softening_init_part(&cells[i]->hydro.parts[pid]); + mhd_init_part(&cells[i]->hydro.parts[pid]); } } + } - /* Output timing */ - ticks corner_time = timings[0] + timings[2] + timings[6] + timings[8] + - timings[17] + timings[19] + timings[23] + timings[25]; + /* Output timing */ + ticks corner_time = timings[0] + timings[2] + timings[6] + timings[8] + + timings[17] + timings[19] + timings[23] + timings[25]; - ticks edge_time = timings[1] + timings[3] + timings[5] + timings[7] + - timings[9] + timings[11] + timings[14] + timings[16] + - timings[18] + timings[20] + timings[22] + timings[24]; + ticks edge_time = timings[1] + timings[3] + timings[5] + timings[7] + + timings[9] + timings[11] + timings[14] + timings[16] + + timings[18] + timings[20] + timings[22] + timings[24]; - ticks face_time = timings[4] + timings[10] + timings[12] + timings[13] + - timings[15] + timings[21]; + ticks face_time = timings[4] + timings[10] + timings[12] + timings[13] + + timings[15] + timings[21]; - ticks self_time = timings[26]; + ticks self_time = timings[26]; - message("Corner calculations took: %.3f %s.", - clocks_from_ticks(corner_time / runs), clocks_getunit()); - message("Edge calculations took: %.3f %s.", - clocks_from_ticks(edge_time / runs), clocks_getunit()); - message("Face calculations took: %.3f %s.", - clocks_from_ticks(face_time / runs), clocks_getunit()); - message("Self calculations took: %.3f %s.", - clocks_from_ticks(self_time / runs), clocks_getunit()); - message("SWIFT calculation took: %.3f %s.", - clocks_from_ticks(time / runs), clocks_getunit()); + message("Corner calculations took: %.3f %s.", + clocks_from_ticks(corner_time / runs), clocks_getunit()); + message("Edge calculations took: %.3f %s.", + clocks_from_ticks(edge_time / runs), clocks_getunit()); + message("Face calculations took: %.3f %s.", + clocks_from_ticks(face_time / runs), clocks_getunit()); + message("Self calculations took: %.3f %s.", + clocks_from_ticks(self_time / runs), clocks_getunit()); + message("SWIFT calculation took: %.3f %s.", + clocks_from_ticks(time / runs), clocks_getunit()); - for (int j = 0; j < 125; ++j) - reset_particles(cells[j], &space.hs, vel, press, size, rho); + for (int j = 0; j < 125; ++j) + reset_particles(cells[j], &space.hs, vel, press, size, rho); - /* NOW BRUTE-FORCE CALCULATION */ + /* NOW BRUTE-FORCE CALCULATION */ - const ticks tic = getticks(); + const ticks tic = getticks(); - /* Kick the central cell */ - // runner_do_kick1(&runner, main_cell, 0); + /* Kick the central cell */ + // runner_do_kick1(&runner, main_cell, 0); - /* And drift it */ - // runner_do_drift_particles(&runner, main_cell, 0); + /* And drift it */ + // runner_do_drift_particles(&runner, main_cell, 0); - /* Initialise the particles */ - // for (int j = 0; j < 125; ++j) runner_do_drift_particles(&runner, - // cells[j], 0); + /* Initialise the particles */ + // for (int j = 0; j < 125; ++j) runner_do_drift_particles(&runner, cells[j], + // 0); - /* Do the density calculation */ + /* Do the density calculation */ - /* Run all the pairs (only once !)*/ - for (int i = 0; i < 5; i++) { - for (int j = 0; j < 5; j++) { - for (int k = 0; k < 5; k++) { + /* Run all the pairs (only once !)*/ + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + for (int k = 0; k < 5; k++) { - struct cell *ci = cells[i * 25 + j * 5 + k]; + struct cell *ci = cells[i * 25 + j * 5 + k]; - for (int ii = -1; ii < 2; ii++) { - int iii = i + ii; - if (iii < 0 || iii >= 5) continue; - iii = (iii + 5) % 5; - for (int jj = -1; jj < 2; jj++) { - int jjj = j + jj; - if (jjj < 0 || jjj >= 5) continue; - jjj = (jjj + 5) % 5; - for (int kk = -1; kk < 2; kk++) { - int kkk = k + kk; - if (kkk < 0 || kkk >= 5) continue; - kkk = (kkk + 5) % 5; + for (int ii = -1; ii < 2; ii++) { + int iii = i + ii; + if (iii < 0 || iii >= 5) continue; + iii = (iii + 5) % 5; + for (int jj = -1; jj < 2; jj++) { + int jjj = j + jj; + if (jjj < 0 || jjj >= 5) continue; + jjj = (jjj + 5) % 5; + for (int kk = -1; kk < 2; kk++) { + int kkk = k + kk; + if (kkk < 0 || kkk >= 5) continue; + kkk = (kkk + 5) % 5; - struct cell *cj = cells[iii * 25 + jjj * 5 + kkk]; + struct cell *cj = cells[iii * 25 + jjj * 5 + kkk]; - if (cj > ci) pairs_all_density(&runner, ci, cj); - } + if (cj > ci) pairs_all_density(&runner, ci, cj); } } } } } + } - /* And now the self-interaction for the central cells*/ - for (int j = 0; j < 27; ++j) self_all_density(&runner, inner_cells[j]); + /* And now the self-interaction for the central cells*/ + for (int j = 0; j < 27; ++j) self_all_density(&runner, inner_cells[j]); - /* Ghost to finish everything on the central cells */ - for (int j = 0; j < 27; ++j) runner_do_ghost(&runner, inner_cells[j], 0); + /* Ghost to finish everything on the central cells */ + for (int j = 0; j < 27; ++j) runner_do_ghost(&runner, inner_cells[j], 0); #ifdef EXTRA_HYDRO_LOOP - /* We need to do the gradient loop and the extra ghost! */ - - /* Run all the pairs (only once !)*/ - for (int i = 0; i < 5; i++) { - for (int j = 0; j < 5; j++) { - for (int k = 0; k < 5; k++) { - - struct cell *ci = cells[i * 25 + j * 5 + k]; - - for (int ii = -1; ii < 2; ii++) { - int iii = i + ii; - if (iii < 0 || iii >= 5) continue; - iii = (iii + 5) % 5; - for (int jj = -1; jj < 2; jj++) { - int jjj = j + jj; - if (jjj < 0 || jjj >= 5) continue; - jjj = (jjj + 5) % 5; - for (int kk = -1; kk < 2; kk++) { - int kkk = k + kk; - if (kkk < 0 || kkk >= 5) continue; - kkk = (kkk + 5) % 5; - - struct cell *cj = cells[iii * 25 + jjj * 5 + kkk]; - - if (cj > ci) pairs_all_gradient(&runner, ci, cj); - } + /* We need to do the gradient loop and the extra ghost! */ + + /* Run all the pairs (only once !)*/ + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + for (int k = 0; k < 5; k++) { + + struct cell *ci = cells[i * 25 + j * 5 + k]; + + for (int ii = -1; ii < 2; ii++) { + int iii = i + ii; + if (iii < 0 || iii >= 5) continue; + iii = (iii + 5) % 5; + for (int jj = -1; jj < 2; jj++) { + int jjj = j + jj; + if (jjj < 0 || jjj >= 5) continue; + jjj = (jjj + 5) % 5; + for (int kk = -1; kk < 2; kk++) { + int kkk = k + kk; + if (kkk < 0 || kkk >= 5) continue; + kkk = (kkk + 5) % 5; + + struct cell *cj = cells[iii * 25 + jjj * 5 + kkk]; + + if (cj > ci) pairs_all_gradient(&runner, ci, cj); } } } } } + } - /* And now the self-interaction for the central cells */ - for (int j = 0; j < 27; ++j) self_all_gradient(&runner, inner_cells[j]); + /* And now the self-interaction for the central cells */ + for (int j = 0; j < 27; ++j) self_all_gradient(&runner, inner_cells[j]); - /* Extra ghost to finish everything on the central cells */ - for (int j = 0; j < 27; ++j) - runner_do_extra_ghost(&runner, inner_cells[j], 0); + /* Extra ghost to finish everything on the central cells */ + for (int j = 0; j < 27; ++j) + runner_do_extra_ghost(&runner, inner_cells[j], 0); #endif /* EXTRA_HYDRO_LOOP */ - /* Do the force calculation */ + /* Do the force calculation */ - /* Do the pairs (for the central 27 cells) */ - for (int i = 1; i < 4; i++) { - for (int j = 1; j < 4; j++) { - for (int k = 1; k < 4; k++) { + /* Do the pairs (for the central 27 cells) */ + for (int i = 1; i < 4; i++) { + for (int j = 1; j < 4; j++) { + for (int k = 1; k < 4; k++) { - struct cell *cj = cells[i * 25 + j * 5 + k]; + struct cell *cj = cells[i * 25 + j * 5 + k]; - if (main_cell != cj) pairs_all_force(&runner, main_cell, cj); - } + if (main_cell != cj) pairs_all_force(&runner, main_cell, cj); } } + } - /* And now the self-interaction for the main cell */ - self_all_force(&runner, main_cell); + /* And now the self-interaction for the main cell */ + self_all_force(&runner, main_cell); - /* Finally, give a gentle kick */ - runner_do_end_hydro_force(&runner, main_cell, 0); - // runner_do_kick2(&runner, main_cell, 0); + /* Finally, give a gentle kick */ + runner_do_end_hydro_force(&runner, main_cell, 0); + // runner_do_kick2(&runner, main_cell, 0); - const ticks toc = getticks(); + const ticks toc = getticks(); - /* Output timing */ - message("Brute force calculation took : %.3f %s.", - clocks_from_ticks(toc - tic), clocks_getunit()); + /* Output timing */ + message("Brute force calculation took : %.3f %s.", + clocks_from_ticks(toc - tic), clocks_getunit()); - sprintf(outputFileName, "brute_force_125_%.150s.dat", - outputFileNameExtension); - dump_particle_fields(outputFileName, main_cell, solution, 0); + sprintf(outputFileName, "brute_force_125_%.150s.dat", + outputFileNameExtension); + dump_particle_fields(outputFileName, main_cell, solution, 0); - /* Clean things to make the sanitizer happy ... */ - for (int i = 0; i < 125; ++i) clean_up(cells[i]); - free(solution); + /* Clean things to make the sanitizer happy ... */ + for (int i = 0; i < 125; ++i) clean_up(cells[i]); + free(solution); #ifdef WITH_VECTORIZATION - cache_clean(&runner.ci_cache); - cache_clean(&runner.cj_cache); + cache_clean(&runner.ci_cache); + cache_clean(&runner.cj_cache); #endif - return 0; - } + return 0; +}