From: Arnaud Giersch Date: Tue, 7 Dec 2010 09:23:42 +0000 (+0100) Subject: Initial commit. X-Git-Tag: v0.1~255 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/f29b38ef2a056daa14bbfda2fce78063faa773d4?ds=inline Initial commit. --- f29b38ef2a056daa14bbfda2fce78063faa773d4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..feed568 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*~ +*.d +*.o +localversion +loba +simple_async +simgrid-*-install +*/ diff --git a/Dep.xml b/Dep.xml new file mode 100644 index 0000000..c796848 --- /dev/null +++ b/Dep.xml @@ -0,0 +1,2604 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0653492 --- /dev/null +++ b/Makefile @@ -0,0 +1,70 @@ +SIMGRID_INSTALL_DIR := ./simgrid-3.5-install + +OPTIM_FLAGS += -O3 +DEBUG_FLAGS += -g +CHECK_FLAGS += -Wall -Wextra + +CC := gcc +CXX := g++ + +CPPFLAGS += -I $(SIMGRID_INSTALL_DIR)/include +CPPFLAGS += $(CHECK_FLAGS) + +CFLAGS += -std=c99 +CFLAGS += -fgnu89-inline # workaround simgrid bug +CFLAGS += $(OPTIM_FLAGS) $(DEBUG_FLAGS) + +CXXFLAGS += $(OPTIM_FLAGS) $(DEBUG_FLAGS) + +LDFLAGS += -L $(SIMGRID_INSTALL_DIR)/lib +LDFLAGS += -Wl,-rpath,$(SIMGRID_INSTALL_DIR)/lib + +LINK.o = $(CXX) $(LDFLAGS) $(TARGET_ARCH) +LDLIBS := -lsimgrid + +MAKEDEPEND.C = $(CC) $(CPPFLAGS) -MM -MF $@ $< +MAKEDEPEND.CXX = $(CXX) $(CPPFLAGS) -MM -MF $@ $< + +LOCALVERSION := localversion +SETLOCALVERSION := ./setlocalversion + +SRC.loba := main.cpp \ + communicator.cpp \ + parameters.cpp \ + process.cpp \ + version.cpp + +SRC.simple_async := simple_async.cpp + +SRC := $(SRC.loba) $(SRC.simple_async) +OBJ := $(SRC:%.cpp=%.o) +DEP := $(SRC:%.cpp=%.d) + +TARGETS := loba simple_async + +$(shell $(SETLOCALVERSION)) + +.PHONY: all depend clean + +all: $(TARGETS) + +clean: + $(RM) core core.[0-9]* vgcore.[0-9]* + $(RM) $(LOCALVERSION) + $(RM) $(OBJ) + $(RM) $(DEP) + $(RM) $(TARGETS) + +realclean: clean + $(RM) *~ + +%.d: %.c ; $(MAKEDEPEND.C) +%.d: %.cpp ; $(MAKEDEPEND.CXX) + +version.o: $(patsubst %.cpp,%.o,$(filter-out version.cpp, $(SRC.loba))) + +-include $(DEP) + +.SECONDEXPANSION: +$(TARGETS): $$(patsubst %.cpp,%.o,$$(SRC.$$@)) + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ diff --git a/NOTES b/NOTES new file mode 100644 index 0000000..489006c --- /dev/null +++ b/NOTES @@ -0,0 +1,28 @@ +Process parameters: + + initial_load [neighbors...] + +Communications: + - two channels per host: normal and low_latency + +How shall we manage link failures ? + +Process model (?) + + while (there is something to do) { + compute some task; + get received tasks; + compute load balancing; + send tasks to neighbors; + } + + * Open Questions : + - definition of load on heterogeneous hosts? + - how to detect convergence? + : No need to detect convergence. Computation stops when there + nothing more to do. + + - how to manage link failures? + + - shall we retrieve pending tasks? + : Ideally, why shall. How? By using some acknowledgment? diff --git a/Plat.xml b/Plat.xml new file mode 100644 index 0000000..81e0687 --- /dev/null +++ b/Plat.xml @@ -0,0 +1,7407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application.xml b/application.xml new file mode 100644 index 0000000..be75562 --- /dev/null +++ b/application.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/communicator.cpp b/communicator.cpp new file mode 100644 index 0000000..b78b1c3 --- /dev/null +++ b/communicator.cpp @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include "communicator.h" + +// XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(comm, simu, + "Messages from asynchronous pipes"); + +namespace { + bool comm_test_n_destroy(msg_comm_t& comm) + { + if (MSG_comm_test(comm)) { + MSG_comm_destroy(comm); + return true; + } else + return false; + } +} + +communicator::communicator() +{ + const char* hostname = MSG_host_get_name(MSG_host_self()); + size_t len = std::strlen(hostname); + recv_mbox = new char[len + 1]; + strcpy(recv_mbox, hostname); + recv_task = NULL; + recv_comm = MSG_task_irecv(&recv_task, recv_mbox); +} + +communicator::~communicator() +{ + send_acknowledge(); + if (!sent_comm.empty()) + WARN1("Lost %ld send communications!", (long )sent_comm.size()); + delete[] recv_mbox; +} + + +void communicator::send(m_task_t task, const char *dest) +{ + sent_comm.push_back(MSG_task_isend(task, dest)); + send_acknowledge(); +} + +void communicator::send(m_task_t task, const std::string& dest) +{ + send(task, dest.c_str()); +} + +m_task_t communicator::recv() +{ + m_task_t task = NULL; + if (comm_test_n_destroy(recv_comm)) { + task = recv_task; + recv_task = NULL; + recv_comm = MSG_task_irecv(&recv_task, recv_mbox); + } + return task; +} + +int communicator::sent_count() +{ + send_acknowledge(); + return sent_comm.size(); +} + +void communicator::send_acknowledge() +{ + std::remove_if(sent_comm.begin(), sent_comm.end(), comm_test_n_destroy); +} + +// Local variables: +// mode: c++ +// End: diff --git a/communicator.h b/communicator.h new file mode 100644 index 0000000..ca0d3b2 --- /dev/null +++ b/communicator.h @@ -0,0 +1,34 @@ +// Asynchronous communicator + +#ifndef COMMUNICATOR_H +#define COMMUNICATOR_H + +#include +#include +#include + +class communicator { +public: + communicator(); + ~communicator(); + + void send(m_task_t task, const char *dest); + void send(m_task_t task, const std::string& dest); + m_task_t recv(); + int sent_count(); + +private: + typedef std::list comm_list; + comm_list sent_comm; + char* recv_mbox; + msg_comm_t recv_comm; + m_task_t recv_task; + + void send_acknowledge(); +}; + +#endif // !COMMUNICATOR_H + +// Local variables: +// mode: c++ +// End: diff --git a/load_balance.h b/load_balance.h new file mode 100644 index 0000000..d524aa7 --- /dev/null +++ b/load_balance.h @@ -0,0 +1,13 @@ +#ifndef LOAD_BALANCE_H +#define LOAD_BALANCE_H + +class loba { +public: + +}; + +#endif // !LOAD_BALANCE_H + +// Local variables: +// mode: c++ +// End: diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..df1126a --- /dev/null +++ b/main.cpp @@ -0,0 +1,129 @@ +#include // for strlen() +#include +#include +#include +#include "misc.h" +#include "parameters.h" +#include "process.h" +#include "timer.h" +#include "version.h" + +// Creates a new log category and makes it the default +XBT_LOG_NEW_DEFAULT_CATEGORY(simu, "Simulation messages"); + +// Failure exit status +enum { + EXIT_NO_FAILURE = 0x00, // no error + EXIT_FAILURE_ARGS = 0x01, // bad arguments + EXIT_FAILURE_INIT = 0x02, // failed to initialize simulator + EXIT_FAILURE_SIMU = 0x04, // simulation failed + EXIT_FAILURE_CLEAN = 0x08, // error at cleanup +}; + +int simulation_main(int argc, char *argv[]) +{ + process proc(argc, argv); + return proc.run(); +} + +int main(int argc, char *argv[]) +{ + // Note: variables used after THROW must be declared as volatile. + volatile int exit_status = 0; // global exit status + volatile double simulated_time = -1.0; + timestamp simulation_time; + xbt_ex_t ex; + MSG_error_t res; + + simulation_time.start(); + + // Set default logging threshold. + // xbt_log_control_set("simu.thres:verbose"); + + // Initialize some MSG internal data. + // Note: MSG_global_init() may throw an exception, but it seems + // impossible to catch it correctly :-( + MSG_global_init(&argc, argv); + + // Parse global parameters + int parse_res = param::parse_args(&argc, argv); + if (!parse_res + || param::version_requested || param::help_requested) { + if (param::version_requested) + std::clog << version::name << " version " << version::num << "\n" + << version::copyright << "\n" + "Compiled on " << version::date << "\n\n"; + if (!parse_res || param::help_requested) + param::usage(); + MSG_clean(); + exit(parse_res ? EXIT_NO_FAILURE : EXIT_FAILURE_ARGS); + } + param::print(); + + TRY { + exit_status = EXIT_FAILURE_INIT; // ===== + + // Register the main function of an agent in a global table. + MSG_function_register("simulation_main", simulation_main); + // Preserve some compatibility with old code... + MSG_function_register("Calculs", simulation_main); + + // Create the platform and the application. + MSG_create_environment(param::platform_file); + if (LOG_ISENABLED(xbt_log_priority_verbose)) { + int n = MSG_get_host_number(); + m_host_t *h = MSG_get_host_table(); + VERB1("Got %d hosts.", n); + for (int i = 0; i < n; i++) + VERB2("Host #%d named \"%s\".", i, MSG_host_get_name(h[i])); + xbt_free(h); + } + MSG_launch_application(param::application_file); + + exit_status = EXIT_FAILURE_SIMU; // ===== + + // Launch the MSG simulation. + INFO0("Starting simulation..."); + res = MSG_main(); + INFO0("Simulation ended."); + simulated_time = MSG_get_clock(); + if (res != MSG_OK) + THROW1(0, 0, "MSG_main() failed with status %#x", res); + + exit_status = EXIT_NO_FAILURE; // ===== + } + CATCH (ex) { + int len = strlen(ex.msg); + if (len > 0 && ex.msg[len - 1] == '\n') + ex.msg[len - 1] = '\0'; // strip the ending '\n' + ERROR1("%s", ex.msg); + DEBUG3("Error from %s() in %s:%d", ex.func, ex.file, ex.line); + xbt_ex_free(ex); + } + + // Clean the MSG simulation. + res = MSG_clean(); + if (res != MSG_OK) { + ERROR1("MSG_clean() failed with status %#x", res); + exit_status |= EXIT_FAILURE_CLEAN; + } + + // Report final simulation status. + if (simulated_time >= 0.0) { + simulation_time.stop(); + INFO0(",----[ Results ]"); + INFO1("| Total simulated time...: %g", simulated_time); + INFO1("| Total simulation time..: %g", simulation_time.duration()); + INFO0("`----"); + } + if (exit_status) + ERROR1("Simulation failed (%#x).", exit_status); + else + INFO0("Simulation succeeded."); + + return exit_status; +} + +// Local variables: +// mode: c++ +// End: diff --git a/misc.h b/misc.h new file mode 100644 index 0000000..a4a6db1 --- /dev/null +++ b/misc.h @@ -0,0 +1,17 @@ +#ifndef MISC_H +#define MISC_H + +#include + +/* Returns true if the given priority is enabled for the default + * category. Priority is xbt_log_priority_SUFFIX, where SUFFIX may + * be: trace, debug, verbose, info, warning, error, critical. + */ +#define LOG_ISENABLED(priority) \ + (_XBT_LOG_ISENABLEDV((*_XBT_LOGV(default)), (priority))) + +#endif // !MISC_H + +// Local variables: +// mode: c++ +// End: diff --git a/neighbor.h b/neighbor.h new file mode 100644 index 0000000..13d1108 --- /dev/null +++ b/neighbor.h @@ -0,0 +1,26 @@ +#ifndef NEIGHBOR_H +#define NEIGHBOR_H + +#include +#include + +class neighbor { +public: + neighbor(const char* const name_) + : name(name_) + , load(std::numeric_limits::infinity()) { + } + const std::string& getName() const { return name; } + double getLoad() const { return load; } + void setLoad(double l) { load = l; } + +private: + std::string name; + double load; +}; + +#endif // !NEIGHBOR_H + +// Local variables: +// mode: c++ +// End: diff --git a/parameters.cpp b/parameters.cpp new file mode 100644 index 0000000..307882b --- /dev/null +++ b/parameters.cpp @@ -0,0 +1,82 @@ +#include // for strrchr() +#include +#include // for getopt() +#include +#include "parameters.h" +#include "misc.h" + +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu); + +namespace param { + + const char* program_name; + + const char* platform_file; + const char* application_file; + + int help_requested = 0; + bool version_requested = false; + + int parse_args(int* argc, char* argv[]) + { + program_name = strrchr(argv[0], '/'); + program_name = (program_name ? program_name + 1 : argv[0]); + + int c; + opterr = 0; + while ((c = getopt(*argc, argv, "hV")) != -1) { + switch (c) { + case 'h': + help_requested++; + break; + case 'V': + version_requested = true; + break; + case '?': + WARN1("invalid option -- '%c'", optopt); + break; + } + } + if (version_requested || help_requested) + return 1; + + switch (*argc - optind) { + case 0: + ERROR0("missing parameter -- "); + case 1: + ERROR0("missing parameter -- "); + return 0; + + default: + platform_file = argv[optind]; + application_file = argv[optind + 1]; + for (int i = optind + 2 ; i < *argc ; ++i) + WARN1("unused parameter -- \"%s\"", argv[i]); + break; + } + + return 1; + } + + void print() + { + INFO0(",----[ Simulation parameters ]"); + INFO1("| platform_file.....: \"%s\"", platform_file); + INFO1("| application_file..: \"%s\"", application_file); + INFO0("`----"); + } + + void usage() + { + std::clog << "Usage: " << program_name << " [options] \n"; + std::clog << " -h print help and exit (use -hh or -hhh for extended help)\n"; + if (help_requested < 1) + return; + std::clog << " -V print version and exit\n"; + } + +} // namespace param + +// Local variables: +// mode: c++ +// End: diff --git a/parameters.h b/parameters.h new file mode 100644 index 0000000..cf301e2 --- /dev/null +++ b/parameters.h @@ -0,0 +1,25 @@ +#ifndef PARAMETERS_H +#define PARAMETERS_H + +// Global parameters, shared by all the processes +namespace param { + + extern const char* program_name; + + extern const char* platform_file; + extern const char* application_file; + + extern int help_requested; + extern bool version_requested; + + int parse_args(int* argc, char* argv[]); + void print(); + void usage(); + +} // namespace param + +#endif // !PARAMETERS_H + +// Local variables: +// mode: c++ +// End: diff --git a/platform.xml b/platform.xml new file mode 100644 index 0000000..677cd63 --- /dev/null +++ b/platform.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/process.cpp b/process.cpp new file mode 100644 index 0000000..8ceb469 --- /dev/null +++ b/process.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include "misc.h" +#include "process.h" + +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu); + +struct message { + double measure; + double transfer; +}; + +process::process(int argc, char *argv[]) +{ + if (argc < 2 || !(std::istringstream(argv[1]) >> load)) + throw std::invalid_argument("bad or missing initial load"); + neigh.assign(argv + 2, argv + argc); + e_xbt_log_priority_t logp = xbt_log_priority_verbose; + if (!LOG_ISENABLED(logp)) + return; + LOG1(logp, "My initial load is: %g", load); + std::ostringstream oss; + oss << neigh.size() << " neighbor"; + if (!neigh.empty()) { + oss << (neigh.size() > 1 ? "s: " : ": "); + std::transform(neigh.begin(), neigh.end() - 1, + std::ostream_iterator(oss, ", "), + std::mem_fun_ref(&neighbor::getName)); + oss << neigh.back().getName(); + } + LOG1(logp, "Got %s.", oss.str().c_str()); + print_loads(logp); +} + +void process::print_loads(e_xbt_log_priority_t logp) +{ + if (!LOG_ISENABLED(logp)) + return; + std::ostringstream oss; + if (neigh.empty()) { + oss << "no neighbor!"; + } else { + std::transform(neigh.begin(), neigh.end() - 1, + std::ostream_iterator(oss, ", "), + std::mem_fun_ref(&neighbor::getLoad)); + oss << neigh.back().getLoad(); + } + LOG1(logp, "Neighbor loads: %s", oss.str().c_str()); +} + +int process::run() +{ + INFO0("Coucou !"); + MSG_process_sleep(100.0); // xxx + /* xxx: + * while (there is something to do) { + * compute some task; + * get received tasks; + * compute load balancing; + * send tasks to neighbors; + * } + */ + + /* Open Questions : + * - definition of load on heterogeneous hosts ? + * - how to detect convergence ? + * - how to manage link failures ? + */ + + // xxx: shall we retrieve pending tasks? + + return 0; +} + +// Local variables: +// mode: c++ +// End: diff --git a/process.h b/process.h new file mode 100644 index 0000000..ea35003 --- /dev/null +++ b/process.h @@ -0,0 +1,26 @@ +#ifndef PROCESS_H +#define PROCESS_H + +#include +#include +#include "communicator.h" +#include "neighbor.h" + +class process { +public: + process(int argc, char *argv[]); + ~process() { }; + void print_loads(e_xbt_log_priority_t logp = xbt_log_priority_info); + int run(); + +private: + communicator comm; + std::vector neigh; + double load; +}; + +#endif // !PROCESS_H + +// Local variables: +// mode: c++ +// End: diff --git a/setlocalversion b/setlocalversion new file mode 100755 index 0000000..43ac91a --- /dev/null +++ b/setlocalversion @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +FILE=localversion + +compute_version() +{ + if [ ! -d .git ]; then + return; + fi + head=$(git rev-parse --verify --short HEAD) + printf "~git-%s" "$head" +} + +[ -f "$FILE" ] || touch "$FILE" + +old_version=$(< "$FILE") +version=$(printf '"%s"\n' "$(compute_version)") + +if [ "$version" != "$old_version" ]; then + echo "$version" > "$FILE" +fi diff --git a/simple_async.cpp b/simple_async.cpp new file mode 100644 index 0000000..b2d8bc0 --- /dev/null +++ b/simple_async.cpp @@ -0,0 +1,204 @@ +#include // strlen +#include // sprintf +#include // clock() +#include +#include + +// Creates a new log category and makes it the default +XBT_LOG_NEW_DEFAULT_CATEGORY(simu, "Simulation messages"); + +#define N_MBOX 5 +#define N_MESG 16 + +// Failure exit status +enum { + EXIT_NO_FAILURE = 0x00, // no error + EXIT_FAILURE_ARGS = 0x01, // bad arguments + EXIT_FAILURE_INIT = 0x02, // failed to initialize simulator + EXIT_FAILURE_SIMU = 0x04, // simulation failed + EXIT_FAILURE_CLEAN = 0x08, // error at cleanup +}; + +int sender(int, char *[]) +{ + char mbox_stack[N_MBOX][100]; + msg_comm_t comm_stack[N_MBOX * N_MESG]; + msg_comm_t *comm = comm_stack; + for (int i = 0 ; i < N_MBOX ; i++) + sprintf(mbox_stack[i], "MBox_%02d", i); + + INFO0("Starting..."); + int n = 0; + for (int i = 0 ; i < N_MBOX ; i++) + for (int j = 0 ; j < N_MESG ; j++) { + char task_name[100]; + const char *mailbox = mbox_stack[i]; + unsigned shift = j; + unsigned comm_size = 1 << shift; + m_task_t task; + + sprintf(task_name, "Task_%02d", n); + task = MSG_task_create(task_name, 0, 1024.0 * comm_size, NULL); + INFO4("At %02d, send %s, size %.0f to \"%s\"", n, + MSG_task_get_name(task), + MSG_task_get_data_size(task), mailbox); + *comm++ = MSG_task_isend(task, mailbox); + ++n; + } + + INFO0("Wait for communications to terminate..."); + MSG_comm_waitall(comm_stack, comm - comm_stack, -1.0); + + INFO0("Finished."); + return 0; +} + +int receiver(int, char *[]) +{ + char mbox[N_MBOX][100]; + int comm_count[N_MBOX]; + m_task_t tasks[N_MBOX]; + msg_comm_t comms[N_MBOX]; + + for (int i = 0 ; i < N_MBOX ; i++) { + sprintf(mbox[i], "MBox_%02d", i); + comm_count[i] = N_MESG; + tasks[i] = NULL; + comms[i] = NULL; + } + + INFO0("Starting..."); + xbt_dynar_t dcomms = xbt_dynar_new(sizeof(msg_comm_t), NULL); + for (int i = 0 ; i < N_MBOX ; i++) { + if (comm_count[i] > 0) { + comms[i] = MSG_task_irecv(&tasks[i], mbox[i]); + xbt_dynar_push(dcomms, &comms[i]); + --comm_count[i]; + } + } + int n = 0; + while (xbt_dynar_length(dcomms)) { + MSG_comm_waitany(dcomms); + xbt_dynar_reset(dcomms); + for (int i = 0 ; i < N_MBOX ; i++) { + if (!comms[i]) + continue; + if (!MSG_comm_test(comms[i])) { + xbt_dynar_push(dcomms, &comms[i]); + continue; + } + MSG_comm_destroy(comms[i]); + comms[i] = NULL; + + INFO4("At %02d, received %s, size %.0f from \"%s\"", n++, + MSG_task_get_name(tasks[i]), + MSG_task_get_data_size(tasks[i]), + mbox[i]); + + MSG_task_destroy(tasks[i]); + tasks[i] = NULL; + + if (comm_count[i] > 0) { + comms[i] = MSG_task_irecv(&tasks[i], mbox[i]); + xbt_dynar_push(dcomms, &comms[i]); + --comm_count[i]; + } + } + } + xbt_dynar_free(&dcomms); + + INFO0("Finished."); + return 0; +} + +int main(int argc, char *argv[]) +{ + const char *platform_file; + const char *application_file; + // Note: variables used after THROW must be declared as volatile. + volatile int exit_status; // global exit status + volatile double simulated_time = -1.0; + volatile clock_t start_time = clock(); + xbt_ex_t ex; + MSG_error_t res; + + // Initialize some MSG internal data. + // Note: MSG_global_init() may throw an exception, but it seems + // impossible to catch it correctly :-( + MSG_global_init(&argc, argv); + + exit_status = EXIT_FAILURE_ARGS; // ===== + TRY { + + // Parse global parameters + if (argc != 3) { + INFO1("Usage: %s platform_file application_file", argv[0]); + THROW0(0, 0, "Failed to parse command line\n"); + } + platform_file = argv[1]; + application_file = argv[2]; + + INFO0(",----[ Simulation parameters ]"); + INFO1("| platform_file.....: \"%s\"", platform_file); + INFO1("| application_file..: \"%s\"", application_file); + INFO0("`----"); + + exit_status = EXIT_FAILURE_INIT; // ===== + + // Register the main functions of an agent in a global table. + MSG_function_register("sender", sender); + MSG_function_register("receiver", receiver); + + // Create the platform and the application. + MSG_create_environment(platform_file); + MSG_launch_application(application_file); + + exit_status = EXIT_FAILURE_SIMU; // ===== + + // Launch the MSG simulation. + INFO0("Starting simulation..."); + res = MSG_main(); + INFO0("Simulation ended."); + simulated_time = MSG_get_clock(); + if (res != MSG_OK) + THROW1(0, 0, "MSG_main() failed with status %#x", res); + + exit_status = EXIT_NO_FAILURE; // ===== + } + CATCH (ex) { + int len = strlen(ex.msg); + if (len > 0 && ex.msg[len - 1] == '\n') + len--; // strip the ending '\n' + ERROR2("%.*s", len, ex.msg); + DEBUG3("Error from %s() in %s:%d", ex.func, ex.file, ex.line); + xbt_ex_free(ex); + } + + // Clean the MSG simulation. + res = MSG_clean(); + if (res != MSG_OK) { + ERROR1("MSG_clean() failed with status %#x", res); + exit_status |= EXIT_FAILURE_CLEAN; + } + + // Report final simulation status. + if (simulated_time >= 0.0) { + clock_t end_time = clock(); + double simulation_time = + (double )(end_time - start_time) / CLOCKS_PER_SEC; + INFO0(",----[ Results ]"); + INFO1("| Total simulated time...: %g", simulated_time); + INFO1("| Total simulation time..: %g", simulation_time); + INFO0("`----"); + } + if (exit_status == 0) + INFO0("Simulation succeeded."); + else + ERROR1("Simulation failed (%#x).", exit_status); + + return exit_status; +} + +// Local variables: +// mode: c++ +// End: diff --git a/simple_async.xml b/simple_async.xml new file mode 100644 index 0000000..f88d443 --- /dev/null +++ b/simple_async.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/timer.h b/timer.h new file mode 100644 index 0000000..6ae15eb --- /dev/null +++ b/timer.h @@ -0,0 +1,94 @@ +#ifndef TIMER_H +#define TIMER_H + +#include +#include + +#if NEED_TIMERCLEAR +inline +void timerclear(struct timeval& a) +{ + tv.sec = tv.usec = 0; +} +#endif + +inline +struct timeval operator+(const struct timeval& a, const struct timeval& b) +{ + struct timeval result; + result.tv_sec = a.tv_sec + b.tv_sec; + result.tv_usec = a.tv_usec + b.tv_usec; + if (result.tv_usec >= 1000000) { + ++result.tv_sec; + result.tv_usec -= 1000000; + } + return result; +} + +inline +struct timeval operator-(const struct timeval& a, const struct timeval& b) +{ + timeval result; + result.tv_sec = a.tv_sec - b.tv_sec; + result.tv_usec = a.tv_usec - b.tv_usec; + if (result.tv_usec < 0) { + -- result.tv_sec; + result.tv_usec += 1000000; + } + return result; +} + +double timertod(const timeval& a) +{ + return a.tv_sec + a.tv_usec / 1e6; +} + +class timestamp { +private: + struct rusage before; + struct rusage after; + struct timeval difference; + +public: + timestamp() + { + reset(); + } + + void reset() + { + timerclear(&before.ru_utime); + timerclear(&before.ru_stime); + timerclear(&after.ru_utime); + timerclear(&after.ru_stime); + timerclear(&difference); + } + + void start() + { + getrusage(RUSAGE_SELF, &before); + } + + void stop() + { + getrusage(RUSAGE_SELF, &after); + difference = difference + ((after.ru_utime + after.ru_stime) - + (before.ru_utime + before.ru_stime)); + } + + struct timeval tv_duration() const + { + return difference; + } + + double duration() const + { + return timertod(difference); + } +}; + +#endif // !TIMER_H + +// Local variables: +// mode: c++ +// End: diff --git a/version.cpp b/version.cpp new file mode 100644 index 0000000..db840a1 --- /dev/null +++ b/version.cpp @@ -0,0 +1,16 @@ +#include "version.h" + +namespace version { + + const char name[] = "Asynchronous Load Balancing (loba)"; + const char num[] = "0x00" +#include "localversion" +; + const char date[] = __DATE__ " " __TIME__; + const char copyright[] = "Copyright (c) 2010, Arnaud Giersch "; + +} + +// Local variables: +// mode: c++ +// End: diff --git a/version.h b/version.h new file mode 100644 index 0000000..8bb146a --- /dev/null +++ b/version.h @@ -0,0 +1,17 @@ +#ifndef VERSION_H +#define VERSION_H + +namespace version { + + extern const char name[]; + extern const char num[]; + extern const char date[]; + extern const char copyright[]; + +} + +#endif // !VERSION_H + +// Local variables: +// mode: c++ +// End: