Skip to content
Snippets Groups Projects
Commit 0f7a2dde authored by James Willis's avatar James Willis
Browse files

Tidied up includes and now only the space is passed to fof_naive() and fof_serial().

parent d3b4cb1f
Branches
Tags
1 merge request!543Fof
......@@ -4200,12 +4200,16 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
message("Performing Friends Of Friends search.");
const double l_x = 0.2 * (s->dim[0] / pow(s->nr_gparts, 1./3.));
const double l_x2 = l_x * l_x;
s->l_x2 = l_x2;
ticks tic = getticks();
fof_search_naive(e);
fof_search_naive(s);
message("Naive FOF search took: %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit());
tic = getticks();
fof_search_serial(e);
fof_search_serial(s);
message("Serial FOF search took: %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit());
tic = getticks();
......
......@@ -26,13 +26,38 @@
/* Local headers. */
//#include "active.h"
void fof_search_naive(struct engine *e) {
__attribute__((always_inline)) INLINE int fof_find(const int i, const int *pid) {
int root = i;
while(root != pid[root])
root = pid[root];
const size_t nr_gparts = e->s->nr_gparts;
struct gpart *gparts = e->s->gparts;
const double dim[3] = {e->s->dim[0], e->s->dim[1], e->s->dim[2]};
const double l_x = 0.2 * (dim[0] / pow(nr_gparts, 1./3.));
const double l_x2 = l_x * l_x;
return root;
}
__attribute__((always_inline)) INLINE int fof_find_path_comp(const int i, int *pid) {
int root = i;
while(root != pid[root])
root = pid[root];
/* Perform path compression. */
int index = i;
while(index != root) {
int next = pid[index];
pid[index] = root;
index = next;
}
return root;
}
void fof_search_naive(struct space *s) {
const size_t nr_gparts = s->nr_gparts;
struct gpart *gparts = s->gparts;
const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
const double l_x2 = s->l_x2;
int *pid;
int *num_in_groups;
int num_groups = nr_gparts;
......@@ -117,39 +142,12 @@ void fof_search_naive(struct engine *e) {
free(num_in_groups);
}
__attribute__((always_inline)) INLINE int fof_find(const int i, const int *pid) {
int root = i;
while(root != pid[root])
root = pid[root];
return root;
}
__attribute__((always_inline)) INLINE int fof_find_path_comp(const int i, int *pid) {
int root = i;
while(root != pid[root])
root = pid[root];
/* Perform path compression. */
int index = i;
while(index != root) {
int next = pid[index];
pid[index] = root;
index = next;
}
return root;
}
void fof_search_serial(struct engine *e) {
void fof_search_serial(struct space *s) {
const size_t nr_gparts = e->s->nr_gparts;
struct gpart *gparts = e->s->gparts;
const double dim[3] = {e->s->dim[0], e->s->dim[1], e->s->dim[2]};
const double l_x = 0.2 * (dim[0] / pow(nr_gparts, 1./3.));
const double l_x2 = l_x * l_x;
const size_t nr_gparts = s->nr_gparts;
struct gpart *gparts = s->gparts;
const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
const double l_x2 = s->l_x2;
int *pid;
int *num_in_groups;
int num_groups = nr_gparts;
......
......@@ -24,18 +24,12 @@
#include "../config.h"
/* Local headers */
//#include "active.h"
//#include "cell.h"
#include "engine.h"
//#include "hydro.h"
//#include "part.h"
//#include "runner.h"
//#include "timers.h"
//#include "vector.h"
#include "space.h"
#include "cell.h"
/* Function prototypes. */
void fof_search_naive(struct engine *e);
void fof_search_serial(struct engine *e);
void fof_search_naive(struct space *s);
void fof_search_serial(struct space *s);
void fof_search_cell(struct space *s, struct cell *c, int *pid, int *num_in_groups, int *num_groups);
void fof_search_pair_cells(struct space *s, struct cell *ci, struct cell *cj, int *pid, int *num_in_groups, int *num_groups);
void fof_search_tree_serial(struct space *s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment