diff --git a/Makefile b/Makefile index 5e2a9ce..c44eebd 100644 --- a/Makefile +++ b/Makefile @@ -35,13 +35,13 @@ include include/Makefile FLAGS+=-UECOLAB_LIB -DINSTALLED_ECOLAB_LIB=\"$(PREFIX)/include\" ifdef AEGIS -# must build and test against c++11 now, as TR1 has goone! -CXXFLAGS+=-std=c++11 +# must build and test against c++20 now +CXXFLAGS+=-std=c++20 endif # when upgrading MXE, this will need to be removed ifdef MXE -CXXFLAGS+=-std=c++11 +CXXFLAGS+=-std=c++20 endif @@ -75,7 +75,7 @@ OBJS+=src/xdr_pack.o endif # build for Mac Aqua interface, requires special static build of Tk. -ifdef MAC_OSX_TK +ifdef AQUA CXXFLAGS+=-DMAC_OSX_TK OBJS+=src/getContext.o endif @@ -86,6 +86,8 @@ CDHDRS= # Clunky, but this extracts all .cd files mentioned in header files, CDHDRS+=$(shell bash extractCDHeaders.sh) +cdhdrs: $(CDHDRS:%=include/%) graphcode.cd + ifdef UNURAN CDHDRS+=random_unuran.cd endif @@ -101,6 +103,8 @@ ELIBS=lib/libecolab$(ECOLIBS_EXT).a $(MODS:%=lib/%) # toplevel version include Makefile.version +# run build CD headers before anything else +include cdhdrs # variant of $(VERSION) that has leading 0s stripped (for sonames) SOVERSION=$(subst D0,D,$(subst D00,D,$(VERSION))) @@ -116,7 +120,6 @@ endif all: all-without-models $(MAKE) models - -$(CHMOD) a+x models/*.tcl all-without-models: ecolab-libs lib/libecolab$(ECOLIBS_EXT).a bin/ecolab$(ECOLIBS_EXT) -$(CHMOD) a+x $(SCRIPTS) @@ -125,30 +128,6 @@ ifdef MXE cp -r $(call search,lib*/tcl$(TCLVERSION)) include/tcl cp -r $(call search,lib*/tk$(TCLVERSION)) include/tk endif -# update Makefile.config with the configuration parameters used to build this - echo TK=$(TK)>$(MCFG) - echo ZLIB=$(ZLIB)>>$(MCFG) - echo READLINE=$(READLINE)>>$(MCFG) - echo XDR=$(XDR)>>$(MCFG) - echo UNURAN=$(UNURAN)>>$(MCFG) - echo PRNG=$(PRNG)>>$(MCFG) - echo GNUSL=$(GNUSL)>>$(MCFG) - echo PARMETIS=$(PARMETIS)>>$(MCFG) - echo IGRAPH=$(IGRAPH)>>$(MCFG) - echo SAUCY=$(SAUCY)>>$(MCFG) - echo CAIRO=$(CAIRO)>>$(MCFG) - echo PANGO=$(PANGO)>>$(MCFG) - echo BLT=$(BLT)>>$(MCFG) - echo BDB=$(BDB)>>$(MCFG) - echo GDBM=$(GDBM) >>$(MCFG) - echo GDBM_COMPAT=$(GDBM_COMPAT) >>$(MCFG) - echo MPI=$(MPI)>>$(MCFG) - echo PARALLEL=$(PARALLEL)>>$(MCFG) - echo OPENMP=$(OPENMP)>>$(MCFG) - echo GCC=$(GCC)>>$(MCFG) - echo NOGUI=$(NOGUI)>>$(MCFG) - echo AQUA=$(AQUA)>>$(MCFG) - echo MAC_OSX_TK=$(MAC_OSX_TK)>>$(MCFG) ecolab-libs: lib bin $(MAKE) $(UTILS) @@ -156,9 +135,11 @@ ecolab-libs: lib bin .PHONY: models classdesc -$(OBJS) $(MODS:%=src/%): $(CDHDRS:%=include/%) graphcode.cd +#$(OBJS) $(MODS:%=src/%): $(CDHDRS:%=include/%) graphcode.cd -$(OBJS:.o=.d) $(MODS:%.o=src/%.d): $(ECOLAB_HOME)/$(MCFG) +ifneq ($(MAKECMDGOALS),clean) +$(OBJS:.o=.d) $(MODS:%.o=src/%.d): $(ECOLAB_HOME)/$(MCFG) +endif $(CDHDRS:%=include/%): $(CLASSDESC) @@ -221,6 +202,7 @@ endif .PHONY: clean clean: + -rm $(MCFG) -$(BASIC_CLEAN) generate_nauty_sizes -cd src; $(BASIC_CLEAN) -cd utils; $(BASIC_CLEAN) @@ -240,7 +222,6 @@ clean: -rm -f lib/*.so lib/*.so.* bin/* -rm -rf classdesc-lib cxx_repository -rm -rf ii_files */ii_files - -rm $(MCFG) doc/ecolab/ecolab.html: doc/*.tex (cd doc; ./Makedoc) @@ -255,7 +236,7 @@ latex-docs: #bin/ecolab is a python interpreter supporting MPI bin/ecolab$(ECOLIBS_EXT): src/pythonMain.o lib/libecolab$(ECOLIBS_EXT).a - $(LINK) $(FLAGS) src/pythonMain.o -Wl,-rpath $(ECOLAB_HOME)/lib $(LIBS) $(shell pkg-config --libs python3) -o $@ + $(LINK) $(FLAGS) src/pythonMain.o -Wl,-rpath $(ECOLAB_HOME)/lib $(LIBS) -o $@ -find . \( -name "*.cc" -o -name "*.h" \) -print |etags - .PHONY: install @@ -287,10 +268,13 @@ UNURAN_LIB=$(firstword $(call search,lib*/libunuran.a)) $(ECOLAB_HOME)/$(MCFG): @rm -f $(MCFG) -# absolute dependecies - @if [ -z "$(call search,lib*/tclConfig.sh)" ]; then \ - echo "Error: Cannot find TCL - please install TCL"; fi -# optionals +# absolute dependencies + @if ! $(PKG_CONFIG) --exists python3; then \ + echo "Error: Cannot find Python libs - please install python3-dev"; \ + exit 1; \ + fi +# optional dependecies + @if [ -n "$(call search,lib*/tclConfig.sh)" ]; then echo TCL=1>>$(MCFG); fi @if [ -n "$(call search,lib*/tkConfig.sh)" ]; then echo TK=1>>$(MCFG); fi @if [ -n "$(call search,include/zlib.h)" ]; then echo ZLIB=1>>$(MCFG); fi @if [ -n "$(call search,include/readline/readline.h)" ]; then echo READLINE=1>>$(MCFG); fi @@ -303,8 +287,7 @@ $(ECOLAB_HOME)/$(MCFG): @if [ -n "$(call search,include/parmetis.h)" ]; then echo PARMETIS=1>>$(MCFG); fi @if [ -n "$(call search,include/igraph/igraph.h)" ]; then echo IGRAPH=1>>$(MCFG); fi @if [ -n "$(call search,include/saucy.h)" ]; then echo SAUCY=1>>$(MCFG); fi - @if $(PKG_CONFIG) --exists cairo; then echo CAIRO=1>>$(MCFG); \ - elif [ -n "$(call search,include/blt.h)" ]; then echo BLT=1>>$(MCFG); fi + @if $(PKG_CONFIG) --exists cairo; then echo CAIRO=1>>$(MCFG); fi # select Berkley DB by default, @if [ -n "$(call search,include/db4/db.h)" -o -n "$(call search,include/db.h)" ]; then \ echo BDB=1>>$(MCFG); \ @@ -325,6 +308,9 @@ $(ECOLAB_HOME)/$(MCFG): echo GCC=$(GCC)>>$(MCFG) echo NOGUI=$(NOGUI)>>$(MCFG) echo AQUA=$(AQUA)>>$(MCFG) +ifeq ($(origin XDR),"command line") + echo XDR=$(XDR)>>$(MCFG) +endif #generate_nauty_sizes: generate_nauty_sizes.c # $(CC) $(FLAGS) $(OPT) $< -o $@ @@ -343,12 +329,10 @@ src/getContext.o: src/getContext.cc # ./generate_nauty_sizes >$@ #endif -sure: all - -$(MAKE) $(TESTS) +tests: -cd test; $(MAKE) - -cd test/test_tcl_stl; $(MAKE) - -cd test/tcl-arrays; $(MAKE) - -cd test/complex_tcl_args; $(MAKE) + +sure: all tests sh runtests test/00/*.sh # install documentation on SourceForge diff --git a/include/Makefile b/include/Makefile index 54d0b1c..5c60b62 100644 --- a/include/Makefile +++ b/include/Makefile @@ -383,7 +383,9 @@ FLAGS+=-DZLIB LIBS+=-lz endif +# python FLAGS+=$(shell $(PKG_CONFIG) --cflags python3) +LIBS+=$(shell $(PKG_CONFIG) --libs python3) ifdef XDR # libtirpc is where the XDR routines have been moved to from glibc diff --git a/include/ecolab.h b/include/ecolab.h index ccf3642..f341c27 100644 --- a/include/ecolab.h +++ b/include/ecolab.h @@ -12,6 +12,7 @@ #ifndef ECOLAB_H #define ECOLAB_H #include +#include "pythonBuffer.h" // mpi.h must appear before any standard library stuff #ifdef MPI_SUPPORT @@ -54,6 +55,8 @@ typedef classdesc::string eco_string; namespace ecolab { + using namespace classdesc; + /* these are defined to default values, even if MPI is false */ /// MPI process ID and number of processes unsigned myid(); diff --git a/models/Makefile b/models/Makefile index 71ab8fe..5165a2a 100644 --- a/models/Makefile +++ b/models/Makefile @@ -37,7 +37,7 @@ endif $(MODELS:=.o): %.o: %.cc # how to build a model -$(MODELS:=.so): %.so: %.o ../lib/libecolab.a +$(MODELS:=.so): %.so: %.o ../lib/libecolab$(ECOLIBS_EXT).a $(LINK) $(FLAGS) -shared -Wl,-rpath $(ECOLAB_HOME)/lib $*.o $(LIBS) -o $@ #make MacOS application bundles diff --git a/src/ecolab.cc b/src/ecolab.cc index 2395dc6..31911b0 100644 --- a/src/ecolab.cc +++ b/src/ecolab.cc @@ -11,6 +11,7 @@ #include "cairoSurfaceImage.h" #include "plot.h" #include "pythonBuffer.h" +#include "ecolab.h" #ifdef MPI_SUPPORT #include "graphcode.h" #endif @@ -50,6 +51,18 @@ namespace ecolab Parallel(); }; + static PyObject* exit(Parallel* self, PyObject*) + { + if (self->target) + { +#ifdef MPI_SUPPORT + MPIbuf b; b<target=nullptr; + } + return Py_None; + } + PyMethodDef parallelMethods[]={ {"exit",(PyCFunction)exit,METH_NOARGS,"Signal workers to knock off"}, {nullptr, nullptr, 0, nullptr} @@ -83,23 +96,11 @@ namespace ecolab #ifdef MPI_SUPPORT std::string method=PyUnicode_AsUTF8(PySequence_GetItem(args,0)); // we need to pickle the arguments and kwargs, so leave argument support until later - MPIBuf b; b<target) - { -#ifdef MPI_SUPPORT - MPIBuf b; b<<"return"<target=nullptr; - } - return Py_None; - } - static int init(PyObject* self, PyObject* args, PyObject*) { if (!PySequence_Check(args) || PySequence_Size(args)<1) @@ -138,11 +139,11 @@ namespace ecolab #ifdef MPI_SUPPORT for (;myid()>0;) { - MPIBuf b; b.bcast(0); + MPIbuf b; b.bcast(0); std::string method; b>>method; if (method=="return") break; // we need to pickle the arguments and kwargs, so leave argument support until later - PyObject_Call(PyObject_GetAttrString(target,method.c_str()),Py_Tuple_new(0),nullptr); + PyObject_Call(PyObject_GetAttrString(target,method.c_str()),PyTuple_New(0),nullptr); } #endif } diff --git a/src/pythonMain.cc b/src/pythonMain.cc index 2e0291b..cc498e8 100644 --- a/src/pythonMain.cc +++ b/src/pythonMain.cc @@ -70,6 +70,9 @@ int main(int argc, char* argv[]) for (int i=1; i struct Test { - void runTest() + std::set runTest() { + std::set procs; #ifdef MPI_SUPPORT - MPIBuf()<>p; + procs.insert(p); + } + assert(procs.size()==ecolab::nprocs()); +#else + procs.insert(0); #endif + return procs; } }; diff --git a/test/test_netcomplexity.cc b/test/test_netcomplexity.cc index fa69911..ad867d4 100644 --- a/test/test_netcomplexity.cc +++ b/test/test_netcomplexity.cc @@ -29,8 +29,6 @@ bool nearly_equal(double x,double y) return fabs(x-y) < 1e-10*(fabs(x)+fabs(y)); } -Tcl_Interp *interp; - template void test_iterator() {