Commit b612671b authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

ran format.sh.

parent f4ed3b1c
......@@ -66,7 +66,7 @@ void dump_ensure(struct dump *d, size_t size) {
error("Failed to unmap %zi bytes of dump data (%s).", trunc_count,
strerror(errno));
}
/* Update the size and count. */
d->file_offset += trunc_count;
d->count -= trunc_count;
......@@ -103,7 +103,7 @@ void dump_close(struct dump *d) {
if (munmap(d->data, d->count) != 0) {
error("Failed to unmap dump data (%s).", strerror(errno));
}
/* Truncate the file to the correct length. */
if (ftruncate(d->fd, d->file_offset + d->count) != 0) {
error("Failed to truncate dump file (%s).", strerror(errno));
......@@ -132,7 +132,7 @@ void dump_init(struct dump *d, const char *filename, size_t size) {
/* Adjust the size to be at least the page size. */
const size_t page_mask = ~(sysconf(_SC_PAGE_SIZE) - 1);
size = (size + ~page_mask) & page_mask;
/* Pre-allocate the file size. */
if (posix_fallocate(d->fd, 0, size) != 0) {
error("Failed to pre-allocate the dump file.");
......
......@@ -32,22 +32,21 @@ struct dump {
/* The memory-mapped data of this dump. */
void *data;
/* The size of the memory-mapped data, in bytes. */
size_t size;
/* The number of bytes that have been dumped. */
size_t count;
/* The offset of the data within the current file. */
size_t file_offset;
/* The file with which this memory is associated. */
int fd;
/* Mask containing the significant bits for page addresses. */
size_t page_mask;
};
/* Function prototypes. */
......
......@@ -66,11 +66,19 @@
#include "timers.h"
#include "units.h"
const char *engine_policy_names[13] = {
"none", "rand", "steal", "keep",
"block", "fix_dt", "cpu_tight", "mpi",
"numa_affinity", "hydro", "self_gravity", "external_gravity",
"cosmology_integration"};
const char *engine_policy_names[13] = {"none",
"rand",
"steal",
"keep",
"block",
"fix_dt",
"cpu_tight",
"mpi",
"numa_affinity",
"hydro",
"self_gravity",
"external_gravity",
"cosmology_integration"};
/** The rank of the engine as a global variable (for messages). */
int engine_rank;
......
......@@ -201,7 +201,7 @@ struct engine {
/* Properties of external gravitational potential */
const struct external_potential *external_potential;
/* The (parsed) parameter file */
const struct swift_params *parameter_file;
};
......
......@@ -68,8 +68,8 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
struct task **unlocks_new;
int *unlock_ind_new;
const int size_unlocks_new = s->size_unlocks * 2;
if ((unlocks_new = (struct task **)malloc(
sizeof(struct task *) *size_unlocks_new)) == NULL ||
if ((unlocks_new = (struct task **)malloc(sizeof(struct task *) *
size_unlocks_new)) == NULL ||
(unlock_ind_new = (int *)malloc(sizeof(int) * size_unlocks_new)) ==
NULL)
error("Failed to re-allocate unlocks.");
......@@ -823,7 +823,8 @@ void scheduler_reset(struct scheduler *s, int size) {
if (s->tasks_ind != NULL) free(s->tasks_ind);
/* Allocate the new lists. */
if ((s->tasks = (struct task *)malloc(sizeof(struct task) *size)) == NULL ||
if ((s->tasks = (struct task *)malloc(sizeof(struct task) * size)) ==
NULL ||
(s->tasks_ind = (int *)malloc(sizeof(int) * size)) == NULL)
error("Failed to allocate task lists.");
}
......
......@@ -732,7 +732,8 @@ void space_parts_sort(struct space *s, int *ind, size_t N, int min, int max,
clocks_getunit());
}
void space_parts_sort_mapper(void *map_data, int num_elements, void *extra_data) {
void space_parts_sort_mapper(void *map_data, int num_elements,
void *extra_data) {
/* Unpack the mapping data. */
struct parallel_sort *sort_struct = (struct parallel_sort *)map_data;
......@@ -916,7 +917,8 @@ void space_gparts_sort(struct space *s, int *ind, size_t N, int min, int max,
clocks_getunit());
}
void space_gparts_sort_mapper(void *map_data, int num_elements, void *extra_data) {
void space_gparts_sort_mapper(void *map_data, int num_elements,
void *extra_data) {
/* Unpack the mapping data. */
struct parallel_sort *sort_struct = (struct parallel_sort *)map_data;
......
......@@ -152,8 +152,10 @@ void space_map_parts_xparts(struct space *s,
struct cell *c));
void space_map_cells_post(struct space *s, int full,
void (*fun)(struct cell *c, void *data), void *data);
void space_parts_sort_mapper(void *map_data, int num_elements, void *extra_data);
void space_gparts_sort_mapper(void *map_data, int num_elements, void *extra_data);
void space_parts_sort_mapper(void *map_data, int num_elements,
void *extra_data);
void space_gparts_sort_mapper(void *map_data, int num_elements,
void *extra_data);
void space_rebuild(struct space *s, double h_max, int verbose);
void space_recycle(struct space *s, struct cell *c);
void space_split(struct space *s, struct cell *cells, int verbose);
......
......@@ -52,8 +52,8 @@ const char *taskID_names[task_type_count] = {
"send", "recv", "grav_pp", "grav_mm", "grav_up",
"grav_down", "grav_external", "comm_root"};
const char *subtaskID_names[task_type_count] = {"none", "density",
"force", "grav"};
const char *subtaskID_names[task_type_count] = {"none", "density", "force",
"grav"};
/**
* @brief Computes the overlap between the parts array of two given cells.
......
......@@ -24,8 +24,8 @@
#include <float.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
/* This object's header. */
#include "threadpool.h"
......@@ -147,7 +147,7 @@ void threadpool_map(struct threadpool *tp, threadpool_map_function map_function,
while (tp->num_threads_running < tp->num_threads) {
pthread_cond_wait(&tp->control_cond, &tp->thread_mutex);
}
/* Wait for all threads to be done. */
while (tp->num_threads_waiting < tp->num_threads) {
pthread_cond_wait(&tp->control_cond, &tp->thread_mutex);
......
......@@ -55,6 +55,7 @@ struct threadpool {
/* Function prototypes. */
void threadpool_init(struct threadpool *tp, int num_threads);
void threadpool_map(struct threadpool *tp, threadpool_map_function map_function,
void *map_data, size_t N, int stride, int chunk, void *extra_data);
void *map_data, size_t N, int stride, int chunk,
void *extra_data);
#endif /* SWIFT_THREADPOOL_H */
......@@ -23,8 +23,8 @@
#include <unistd.h>
// Local includes.
#include "../src/threadpool.h"
#include "../src/atomic.h"
#include "../src/threadpool.h"
void map_function_first(void *map_data, int num_elements, void *extra_data) {
const int *inputs = (int *)map_data;
......
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