Commit b6e8d2b6 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

lock_type --> swift_lock_type

parent 21aef1a0
......@@ -431,10 +431,6 @@ int main(int argc, char *argv[]) {
/* Write the state of the system before starting time integration. */
if (!dry_run) engine_dump_snapshot(&e);
/* Now that everything is ready, no need for the parameters any more */
free(params);
params = NULL;
/* Init the runner history. */
#ifdef HIST
for (k = 0; k < runner_hist_N; k++) runner_hist_bins[k] = 0;
......
......@@ -136,7 +136,7 @@ struct cell {
int hold, ghold;
/* Spin lock for various uses. */
lock_type lock, glock;
swift_lock_type lock, glock;
/* ID of the previous owner, e.g. runner. */
int owner;
......
......@@ -1997,7 +1997,7 @@ void engine_step(struct engine *e) {
clocks_gettime(&time1);
e->tic_step = getticks();
/* Collect the cell data. */
for (int k = 0; k < s->nr_cells; k++)
if (s->cells[k].nodeID == e->nodeID) {
......@@ -2505,6 +2505,7 @@ void engine_init(struct engine *e, struct space *s,
e->physical_constants = physical_constants;
e->hydro_properties = hydro;
e->external_potential = potential;
e->parameter_file = params;
engine_rank = nodeID;
/* Make the space link back to the engine. */
......@@ -2555,7 +2556,7 @@ void engine_init(struct engine *e, struct space *s,
if (nodeID == 0) message("prefer NUMA-distant CPUs");
/* Get list of numa nodes of all available cores. */
int *nodes = malloc( nr_affinity_cores * sizeof(int));
int *nodes = malloc(nr_affinity_cores * sizeof(int));
int nnodes = 0;
for (int i = 0; i < nr_affinity_cores; i++) {
nodes[i] = numa_node_of_cpu(cpuid[i]);
......@@ -2564,7 +2565,7 @@ void engine_init(struct engine *e, struct space *s,
nnodes += 1;
/* Count cores per node. */
int *core_counts = malloc( nnodes * sizeof(int));
int *core_counts = malloc(nnodes * sizeof(int));
for (int i = 0; i < nr_affinity_cores; i++) {
core_counts[nodes[i]] = 0;
}
......@@ -2573,7 +2574,7 @@ void engine_init(struct engine *e, struct space *s,
}
/* Index cores within each node. */
int *core_indices = malloc( nr_affinity_cores * sizeof(int));
int *core_indices = malloc(nr_affinity_cores * sizeof(int));
for (int i = nr_affinity_cores - 1; i >= 0; i--) {
core_indices[i] = core_counts[nodes[i]];
core_counts[nodes[i]] -= 1;
......@@ -2585,13 +2586,13 @@ void engine_init(struct engine *e, struct space *s,
while (!done) {
done = 1;
for (int i = 1; i < nr_affinity_cores; i++) {
if ( core_indices[i] < core_indices[i-1] ) {
int t = cpuid[i-1];
cpuid[i-1] = cpuid[i];
if (core_indices[i] < core_indices[i - 1]) {
int t = cpuid[i - 1];
cpuid[i - 1] = cpuid[i];
cpuid[i] = t;
t = core_indices[i-1];
core_indices[i-1] = core_indices[i];
t = core_indices[i - 1];
core_indices[i - 1] = core_indices[i];
core_indices[i] = t;
done = 0;
}
......@@ -2604,11 +2605,10 @@ void engine_init(struct engine *e, struct space *s,
}
}
#endif
}
else {
} else {
if (nodeID == 0) message("no processor affinity used");
}/* with_aff */
} /* with_aff */
/* Avoid (unexpected) interference between engine and runner threads. We can
* do this once we've made at least one call to engine_entry_affinity and
......@@ -2771,7 +2771,8 @@ void engine_init(struct engine *e, struct space *s,
error("Failed to create runner thread.");
/* Try to pin the runner to a given core */
if (with_aff && (e->policy & engine_policy_setaffinity) == engine_policy_setaffinity) {
if (with_aff &&
(e->policy & engine_policy_setaffinity) == engine_policy_setaffinity) {
#if defined(HAVE_SETAFFINITY)
/* Set a reasonable queue ID. */
......@@ -2800,7 +2801,7 @@ void engine_init(struct engine *e, struct space *s,
e->runners[k].qid = k * nr_queues / e->nr_threads;
}
if (verbose) {
if (with_aff)
if (with_aff)
message("runner %i on cpuid=%i with qid=%i.", e->runners[k].id,
e->runners[k].cpuid, e->runners[k].qid);
else
......
......@@ -189,6 +189,9 @@ struct engine {
/* Properties of external gravitational potential */
const struct external_potential *external_potential;
/* The (parsed) parameter file */
const struct swift_params *parameter_file;
};
/* Function prototypes. */
......@@ -197,7 +200,7 @@ void engine_compute_next_snapshot_time(struct engine *e);
void engine_dump_snapshot(struct engine *e);
void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, int nr_nodes, int nodeID,
int nr_threads, int with_aff, int policy, int verbose,
int nr_threads, int with_aff, int policy, int verbose,
const struct phys_const *physical_constants,
const struct hydro_props *hydro,
const struct external_potential *potential);
......
......@@ -27,7 +27,7 @@
#ifdef PTHREAD_SPINLOCK
#include <pthread.h>
#define lock_type pthread_spinlock_t
#define swift_lock_type pthread_spinlock_t
#define lock_init(l) (pthread_spin_init(l, PTHREAD_PROCESS_PRIVATE) != 0)
#define lock_destroy(l) (pthread_spin_destroy(l) != 0)
#define lock_lock(l) (pthread_spin_lock(l) != 0)
......@@ -36,7 +36,7 @@
#define lock_unlock_blind(l) pthread_spin_unlock(l)
#elif defined(PTHREAD_LOCK)
#include <pthread.h>
#define lock_type pthread_mutex_t
#define swift_lock_type pthread_mutex_t
#define lock_init(l) (pthread_mutex_init(l, NULL) != 0)
#define lock_destroy(l) (pthread_mutex_destroy(l) != 0)
#define lock_lock(l) (pthread_mutex_lock(l) != 0)
......@@ -44,7 +44,7 @@
#define lock_unlock(l) (pthread_mutex_unlock(l) != 0)
#define lock_unlock_blind(l) pthread_mutex_unlock(l)
#else
#define lock_type volatile int
#define swift_lock_type volatile int
#define lock_init(l) (*(l) = 0)
#define lock_destroy(l) 0
INLINE static int lock_lock(volatile int *l) {
......
......@@ -303,7 +303,7 @@ static void parse_value(char *line, struct swift_params *params) {
strcpy(params->data[params->paramCount].value, token);
if (params->paramCount == PARSER_MAX_NO_OF_PARAMS - 1) {
error(
"MMaximal number of parameters in parameter file reached. Aborting "
"Maximal number of parameters in parameter file reached. Aborting "
"!");
} else {
params->paramCount++;
......@@ -361,8 +361,7 @@ static void parse_section_param(char *line, int *isFirstParam,
strcpy(params->data[params->paramCount].name, paramName);
strcpy(params->data[params->paramCount].value, token);
if (params->paramCount == PARSER_MAX_NO_OF_PARAMS - 1) {
error(
"MMaximal number of parameters in parameter file reached. Aborting !");
error("Maximal number of parameters in parameter file reached. Aborting !");
} else {
params->paramCount++;
}
......
......@@ -22,6 +22,10 @@
/* Config parameters. */
#include "../config.h"
#if defined(HAVE_HDF5)
#include <hdf5.h>
#endif
/* Some constants. */
#define PARSER_MAX_LINE_SIZE 256
#define PARSER_MAX_NO_OF_PARAMS 256
......@@ -60,4 +64,8 @@ double parser_get_param_double(const struct swift_params *params,
void parser_get_param_string(const struct swift_params *params,
const char *name, char *retParam);
#if defined(HAVE_HDF5)
void parser_write_params_to_hdf5(const struct swift_params *params, hid_t grp);
#endif
#endif /* SWIFT_PARSER_H */
......@@ -133,7 +133,7 @@ void queue_init(struct queue *q, struct task *tasks) {
struct task *queue_gettask(struct queue *q, const struct task *prev,
int blocking) {
lock_type *qlock = &q->lock;
swift_lock_type *qlock = &q->lock;
struct task *res = NULL;
/* Grab the task lock. */
......
......@@ -41,7 +41,7 @@ extern int queue_counter[queue_counter_count];
struct queue {
/* The lock to access this queue. */
lock_type lock;
swift_lock_type lock;
/* Size, count and next element. */
int size, count;
......
......@@ -89,7 +89,7 @@ struct scheduler {
int nr_unlocks, size_unlocks;
/* Lock for this scheduler. */
lock_type lock;
swift_lock_type lock;
/* Waiting queue. */
pthread_mutex_t sleep_mutex;
......
......@@ -562,6 +562,12 @@ void write_output_single(struct engine* e, const char* baseName,
writeSPHflavour(h_grp);
H5Gclose(h_grp);
/* Print the runtime parameters */
h_grp = H5Gcreate(h_file, "/Parameters", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (h_grp < 0) error("Error while creating parameters group");
parser_write_params_to_hdf5(e->parameter_file, h_grp);
H5Gclose(h_grp);
/* Print the system of Units */
writeUnitSystem(h_file, us);
......
......@@ -97,7 +97,7 @@ struct space {
int periodic;
/* General-purpose lock for this space. */
lock_type lock;
swift_lock_type lock;
/* Number of queues in the system. */
int nr_queues;
......
......@@ -77,7 +77,7 @@ struct task {
char skip, tight, implicit;
int flags, wait, rank, weight;
lock_type lock;
swift_lock_type lock;
struct cell *ci, *cj;
......
Supports Markdown
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