Commit a3c1f0f9 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Logger: strays implemented

parent 6e8bd998
......@@ -407,7 +407,6 @@ void engine_exchange_strays(struct engine *e, const size_t offset_parts,
size_t *Nbpart) {
#ifdef WITH_MPI
struct space *s = e->s;
ticks tic = getticks();
......@@ -455,8 +454,11 @@ void engine_exchange_strays(struct engine *e, const size_t offset_parts,
&s->xparts[offset_parts + k], 1);
#ifdef WITH_LOGGER
const int logger_flag = logger_generate_flag(
logger_flag_mpi | logger_flag_delete, node_id);
/* Log the particle when leaving a rank. */
logger_log_part(e->log, s->parts[offset_parts + k],
logger_log_part(e->logger, &s->parts[offset_parts + k],
logger_mask_data[logger_x].mask |
logger_mask_data[logger_v].mask |
logger_mask_data[logger_a].mask |
......@@ -465,8 +467,8 @@ void engine_exchange_strays(struct engine *e, const size_t offset_parts,
logger_mask_data[logger_rho].mask |
logger_mask_data[logger_consts].mask |
logger_mask_data[logger_special_flags].mask,
s->xparts[offset_parts + k].logger_data.last_offset,
logger_generate_flag(logger_flag_mpi, node_id));
&s->xparts[offset_parts + k].logger_data.last_offset,
logger_flag);
#endif
}
......@@ -505,14 +507,17 @@ void engine_exchange_strays(struct engine *e, const size_t offset_parts,
proxy_sparts_load(&e->proxies[pid], &s->sparts[offset_sparts + k], 1);
#ifdef WITH_LOGGER
/* Log the particle when leaving a rank. */
logger_log_spart(e->log, s->sparts[offset_sparts + k],
const int logger_flag = logger_generate_flag(
logger_flag_mpi | logger_flag_delete, node_id);
/* Log the particle when leaving a rank. */
logger_log_spart(e->logger, &s->sparts[offset_sparts + k],
logger_mask_data[logger_x].mask |
logger_mask_data[logger_v].mask |
logger_mask_data[logger_consts].mask |
logger_mask_data[logger_special_flags].mask,
s->sparts[offset_parts + k].logger_data.last_offset,
logger_generate_flag(logger_flag_mpi, node_id));
&s->sparts[offset_parts + k].logger_data.last_offset,
logger_flag);
#endif
}
......@@ -585,17 +590,20 @@ void engine_exchange_strays(struct engine *e, const size_t offset_parts,
#ifdef WITH_LOGGER
/* Write only the dark matter particles */
if (gp->type == swift_type_dark_matter) {
if (s->gparts[offset_gparts + k].type == swift_type_dark_matter) {
const int logger_flag = logger_generate_flag(
logger_flag_mpi | logger_flag_delete, node_id);
/* Log the particle when leaving a rank. */
logger_log_gpart(e->log, s->gparts[offset_gparts + k],
logger_log_gpart(e->logger, &s->gparts[offset_gparts + k],
logger_mask_data[logger_x].mask |
logger_mask_data[logger_v].mask |
logger_mask_data[logger_a].mask |
logger_mask_data[logger_consts].mask |
logger_mask_data[logger_special_flags].mask,
s->sparts[offset_parts + k].logger_data.last_offset,
logger_generate_flag(logger_flag_mpi, node_id));
&s->sparts[offset_parts + k].logger_data.last_offset,
logger_flag);
}
#endif
}
......@@ -819,7 +827,8 @@ void engine_exchange_strays(struct engine *e, const size_t offset_parts,
sizeof(struct bpart) * prox->nr_bparts_in);
#ifdef WITH_LOGGER
logger_log_recv_strays(e->log, &s->parts[offset_parts + count_parts], prox->nr_parts_in,
logger_log_recv_strays(e->logger, &s->parts[offset_parts + count_parts],
&s->xparts[offset_parts + count_parts], prox->nr_parts_in,
&s->gparts[offset_gparts + count_gparts], prox->nr_gparts_in,
&s->sparts[offset_sparts + count_sparts], prox->nr_sparts_in,
&s->bparts[offset_bparts + count_bparts], prox->nr_bparts_in,
......
......@@ -1039,9 +1039,9 @@ void engine_redistribute(struct engine *e) {
#ifdef WITH_LOGGER
/* Log the received particles */
logger_log_after_communcations(s->parts, s->nr_parts, counts,
s->gparts, s->nr_gparts, gcounts,
s->sparts, s->nr_sparts, scounts,
s->bparts, s->nr_bparts, bcounts);
s->gparts, s->nr_gparts, g_counts,
s->sparts, s->nr_sparts, s_counts,
s->bparts, s->nr_bparts, b_counts);
#endif
/* Restore the part<->gpart and spart<->gpart links.
......
......@@ -915,11 +915,62 @@ void logger_log_after_communcations(
*/
void logger_log_recv_strays(
struct logger_writer *log,
struct part *parts, size_t nr_parts, int *counts,
struct gpart *gparts, size_t nr_gparts, int *g_counts,
struct spart *sparts, size_t nr_sparts, int *s_counts,
struct bpart *bparts, size_t nr_bparts, int *b_counts) {
error("TODO");
struct part *parts, struct xpart *xparts, size_t nr_parts,
struct gpart *gparts, size_t nr_gparts,
struct spart *sparts, size_t nr_sparts,
struct bpart *bparts, size_t nr_bparts,
int node_id) {
const int flag = logger_generate_flag(logger_flag_mpi | logger_flag_create,
node_id);
/* Log the gas particles */
const unsigned int mask_hydro =
logger_mask_data[logger_x].mask | logger_mask_data[logger_v].mask |
logger_mask_data[logger_a].mask | logger_mask_data[logger_u].mask |
logger_mask_data[logger_h].mask | logger_mask_data[logger_rho].mask |
logger_mask_data[logger_consts].mask |
logger_mask_data[logger_special_flags].mask;
for(size_t i = 0; i < nr_parts; i++) {
logger_log_part(log, &parts[i], mask_hydro,
&xparts[i].logger_data.last_offset,
flag);
xparts[i].logger_data.steps_since_last_output = 0;
}
/* Log the stellar particles */
const unsigned int mask_stars = logger_mask_data[logger_x].mask |
logger_mask_data[logger_v].mask |
logger_mask_data[logger_consts].mask |
logger_mask_data[logger_special_flags].mask;
for(size_t i = 0; i < nr_sparts; i++) {
logger_log_spart(log, &sparts[i], mask_stars,
&sparts[i].logger_data.last_offset,
/* Special flags */ 0);
sparts[i].logger_data.steps_since_last_output = 0;
}
/* Log the gparts */
const unsigned int mask_grav =
logger_mask_data[logger_x].mask | logger_mask_data[logger_v].mask |
logger_mask_data[logger_a].mask | logger_mask_data[logger_consts].mask |
logger_mask_data[logger_special_flags].mask;
for(size_t i = 0; i < nr_gparts; i++) {
/* Log only the dark matter */
if (gparts[i].type != swift_type_dark_matter) continue;
logger_log_gpart(log, &gparts[i], mask_grav,
&gparts[i].logger_data.last_offset,
/* Special flags */ 0);
gparts[i].logger_data.steps_since_last_output = 0;
}
/* Log the bparts */
if (nr_bparts > 0) {
error("TODO");
}
}
#endif
......@@ -935,6 +986,9 @@ void logger_struct_dump(const struct logger_writer *log, FILE *stream) {
"logger", "logger");
}
// TODO remove that
void dump_restart(struct dump *dump, char *log_name, int size) {}
/**
* @brief Restore a logger struct from the given FILE as a stream of
* bytes.
......
......@@ -38,7 +38,7 @@ struct part;
struct engine;
#define logger_major_version 0
#define logger_minor_version 2
#define logger_minor_version 3
/**
* Logger entries contain messages representing the particle data at a given
......@@ -95,8 +95,10 @@ enum logger_masks_number {
} __attribute__((packed));
enum logger_special_flags {
logger_flag_change_type = 0,
logger_flag_mpi = 1,
logger_flag_change_type = 1 << 0, /* Flag for a change of particle type */
logger_flag_mpi = 1 << 1, /* Flag for a change of MPI rank */
logger_flag_delete = 1 << 2, /* Flag for a deleted particle */
logger_flag_create = 1 << 3 /* Flag for a created particle */
} __attribute__((packed));
struct mask_data {
......@@ -185,7 +187,7 @@ void logger_struct_dump(const struct logger_writer *log, FILE *stream);
void logger_struct_restore(struct logger_writer *log, FILE *stream);
int logger_generate_flag(enum logger_special_flags flag, int data) {
INLINE static int logger_generate_flag(enum logger_special_flags flag, int data) {
#ifdef SWIFT_DEBUG_CHECKS
if (flag & 0xFFFFFF00) {
error("The special flag in the logger cannot be larger than 1 byte.");
......@@ -206,6 +208,15 @@ void logger_log_after_communcations(
struct gpart *gparts, size_t nr_gparts, int *g_counts,
struct spart *sparts, size_t nr_sparts, int *s_counts,
struct bpart *bparts, size_t nr_bparts, int *b_counts);
void logger_log_recv_strays(
struct logger_writer *log,
struct part *parts, struct xpart *xparts, size_t nr_parts,
struct gpart *gparts, size_t nr_gparts,
struct spart *sparts, size_t nr_sparts,
struct bpart *bparts, size_t nr_bparts,
int node_id);
#endif
/**
......
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