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

fix and format space.c, forgot one field in space.h.

parent 943b0e1f
...@@ -311,7 +311,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -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; int j, k, cdim[3], nr_parts = s->nr_parts, nr_gparts = s->nr_gparts;
struct cell *restrict c, *restrict cells; struct cell *restrict c, *restrict cells;
struct part *restrict p; struct part *restrict p;
int *ind; size_t *ind;
double ih[3], dim[3]; double ih[3], dim[3];
ticks tic = getticks(); ticks tic = getticks();
...@@ -324,8 +324,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -324,8 +324,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Run through the particles and get their cell index. */ /* Run through the particles and get their cell index. */
// tic = getticks(); // tic = getticks();
const int ind_size = s->size_parts; const size_t ind_size = s->size_parts;
if ((ind = (int *)malloc(sizeof(int) * ind_size)) == NULL) if ((ind = (size_t *)malloc(sizeof(size_t) * ind_size)) == NULL)
error("Failed to allocate temporary particle indices."); error("Failed to allocate temporary particle indices.");
ih[0] = s->ih[0]; ih[0] = s->ih[0];
ih[1] = s->ih[1]; ih[1] = s->ih[1];
...@@ -376,10 +376,10 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -376,10 +376,10 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Re-allocate the index array if needed.. */ /* Re-allocate the index array if needed.. */
if (s->nr_parts > ind_size) { if (s->nr_parts > ind_size) {
int *ind_new; size_t *ind_new;
if ((ind_new = (int *)malloc(sizeof(int) * s->nr_parts)) == NULL) if ((ind_new = (size_t *)malloc(sizeof(size_t) * s->nr_parts)) == NULL)
error("Failed to allocate temporary particle indices."); 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); free(ind);
ind = ind_new; ind = ind_new;
} }
...@@ -419,7 +419,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -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. */ /* Run through the gravity particles and get their cell index. */
// tic = getticks(); // 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."); error("Failed to allocate temporary particle indices.");
for (k = 0; k < nr_gparts; k++) { for (k = 0; k < nr_gparts; k++) {
struct gpart *gp = &s->gparts[k]; struct gpart *gp = &s->gparts[k];
...@@ -506,7 +506,7 @@ void space_split(struct space *s, struct cell *cells, int verbose) { ...@@ -506,7 +506,7 @@ void space_split(struct space *s, struct cell *cells, int verbose) {
* @param verbose Are we talkative ? * @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) { int verbose) {
ticks tic = getticks(); ticks tic = getticks();
...@@ -554,7 +554,7 @@ void space_parts_sort(struct space *s, int *ind, int N, int min, int max, ...@@ -554,7 +554,7 @@ void space_parts_sort(struct space *s, int *ind, int N, int min, int max,
void space_do_parts_sort() { void space_do_parts_sort() {
/* Pointers to the sorting data. */ /* 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 part *parts = space_sort_struct.parts;
struct xpart *xparts = space_sort_struct.xparts; struct xpart *xparts = space_sort_struct.xparts;
...@@ -676,11 +676,12 @@ void space_do_parts_sort() { ...@@ -676,11 +676,12 @@ void space_do_parts_sort() {
} /* main loop. */ } /* 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) { int max) {
struct qstack { struct qstack {
volatile int i, j, min, max; volatile size_t i, j;
volatile int min, max;
volatile int ready; volatile int ready;
}; };
struct qstack *qstack; struct qstack *qstack;
...@@ -688,7 +689,8 @@ void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min, ...@@ -688,7 +689,8 @@ void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min,
volatile unsigned int first, last, waiting; volatile unsigned int first, last, waiting;
int pivot; int pivot;
int i, ii, j, jj, temp_i, qid; size_t i, ii, j, jj, temp_i;
int qid;
struct gpart temp_p; struct gpart temp_p;
/* for ( int k = 0 ; k < N ; k++ ) /* for ( int k = 0 ; k < N ; k++ )
...@@ -1186,7 +1188,7 @@ struct cell *space_getcell(struct space *s) { ...@@ -1186,7 +1188,7 @@ struct cell *space_getcell(struct space *s) {
* recursively. * 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) { int periodic, double h_max, int verbose) {
/* Store everything in the space. */ /* Store everything in the space. */
......
...@@ -114,7 +114,7 @@ struct qstack { ...@@ -114,7 +114,7 @@ struct qstack {
struct parallel_sort { struct parallel_sort {
struct part *parts; struct part *parts;
struct xpart *xparts; struct xpart *xparts;
int *ind; size_t *ind;
struct qstack *stack; struct qstack *stack;
unsigned int stack_size; unsigned int stack_size;
volatile unsigned int first, last, waiting; volatile unsigned int first, last, waiting;
......
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