Commit 1b316fc5 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'master' into local_variable_cleanup

Conflicts:
	src/engine.c
parents cc4c84ba 1f9e985c
......@@ -414,7 +414,7 @@ int main(int argc, char *argv[]) {
message("space %s periodic.", s.periodic ? "is" : "isn't");
message("highest-level cell dimensions are [ %i %i %i ].", s.cdim[0],
s.cdim[1], s.cdim[2]);
message("%i parts in %i cells.", s.nr_parts, s.tot_cells);
message("%zi parts in %i cells.", s.nr_parts, s.tot_cells);
message("maximum depth is %d.", s.maxdepth);
// message( "cutoffs in [ %g %g ]." , s.h_min , s.h_max ); fflush(stdout);
}
......
......@@ -51,7 +51,7 @@
*/
void printParticle(struct part *parts, struct xpart *xparts, long long int id,
int N) {
size_t N) {
int found = 0;
......@@ -67,7 +67,7 @@ void printParticle(struct part *parts, struct xpart *xparts, long long int id,
if (!found) printf("## Particles[???] id=%lld not found\n", id);
}
void printgParticle(struct gpart *parts, long long int id, int N) {
void printgParticle(struct gpart *parts, long long int id, size_t N) {
int found = 0;
......
......@@ -23,9 +23,9 @@
#include "cell.h"
#include "part.h"
void printParticle(struct part *parts, struct xpart *xparts, long long int i,
int N);
void printgParticle(struct gpart *parts, long long int i, int N);
void printParticle(struct part *parts, struct xpart *xparts, long long int id,
size_t N);
void printgParticle(struct gpart *parts, long long int id, size_t N);
void printParticle_single(struct part *p, struct xpart *xp);
#ifdef HAVE_METIS
......
......@@ -153,7 +153,8 @@ void engine_redistribute(struct engine *e) {
/* Start by sorting the particles according to their nodes and
getting the counts. The counts array is indexed as
count[from * nr_nodes + to]. */
int *counts, *dest;
int *counts;
size_t *dest;
double ih[3], dim[3];
ih[0] = s->ih[0];
ih[1] = s->ih[1];
......@@ -162,7 +163,7 @@ void engine_redistribute(struct engine *e) {
dim[1] = s->dim[1];
dim[2] = s->dim[2];
if ((counts = (int *)malloc(sizeof(int) *nr_nodes *nr_nodes)) == NULL ||
(dest = (int *)malloc(sizeof(int) * s->nr_parts)) == NULL)
(dest = (size_t *)malloc(sizeof(size_t) * s->nr_parts)) == NULL)
error("Failed to allocate count and dest buffers.");
bzero(counts, sizeof(int) * nr_nodes * nr_nodes);
struct part *parts = s->parts;
......@@ -594,7 +595,7 @@ void engine_exchange_cells(struct engine *e) {
* @return The number of arrived parts copied to parts and xparts.
*/
int engine_exchange_strays(struct engine *e, int offset, int *ind, int N) {
int engine_exchange_strays(struct engine *e, int offset, size_t *ind, size_t N) {
#ifdef WITH_MPI
......@@ -646,9 +647,9 @@ int engine_exchange_strays(struct engine *e, int offset, int *ind, int N) {
/* Count the total number of incoming particles and make sure we have
enough space to accommodate them. */
int count_in = 0;
size_t count_in = 0;
for (int k = 0; k < e->nr_proxies; k++) count_in += e->proxies[k].nr_parts_in;
if (e->verbose) message("sent out %i particles, got %i back.", N, count_in);
if (e->verbose) message("sent out %zi particles, got %zi back.", N, count_in);
if (offset + count_in > s->size_parts) {
s->size_parts = (offset + count_in) * 1.05;
struct part *parts_new = NULL;
......@@ -1174,7 +1175,7 @@ void engine_print_task_counts(struct engine *e) {
printf(" %s=%i", taskID_names[k], counts[k]);
printf(" skipped=%i ]\n", counts[task_type_count]);
fflush(stdout);
message("nr_parts = %i.", e->s->nr_parts);
message("nr_parts = %zi.", e->s->nr_parts);
}
/**
......@@ -1773,8 +1774,8 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
/* Re-allocate the local parts. */
if (e->nodeID == 0)
message("Re-allocating parts array from %i to %i.", s->size_parts,
(int)(s->nr_parts * 1.2));
message("Re-allocating parts array from %zi to %zi.", s->size_parts,
(size_t)(s->nr_parts * 1.2));
s->size_parts = s->nr_parts * 1.2;
struct part *parts_new = NULL;
struct xpart *xparts_new = NULL;
......
......@@ -182,7 +182,7 @@ void engine_init_particles(struct engine *e);
void engine_step(struct engine *e);
void engine_maketasks(struct engine *e);
void engine_split(struct engine *e, struct partition *initial_partition);
int engine_exchange_strays(struct engine *e, int offset, int *ind, int N);
int engine_exchange_strays(struct engine *e, int offset, size_t *ind, size_t N);
void engine_rebuild(struct engine *e);
void engine_repartition(struct engine *e);
void engine_makeproxies(struct engine *e);
......
......@@ -311,7 +311,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
int j, k, cdim[3], nr_parts = s->nr_parts, nr_gparts = s->nr_gparts;
struct cell *restrict c, *restrict cells;
struct part *restrict p;
int *ind;
size_t *ind;
double ih[3], dim[3];
ticks tic = getticks();
......@@ -324,8 +324,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Run through the particles and get their cell index. */
// tic = getticks();
const int ind_size = s->size_parts;
if ((ind = (int *)malloc(sizeof(int) * ind_size)) == NULL)
const size_t ind_size = s->size_parts;
if ((ind = (size_t *)malloc(sizeof(size_t) * ind_size)) == NULL)
error("Failed to allocate temporary particle indices.");
ih[0] = s->ih[0];
ih[1] = s->ih[1];
......@@ -376,10 +376,10 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Re-allocate the index array if needed.. */
if (s->nr_parts > ind_size) {
int *ind_new;
if ((ind_new = (int *)malloc(sizeof(int) * s->nr_parts)) == NULL)
size_t *ind_new;
if ((ind_new = (size_t *)malloc(sizeof(size_t) * s->nr_parts)) == NULL)
error("Failed to allocate temporary particle indices.");
memcpy(ind_new, ind, sizeof(int) * nr_parts);
memcpy(ind_new, ind, sizeof(size_t) * nr_parts);
free(ind);
ind = ind_new;
}
......@@ -419,7 +419,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Run through the gravity particles and get their cell index. */
// tic = getticks();
if ((ind = (int *)malloc(sizeof(int) * s->size_gparts)) == NULL)
if ((ind = (size_t *)malloc(sizeof(size_t) * s->size_gparts)) == NULL)
error("Failed to allocate temporary particle indices.");
for (k = 0; k < nr_gparts; k++) {
struct gpart *gp = &s->gparts[k];
......@@ -506,7 +506,7 @@ void space_split(struct space *s, struct cell *cells, int verbose) {
* @param verbose Are we talkative ?
*/
void space_parts_sort(struct space *s, int *ind, int N, int min, int max,
void space_parts_sort(struct space *s, size_t *ind, size_t N, int min, int max,
int verbose) {
ticks tic = getticks();
......@@ -554,7 +554,7 @@ void space_parts_sort(struct space *s, int *ind, int N, int min, int max,
void space_do_parts_sort() {
/* Pointers to the sorting data. */
int *ind = space_sort_struct.ind;
size_t *ind = space_sort_struct.ind;
struct part *parts = space_sort_struct.parts;
struct xpart *xparts = space_sort_struct.xparts;
......@@ -570,8 +570,8 @@ void space_do_parts_sort() {
if (!space_sort_struct.waiting) return;
/* Get the stack entry. */
int i = space_sort_struct.stack[qid].i;
int j = space_sort_struct.stack[qid].j;
ptrdiff_t i = space_sort_struct.stack[qid].i;
ptrdiff_t j = space_sort_struct.stack[qid].j;
int min = space_sort_struct.stack[qid].min;
int max = space_sort_struct.stack[qid].max;
space_sort_struct.stack[qid].ready = 0;
......@@ -585,13 +585,13 @@ void space_do_parts_sort() {
i, j, min, max, pivot); */
/* One pass of QuickSort's partitioning. */
int ii = i;
int jj = j;
ptrdiff_t ii = i;
ptrdiff_t jj = j;
while (ii < jj) {
while (ii <= j && ind[ii] <= pivot) ii++;
while (jj >= i && ind[jj] > pivot) jj--;
if (ii < jj) {
int temp_i = ind[ii];
size_t temp_i = ind[ii];
ind[ii] = ind[jj];
ind[jj] = temp_i;
struct part temp_p = parts[ii];
......@@ -676,11 +676,12 @@ void space_do_parts_sort() {
} /* main loop. */
}
void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min,
void space_gparts_sort(struct gpart *gparts, size_t *ind, size_t N, int min,
int max) {
struct qstack {
volatile int i, j, min, max;
volatile size_t i, j;
volatile int min, max;
volatile int ready;
};
struct qstack *qstack;
......@@ -688,7 +689,8 @@ void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min,
volatile unsigned int first, last, waiting;
int pivot;
int i, ii, j, jj, temp_i, qid;
ptrdiff_t i, ii, j, jj, temp_i;
int qid;
struct gpart temp_p;
/* for ( int k = 0 ; k < N ; k++ )
......@@ -1186,7 +1188,7 @@ struct cell *space_getcell(struct space *s) {
* recursively.
*/
void space_init(struct space *s, double dim[3], struct part *parts, int N,
void space_init(struct space *s, double dim[3], struct part *parts, size_t N,
int periodic, double h_max, int verbose) {
/* Store everything in the space. */
......
......@@ -20,6 +20,9 @@
#define SWIFT_SPACE_H
/* Includes. */
#include <stddef.h>
/* Local includes. */
#include "cell.h"
#include "part.h"
......@@ -85,8 +88,8 @@ struct space {
struct gpart *gparts;
/* The total number of parts in the space. */
int nr_parts, size_parts;
int nr_gparts, size_gparts;
size_t nr_parts, size_parts;
size_t nr_gparts, size_gparts;
/* Is the space periodic? */
int periodic;
......@@ -102,18 +105,19 @@ struct space {
/* Buffers for parts that we will receive from foreign cells. */
struct part *parts_foreign;
int nr_parts_foreign, size_parts_foreign;
size_t nr_parts_foreign, size_parts_foreign;
};
/* Interval stack necessary for parallel particle sorting. */
struct qstack {
volatile int i, j, min, max;
volatile ptrdiff_t i, j;
volatile int min, max;
volatile int ready;
};
struct parallel_sort {
struct part *parts;
struct xpart *xparts;
int *ind;
size_t *ind;
struct qstack *stack;
unsigned int stack_size;
volatile unsigned int first, last, waiting;
......@@ -121,13 +125,13 @@ struct parallel_sort {
extern struct parallel_sort space_sort_struct;
/* function prototypes. */
void space_parts_sort(struct space *s, int *ind, int N, int min, int max,
void space_parts_sort(struct space *s, size_t *ind, size_t N, int min, int max,
int verbose);
void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min, int max);
void space_gparts_sort(struct gpart *gparts, size_t *ind, size_t N, int min, int max);
struct cell *space_getcell(struct space *s);
int space_getsid(struct space *s, struct cell **ci, struct cell **cj,
double *shift);
void space_init(struct space *s, double dim[3], struct part *parts, int N,
void space_init(struct space *s, double dim[3], struct part *parts, size_t N,
int periodic, double h_max, int verbose);
void space_map_cells_pre(struct space *s, int full,
void (*fun)(struct cell *c, void *data), void *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