Skip to content
Snippets Groups Projects
Commit d7e1dbef authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Google style formatting

parent d4ad8e44
No related branches found
No related tags found
1 merge request!64Agreed upon version of the density vectorization test
...@@ -19,20 +19,17 @@ ...@@ -19,20 +19,17 @@
* *
******************************************************************************/ ******************************************************************************/
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include "error.h" #include "error.h"
#include "part.h" #include "part.h"
#include "cell.h" #include "cell.h"
#include "tools.h" #include "tools.h"
#include "swift.h" #include "swift.h"
/** /**
* Factorize a given integer, attempts to keep larger pair of factors. * Factorize a given integer, attempts to keep larger pair of factors.
*/ */
...@@ -50,8 +47,6 @@ void factor(int value, int *f1, int *f2) { ...@@ -50,8 +47,6 @@ void factor(int value, int *f1, int *f2) {
} }
} }
/** /**
* @brief Compute the average number of pairs per particle using * @brief Compute the average number of pairs per particle using
* a brute-force O(N^2) computation. * a brute-force O(N^2) computation.
...@@ -181,24 +176,22 @@ void pairs_single_density(double *dim, long long int pid, ...@@ -181,24 +176,22 @@ void pairs_single_density(double *dim, long long int pid,
fflush(stdout); fflush(stdout);
} }
void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
float r2, hi, hj, hig2, hjg2, dx[3]; float r2, hi, hj, hig2, hjg2, dx[3];
struct part *pi, *pj; struct part *pi, *pj;
/* Implements a double-for loop and checks every interaction */ /* Implements a double-for loop and checks every interaction */
for( int i=0; i<ci->count; ++i) { for (int i = 0; i < ci->count; ++i) {
pi = &ci->parts[i]; pi = &ci->parts[i];
hi = pi->h; hi = pi->h;
hig2 = hi * hi * kernel_gamma2; hig2 = hi * hi * kernel_gamma2;
for(int j=0; j<cj->count; ++j) { for (int j = 0; j < cj->count; ++j) {
pj = &cj->parts[j]; pj = &cj->parts[j];
/* Pairwise distance */ /* Pairwise distance */
r2 = 0.0f; r2 = 0.0f;
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
...@@ -209,28 +202,29 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { ...@@ -209,28 +202,29 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Hit or miss? */ /* Hit or miss? */
if (r2 < hig2) { if (r2 < hig2) {
//message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, pi->rho); // message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass,
// pi->rho);
/* Interact */
runner_iact_nonsym_density(r2, dx, hi, pj->h, pi, pj);
//message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, pi->rho); /* Interact */
} runner_iact_nonsym_density(r2, dx, hi, pj->h, pi, pj);
// message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass,
// pi->rho);
}
} }
} }
/* Reverse double-for loop and checks every interaction */ /* Reverse double-for loop and checks every interaction */
for( int j=0; j<cj->count; ++j) { for (int j = 0; j < cj->count; ++j) {
pj = &cj->parts[j]; pj = &cj->parts[j];
hj = pj->h; hj = pj->h;
hjg2 = hj * hj * kernel_gamma2; hjg2 = hj * hj * kernel_gamma2;
for(int i=0; i<ci->count; ++i) { for (int i = 0; i < ci->count; ++i) {
pi = &ci->parts[i]; pi = &ci->parts[i];
/* Pairwise distance */ /* Pairwise distance */
r2 = 0.0f; r2 = 0.0f;
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
...@@ -241,18 +235,13 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { ...@@ -241,18 +235,13 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Hit or miss? */ /* Hit or miss? */
if (r2 < hjg2) { if (r2 < hjg2) {
/* Interact */ /* Interact */
runner_iact_nonsym_density(r2, dx, hj, pi->h, pj, pi); runner_iact_nonsym_density(r2, dx, hj, pi->h, pj, pi);
}
}
} }
} }
} }
void pairs_single_grav(double *dim, long long int pid, void pairs_single_grav(double *dim, long long int pid,
struct gpart *__restrict__ parts, int N, int periodic) { struct gpart *__restrict__ parts, int N, int periodic) {
...@@ -307,7 +296,6 @@ void pairs_single_grav(double *dim, long long int pid, ...@@ -307,7 +296,6 @@ void pairs_single_grav(double *dim, long long int pid,
pi.part->id, a[0], a[1], a[2], aabs[0], aabs[1], aabs[2]); pi.part->id, a[0], a[1], a[2], aabs[0], aabs[1], aabs[2]);
} }
/** /**
* @brief Test the density function by dumping it for two random parts. * @brief Test the density function by dumping it for two random parts.
* *
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#ifndef SWIFT_TOOL_H #ifndef SWIFT_TOOL_H
#define SWIFT_TOOL_H #define SWIFT_TOOL_H
#include "runner.h" #include "runner.h"
#include "cell.h" #include "cell.h"
...@@ -38,5 +37,4 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj); ...@@ -38,5 +37,4 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj);
void pairs_n2(double *dim, struct part *__restrict__ parts, int N, void pairs_n2(double *dim, struct part *__restrict__ parts, int N,
int periodic); int periodic);
#endif /* SWIFT_TOOL_H */ #endif /* SWIFT_TOOL_H */
...@@ -20,7 +20,6 @@ struct cell *make_cell(size_t n, double *offset, double h, ...@@ -20,7 +20,6 @@ struct cell *make_cell(size_t n, double *offset, double h,
error("couldn't allocate particles, no. of particles: %d", (int)count); error("couldn't allocate particles, no. of particles: %d", (int)count);
} }
part = cell->parts; part = cell->parts;
for (x = 0; x < n; ++x) { for (x = 0; x < n; ++x) {
for (y = 0; y < n; ++y) { for (y = 0; y < n; ++y) {
...@@ -182,7 +181,6 @@ int main(int argc, char *argv[]) { ...@@ -182,7 +181,6 @@ int main(int argc, char *argv[]) {
pairs_all_density(&runner, ci, cj); pairs_all_density(&runner, ci, cj);
dump_particle_fields("brute_force.dat", ci, cj); dump_particle_fields("brute_force.dat", ci, cj);
/* Clean things to make the sanitizer happy ... */ /* Clean things to make the sanitizer happy ... */
clean_up(ci); clean_up(ci);
clean_up(cj); clean_up(cj);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment