Skip to content

Commit

Permalink
refactor build process (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
stgeke authored Nov 14, 2017
1 parent 9533e65 commit eecae89
Show file tree
Hide file tree
Showing 27 changed files with 139 additions and 129 deletions.
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
- TEST=findpts_el_2_test2 NP=2
- TEST=findpts_el_3_test NP=2
- TEST=findpts_el_3_test2 NP=2
- TEST=findpts_el_2_test2 NP=2
- TEST=findpts_local_test NP=2
- TEST=findpts_test NP=2
- TEST=gs_test NP=2
Expand All @@ -31,14 +32,9 @@ env:
- TEST=xxt_test NP=3
- TEST=xxt_test2 NP=2

matrix:
allow_failures:
- env: TEST=findpts_el_2_test2 NP=2
- env: TEST=gs_test_old NP=2

install: true

script:
- cd $ROOT_DIR/src
- make CC=mpicc $TEST
- mpiexec -np $NP ./$TEST
- cd $ROOT_DIR
- make CC=mpicc tests/$TEST
- mpiexec -np $NP ./tests/$TEST
113 changes: 113 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
MPI ?= 1
MPIIO ?= 1
ADDUS ?= 1
USREXIT ?= 0
LIBNAME ?= gs
BLAS ?= 0
CFLAGS ?= -O2

SRCROOT=.
TESTDIR=$(SRCROOT)/tests
SRCDIR=$(SRCROOT)/src
INCDIR=$(SRCROOT)/src
LIBDIR=$(SRCROOT)/lib

ifneq (,$(strip $(PREFIX)))
INSTALL_ROOT = $(PREFIX)
else
INSTALL_ROOT = $(LIBDIR)
endif

ifneq (0,$(MPI))
G+=-DMPI
endif

ifneq (0,$(MPIIO))
ifneq (0,$(MPI))
G+=-DUSEMPIIO
endif
endif

ifneq (0,$(ADDUS))
G+=-DUNDERSCORE
endif

ifneq (0,$(USREXIT))
G+=-DUSE_USR_EXIT
endif

ifeq (0,$(BLAS))
G+=-DUSE_NAIVE_BLAS
endif

ifeq (1,$(BLAS))
G+=-DUSE_CBLAS
endif

ifneq ($(PREFIX),)
G+=-DPREFIX=$(PREFIX)
endif

ifneq ($(FPREFIX),)
G+=-DFPREFIX=$(FPREFIX)
endif

G+=-DGLOBAL_LONG_LONG
#G+=-DPRINT_MALLOCS=1
#G+=-DGS_TIMING -DGS_BARRIER

CCCMD=$(CC) $(CFLAGS) -I$(INCDIR) $(G)
LINKCMD=$(CC) $(CFLAGS) -I$(INCDIR) $(G) $^ -o $@ -L$(SRCDIR) -l$(LIBNAME) -lm $(LDFLAGS)

TESTS=$(TESTDIR)/sort_test $(TESTDIR)/sort_test2 $(TESTDIR)/sarray_sort_test $(TESTDIR)/spchol_test \
$(TESTDIR)/comm_test $(TESTDIR)/crystal_test $(TESTDIR)/sarray_transfer_test \
$(TESTDIR)/gs_test $(TESTDIR)/gs_unique_test \
$(TESTDIR)/xxt_test $(TESTDIR)/xxt_test2 $(TESTDIR)/crs_test \
$(TESTDIR)/findpts_el_2_test $(TESTDIR)/findpts_el_2_test2 \
$(TESTDIR)/findpts_el_3_test $(TESTDIR)/findpts_el_3_test2 \
$(TESTDIR)/findpts_local_test $(TESTDIR)/findpts_test \
$(TESTDIR)/poly_test $(TESTDIR)/poly_test2 $(TESTDIR)/lob_bnd_test $(TESTDIR)/obbox_test

GS=$(SRCDIR)/gs.o $(SRCDIR)/sort.o $(SRCDIR)/sarray_transfer.o $(SRCDIR)/sarray_sort.o \
$(SRCDIR)/gs_local.o $(SRCDIR)/fail.o $(SRCDIR)/crystal.o $(SRCDIR)/comm.o $(SRCDIR)/tensor.o
XXT=$(SRCDIR)/sparse_cholesky.o $(SRCDIR)/xxt.o
AMG=$(SRCDIR)/amg.o
FWRAPPER=$(SRCDIR)/fcrystal.o $(SRCDIR)/fcrs.o $(SRCDIR)/findpts.o
INTP=$(SRCDIR)/findpts_local.o $(SRCDIR)/obbox.o $(SRCDIR)/poly.o $(SRCDIR)/lob_bnd.o $(SRCDIR)/findpts_el_3.o $(SRCDIR)/findpts_el_2.o

.PHONY: all lib install deps tests clean objects odepinfo

all : lib tests

lib: $(GS) $(XXT) $(AMG) $(FWRAPPER) $(INTP) $(SRCDIR)/rand_elt_test.o
@$(AR) cr $(SRCDIR)/lib$(LIBNAME).a $?
@ranlib $(SRCDIR)/lib$(LIBNAME).a

install: lib
@mkdir -p $(INSTALL_ROOT)
@cp -v $(SRCDIR)/lib$(LIBNAME).a $(INSTALL_ROOT)

tests: $(TESTS)

clean: ; @$(RM) $(SRCDIR)/*.o $(SRCDIR)/*.s $(SRCDIR)/*.a $(TESTS)

cmds: ; @echo CC = $(CCCMD); echo LINK = $(LINKCMD);

deps: ; ./cdep.py *.c > makefile.cdep;

odepinfo: deps objects; @./odep_info.py *.o

$(TESTS): % : %.o | lib
$(LINKCMD)

-include makefile.cdep

%.o: %.c ; $(CCCMD) -c $< -o $@
%.s: %.c ; $(CCCMD) -S $< -o $@
objects: $(OBJECTS) ;

#poly_imp.h: gen_poly_imp.c
# $(RM) poly_imp.h;
# $(CC) -lgmp -lm gen_poly_imp.c -o gen_poly_imp;
# ./gen_poly_imp > poly_imp.h;
# $(RM) gen_poly_imp
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ The build system relies on GNU Make with the `make` command. To compile gslib ju

```
cd src
make CC=mpicc CFLAGS="-O2"
make CC=mpicc
make PREFIX=<install path> install
```

This will create a library called `libgs.a`. They key `ADDUS` determines the name mangling (add underscore) for the Fortran interface.


# Applications

**\[1]&#160;[Nek5000](https://nek5000.mcs.anl.gov/)**: Nek5000 is the open-source, highly-scalable, spectral element code.
Expand Down
97 changes: 0 additions & 97 deletions src/Makefile

This file was deleted.

Loading

0 comments on commit eecae89

Please sign in to comment.