Commit 45d31e75 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Fix up errors and warnings from g++

parent 23e073ca
......@@ -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
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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,
......
......@@ -3489,7 +3489,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];
......@@ -5434,7 +5434,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
......
......@@ -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 */
......
......@@ -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) {
......
......@@ -166,9 +166,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++) {
......@@ -180,8 +180,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];
......@@ -254,9 +255,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++) {
......@@ -268,8 +269,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];
......@@ -333,8 +335,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++) {
......@@ -346,8 +349,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];
......@@ -411,8 +415,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++) {
......@@ -424,8 +429,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];
......@@ -589,7 +595,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
......@@ -637,7 +644,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
......@@ -746,8 +754,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;
......@@ -762,8 +771,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];
......
......@@ -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. */
......
......@@ -581,7 +581,9 @@ 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];
......
......@@ -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))
......
......@@ -140,7 +140,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_entropy(p);
const float u_int = hydro_get_internal_energy(p);
const float u_inter = hydro_get_internal_energy(p);
/* Collect mass */
stats.mass += m;
......@@ -162,7 +162,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]);
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);
......
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