Skip to content

Commit

Permalink
Fixed loop in build.
Browse files Browse the repository at this point in the history
Still working on testParallel.
  • Loading branch information
highperformancecoder committed Sep 27, 2024
1 parent efa515e commit 3440aee
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 70 deletions.
72 changes: 28 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)))
Expand All @@ -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)
Expand All @@ -125,40 +128,18 @@ 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)
$(MAKE) $(ELIBS)

.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)

Expand Down Expand Up @@ -221,6 +202,7 @@ endif

.PHONY: clean
clean:
-rm $(MCFG)
-$(BASIC_CLEAN) generate_nauty_sizes
-cd src; $(BASIC_CLEAN)
-cd utils; $(BASIC_CLEAN)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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); \
Expand All @@ -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 $@
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions include/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions include/ecolab.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef ECOLAB_H
#define ECOLAB_H
#include <stdlib.h>
#include "pythonBuffer.h"

// mpi.h must appear before any standard library stuff
#ifdef MPI_SUPPORT
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion models/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 16 additions & 15 deletions src/ecolab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "cairoSurfaceImage.h"
#include "plot.h"
#include "pythonBuffer.h"
#include "ecolab.h"
#ifdef MPI_SUPPORT
#include "graphcode.h"
#endif
Expand Down Expand Up @@ -50,6 +51,18 @@ namespace ecolab
Parallel();
};

static PyObject* exit(Parallel* self, PyObject*)
{
if (self->target)
{
#ifdef MPI_SUPPORT
MPIbuf b; b<<string("return")<<bcast(0);
#endif
self->target=nullptr;
}
return Py_None;
}

PyMethodDef parallelMethods[]={
{"exit",(PyCFunction)exit,METH_NOARGS,"Signal workers to knock off"},
{nullptr, nullptr, 0, nullptr}
Expand Down Expand Up @@ -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<<method<<bcast(0);
MPIbuf b; b<<method<<bcast(0);
#endif
return PyObject_Call(PyObject_GetAttr(target,PySequence_GetItem(args,0)),PyTuple_New(0),nullptr);
}

static PyObject* exit(Parallel* self, PyObject*)
{
if (self->target)
{
#ifdef MPI_SUPPORT
MPIBuf b; b<<"return"<<bcast(0);
#endif
self->target=nullptr;
}
return Py_None;
}

static int init(PyObject* self, PyObject* args, PyObject*)
{
if (!PySequence_Check(args) || PySequence_Size(args)<1)
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 5 additions & 2 deletions src/pythonMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ int main(int argc, char* argv[])
for (int i=1; i<argc; ++i)
PyList_Append(pyArgv, PyUnicode_FromString(argv[i]));
PySys_SetObject("argv",pyArgv);

return PyRun_SimpleFile(script,argv[1]);

int err=0;
if (err=PyRun_SimpleFile(script,argv[1]))
PyErr_Print();
return err;
}
7 changes: 4 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ GDBM+=-lgdbm
MODELS=testParallel
# vector-pair - doesn't currently compile - see ticket #161
#EXTRAMODELS=test_tcl_stl.exe tcl-arrays.exe complex_tcl_args.exe
EXES=test_omp_rw_lock testCheckpointableFile test_netcomplexity test_boostgraph test_ecostrstream posTest testarrays callTclArgsMethod pangoTest
#EXES=test_omp_rw_lock testCheckpointableFile test_netcomplexity test_boostgraph test_ecostrstream posTest testarrays pangoTest testParallel
EXES=test_omp_rw_lock testCheckpointableFile test_netcomplexity test_ecostrstream posTest testarrays pangoTest
SPECIALS=testNDBM testBDB

ifeq ($(CC),gcc)
Expand All @@ -38,7 +39,7 @@ CXXFLAGS+=-std=c++11
endif

#chmod command is to counteract AEGIS removing execute privelege from scripts
all: $(MODELS) $(EXES) $(SPECIALS)
all: $(MODELS:=.so) $(EXES) $(SPECIALS)
-$(CHMOD) a+x *.tcl

ifeq ($(OS),Darwin)
Expand All @@ -50,7 +51,7 @@ $(MODELS:=.o): %.o: %.cc
$(CPLUSPLUS) -c -g $(FLAGS) $(CXXFLAGS) $<

# how to build a model
$(MODELS:=.so): %.so: %.o ../lib/libecolab.a
$(MODELS:=.so): %.so: %.o
$(LINK) $(FLAGS) -shared -Wl,-rpath $(ECOLAB_HOME)/lib $*.o $(LIBS) -o $@

# temporary workaround until directories of same name go
Expand Down
4 changes: 3 additions & 1 deletion test/testParallel.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "testParallel.h"
#include "testParallel.cd"
#include "ecolab.h"
#include "ecolab_epilogue.h"

Test test;
CLASSDESC_ADD_GLOBAL(test);
CLASSDESC_PYTHON_MODULE(test);
CLASSDESC_PYTHON_MODULE(testParallel);

17 changes: 15 additions & 2 deletions test/testParallel.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#include "ecolab.h"
#include <set>
struct Test
{
void runTest()
std::set<unsigned> runTest()
{
std::set<unsigned> procs;
#ifdef MPI_SUPPORT
MPIBuf()<<ecolab::myid()<<send(0);
classdesc::MPIbuf buf;
buf<<ecolab::myid();
buf.gather(0);
while (buf.pos()<buf.size())
{
unsigned p; buf>>p;
procs.insert(p);
}
assert(procs.size()==ecolab::nprocs());
#else
procs.insert(0);
#endif
return procs;
}
};
2 changes: 0 additions & 2 deletions test/test_netcomplexity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class B>
void test_iterator()
{
Expand Down

0 comments on commit 3440aee

Please sign in to comment.