Skip to content

Commit

Permalink
Multiple fixes
Browse files Browse the repository at this point in the history
Closes #1. Rationalizes the interface a little. Remove all support
for multi-dimensional global arrays -- 1D only.
  • Loading branch information
kpamnany committed Feb 21, 2017
1 parent 6379a29 commit 719a539
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 133 deletions.
58 changes: 28 additions & 30 deletions include/gasp.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "dtree_debug.h"
#include "log.h"

#define GARRAY_MAX_DIMS 1

/* gasp handle */
typedef struct gasp_tag {
Expand All @@ -25,7 +24,7 @@ typedef struct gasp_tag {
/* global array */
typedef struct garray_tag {
gasp_t *g;
int64_t ndims, *dims, *chunks, elem_size, nextra_elems, nelems_per_rank,
int64_t num_elems, *chunks, elem_size, nextra_elems, nelems_per_rank,
nlocal_elems;
int8_t *buffer;
MPI_Win win;
Expand All @@ -46,7 +45,6 @@ typedef struct dtree_tag {
double tot_children;

/* MPI info */
int my_rank, num_ranks;
int16_t *children_req_bufs;
MPI_Request parent_req, *children_reqs;

Expand Down Expand Up @@ -76,54 +74,54 @@ typedef struct dtree_tag {
/* gasp interface
*/

int64_t gasp_init(int ac, char **av, gasp_t **g);
void gasp_shutdown(gasp_t *g);
void gasp_sync();
int gasp_init(int ac, char **av, gasp_t **g);
void gasp_shutdown(gasp_t *g);
void gasp_sync();

/* number of participating ranks */
int64_t gasp_nranks();
int gasp_nranks();

/* this rank's unique identifier */
int64_t gasp_rank();
int gasp_rank();

/* global array */
int64_t garray_create(gasp_t *g, int64_t ndims, int64_t *dims, int64_t elem_size,
int64_t *chunks, garray_t **ga);
void garray_destroy(garray_t *ga);
int garray_create(gasp_t *g, int64_t num_elems, int64_t elem_size,
int64_t *chunks, garray_t **ga);
void garray_destroy(garray_t *ga);

int64_t garray_ndims(garray_t *ga);
int64_t garray_length(garray_t *ga);
int64_t garray_size(garray_t *ga, int64_t *dims);
int64_t garray_length(garray_t *ga);
int64_t garray_elemsize(garray_t *ga);

int64_t garray_get(garray_t *ga, int64_t *lo, int64_t *hi, void *buf);
int64_t garray_put(garray_t *ga, int64_t *lo, int64_t *hi, void *buf);
int garray_get(garray_t *ga, int64_t lo, int64_t hi, void *buf);
int garray_put(garray_t *ga, int64_t lo, int64_t hi, void *buf);

int64_t garray_distribution(garray_t *ga, int64_t rank, int64_t *lo, int64_t *hi);
int64_t garray_access(garray_t *ga, int64_t *lo, int64_t *hi, void **buf);
int garray_distribution(garray_t *ga, int rank, int64_t *lo, int64_t *hi);
int garray_access(garray_t *ga, int64_t lo, int64_t hi, void **buf);

void garray_flush(garray_t *ga);
void garray_flush(garray_t *ga);

/* dtree */
int dtree_create(gasp_t *g, int fan_out, int64_t num_work_items,
int can_parent, int parents_work, double rank_mul,
int num_threads, int (*threadid)(),
double first, double rest, int16_t min_distrib, dtree_t **dt, int *is_parent);
void dtree_destroy(dtree_t *dt);
int dtree_create(gasp_t *g, int fan_out, int64_t num_work_items,
int can_parent, int parents_work, double rank_mul,
int num_threads, int (*threadid)(),
double first, double rest, int16_t min_distrib,
dtree_t **dt, int *is_parent);
void dtree_destroy(dtree_t *dt);

/* call to get initial work allocation; before dtree_run() is called */
int64_t dtree_initwork(dtree_t *dt, int64_t *first_item, int64_t *last_item);
int64_t dtree_initwork(dtree_t *dt, int64_t *first_item, int64_t *last_item);

/* get a block of work */
int64_t dtree_getwork(dtree_t *dt, int64_t *first_item, int64_t *last_item);
int64_t dtree_getwork(dtree_t *dt, int64_t *first_item, int64_t *last_item);

/* call from a thread repeatedly until it returns 0 */
int dtree_run(dtree_t *dt);
int dtree_run(dtree_t *dt);

/* utility helpers */
uint64_t rdtsc();
void cpu_pause();
void start_sde_tracing();
void stop_sde_tracing();
void cpu_pause();
void start_sde_tracing();
void stop_sde_tracing();

#endif /* _GASP_H */

13 changes: 13 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ CC=mpicc
CRAY?=no
INTEL?=no

ifneq ($(wildcard /opt/cray/.),)
CRAY=yes
endif

.SUFFIXES: .c .h .o .a
.PHONY: clean test

Expand All @@ -18,16 +22,25 @@ CFLAGS+=-fpic
CFLAGS+=-I./include
CFLAGS+=-I./src

ifdef TRACE_DTREE
CFLAGS+=-DTRACE_DTREE=$(TRACE_DTREE)
endif
ifdef SHOW_DTREE
CFLAGS+=-DSHOW_DTREE=1
endif

ifeq ($(CRAY),yes)
CC=cc
#CFLAGS+=-craympich-mt
CFLAGS+=-DSDE_TRACING=1
LDFLAGS+=-Wl,--whole-archive,-ldmapp,--no-whole-archive
LDFLAGS+=-Wl,-rpath=/global/u1/k/kpamnany/mpich2-intel/lib
endif

ifeq ($(INTEL),yes)
CC=mpiicc
CFLAGS+=-mt_mpi
CFLAGS+=-DSDE_TRACING=1
endif

SRCS=src/gasp.c src/garray.c src/dtree.c src/log.c
Expand Down
5 changes: 3 additions & 2 deletions src/dtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ static void init_distrib_fractions(dtree_t *dt)
dt->distrib_fractions[0] = 1.0;

/* report rank multiplier */
MPI_Send(&dt->rank_mul, 1, MPI_DOUBLE, dt->parent, 0, MPI_COMM_WORLD);
if (dt->parent != -1)
MPI_Send(&dt->rank_mul, 1, MPI_DOUBLE, dt->parent, 0, MPI_COMM_WORLD);
}

/* reports work their way up */
Expand Down Expand Up @@ -349,7 +350,7 @@ int dtree_create(gasp_t *g,
if (dt->num_children) {
printf("[%04d] parent=[%04d], #children=%d (",
dt->g->rank, dt->parent, dt->num_children);
for (i = 0; i < dt->num_children-1; i++)
for (int i = 0; i < dt->num_children-1; i++)
printf("%d,", dt->children[i]);
printf("%d)\n", dt->children[dt->num_children-1]);
}
Expand Down
Loading

0 comments on commit 719a539

Please sign in to comment.