diff --git a/INSTALL.swift b/INSTALL.swift index e7b5fe693ecc81e530855f577e018feb562a2d40..1782b75e34e2028110717d7873bc2c97365f8240 100644 --- a/INSTALL.swift +++ b/INSTALL.swift @@ -34,13 +34,17 @@ directory. See README for run parameters. SWIFT has been successfully built and tested with the following compilers: - - GCC 4.8.x + - GCC 4.8.x - Intel ICC 15.0.x - - clang 3.4.x + - clang 3.4.x More recent versions and slightly older ones should also be able to build the software. +It has also been built with Intel and GNU C++ compilers, but that currently +requires the --disable-vec and, for Intel, --disable-compiler-warnings +configure options. + By default an attempt to choose suitable set of optimizing compiler flags will be made, targeted for the host machine of the build. If this doesn't work or the binaries will for another architecture then you can stop the @@ -61,7 +65,7 @@ You could also add some additional flags: ./configure --enable-debug --disable-optimization CFLAGS="-O2" -for instance. GCC address sanitizer flags can be included using the +for instance. GCC address sanitizer flags can be included using the ./configure --enable-sanitizer @@ -115,7 +119,7 @@ before you can build it. - GSL: To use cosmological time integration, a version of the GSL must be available. - - libtool: The build system relies on libtool. + - libtool: The build system relies on libtool as well as the other autotools. Optional Dependencies diff --git a/configure.ac b/configure.ac index 85446a9d9a4396bd820e43dd4d95a91fc7b0e324..b62a31aed13b10a16393c654359dff4a296c1bfd 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,9 @@ AC_USE_SYSTEM_EXTENSIONS AX_COMPILER_VENDOR AX_COMPILER_VERSION +# Restrict support. +AC_C_RESTRICT + # Interprocedural optimization support. Needs special handling for linking and # archiving as well as compilation with Intels, needs to be done before # libtool is configured (to use correct LD). @@ -464,6 +467,14 @@ AC_SUBST([METIS_LIBS]) AC_SUBST([METIS_INCS]) AM_CONDITIONAL([HAVEMETIS],[test -n "$METIS_LIBS"]) +# METIS fixed width integer printing can require this, so define. Only needed +# for some non C99 compilers, i.e. C++ pre C++11. +AH_VERBATIM([__STDC_FORMAT_MACROS], + [/* Needed to get PRIxxx macros from stdint.h when not using C99 */ +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS 1 +#endif]) + # Check for grackle. have_grackle="no" AC_ARG_WITH([grackle], diff --git a/examples/main.c b/examples/main.c index 45df57395cef2a8a04f0feadfc06931127a0af95..40cfca8499d9d6148dc3c821c7fd055fa81aef16 100644 --- a/examples/main.c +++ b/examples/main.c @@ -432,7 +432,8 @@ int main(int argc, char *argv[]) { } /* Read the parameter file */ - struct swift_params *params = malloc(sizeof(struct swift_params)); + struct swift_params *params = + (struct swift_params *)malloc(sizeof(struct swift_params)); if (params == NULL) error("Error allocating memory for the parameter file."); if (myrank == 0) { message("Reading runtime parameters from file '%s'", paramFileName); diff --git a/src/align.h b/src/align.h index 54435c4c9baa1ce9dc511e2903b7e2be2d6655de..243557ee0b4c6c0ae6d7ee75d92c50ec5e3b2f4a 100644 --- a/src/align.h +++ b/src/align.h @@ -49,11 +49,11 @@ * @param alignment The alignment in bytes of the array. */ #if defined(__ICC) -#define swift_align_information(array, alignment) \ +#define swift_align_information(type, array, alignment) \ __assume_aligned(array, alignment); #elif defined(__GNUC__) -#define swift_align_information(array, alignment) \ - array = __builtin_assume_aligned(array, alignment); +#define swift_align_information(type, array, alignment) \ + array = (type *)__builtin_assume_aligned(array, alignment); #else #define swift_align_information(array, alignment) ; #endif @@ -72,7 +72,7 @@ */ #define swift_declare_aligned_ptr(type, array, ptr, alignment) \ type *restrict array = ptr; \ - swift_align_information(array, alignment); + swift_align_information(type, array, alignment); /** * @brief Macro to tell the compiler that a given number is 0 modulo a given diff --git a/src/atomic.h b/src/atomic.h index 4f180c643a304a801a9d70940fd12f9f193941e1..b09ed3dd22001586cfde8545e636de67a819c003 100644 --- a/src/atomic.h +++ b/src/atomic.h @@ -26,9 +26,10 @@ #include "inline.h" #define atomic_add(v, i) __sync_fetch_and_add(v, i) +#define atomic_sub(v, i) __sync_fetch_and_sub(v, i) #define atomic_or(v, i) __sync_fetch_and_or(v, i) #define atomic_inc(v) atomic_add(v, 1) -#define atomic_dec(v) atomic_add(v, -1) +#define atomic_dec(v) atomic_sub(v, 1) #define atomic_cas(v, o, n) __sync_val_compare_and_swap(v, o, n) #define atomic_swap(v, n) __sync_lock_test_and_set(v, n) diff --git a/src/clocks.c b/src/clocks.c index 4b8b269143bb3dba606c77a00eaf12b3b614eb8f..fbaa83f15fafda23751d5d6c34d40750132287b5 100644 --- a/src/clocks.c +++ b/src/clocks.c @@ -45,7 +45,7 @@ static unsigned long long clocks_cpufreq = 0; static ticks clocks_start = 0; /* The units of any returned times. */ -static char *clocks_units[] = {"ms", "~ms"}; +static const char *clocks_units[] = {"ms", "~ms"}; static int clocks_units_index = 0; static double clocks_units_scale = 1000.0; diff --git a/src/common_io.c b/src/common_io.c index b6a4f1975ac2022b9934de50cf008d8ae9928bc0..53ca5cc4b72d57756e3cf3cd406108923ae81659 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -142,7 +142,7 @@ int io_is_double_precision(enum IO_DATA_TYPE type) { * * Calls #error() if an error occurs. */ -void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type, +void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, void* data) { hid_t h_attr = 0, h_err = 0; @@ -173,7 +173,7 @@ void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type, void io_write_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, void* data, int num) { hid_t h_space = 0, h_attr = 0, h_err = 0; - hsize_t dim[1] = {num}; + hsize_t dim[1] = {(hsize_t)num}; h_space = H5Screate(H5S_SIMPLE); if (h_space < 0) { @@ -421,7 +421,7 @@ void io_copy_mapper(void* restrict temp, int N, void* restrict extra_data) { const size_t copySize = typeSize * props.dimension; /* How far are we with this chunk? */ - char* restrict temp_c = temp; + char* restrict temp_c = (char*)temp; const ptrdiff_t delta = (temp_c - props.start_temp_c) / copySize; for (int k = 0; k < N; k++) { @@ -443,7 +443,7 @@ void io_convert_part_f_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - float* restrict temp_f = temp; + float* restrict temp_f = (float*)temp; const ptrdiff_t delta = (temp_f - props.start_temp_f) / dim; for (int i = 0; i < N; i++) @@ -463,7 +463,7 @@ void io_convert_part_d_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - double* restrict temp_d = temp; + double* restrict temp_d = (double*)temp; const ptrdiff_t delta = (temp_d - props.start_temp_d) / dim; for (int i = 0; i < N; i++) @@ -483,7 +483,7 @@ void io_convert_gpart_f_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - float* restrict temp_f = temp; + float* restrict temp_f = (float*)temp; const ptrdiff_t delta = (temp_f - props.start_temp_f) / dim; for (int i = 0; i < N; i++) @@ -503,7 +503,7 @@ void io_convert_gpart_d_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - double* restrict temp_d = temp; + double* restrict temp_d = (double*)temp; const ptrdiff_t delta = (temp_d - props.start_temp_d) / dim; for (int i = 0; i < N; i++) @@ -534,7 +534,7 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, if (props.conversion == 0) { /* No conversion */ /* Prepare some parameters */ - char* temp_c = temp; + char* temp_c = (char*)temp; props.start_temp_c = temp_c; /* Copy the whole thing into a buffer */ @@ -546,8 +546,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, if (props.convert_part_f != NULL) { /* Prepare some parameters */ - float* temp_f = temp; - props.start_temp_f = temp; + float* temp_f = (float*)temp; + props.start_temp_f = (float*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -558,8 +558,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, } else if (props.convert_part_d != NULL) { /* Prepare some parameters */ - double* temp_d = temp; - props.start_temp_d = temp; + double* temp_d = (double*)temp; + props.start_temp_d = (double*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -570,8 +570,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, } else if (props.convert_gpart_f != NULL) { /* Prepare some parameters */ - float* temp_f = temp; - props.start_temp_f = temp; + float* temp_f = (float*)temp; + props.start_temp_f = (float*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -582,8 +582,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, } else if (props.convert_gpart_d != NULL) { /* Prepare some parameters */ - double* temp_d = temp; - props.start_temp_d = temp; + double* temp_d = (double*)temp; + props.start_temp_d = (double*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -604,10 +604,12 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* message("Converting ! factor=%e", factor); */ if (io_is_double_precision(props.type)) { - swift_declare_aligned_ptr(double, temp_d, temp, IO_BUFFER_ALIGNMENT); + swift_declare_aligned_ptr(double, temp_d, (double*)temp, + IO_BUFFER_ALIGNMENT); for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; } else { - swift_declare_aligned_ptr(float, temp_f, temp, IO_BUFFER_ALIGNMENT); + swift_declare_aligned_ptr(float, temp_f, (float*)temp, + IO_BUFFER_ALIGNMENT); for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor; } } diff --git a/src/common_io.h b/src/common_io.h index d37b52a13a1420fb325b054de13a62bbc4ad17aa..c317238160e45a9d141619d313e47c715adf8537 100644 --- a/src/common_io.h +++ b/src/common_io.h @@ -60,7 +60,7 @@ hid_t io_hdf5_type(enum IO_DATA_TYPE type); size_t io_sizeof_type(enum IO_DATA_TYPE type); int io_is_double_precision(enum IO_DATA_TYPE type); -void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type, +void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, void* data); void io_write_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, diff --git a/src/engine.c b/src/engine.c index 79c00681df15460ee2e69b634b5d8661b04b3c0f..5972702f9d7048560a1b288dda103f9b049f9d43 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2123,7 +2123,7 @@ void engine_exchange_proxy_multipoles(struct engine *e) { } /* Wait for all the requests to arrive home */ - MPI_Status *stats = malloc(count_requests * sizeof(MPI_Status)); + MPI_Status *stats = (MPI_Status *)malloc(count_requests * sizeof(MPI_Status)); int res; if ((res = MPI_Waitall(count_requests, requests, stats)) != MPI_SUCCESS) { for (int k = 0; k < count_requests; ++k) { @@ -2313,7 +2313,8 @@ void engine_make_self_gravity_tasks(struct engine *e) { task_subtype_none, 0, 0, NULL, NULL); /* Create a grid of ghosts to deal with the dependencies */ - if ((ghosts = malloc(n_ghosts * sizeof(struct task *))) == 0) + if ((ghosts = (struct task **)malloc(n_ghosts * sizeof(struct task *))) == + 0) error("Error allocating memory for gravity fft ghosts"); /* Make the ghosts implicit and add the dependencies */ @@ -3024,7 +3025,8 @@ void engine_maketasks(struct engine *e) { e->size_links += s->tot_cells * self_grav_tasks_per_cell; /* Allocate the new list */ - if ((e->links = malloc(sizeof(struct link) * e->size_links)) == NULL) + if ((e->links = (struct link *)malloc(sizeof(struct link) * e->size_links)) == + NULL) error("Failed to allocate cell-task links."); e->nr_links = 0; @@ -3491,7 +3493,7 @@ int engine_marktasks(struct engine *e) { int rebuild_space = 0; /* Run through the tasks and mark as skip or not. */ - size_t extra_data[3] = {(size_t)e, rebuild_space, (size_t)&e->sched}; + size_t extra_data[3] = {(size_t)e, (size_t)rebuild_space, (size_t)&e->sched}; threadpool_map(&e->threadpool, engine_marktasks_mapper, s->tasks, s->nr_tasks, sizeof(struct task), 0, extra_data); rebuild_space = extra_data[1]; @@ -5217,7 +5219,7 @@ void engine_init( parser_get_param_string(params, "Snapshots:basename", e->snapshotBaseName); e->snapshotCompression = parser_get_opt_param_int(params, "Snapshots:compression", 0); - e->snapshotUnits = malloc(sizeof(struct unit_system)); + e->snapshotUnits = (struct unit_system *)malloc(sizeof(struct unit_system)); units_init_default(e->snapshotUnits, params, "Snapshots", internal_units); e->snapshotOutputCount = 0; e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min"); @@ -5338,7 +5340,7 @@ void engine_config(int restart, struct engine *e, if (nr_cores > CPU_SETSIZE) /* Unlikely, except on e.g. SGI UV. */ error("must allocate dynamic cpu_set_t (too many cores per node)"); - char *buf = malloc((nr_cores + 1) * sizeof(char)); + char *buf = (char *)malloc((nr_cores + 1) * sizeof(char)); buf[nr_cores] = '\0'; for (int j = 0; j < nr_cores; ++j) { /* Reversed bit order from convention, but same as e.g. Intel MPI's @@ -5353,7 +5355,7 @@ void engine_config(int restart, struct engine *e, if (with_aff) { - cpuid = malloc(nr_affinity_cores * sizeof(int)); + cpuid = (int *)malloc(nr_affinity_cores * sizeof(int)); int skip = 0; for (int k = 0; k < nr_affinity_cores; k++) { @@ -5371,7 +5373,7 @@ void engine_config(int restart, struct engine *e, 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 = (int *)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]); @@ -5380,7 +5382,7 @@ void engine_config(int restart, struct engine *e, nnodes += 1; /* Count cores per node. */ - int *core_counts = malloc(nnodes * sizeof(int)); + int *core_counts = (int *)malloc(nnodes * sizeof(int)); for (int i = 0; i < nr_affinity_cores; i++) { core_counts[nodes[i]] = 0; } @@ -5389,7 +5391,7 @@ void engine_config(int restart, struct engine *e, } /* Index cores within each node. */ - int *core_indices = malloc(nr_affinity_cores * sizeof(int)); + int *core_indices = (int *)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; @@ -5463,7 +5465,7 @@ void engine_config(int restart, struct engine *e, if (e->nodeID == 0) { /* When restarting append to these files. */ - char *mode; + const char *mode; if (restart) mode = "a"; else @@ -5889,16 +5891,17 @@ void engine_struct_restore(struct engine *e, FILE *stream) { /* Now for the other pointers, these use their own restore functions. */ /* Note all this memory leaks, but is used once. */ - struct space *s = malloc(sizeof(struct space)); + struct space *s = (struct space *)malloc(sizeof(struct space)); space_struct_restore(s, stream); e->s = s; s->e = e; - struct unit_system *us = malloc(sizeof(struct unit_system)); + struct unit_system *us = + (struct unit_system *)malloc(sizeof(struct unit_system)); units_struct_restore(us, stream); e->internal_units = us; - us = malloc(sizeof(struct unit_system)); + us = (struct unit_system *)malloc(sizeof(struct unit_system)); units_struct_restore(us, stream); e->snapshotUnits = us; @@ -5907,31 +5910,35 @@ void engine_struct_restore(struct engine *e, FILE *stream) { e->cosmology = cosmo; #ifdef WITH_MPI - struct repartition *reparttype = malloc(sizeof(struct repartition)); + struct repartition *reparttype = + (struct repartition *)malloc(sizeof(struct repartition)); partition_struct_restore(reparttype, stream); e->reparttype = reparttype; #endif - struct phys_const *physical_constants = malloc(sizeof(struct phys_const)); + struct phys_const *physical_constants = + (struct phys_const *)malloc(sizeof(struct phys_const)); phys_const_struct_restore(physical_constants, stream); e->physical_constants = physical_constants; - struct hydro_props *hydro_properties = malloc(sizeof(struct hydro_props)); + struct hydro_props *hydro_properties = + (struct hydro_props *)malloc(sizeof(struct hydro_props)); hydro_props_struct_restore(hydro_properties, stream); e->hydro_properties = hydro_properties; struct gravity_props *gravity_properties = - malloc(sizeof(struct gravity_props)); + (struct gravity_props *)malloc(sizeof(struct gravity_props)); gravity_props_struct_restore(gravity_properties, stream); e->gravity_properties = gravity_properties; struct external_potential *external_potential = - malloc(sizeof(struct external_potential)); + (struct external_potential *)malloc(sizeof(struct external_potential)); potential_struct_restore(external_potential, stream); e->external_potential = external_potential; struct cooling_function_data *cooling_func = - malloc(sizeof(struct cooling_function_data)); + (struct cooling_function_data *)malloc( + sizeof(struct cooling_function_data)); cooling_struct_restore(cooling_func, stream); e->cooling_func = cooling_func; @@ -5939,11 +5946,12 @@ void engine_struct_restore(struct engine *e, FILE *stream) { chemistry_struct_restore(chemistry, stream); e->chemistry = chemistry; - struct sourceterms *sourceterms = malloc(sizeof(struct sourceterms)); + struct sourceterms *sourceterms = (struct sourceterms *) malloc(sizeof(struct sourceterms)); sourceterms_struct_restore(sourceterms, stream); e->sourceterms = sourceterms; - struct swift_params *parameter_file = malloc(sizeof(struct swift_params)); + struct swift_params *parameter_file = + (struct swift_params *)malloc(sizeof(struct swift_params)); parser_struct_restore(parameter_file, stream); e->parameter_file = parameter_file; diff --git a/src/gravity_cache.h b/src/gravity_cache.h index 097e4e1cb36e74ddb548fb3ab74196dd66512e6e..d46dc3cb1f307aee0b5c7352ea3c5b27b640cfdc 100644 --- a/src/gravity_cache.h +++ b/src/gravity_cache.h @@ -187,8 +187,9 @@ __attribute__((always_inline)) INLINE static void gravity_cache_populate( /* Particles used for padding should get impossible positions * that have a reasonable magnitude. We use the cell width for this */ - const float pos_padded[3] = {-2. * cell->width[0], -2. * cell->width[1], - -2. * cell->width[2]}; + const float pos_padded[3] = {-2.f * (float)cell->width[0], + -2.f * (float)cell->width[1], + -2.f * (float)cell->width[2]}; const float eps_padded = epsilon[0]; /* Pad the caches */ @@ -247,8 +248,9 @@ gravity_cache_populate_no_mpole(timebin_t max_active_bin, /* Particles used for padding should get impossible positions * that have a reasonable magnitude. We use the cell width for this */ - const float pos_padded[3] = {-2. * cell->width[0], -2. * cell->width[1], - -2. * cell->width[2]}; + const float pos_padded[3] = {-2.f * (float)cell->width[0], + -2.f * (float)cell->width[1], + -2.f * (float)cell->width[2]}; const float eps_padded = epsilon[0]; /* Pad the caches */ diff --git a/src/hydro_space.c b/src/hydro_space.c index c4a6f9c1495a44050c5477ebfdf0bb76a64bfc51..442945caf83a692efadf7755ebf463ebde38e0a4 100644 --- a/src/hydro_space.c +++ b/src/hydro_space.c @@ -47,6 +47,5 @@ __attribute__((always_inline)) INLINE void hydro_space_init( } } #else -__attribute__((always_inline)) INLINE void hydro_space_init( - struct hydro_space *hs, const struct space *s) {} +void hydro_space_init(struct hydro_space *hs, const struct space *s) {} #endif diff --git a/src/inline.h b/src/inline.h index 538f6f520c9d6187dc02f1cbd5d59480aac7bdb2..7477153b5ba3b3a42a63982292909dd3f3a396d0 100644 --- a/src/inline.h +++ b/src/inline.h @@ -27,11 +27,15 @@ * @brief Defines inline */ #ifndef INLINE +#ifdef __cplusplus +#define INLINE inline +#else #if __GNUC__ && !__GNUC_STDC_INLINE__ #define INLINE extern inline #else #define INLINE inline #endif #endif +#endif #endif /* SWIFT_INLINE_H */ diff --git a/src/io_properties.h b/src/io_properties.h index 7afd22a7dc5cb81571e098e7d1b4a1b1efc30682..17db123ba8325ede0c7af4e4b005e359cace7a7f 100644 --- a/src/io_properties.h +++ b/src/io_properties.h @@ -113,7 +113,7 @@ struct io_props { * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_input_field_( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum DATA_IMPORTANCE importance, enum unit_conversion_factor units, char* field, size_t partSize) { struct io_props r; @@ -155,7 +155,7 @@ INLINE static struct io_props io_make_input_field_( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, char* field, size_t partSize) { struct io_props r; strcpy(r.name, name); @@ -198,7 +198,7 @@ INLINE static struct io_props io_make_output_field_( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_FLOAT( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t partSize, const struct part* parts, conversion_func_part_float functionPtr) { @@ -235,7 +235,7 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t partSize, const struct part* parts, conversion_func_part_double functionPtr) { @@ -280,7 +280,7 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t gpartSize, const struct gpart* gparts, conversion_func_gpart_float functionPtr) { @@ -317,7 +317,7 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t gpartSize, const struct gpart* gparts, conversion_func_gpart_double functionPtr) { diff --git a/src/logger.c b/src/logger.c index 0e0bc930c0841f985da2c353357a69b69aba5d91..38cb220b94dd14680584e9edca75883e1df16907 100644 --- a/src/logger.c +++ b/src/logger.c @@ -108,7 +108,7 @@ void logger_log_part(struct part *p, unsigned int mask, size_t *offset, /* Allocate a chunk of memory in the dump of the right size. */ size_t offset_new; - char *buff = dump_get(dump, size, &offset_new); + char *buff = (char *)dump_get(dump, size, &offset_new); /* Write the header. */ uint64_t temp = (((uint64_t)(offset_new - *offset)) & 0xffffffffffffffULL) | @@ -192,7 +192,7 @@ void logger_log_gpart(struct gpart *p, unsigned int mask, size_t *offset, /* Allocate a chunk of memory in the dump of the right size. */ size_t offset_new; - char *buff = dump_get(dump, size, &offset_new); + char *buff = (char *)dump_get(dump, size, &offset_new); /* Write the header. */ uint64_t temp = (((uint64_t)(offset_new - *offset)) & 0xffffffffffffffULL) | @@ -244,7 +244,7 @@ void logger_log_timestamp(unsigned long long int timestamp, size_t *offset, /* Allocate a chunk of memory in the dump of the right size. */ size_t offset_new; - char *buff = dump_get(dump, size, &offset_new); + char *buff = (char *)dump_get(dump, size, &offset_new); /* Write the header. */ uint64_t temp = (((uint64_t)(offset_new - *offset)) & 0xffffffffffffffULL) | diff --git a/src/parallel_io.c b/src/parallel_io.c index aac11f9f1c7ae3b1f800bdce828a4156356c9879..315c187e65f1a30b0401cb9368944f8f9968223a 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -128,16 +128,16 @@ void readArray_chunk(hid_t h_data, hid_t h_plist_id, /* message("Converting ! factor=%e", factor); */ if (io_is_double_precision(props.type)) { - double* temp_d = temp; + double* temp_d = (double*)temp; for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; } else { - float* temp_f = temp; + float* temp_f = (float*)temp; for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor; } } /* Copy temporary buffer to particle data */ - char* temp_c = temp; + char* temp_c = (char*)temp; for (size_t i = 0; i < N; ++i) memcpy(props.field + i * props.partSize, &temp_c[i * copySize], copySize); @@ -640,7 +640,8 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units, H5Gclose(h_grp); /* Read the unit system used in the ICs */ - struct unit_system* ic_units = malloc(sizeof(struct unit_system)); + struct unit_system* ic_units = + (struct unit_system*)malloc(sizeof(struct unit_system)); if (ic_units == NULL) error("Unable to allocate memory for IC unit system"); io_read_unit_system(h_file, ic_units, mpi_rank); @@ -683,7 +684,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units, /* Allocate memory to store SPH particles */ if (with_hydro) { *Ngas = N[0]; - if (posix_memalign((void*)parts, part_align, + if (posix_memalign((void**)parts, part_align, (*Ngas) * sizeof(struct part)) != 0) error("Error while allocating memory for particles"); bzero(*parts, *Ngas * sizeof(struct part)); @@ -692,7 +693,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units, /* Allocate memory to store star particles */ if (with_stars) { *Nstars = N[swift_type_star]; - if (posix_memalign((void*)sparts, spart_align, + if (posix_memalign((void**)sparts, spart_align, *Nstars * sizeof(struct spart)) != 0) error("Error while allocating memory for star particles"); bzero(*sparts, *Nstars * sizeof(struct spart)); @@ -704,7 +705,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units, *Ngparts = (with_hydro ? N[swift_type_gas] : 0) + N[swift_type_dark_matter] + (with_stars ? N[swift_type_star] : 0); - if (posix_memalign((void*)gparts, gpart_align, + if (posix_memalign((void**)gparts, gpart_align, *Ngparts * sizeof(struct gpart)) != 0) error("Error while allocating memory for gravity particles"); bzero(*gparts, *Ngparts * sizeof(struct gpart)); @@ -1199,7 +1200,7 @@ void write_output_parallel(struct engine* e, const char* baseName, case swift_type_dark_matter: /* Allocate temporary array */ - if (posix_memalign((void*)&dmparts, gpart_align, + if (posix_memalign((void**)&dmparts, gpart_align, Ndm * sizeof(struct gpart)) != 0) error( "Error while allocating temporart memory for " diff --git a/src/parser.c b/src/parser.c index cbd63e913010066cbd39418b81609f4669404213..af9ef5fd6b7228dd4ad96640b59322175586862b 100644 --- a/src/parser.c +++ b/src/parser.c @@ -110,9 +110,9 @@ void parser_set_param(struct swift_params *params, const char *namevalue) { value[0] = '\0'; /* Name is part until second colon. */ - char *p1 = strchr(namevalue, ':'); + const char *p1 = strchr(namevalue, ':'); if (p1 != NULL) { - char *p2 = strchr(p1 + 1, ':'); + const char *p2 = strchr(p1 + 1, ':'); if (p2 != NULL) { memcpy(name, namevalue, p2 - namevalue); name[p2 - namevalue] = '\0'; diff --git a/src/partition.c b/src/partition.c index b46172d859e1e19221ee86ecf2c28650715281ef..8203c255d484672254b249042db22f5952579b4e 100644 --- a/src/partition.c +++ b/src/partition.c @@ -442,7 +442,8 @@ static void pick_metis(struct space *s, int nregions, double *vertexw, * of old and new ranks. Each element of the array has a cell count and * an unique index so we can sort into decreasing counts. */ int indmax = nregions * nregions; - struct indexval *ivs = malloc(sizeof(struct indexval) * indmax); + struct indexval *ivs = + (struct indexval *)malloc(sizeof(struct indexval) * indmax); bzero(ivs, sizeof(struct indexval) * indmax); for (int k = 0; k < ncells; k++) { int index = regionid[k] + nregions * s->cells_top[k].nodeID; @@ -453,8 +454,8 @@ static void pick_metis(struct space *s, int nregions, double *vertexw, /* Go through the ivs using the largest counts first, these are the * regions with the most cells in common, old partition to new. */ - int *oldmap = malloc(sizeof(int) * nregions); - int *newmap = malloc(sizeof(int) * nregions); + int *oldmap = (int *)malloc(sizeof(int) * nregions); + int *newmap = (int *)malloc(sizeof(int) * nregions); for (int k = 0; k < nregions; k++) { oldmap[k] = -1; newmap[k] = -1; @@ -1267,7 +1268,7 @@ int partition_space_to_space(double *oldh, double *oldcdim, int *oldnodeIDs, */ void partition_store_celllist(struct space *s, struct repartition *reparttype) { if (reparttype->celllist != NULL) free(reparttype->celllist); - reparttype->celllist = malloc(sizeof(int) * s->nr_cells); + reparttype->celllist = (int *)malloc(sizeof(int) * s->nr_cells); reparttype->ncelllist = s->nr_cells; if (reparttype->celllist == NULL) error("Failed to allocate celllist"); @@ -1333,7 +1334,7 @@ void partition_struct_restore(struct repartition *reparttype, FILE *stream) { /* Also restore the celllist, if we have one. */ if (reparttype->ncelllist > 0) { - reparttype->celllist = malloc(sizeof(int) * reparttype->ncelllist); + reparttype->celllist = (int *)malloc(sizeof(int) * reparttype->ncelllist); if (reparttype->celllist == NULL) error("Failed to allocate celllist"); restart_read_blocks(reparttype->celllist, sizeof(int) * reparttype->ncelllist, 1, stream, NULL, diff --git a/src/proxy.c b/src/proxy.c index 4c110d1a23cbe337978147567b2e6ad8a6d6ba65..10df8d191db992bdd26b39cd18e950f41c4690b3 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -145,14 +145,15 @@ void proxy_addcell_in(struct proxy *p, struct cell *c, int type) { p->size_cells_in *= proxy_buffgrow; struct cell **temp_cell; - if ((temp_cell = malloc(sizeof(struct cell *) * p->size_cells_in)) == NULL) + if ((temp_cell = (struct cell **)malloc(sizeof(struct cell *) * + p->size_cells_in)) == NULL) error("Failed to allocate incoming cell list."); memcpy(temp_cell, p->cells_in, sizeof(struct cell *) * p->nr_cells_in); free(p->cells_in); p->cells_in = temp_cell; int *temp_type; - if ((temp_type = malloc(sizeof(int) * p->size_cells_in)) == NULL) + if ((temp_type = (int *)malloc(sizeof(int) * p->size_cells_in)) == NULL) error("Failed to allocate incoming cell type list."); memcpy(temp_type, p->cells_in_type, sizeof(int) * p->nr_cells_in); free(p->cells_in_type); @@ -190,14 +191,15 @@ void proxy_addcell_out(struct proxy *p, struct cell *c, int type) { p->size_cells_out *= proxy_buffgrow; struct cell **temp_cell; - if ((temp_cell = malloc(sizeof(struct cell *) * p->size_cells_out)) == NULL) + if ((temp_cell = (struct cell **)malloc(sizeof(struct cell *) * + p->size_cells_out)) == NULL) error("Failed to allocate outgoing cell list."); memcpy(temp_cell, p->cells_out, sizeof(struct cell *) * p->nr_cells_out); free(p->cells_out); p->cells_out = temp_cell; int *temp_type; - if ((temp_type = malloc(sizeof(int) * p->size_cells_out)) == NULL) + if ((temp_type = (int *)malloc(sizeof(int) * p->size_cells_out)) == NULL) error("Failed to allocate outgoing cell type list."); memcpy(temp_type, p->cells_out_type, sizeof(int) * p->nr_cells_out); free(p->cells_out_type); diff --git a/src/restart.c b/src/restart.c index 4f4d2b9fba2b40c21f767894cc20d79c8c748aea..952df783626630c36dab410900c417461de07c04 100644 --- a/src/restart.c +++ b/src/restart.c @@ -93,7 +93,7 @@ char **restart_locate(const char *dir, const char *basename, int *nfiles) { char **files = NULL; if (glob(pattern, 0, NULL, &globbuf) == 0) { *nfiles = globbuf.gl_pathc; - files = malloc(sizeof(char *) * *nfiles); + files = (char **)malloc(sizeof(char *) * *nfiles); for (int i = 0; i < *nfiles; i++) { files[i] = strdup(globbuf.gl_pathv[i]); } @@ -133,15 +133,16 @@ void restart_write(struct engine *e, const char *filename) { error("Failed to open restart file: %s (%s)", filename, strerror(errno)); /* Dump our signature and version. */ - restart_write_blocks(SWIFT_RESTART_SIGNATURE, strlen(SWIFT_RESTART_SIGNATURE), - 1, stream, "signature", "SWIFT signature"); + restart_write_blocks((void *)SWIFT_RESTART_SIGNATURE, + strlen(SWIFT_RESTART_SIGNATURE), 1, stream, "signature", + "SWIFT signature"); restart_write_blocks((void *)package_version(), strlen(package_version()), 1, stream, "version", "SWIFT version"); engine_struct_dump(e, stream); /* Just an END statement to spot truncated files. */ - restart_write_blocks(SWIFT_RESTART_END_SIGNATURE, + restart_write_blocks((void *)SWIFT_RESTART_END_SIGNATURE, strlen(SWIFT_RESTART_END_SIGNATURE), 1, stream, "endsignature", "SWIFT end signature"); diff --git a/src/runner.c b/src/runner.c index 4dbadd278bac5d8ad9a3c340409ba62d15c55f19..8d9ed078bb423b2b55e8f50fdbe5e81ec1d15bd9 100644 --- a/src/runner.c +++ b/src/runner.c @@ -676,7 +676,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { /* Init the list of active particles that have to be updated. */ int *pid = NULL; - if ((pid = malloc(sizeof(int) * c->count)) == NULL) + if ((pid = (int *)malloc(sizeof(int) * c->count)) == NULL) error("Can't allocate memory for pid."); for (int k = 0; k < c->count; k++) if (part_is_active(&parts[k], e)) { @@ -2083,7 +2083,7 @@ void *runner_main(void *data) { break; case task_type_recv: if (t->subtype == task_subtype_tend) { - cell_unpack_end_step(ci, t->buff); + cell_unpack_end_step(ci, (struct pcell_step *)t->buff); free(t->buff); } else if (t->subtype == task_subtype_xv) { runner_do_recv_part(r, ci, 1, 1); @@ -2096,7 +2096,7 @@ void *runner_main(void *data) { } else if (t->subtype == task_subtype_spart) { runner_do_recv_spart(r, ci, 1); } else if (t->subtype == task_subtype_multipole) { - cell_unpack_multipoles(ci, t->buff); + cell_unpack_multipoles(ci, (struct gravity_tensors *)t->buff); free(t->buff); } else { error("Unknown/invalid task subtype (%d).", t->subtype); diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 7ed6db614a5ca5a390b58498c539b8e87fffa558..0adfef773206d1d01ae25d3a8e748a9538cd8385 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -171,9 +171,9 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - (cj->loc[0] + shift[0]), - pi->x[1] - (cj->loc[1] + shift[1]), - pi->x[2] - (cj->loc[2] + shift[2])}; + const float pix[3] = {(float)(pi->x[0] - (cj->loc[0] + shift[0])), + (float)(pi->x[1] - (cj->loc[1] + shift[1])), + (float)(pi->x[2] - (cj->loc[2] + shift[2]))}; /* Loop over the parts in cj. */ for (int pjd = 0; pjd < count_j; pjd++) { @@ -185,8 +185,9 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, const int pj_active = part_is_active(pj, e); /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - cj->loc[0], pj->x[1] - cj->loc[1], - pj->x[2] - cj->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - cj->loc[0]), + (float)(pj->x[1] - cj->loc[1]), + (float)(pj->x[2] - cj->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -270,9 +271,9 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - (cj->loc[0] + shift[0]), - pi->x[1] - (cj->loc[1] + shift[1]), - pi->x[2] - (cj->loc[2] + shift[2])}; + const float pix[3] = {(float)(pi->x[0] - (cj->loc[0] + shift[0])), + (float)(pi->x[1] - (cj->loc[1] + shift[1])), + (float)(pi->x[2] - (cj->loc[2] + shift[2]))}; /* Loop over the parts in cj. */ for (int pjd = 0; pjd < count_j; pjd++) { @@ -284,8 +285,9 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, const float hjg2 = hj * hj * kernel_gamma2; /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - cj->loc[0], pj->x[1] - cj->loc[1], - pj->x[2] - cj->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - cj->loc[0]), + (float)(pj->x[1] - cj->loc[1]), + (float)(pj->x[2] - cj->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -363,8 +365,9 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - c->loc[0], pi->x[1] - c->loc[1], - pi->x[2] - c->loc[2]}; + const float pix[3] = {(float)(pi->x[0] - c->loc[0]), + (float)(pi->x[1] - c->loc[1]), + (float)(pi->x[2] - c->loc[2])}; /* Loop over the parts in cj. */ for (int pjd = pid + 1; pjd < count; pjd++) { @@ -376,8 +379,9 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { const int pj_active = part_is_active(pj, e); /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - c->loc[0], pj->x[1] - c->loc[1], - pj->x[2] - c->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - c->loc[0]), + (float)(pj->x[1] - c->loc[1]), + (float)(pj->x[2] - c->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -455,8 +459,9 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - c->loc[0], pi->x[1] - c->loc[1], - pi->x[2] - c->loc[2]}; + const float pix[3] = {(float)(pi->x[0] - c->loc[0]), + (float)(pi->x[1] - c->loc[1]), + (float)(pi->x[2] - c->loc[2])}; /* Loop over the parts in cj. */ for (int pjd = pid + 1; pjd < count; pjd++) { @@ -468,8 +473,9 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { const int pj_active = part_is_active(pj, e); /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - c->loc[0], pj->x[1] - c->loc[1], - pj->x[2] - c->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - c->loc[0]), + (float)(pj->x[1] - c->loc[1]), + (float)(pj->x[2] - c->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -658,7 +664,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, const double pjz = pj->x[2]; /* Compute the pairwise distance. */ - float dx[3] = {pix - pjx, piy - pjy, piz - pjz}; + float dx[3] = {(float)(pix - pjx), (float)(piy - pjy), + (float)(piz - pjz)}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; #ifdef SWIFT_DEBUG_CHECKS @@ -708,7 +715,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, const double pjz = pj->x[2]; /* Compute the pairwise distance. */ - float dx[3] = {pix - pjx, piy - pjy, piz - pjz}; + float dx[3] = {(float)(pix - pjx), (float)(piy - pjy), + (float)(piz - pjz)}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; #ifdef SWIFT_DEBUG_CHECKS @@ -822,8 +830,9 @@ void DOSELF_SUBSET(struct runner *r, struct cell *restrict ci, /* Get a hold of the ith part in ci. */ struct part *pi = &parts[ind[pid]]; - const float pix[3] = {pi->x[0] - ci->loc[0], pi->x[1] - ci->loc[1], - pi->x[2] - ci->loc[2]}; + const float pix[3] = {(float)(pi->x[0] - ci->loc[0]), + (float)(pi->x[1] - ci->loc[1]), + (float)(pi->x[2] - ci->loc[2])}; const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; @@ -838,8 +847,9 @@ void DOSELF_SUBSET(struct runner *r, struct cell *restrict ci, struct part *restrict pj = &parts_j[pjd]; /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - ci->loc[0], pj->x[1] - ci->loc[1], - pj->x[2] - ci->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - ci->loc[0]), + (float)(pj->x[1] - ci->loc[1]), + (float)(pj->x[2] - ci->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -1254,7 +1264,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, sort_active_i = sort_i; count_active_i = count_i; } else if (cell_is_active_hydro(ci, e)) { - if (posix_memalign((void *)&sort_active_i, SWIFT_CACHE_ALIGNMENT, + if (posix_memalign((void **)&sort_active_i, SWIFT_CACHE_ALIGNMENT, sizeof(struct entry) * count_i) != 0) error("Failed to allocate active sortlists."); @@ -1272,7 +1282,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, sort_active_j = sort_j; count_active_j = count_j; } else if (cell_is_active_hydro(cj, e)) { - if (posix_memalign((void *)&sort_active_j, SWIFT_CACHE_ALIGNMENT, + if (posix_memalign((void **)&sort_active_j, SWIFT_CACHE_ALIGNMENT, sizeof(struct entry) * count_j) != 0) error("Failed to allocate active sortlists."); @@ -1717,7 +1727,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { /* Set up indt. */ int *indt = NULL; int countdt = 0, firstdt = 0; - if (posix_memalign((void *)&indt, VEC_SIZE * sizeof(int), + if (posix_memalign((void **)&indt, VEC_SIZE * sizeof(int), count * sizeof(int)) != 0) error("Failed to allocate indt."); for (int k = 0; k < count; k++) @@ -1894,7 +1904,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) { /* Set up indt. */ int *indt = NULL; int countdt = 0, firstdt = 0; - if (posix_memalign((void *)&indt, VEC_SIZE * sizeof(int), + if (posix_memalign((void **)&indt, VEC_SIZE * sizeof(int), count * sizeof(int)) != 0) error("Failed to allocate indt."); for (int k = 0; k < count; k++) diff --git a/src/runner_doiact_fft.c b/src/runner_doiact_fft.c index 9e9841496707cb0d0dc0b7b6f3d8d98399414d91..1bc3846531504087c1f696f8b3d8eeb6c88dfe71 100644 --- a/src/runner_doiact_fft.c +++ b/src/runner_doiact_fft.c @@ -194,12 +194,12 @@ void runner_do_grav_fft(struct runner* r, int timer) { #endif /* Allocates some memory for the density mesh */ - double* restrict rho = fftw_malloc(sizeof(double) * N * N * N); + double* restrict rho = (double*)fftw_malloc(sizeof(double) * N * N * N); if (rho == NULL) error("Error allocating memory for density mesh"); /* Allocates some memory for the mesh in Fourier space */ fftw_complex* restrict frho = - fftw_malloc(sizeof(fftw_complex) * N * N * (N_half + 1)); + (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * N * N * (N_half + 1)); if (frho == NULL) error("Error allocating memory for transform of density mesh"); diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index cee0737cbae7b7d1d67d74d829447a77ada66928..0bc7b851c05e94974ef6337ba3d8df5e5420c9a1 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -208,10 +208,10 @@ static INLINE void runner_dopair_grav_pp_full(const struct engine *e, float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(cj_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded_j, VEC_SIZE); /* Loop over every particle in the other cell. */ @@ -299,10 +299,10 @@ static INLINE void runner_dopair_grav_pp_truncated( float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(cj_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded_j, VEC_SIZE); /* Loop over every particle in the other cell. */ @@ -496,12 +496,12 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) { const float rmax2_j = rmax_j * rmax_j; const struct multipole *multi_i = &ci->multipole->m_pole; const struct multipole *multi_j = &cj->multipole->m_pole; - const float CoM_i[3] = {ci->multipole->CoM[0] - shift_i[0], - ci->multipole->CoM[1] - shift_i[1], - ci->multipole->CoM[2] - shift_i[2]}; - const float CoM_j[3] = {cj->multipole->CoM[0] - shift_j[0], - cj->multipole->CoM[1] - shift_j[1], - cj->multipole->CoM[2] - shift_j[2]}; + const float CoM_i[3] = {(float)(ci->multipole->CoM[0] - shift_i[0]), + (float)(ci->multipole->CoM[1] - shift_i[1]), + (float)(ci->multipole->CoM[2] - shift_i[2])}; + const float CoM_j[3] = {(float)(cj->multipole->CoM[0] - shift_j[0]), + (float)(cj->multipole->CoM[1] - shift_j[1]), + (float)(cj->multipole->CoM[2] - shift_j[2])}; /* Start by constructing particle caches */ @@ -686,10 +686,10 @@ void runner_doself_grav_pp_full(struct runner *r, struct cell *c) { float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(ci_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded, VEC_SIZE); /* Loop over every other particle in the cell. */ @@ -812,10 +812,10 @@ void runner_doself_grav_pp_truncated(struct runner *r, struct cell *c) { float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(ci_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded, VEC_SIZE); /* Loop over every other particle in the cell. */ diff --git a/src/scheduler.c b/src/scheduler.c index 46dd82a513d504ef6834983935f8893fb633dacd..f9cfff5645c571a6bae1d0dc111766e2b2be1120 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -136,7 +136,7 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) { * ind = (ta * task_subtype_count + sa) * max_nber_dep * 2 * where ta is the value of task_type and sa is the value of * task_subtype */ - int *table = malloc(nber_relation * sizeof(int)); + int *table = (int *)malloc(nber_relation * sizeof(int)); if (table == NULL) error("Error allocating memory for task-dependency graph."); @@ -1144,7 +1144,7 @@ void scheduler_reset(struct scheduler *s, int size) { scheduler_free_tasks(s); /* Allocate the new lists. */ - if (posix_memalign((void *)&s->tasks, task_align, + if (posix_memalign((void **)&s->tasks, task_align, size * sizeof(struct task)) != 0) error("Failed to allocate task array."); @@ -1463,7 +1463,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { case task_type_recv: #ifdef WITH_MPI if (t->subtype == task_subtype_tend) { - t->buff = malloc(sizeof(struct pcell_step) * t->ci->pcell_size); + t->buff = (struct pcell_step *)malloc(sizeof(struct pcell_step) * + t->ci->pcell_size); err = MPI_Irecv( t->buff, t->ci->pcell_size * sizeof(struct pcell_step), MPI_BYTE, t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req); @@ -1482,7 +1483,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { err = MPI_Irecv(t->ci->sparts, t->ci->scount, spart_mpi_type, t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req); } else if (t->subtype == task_subtype_multipole) { - t->buff = malloc(sizeof(struct gravity_tensors) * t->ci->pcell_size); + t->buff = (struct gravity_tensors *)malloc( + sizeof(struct gravity_tensors) * t->ci->pcell_size); err = MPI_Irecv( t->buff, sizeof(struct gravity_tensors) * t->ci->pcell_size, MPI_BYTE, t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req); @@ -1500,8 +1502,9 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { case task_type_send: #ifdef WITH_MPI if (t->subtype == task_subtype_tend) { - t->buff = malloc(sizeof(struct pcell_step) * t->ci->pcell_size); - cell_pack_end_step(t->ci, t->buff); + t->buff = (struct pcell_step *)malloc(sizeof(struct pcell_step) * + t->ci->pcell_size); + cell_pack_end_step(t->ci, (struct pcell_step *)t->buff); if ((t->ci->pcell_size * sizeof(struct pcell_step)) > s->mpi_message_limit) err = MPI_Isend( @@ -1538,8 +1541,9 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { err = MPI_Issend(t->ci->sparts, t->ci->scount, spart_mpi_type, t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req); } else if (t->subtype == task_subtype_multipole) { - t->buff = malloc(sizeof(struct gravity_tensors) * t->ci->pcell_size); - cell_pack_multipoles(t->ci, t->buff); + t->buff = (struct gravity_tensors *)malloc( + sizeof(struct gravity_tensors) * t->ci->pcell_size); + cell_pack_multipoles(t->ci, (struct gravity_tensors *)t->buff); err = MPI_Isend( t->buff, t->ci->pcell_size * sizeof(struct gravity_tensors), MPI_BYTE, t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req); diff --git a/src/single_io.c b/src/single_io.c index 79dc6d43d645862edb3e0f8a9a6480f368265a50..4ba85c2b1b6970469b17ac2d475e297b848604c6 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -131,16 +131,16 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N, /* message("Converting ! factor=%e", factor); */ if (io_is_double_precision(prop.type)) { - double* temp_d = temp; + double* temp_d = (double*)temp; for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; } else { - float* temp_f = temp; + float* temp_f = (float*)temp; for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor; } } /* Copy temporary buffer to particle data */ - char* temp_c = temp; + char* temp_c = (char*)temp; for (size_t i = 0; i < N; ++i) memcpy(prop.field + i * prop.partSize, &temp_c[i * copySize], copySize); @@ -387,7 +387,8 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, H5Gclose(h_grp); /* Read the unit system used in the ICs */ - struct unit_system* ic_units = malloc(sizeof(struct unit_system)); + struct unit_system* ic_units = + (struct unit_system*)malloc(sizeof(struct unit_system)); if (ic_units == NULL) error("Unable to allocate memory for IC unit system"); io_read_unit_system(h_file, ic_units, 0); @@ -428,8 +429,8 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, /* Allocate memory to store SPH particles */ if (with_hydro) { *Ngas = N[swift_type_gas]; - if (posix_memalign((void*)parts, part_align, *Ngas * sizeof(struct part)) != - 0) + if (posix_memalign((void**)parts, part_align, + *Ngas * sizeof(struct part)) != 0) error("Error while allocating memory for SPH particles"); bzero(*parts, *Ngas * sizeof(struct part)); } @@ -437,7 +438,7 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, /* Allocate memory to store star particles */ if (with_stars) { *Nstars = N[swift_type_star]; - if (posix_memalign((void*)sparts, spart_align, + if (posix_memalign((void**)sparts, spart_align, *Nstars * sizeof(struct spart)) != 0) error("Error while allocating memory for star particles"); bzero(*sparts, *Nstars * sizeof(struct spart)); @@ -449,7 +450,7 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, *Ngparts = (with_hydro ? N[swift_type_gas] : 0) + N[swift_type_dark_matter] + (with_stars ? N[swift_type_star] : 0); - if (posix_memalign((void*)gparts, gpart_align, + if (posix_memalign((void**)gparts, gpart_align, *Ngparts * sizeof(struct gpart)) != 0) error("Error while allocating memory for gravity particles"); bzero(*gparts, *Ngparts * sizeof(struct gpart)); @@ -581,7 +582,8 @@ void write_output_single(struct engine* e, const char* baseName, /* Number of unassociated gparts */ const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0; - long long N_total[swift_type_count] = {Ngas, Ndm, 0, 0, Nstars, 0}; + long long N_total[swift_type_count] = { + (long long)Ngas, (long long)Ndm, 0, 0, (long long)Nstars, 0}; /* File name */ char fileName[FILENAME_BUFFER_SIZE]; @@ -765,7 +767,7 @@ void write_output_single(struct engine* e, const char* baseName, case swift_type_dark_matter: /* Allocate temporary array */ - if (posix_memalign((void*)&dmparts, gpart_align, + if (posix_memalign((void**)&dmparts, gpart_align, Ndm * sizeof(struct gpart)) != 0) error("Error while allocating temporart memory for DM particles"); bzero(dmparts, Ndm * sizeof(struct gpart)); diff --git a/src/space.c b/src/space.c index c0381b619f1aa8b1847fda84e3b15255cdfc9f85..329526fe14e38220750903058bc5201ef7486f63 100644 --- a/src/space.c +++ b/src/space.c @@ -319,12 +319,12 @@ void space_regrid(struct space *s, int verbose) { /* Get the new putative cell dimensions. */ const int cdim[3] = { - floor(s->dim[0] / - fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), - floor(s->dim[1] / - fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), - floor(s->dim[2] / - fmax(h_max * kernel_gamma * space_stretch, s->cell_min))}; + (int)floor(s->dim[0] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), + (int)floor(s->dim[1] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), + (int)floor(s->dim[2] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min))}; /* Check if we have enough cells for periodicity. */ if (s->periodic && (cdim[0] < 3 || cdim[1] < 3 || cdim[2] < 3)) @@ -423,21 +423,21 @@ void space_regrid(struct space *s, int verbose) { /* Allocate the highest level of cells. */ s->tot_cells = s->nr_cells = cdim[0] * cdim[1] * cdim[2]; - if (posix_memalign((void *)&s->cells_top, cell_align, + if (posix_memalign((void **)&s->cells_top, cell_align, s->nr_cells * sizeof(struct cell)) != 0) error("Failed to allocate top-level cells."); bzero(s->cells_top, s->nr_cells * sizeof(struct cell)); /* Allocate the multipoles for the top-level cells. */ if (s->gravity) { - if (posix_memalign((void *)&s->multipoles_top, multipole_align, + if (posix_memalign((void **)&s->multipoles_top, multipole_align, s->nr_cells * sizeof(struct gravity_tensors)) != 0) error("Failed to allocate top-level multipoles."); bzero(s->multipoles_top, s->nr_cells * sizeof(struct gravity_tensors)); } /* Allocate the indices of local cells */ - if (posix_memalign((void *)&s->local_cells_top, SWIFT_STRUCT_ALIGNMENT, + if (posix_memalign((void **)&s->local_cells_top, SWIFT_STRUCT_ALIGNMENT, s->nr_cells * sizeof(int)) != 0) error("Failed to allocate indices of local top-level cells."); bzero(s->local_cells_top, s->nr_cells * sizeof(int)); @@ -1346,8 +1346,8 @@ void space_parts_sort(struct space *s, int *ind, size_t N, int min, int max, sort_struct.xparts = s->xparts; sort_struct.ind = ind; sort_struct.stack_size = 2 * (max - min + 1) + 10 + s->e->nr_threads; - if ((sort_struct.stack = - malloc(sizeof(struct qstack) * sort_struct.stack_size)) == NULL) + if ((sort_struct.stack = (struct qstack *)malloc( + sizeof(struct qstack) * sort_struct.stack_size)) == NULL) error("Failed to allocate sorting stack."); for (unsigned int i = 0; i < sort_struct.stack_size; i++) sort_struct.stack[i].ready = 0; @@ -1530,8 +1530,8 @@ void space_sparts_sort(struct space *s, int *ind, size_t N, int min, int max, sort_struct.sparts = s->sparts; sort_struct.ind = ind; sort_struct.stack_size = 2 * (max - min + 1) + 10 + s->e->nr_threads; - if ((sort_struct.stack = - malloc(sizeof(struct qstack) * sort_struct.stack_size)) == NULL) + if ((sort_struct.stack = (struct qstack *)malloc( + sizeof(struct qstack) * sort_struct.stack_size)) == NULL) error("Failed to allocate sorting stack."); for (unsigned int i = 0; i < sort_struct.stack_size; i++) sort_struct.stack[i].ready = 0; @@ -1713,8 +1713,8 @@ void space_gparts_sort(struct space *s, int *ind, size_t N, int min, int max, sort_struct.gparts = s->gparts; sort_struct.ind = ind; sort_struct.stack_size = 2 * (max - min + 1) + 10 + s->e->nr_threads; - if ((sort_struct.stack = - malloc(sizeof(struct qstack) * sort_struct.stack_size)) == NULL) + if ((sort_struct.stack = (struct qstack *)malloc( + sizeof(struct qstack) * sort_struct.stack_size)) == NULL) error("Failed to allocate sorting stack."); for (unsigned int i = 0; i < sort_struct.stack_size; i++) sort_struct.stack[i].ready = 0; @@ -2062,7 +2062,7 @@ void space_split_recursive(struct space *s, struct cell *c, const int allocate_buffer = (buff == NULL && gbuff == NULL && sbuff == NULL); if (allocate_buffer) { if (count > 0) { - if (posix_memalign((void *)&buff, SWIFT_STRUCT_ALIGNMENT, + if (posix_memalign((void **)&buff, SWIFT_STRUCT_ALIGNMENT, sizeof(struct cell_buff) * count) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < count; k++) { @@ -2072,7 +2072,7 @@ void space_split_recursive(struct space *s, struct cell *c, } } if (gcount > 0) { - if (posix_memalign((void *)&gbuff, SWIFT_STRUCT_ALIGNMENT, + if (posix_memalign((void **)&gbuff, SWIFT_STRUCT_ALIGNMENT, sizeof(struct cell_buff) * gcount) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < gcount; k++) { @@ -2082,7 +2082,7 @@ void space_split_recursive(struct space *s, struct cell *c, } } if (scount > 0) { - if (posix_memalign((void *)&sbuff, SWIFT_STRUCT_ALIGNMENT, + if (posix_memalign((void **)&sbuff, SWIFT_STRUCT_ALIGNMENT, sizeof(struct cell_buff) * scount) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < scount; k++) { @@ -2510,7 +2510,7 @@ void space_getcells(struct space *s, int nr_cells, struct cell **cells) { /* Is the cell buffer empty? */ if (s->cells_sub == NULL) { - if (posix_memalign((void *)&s->cells_sub, cell_align, + if (posix_memalign((void **)&s->cells_sub, cell_align, space_cellallocchunk * sizeof(struct cell)) != 0) error("Failed to allocate more cells."); @@ -2523,7 +2523,7 @@ void space_getcells(struct space *s, int nr_cells, struct cell **cells) { /* Is the multipole buffer empty? */ if (s->gravity && s->multipoles_sub == NULL) { if (posix_memalign( - (void *)&s->multipoles_sub, multipole_align, + (void **)&s->multipoles_sub, multipole_align, space_cellallocchunk * sizeof(struct gravity_tensors)) != 0) error("Failed to allocate more multipoles."); @@ -2740,8 +2740,8 @@ void space_first_init_sparts(struct space *s) { void space_init_parts_mapper(void *restrict map_data, int count, void *restrict extra_data) { - struct part *restrict parts = map_data; - const struct hydro_space *restrict hs = extra_data; + struct part *restrict parts = (struct part *)map_data; + const struct hydro_space *restrict hs = (struct hydro_space *)extra_data; for (int k = 0; k < count; k++) hydro_init_part(&parts[k], hs); } @@ -2766,7 +2766,7 @@ void space_init_parts(struct space *s, int verbose) { void space_init_gparts_mapper(void *restrict map_data, int count, void *restrict extra_data) { - struct gpart *gparts = map_data; + struct gpart *gparts = (struct gpart *)map_data; for (int k = 0; k < count; k++) gravity_init_gpart(&gparts[k]); } @@ -2791,8 +2791,8 @@ void space_init_gparts(struct space *s, int verbose) { void space_convert_quantities_mapper(void *restrict map_data, int count, void *restrict extra_data) { - struct space *s = extra_data; - struct part *restrict parts = map_data; + struct space *s = (struct space *)extra_data; + struct part *restrict parts = (struct part *)map_data; const ptrdiff_t index = parts - s->parts; struct xpart *restrict xparts = s->xparts + index; for (int k = 0; k < count; k++) @@ -3007,7 +3007,7 @@ void space_init(struct space *s, const struct swift_params *params, /* Allocate the extra parts array for the gas particles. */ if (Npart > 0) { - if (posix_memalign((void *)&s->xparts, xpart_align, + if (posix_memalign((void **)&s->xparts, xpart_align, Npart * sizeof(struct xpart)) != 0) error("Failed to allocate xparts."); bzero(s->xparts, Npart * sizeof(struct xpart)); @@ -3055,15 +3055,15 @@ void space_replicate(struct space *s, int replicate, int verbose) { struct gpart *gparts = NULL; struct spart *sparts = NULL; - if (posix_memalign((void *)&parts, part_align, + if (posix_memalign((void **)&parts, part_align, s->nr_parts * sizeof(struct part)) != 0) error("Failed to allocate new part array."); - if (posix_memalign((void *)&gparts, gpart_align, + if (posix_memalign((void **)&gparts, gpart_align, s->nr_gparts * sizeof(struct gpart)) != 0) error("Failed to allocate new gpart array."); - if (posix_memalign((void *)&sparts, spart_align, + if (posix_memalign((void **)&sparts, spart_align, s->nr_sparts * sizeof(struct spart)) != 0) error("Failed to allocate new spart array."); @@ -3300,10 +3300,10 @@ void space_struct_restore(struct space *s, FILE *stream) { if (s->nr_parts > 0) { /* Need the memory for these. */ - if (posix_memalign((void *)&s->parts, part_align, + if (posix_memalign((void **)&s->parts, part_align, s->size_parts * sizeof(struct part)) != 0) error("Failed to allocate restore part array."); - if (posix_memalign((void *)&s->xparts, xpart_align, + if (posix_memalign((void **)&s->xparts, xpart_align, s->size_parts * sizeof(struct xpart)) != 0) error("Failed to allocate restore xpart array."); @@ -3314,7 +3314,7 @@ void space_struct_restore(struct space *s, FILE *stream) { } s->gparts = NULL; if (s->nr_gparts > 0) { - if (posix_memalign((void *)&s->gparts, gpart_align, + if (posix_memalign((void **)&s->gparts, gpart_align, s->size_gparts * sizeof(struct gpart)) != 0) error("Failed to allocate restore gpart array."); @@ -3324,7 +3324,7 @@ void space_struct_restore(struct space *s, FILE *stream) { s->sparts = NULL; if (s->nr_sparts > 0) { - if (posix_memalign((void *)&s->sparts, spart_align, + if (posix_memalign((void **)&s->sparts, spart_align, s->size_sparts * sizeof(struct spart)) != 0) error("Failed to allocate restore spart array."); diff --git a/src/statistics.c b/src/statistics.c index 7223ffd9cd463205b6d97d28f7e095b1061a9de5..ed3197fbd0538394bb1c40d834c16e174a410068 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -165,7 +165,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) { const double x[3] = {p->x[0], p->x[1], p->x[2]}; const float m = hydro_get_mass(p); const float entropy = hydro_get_physical_entropy(p, cosmo); - const float u_int = hydro_get_physical_internal_energy(p, cosmo); + const float u_inter = hydro_get_physical_internal_energy(p, cosmo); /* Collect mass */ stats.mass += m; @@ -188,7 +188,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) { /* Collect energies. */ stats.E_kin += 0.5f * m * (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) * a_inv2; /* 1/2 m a^2 \dot{r}^2 */ - stats.E_int += m * u_int; + stats.E_int += m * u_inter; stats.E_rad += cooling_get_radiated_energy(xp); if (gp != NULL) { stats.E_pot_self += m * gravity_get_potential(gp) * a_inv; diff --git a/tests/test125cells.c b/tests/test125cells.c index c00933e587269d3743aaaf26da8515897fc6e70b..7ec0a7baa200d902f73aaba78cabe735880f0b18 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -47,7 +47,7 @@ #define DOPAIR2_NAME "runner_dopair2_force" #endif -#define NODE_ID 1 +#define NODE_ID 0 enum velocity_field { velocity_zero, diff --git a/tests/test27cells.c b/tests/test27cells.c index 76fd18565907bd3eb1c738d2e2cb46680e926cfd..6b275094de8f2f1a54e94f35ae10e347adb19b4f 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -67,7 +67,7 @@ #endif #endif -#define NODE_ID 1 +#define NODE_ID 0 enum velocity_types { velocity_zero, diff --git a/tests/testPeriodicBC.c b/tests/testPeriodicBC.c index 541f1a99732dac5b74123c986f16caa3ba6f7aac..ffbb37a99781e6a4aed6e34fe016f239d949c870 100644 --- a/tests/testPeriodicBC.c +++ b/tests/testPeriodicBC.c @@ -49,7 +49,7 @@ #define DOPAIR1_NAME "runner_dopair1_density" #endif -#define NODE_ID 1 +#define NODE_ID 0 enum velocity_types { velocity_zero,