From 570f604b0852935e6781f63a1f54dfbeb23cd7d4 Mon Sep 17 00:00:00 2001 From: Chuck Atkins <chuck.atkins@kitware.com> Date: Tue, 28 Mar 2017 13:10:12 -0400 Subject: [PATCH] Removing Makefiles --- Makefile | 72 --- Makefile.libs | 87 --- bindings/python/Makefile | 53 -- buildADIOS1.sh | 53 -- buildBP.sh | 52 -- buildDataMan.sh | 55 -- examples/globalArray/Makefile | 36 -- examples/groupless/basic/Makefile | 26 - examples/groupless/compound/Makefile | 26 - examples/groupless/multistep/Makefile | 26 - examples/heatTransfer/Makefile | 66 --- examples/hello/Makefile | 35 -- examples/hello/adios1Writer/Makefile | 36 -- examples/hello/bpReader/Makefile | 31 -- examples/hello/bpWriter/Makefile | 31 -- examples/hello/compound/Makefile | 31 -- examples/hello/datamanReader/Makefile | 44 -- examples/hello/datamanWriter/Makefile | 44 -- examples/hello/timeBP/Makefile | 31 -- examples/hello/timeBP/test.sh | 5 - examples/solidfluid/Makefile | 33 -- examples/xmlParser/Makefile | 35 -- source/ADIOS.cpp | 346 ++++++++++++ source/ADIOS_C.cpp | 250 +++++++++ source/capsule/heap/STLVector.cpp | 80 +++ source/capsule/shmem/ShmSystemV.cpp | 80 +++ source/core/Capsule.cpp | 26 + source/core/Engine.cpp | 305 +++++++++++ source/core/Method.cpp | 63 +++ source/core/Support.cpp | 90 ++++ source/core/Transform.cpp | 27 + source/core/Transport.cpp | 49 ++ source/engine/adios1/ADIOS1Reader.cpp | 230 ++++++++ source/engine/adios1/ADIOS1Writer.cpp | 449 ++++++++++++++++ source/engine/bp/BPFileReader.cpp | 230 ++++++++ source/engine/bp/BPFileWriter.cpp | 508 ++++++++++++++++++ source/engine/dataman/DataManReader.cpp | 318 +++++++++++ source/engine/dataman/DataManWriter.cpp | 408 ++++++++++++++ source/format/BP1.cpp | 71 +++ source/format/BP1Aggregator.cpp | 95 ++++ source/format/BP1Writer.cpp | 394 ++++++++++++++ source/functions/adiosFunctions.cpp | 643 +++++++++++++++++++++++ source/mpidummy.cpp | 320 +++++++++++ source/transform/BZip2.cpp | 30 ++ source/transport/file/FStream.cpp | 71 +++ source/transport/file/FileDescriptor.cpp | 128 +++++ source/transport/file/FilePointer.cpp | 87 +++ source/transport/wan/MdtmMan.cpp | 75 +++ src/ADIOS.cpp | 317 ----------- src/ADIOS_C.cpp | 246 --------- src/capsule/heap/STLVector.cpp | 87 --- src/capsule/shmem/ShmSystemV.cpp | 96 ---- src/core/Capsule.cpp | 37 -- src/core/Engine.cpp | 185 ------- src/core/Method.cpp | 73 --- src/core/Support.cpp | 115 ---- src/core/Transform.cpp | 32 -- src/core/Transport.cpp | 62 --- src/engine/adios1/ADIOS1Reader.cpp | 178 ------- src/engine/adios1/ADIOS1Writer.cpp | 369 ------------- src/engine/bp/BPFileReader.cpp | 178 ------- src/engine/bp/BPFileWriter.cpp | 397 -------------- src/engine/dataman/DataManReader.cpp | 253 --------- src/engine/dataman/DataManWriter.cpp | 304 ----------- src/format/BP1.cpp | 67 --- src/format/BP1Aggregator.cpp | 97 ---- src/format/BP1Writer.cpp | 379 ------------- src/functions/adiosFunctions.cpp | 595 --------------------- src/mpidummy.cpp | 256 --------- src/transform/BZip2.cpp | 45 -- src/transport/file/FStream.cpp | 84 --- src/transport/file/FileDescriptor.cpp | 135 ----- src/transport/file/FilePointer.cpp | 98 ---- src/transport/wan/MdtmMan.cpp | 96 ---- 74 files changed, 5373 insertions(+), 5689 deletions(-) delete mode 100644 Makefile delete mode 100644 Makefile.libs delete mode 100644 bindings/python/Makefile delete mode 100755 buildADIOS1.sh delete mode 100755 buildBP.sh delete mode 100755 buildDataMan.sh delete mode 100644 examples/globalArray/Makefile delete mode 100644 examples/groupless/basic/Makefile delete mode 100644 examples/groupless/compound/Makefile delete mode 100644 examples/groupless/multistep/Makefile delete mode 100644 examples/heatTransfer/Makefile delete mode 100644 examples/hello/Makefile delete mode 100644 examples/hello/adios1Writer/Makefile delete mode 100644 examples/hello/bpReader/Makefile delete mode 100644 examples/hello/bpWriter/Makefile delete mode 100644 examples/hello/compound/Makefile delete mode 100644 examples/hello/datamanReader/Makefile delete mode 100644 examples/hello/datamanWriter/Makefile delete mode 100644 examples/hello/timeBP/Makefile delete mode 100755 examples/hello/timeBP/test.sh delete mode 100644 examples/solidfluid/Makefile delete mode 100644 examples/xmlParser/Makefile create mode 100644 source/ADIOS.cpp create mode 100644 source/ADIOS_C.cpp create mode 100644 source/capsule/heap/STLVector.cpp create mode 100644 source/capsule/shmem/ShmSystemV.cpp create mode 100644 source/core/Capsule.cpp create mode 100644 source/core/Engine.cpp create mode 100644 source/core/Method.cpp create mode 100644 source/core/Support.cpp create mode 100644 source/core/Transform.cpp create mode 100644 source/core/Transport.cpp create mode 100644 source/engine/adios1/ADIOS1Reader.cpp create mode 100644 source/engine/adios1/ADIOS1Writer.cpp create mode 100644 source/engine/bp/BPFileReader.cpp create mode 100644 source/engine/bp/BPFileWriter.cpp create mode 100644 source/engine/dataman/DataManReader.cpp create mode 100644 source/engine/dataman/DataManWriter.cpp create mode 100644 source/format/BP1.cpp create mode 100644 source/format/BP1Aggregator.cpp create mode 100644 source/format/BP1Writer.cpp create mode 100644 source/functions/adiosFunctions.cpp create mode 100644 source/mpidummy.cpp create mode 100644 source/transform/BZip2.cpp create mode 100644 source/transport/file/FStream.cpp create mode 100644 source/transport/file/FileDescriptor.cpp create mode 100644 source/transport/file/FilePointer.cpp create mode 100644 source/transport/wan/MdtmMan.cpp delete mode 100644 src/ADIOS.cpp delete mode 100644 src/ADIOS_C.cpp delete mode 100644 src/capsule/heap/STLVector.cpp delete mode 100644 src/capsule/shmem/ShmSystemV.cpp delete mode 100644 src/core/Capsule.cpp delete mode 100644 src/core/Engine.cpp delete mode 100644 src/core/Method.cpp delete mode 100644 src/core/Support.cpp delete mode 100644 src/core/Transform.cpp delete mode 100644 src/core/Transport.cpp delete mode 100644 src/engine/adios1/ADIOS1Reader.cpp delete mode 100644 src/engine/adios1/ADIOS1Writer.cpp delete mode 100644 src/engine/bp/BPFileReader.cpp delete mode 100644 src/engine/bp/BPFileWriter.cpp delete mode 100644 src/engine/dataman/DataManReader.cpp delete mode 100644 src/engine/dataman/DataManWriter.cpp delete mode 100644 src/format/BP1.cpp delete mode 100644 src/format/BP1Aggregator.cpp delete mode 100644 src/format/BP1Writer.cpp delete mode 100644 src/functions/adiosFunctions.cpp delete mode 100644 src/mpidummy.cpp delete mode 100644 src/transform/BZip2.cpp delete mode 100644 src/transport/file/FStream.cpp delete mode 100644 src/transport/file/FileDescriptor.cpp delete mode 100644 src/transport/file/FilePointer.cpp delete mode 100644 src/transport/wan/MdtmMan.cpp diff --git a/Makefile b/Makefile deleted file mode 100644 index f8f63f7b4..000000000 --- a/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# Makefile for testing purposes, will build libadios.a, libadios_nompi.a -# Created on: Oct 4, 2016 -# Author: wfg - -#DEFAULT COMPILERS IN PATH, LIBS will be modified in Makefile.libs -CC:=g++ -MPICC:=mpic++ -LIBS:= - -SHARED:=no -CFLAGS:=-c -Wall -Wpedantic -std=c++11 -O0 -g -LINKERMPI:=ar -LINKERNoMPI:=ar -LINKERFLAGS:= rcs -LIBEXT:=a - -ifeq ($(SHARED),yes) - CFLAGS+= -fPIC - LINKERMPI=$(MPICC) - LINKERNoMPI=$(CC) - LINKERFLAGS= -shared -o - LIBEXT=so -endif - - -#ADIOS -HFiles:=$(shell find ./include -type f -name "*.h") -CPPFiles:=$(shell find ./src -type f -name "*.cpp") -INC:=-I./include -VPATH = ./src ./src/core ./src/functions \ - ./src/engine/bp ./src/engine/dataman ./src/engine/adios1 \ - ./src/transport/file ./src/transport/wan \ - ./src/capsule/heap ./src/capsule/shmem \ - ./src/transform \ - ./src/format - -#SEPARATE EXTERNAL HEADERS AND LIBRARIES HANDLING in Makefile.libs, export variables -export $(HFiles) $(CPPFiles) $(CFLAGS) $(INC) $(LIBS) -include Makefile.libs - -OBJMPI:=$(patsubst %.cpp, ./bin/mpi/%.o, $(notdir $(CPPFiles)) ) -OBJMPI:=$(patsubst ./bin/mpi/mpidummy.o, ,$(OBJMPI) ) #remove mpidummy from compilation - -OBJNoMPI:=$(patsubst %.cpp, ./bin/nompi/%.o, $(notdir $(CPPFiles)) ) -OBJNoMPI:=$(patsubst ./bin/nompi/MPIFile.o, ,$(OBJNoMPI) ) #remove MPIFile from compilation (not supported in serial) - -.PHONY: all clean mpi nompi - -all: mpi nompi - -mpi: $(HFiles) $(OBJMPI) - @( mkdir -p ./lib ); - $(LINKERMPI) $(LINKERFLAGS) ./lib/libadios.$(LIBEXT) $(OBJMPI) - @echo "Finished building MPI library ./lib/libadios.$(LIBEXT)"; - @echo - -./bin/mpi/%.o: %.cpp $(HFiles) - @( mkdir -p ./bin/mpi ); - $(MPICC) $(CFLAGS) $(INC) -o $@ $< - -nompi: $(HFiles) $(OBJNoMPI) - @( mkdir -p ./lib ); - $(LINKERNoMPI) $(LINKERFLAGS) ./lib/libadios_nompi.$(LIBEXT) $(OBJNoMPI) - @echo "Finished building noMPI library ./lib/libadios.$(LIBEXT)"; - @echo - -./bin/nompi/%.o: %.cpp $(HFiles) - @( mkdir -p ./bin/nompi ); - $(CC) $(CFLAGS) $(INC) -DADIOS_NOMPI -o $@ $< - -clean: - rm ./bin/mpi/*.o ./bin/nompi/*.o ./lib/* diff --git a/Makefile.libs b/Makefile.libs deleted file mode 100644 index 2f736c1e9..000000000 --- a/Makefile.libs +++ /dev/null @@ -1,87 +0,0 @@ -#Language API -LANGUAGE_INC:=./include -LANGUAGE_SRC:=./src - -ifeq ($(C_API),yes) -else - HFiles:=$(filter-out $(LANGUAGE_INC)/ADIOS_C.h,$(HFiles)) - CPPFiles:=$(filter-out $(LANGUAGE_SRC)/ADIOS_C.cpp,$(CPPFiles)) -endif - -#EXTERNAL DEPENDECIES -ENGINE_INC:=./include/engine -ENGINE_SRC:=./src/engine -TRANSPORT_INC:=./include/transport -TRANSPORT_SRC:=./src/transport - -ifeq ($(HAVE_DATAMAN),yes) - DATAMAN_LOC:=/Users/w4g/Dropbox/lib/DataMan# need to change this to your local dataman location - CFLAGS += -DHAVE_DATAMAN - INC += -I$(DATAMAN_LOC)/include - LIBS += -L$(DATAMAN_LOC)/lib -ldataman -else - HFiles:=$(filter-out $(ENGINE_INC)/dataman/DataManWriter.h,$(HFiles)) - HFiles:=$(filter-out $(ENGINE_INC)/dataman/DataManReader.h,$(HFiles)) - HFiles:=$(filter-out $(TRANSPORT_INC)/wan/MdtmMan.h,$(HFiles)) - - CPPFiles:=$(filter-out $(ENGINE_SRC)/dataman/DataManWriter.cpp,$(CPPFiles)) - CPPFiles:=$(filter-out $(ENGINE_SRC)/dataman/DataManReader.cpp,$(CPPFiles)) - CPPFiles:=$(filter-out $(TRANSPORT_SRC)/wan/MdtmMan.cpp,$(CPPFiles)) -endif - - -ifeq ($(HAVE_ADIOS1),yes) - ADIOS1_DIR=/opt/adios/lean/1.11# need to change this to your local adios 1.x installation - CFLAGS += -DHAVE_ADIOS1 - INC += -I$(ADIOS1_DIR)/include - LIBS += $(shell ${ADIOS1_DIR}/bin/adios_config -l) -else - HFiles:=$(filter-out $(ENGINE_INC)/adios1/ADIOS1Writer.h,$(HFiles)) - HFiles:=$(filter-out $(ENGINE_INC)/adios1/ADIOS1Reader.h,$(HFiles)) - CPPFiles:=$(filter-out $(ENGINE_SRC)/adios1/ADIOS1Writer.cpp,$(CPPFiles)) - CPPFiles:=$(filter-out $(ENGINE_SRC)/adios1/ADIOS1Reader.cpp,$(CPPFiles)) -endif - - - -#EXTERNAL DEPENDENCIES -ifeq ($(HAVE_NETCDF),yes) - LIBS += -lnetcdf - CFLAGS += -DHAVE_NETCDF -else - HFiles:=$(filter-out $(TRANSPORT_INC)/NetCDF4.h,$(HFiles)) - CPPFiles:=$(filter-out $(TRANSPORT_SRC)/NetCDF4.cpp,$(CPPFiles)) -endif - -ifeq ($(HAVE_PHDF5),yes) - LIBS += -lhdf5 - CFLAGS += -DHAVE_PHDF5 -else - HFiles:=$(filter-out $(TRANSPORT_INC)/PHDF5.h,$(HFiles)) - CPPFiles:=$(filter-out $(TRANSPORT_SRC)/PHDF5.cpp,$(CPPFiles)) -endif - - -ifeq ($(HAVE_BZIP2),yes) - LIBS += -lbz2 - CFLAGS += -DHAVE_BZIP2 -else - HFiles:=$(filter-out $(TRANSFORM_INC)/BZIP2.h,$(HFiles)) - CPPFiles:=$(filter-out $(TRANSFORM_SRC)/BZIP2.cpp,$(CPPFiles)) -endif - -ifeq ($(HAVE_SZIP),yes) - LIBS += -lsz - CFLAGS += -DHAVE_SZIP -else - HFiles:=$(filter-out $(TRANSFORM_INC)/SZIP.h,$(HFiles)) - CPPFiles:=$(filter-out $(TRANSFORM_SRC)/SZIP.cpp,$(CPPFiles)) -endif - -ifeq ($(HAVE_ZLIB),yes) - LIBS += -lz - CFLAGS += -DHAVE_ZLIB -else - HFiles:=$(filter-out $(TRANSFORM_INC)/ZLIB.h,$(HFiles)) - CPPFiles:=$(filter-out $(TRANSFORM_SRC)/ZLIB.cpp,$(CPPFiles)) -endif diff --git a/bindings/python/Makefile b/bindings/python/Makefile deleted file mode 100644 index 76ea1342a..000000000 --- a/bindings/python/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -#Makefile -# Created on: Mar 13, 2017 -# Author: wfg - -MPICC:=mpic++ - -CPPFiles:=$(shell find ./src -type f -name "*.cpp") -OBJS:=$(patsubst %.cpp, ./bin/%.o, $(notdir $(CPPFiles)) ) - -# location of the Python header files -PYTHON_VERSION:= 2.7 -PYTHON_INC:= /usr/include/python$(PYTHON_VERSION) -PYTHON_LIBLOC:= /usr/lib/python$(PYTHON_VERSION)/config-x86_64-linux-gnu/ - - -ifeq ($(HAVE_PYBIND11),yes) # USE PYBIND11 (headers only) - BIND_FLAG:= -DHAVE_PYBIND11 - BIND_INC:= /home/wfg/workspace/pybind11/include - BIND_LIBS:= - OBJS:=$(patsubst ./bin/glueBoostPython.o, ,$(OBJS) ) #remove BoostPython -else # USE BOOST PYTHON (default) - BIND_FLAG:= -DHAVE_BOOSTPYTHON - BIND_INC:= /opt/boost_1_63_0/ - BIND_LIBS:= -L/opt/boost_1_63_0/stage/lib/ -lboost_python -lboost_numpy - OBJS:=$(patsubst ./bin/gluePyBind11.o, ,$(OBJS) ) #remove PyBind11 -endif - - -# location of ADIOS include and lib -ADIOS_INC:= /home/wfg/workspace/ADIOSPP/include -ADIOS_LIB:= /home/wfg/workspace/ADIOSPP/lib -ADIOSPy_INC:=./include - - -CFLAGS:=-c -Wall -fPIC -O0 -g -std=c++11 -Wno-deprecated-declarations $(BIND_FLAG) -INC:= -I$(PYTHON_INC) -I$(BIND_INC) -I$(ADIOS_INC) -I$(ADIOSPy_INC) -LIBS:= -L$(ADIOS_LIB) -ladios $(BIND_LIBS) -L$(PYTHON_LIBLOC) -lpython$(PYTHON_VERSION) - - -# compile mesh classes -TARGET = ADIOSPy - -all: $(TARGET).so - -$(TARGET).so: $(OBJS) - $(MPICC) -shared -o $(TARGET).so -Wl,--export-dynamic $(OBJS) $(LIBS) - -./bin/%.o: ./src/%.cpp - @( mkdir -p ./bin ); - $(MPICC) $(INC) $(CFLAGS) -o $@ $< - -clean: - rm ./bin/*.o *.so \ No newline at end of file diff --git a/buildADIOS1.sh b/buildADIOS1.sh deleted file mode 100755 index 7549f24af..000000000 --- a/buildADIOS1.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - - -# buildTest.sh for ADIOS1 Writer example -# Created on: Mar 27, 2017 -# Author: pnb -# Recommended: do a "make clean" the first time - -MPICOMPILER=mpic++ -ADIOS1_DIR=/opt/adios/1.11 - -if [ "$(uname)" == "Darwin" ]; then - CCOMPILER=clang++ -elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - CCOMPILER=g++ -fi -echo "######################################################################################" -echo "Start building ADIOS ./lib/libadios.a ./libadios_nompi.a" -echo "######################################################################################" -echo -make -j4 HAVE_ADIOS1=yes ADIOS1_DIR=${ADIOS1_DIR} CC=$CCOMPILER MPICC=$MPICOMPILER #build the ./lib/libadios.a and ./libadios_nompi.a -echo -echo "#################################################################" -echo "Building ADIOS1Writer example" -echo "#################################################################" -make -j4 -C ./examples/hello/adios1Writer CC=$CCOMPILER MPICC=$MPICOMPILER mpi -#make -j4 -C ./examples/hello/adios1Reader CC=$CCOMPILER MPICC=$MPICOMPILER mpi -echo -echo -echo -echo "#################################################################" -echo "Running the MPI example" -echo "#################################################################" -echo -echo -echo "#################################################################" -echo "ADIOS1 writer" -echo "#################################################################" -mpirun -np 4 ./examples/hello/adios1Writer/helloADIOS1Writer.exe -echo "DONE...check for myDoubles.bp directory" - -echo "#################################################################" -echo "ADIOS1 reader..not ready yet" -echo "#################################################################" -#./examples/hello/adios1Writer/helloADIOS1Reader.exe -echo -echo -echo "#################################################################" -echo "To run mpi version with 4 mpi processes: " -echo "mpirun -n 4 ./examples/hello/bpWriter/helloBPWriter.exe" -echo "mpirun -n 4 ./examples/hello/bpReader/helloBPReader.exe" -echo "END" -echo "################################################################" diff --git a/buildBP.sh b/buildBP.sh deleted file mode 100755 index 1da55d54d..000000000 --- a/buildBP.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - - -# buildTest.sh for BP Writer example -# Created on: Feb 9, 2017 -# Author: wfg -# Recommended: do a "make clean" the first time - -MPICOMPILER=mpic++ - -if [ "$(uname)" == "Darwin" ]; then - CCOMPILER=clang++ -elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - CCOMPILER=g++ -fi -echo "######################################################################################" -echo "Start building ADIOS ./lib/libadios.a ./libadios_nompi.a" -echo "######################################################################################" -echo -make -j4 CC=$CCOMPILER MPICC=$MPICOMPILER #build the ./lib/libadios.a and ./libadios_nompi.a -echo -echo "#################################################################" -echo "Building BPWriter example" -echo "#################################################################" -make -j4 -C ./examples/hello/bpWriter CC=$CCOMPILER MPICC=$MPICOMPILER -#make -j4 -C ./examples/hello/bpReader CC=$CCOMPILER MPICC=$MPICOMPILER -echo -echo -echo -echo "#################################################################" -echo "Running nompi.exe example" -echo "#################################################################" -echo -echo -echo "#################################################################" -echo "BP writer" -echo "#################################################################" -./examples/hello/bpWriter/helloBPWriter_nompi.exe -echo "DONE...check for myDoubles_nompi.bp directory" - -echo "#################################################################" -echo "BP reader..not ready yet" -echo "#################################################################" -#./examples/hello/bpWriter/helloBPReader.exe -echo -echo -echo "#################################################################" -echo "To run mpi version with 4 mpi processes: " -echo "mpirun -n 4 ./examples/hello/bpWriter/helloBPWriter.exe" -echo "mpirun -n 4 ./examples/hello/bpReader/helloBPReader.exe" -echo "END" -echo "################################################################" diff --git a/buildDataMan.sh b/buildDataMan.sh deleted file mode 100755 index 886d96447..000000000 --- a/buildDataMan.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - - -# buildTest.sh for Dataman example -# Created on: Feb 9, 2017 -# Author: wfg - -DATAMAN_LOCATION=/Users/w4g/Dropbox/lib/DataMan -MPICOMPILER=mpic++ - -if [ "$(uname)" == "Darwin" ]; then - CCOMPILER=g++ - export DYLD_LIBRARY_PATH=$DATAMAN_LOCATION/lib:$DYLD_LIBRARY_PATH -elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - CCOMPILER=g++ - export LD_LIBRARY_PATH=$DATAMAN_LOCATION/lib:$LD_LIBRARY_PATH -fi -echo "######################################################################################" -echo "Start building ADIOS ./lib/libadios.a ./libadios_nompi.a with DataMan library" -echo "######################################################################################" -echo -make -j4 HAVE_DATAMAN=yes DATAMAN_LOC=$DATAMAN_LOCATION CC=$CCOMPILER MPICC=$MPICOMPILER #build the ./lib/libadios.a and ./libadios_nompi.a -echo -echo "#################################################################" -echo "Building Dataman Reader and Writer examples" -echo "#################################################################" -make -j4 -C ./examples/hello/datamanWriter HAVE_DATAMAN=yes DATAMAN_LOC=$DATAMAN_LOCATION CC=$CCOMPILER MPICC=$MPICOMPILER -echo -make -j4 -C ./examples/hello/datamanReader HAVE_DATAMAN=yes DATAMAN_LOC=$DATAMAN_LOCATION CC=$CCOMPILER MPICC=$MPICOMPILER - -echo -echo -echo "#################################################################" -echo "Running nompi.exe examples" -echo "#################################################################" -echo -echo -echo "#################################################################" -echo "DataMan writer" -echo "#################################################################" -./examples/hello/datamanWriter/helloDataManWriter_nompi.exe - -echo "#################################################################" -echo "DataMan reader" -echo "#################################################################" -#./examples/hello/datamanReader/helloDataManReader_nompi.exe - -echo -echo -echo "#################################################################" -echo "To run mpi version with 4 mpi processes: " -echo "mpirun -n 4 ./examples/hello/datamanWriter/helloDatamanWriter.exe" -echo "mpirun -n 4 ./examples/hello/datamanReader/helloDatamanReader.exe" -echo "END" -echo "################################################################" diff --git a/examples/globalArray/Makefile b/examples/globalArray/Makefile deleted file mode 100644 index 5548dd15f..000000000 --- a/examples/globalArray/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# Makefile for testing purposes, will build libadios.a -# Created on: Oct 31, 2016 -# Author: pnorbert - - -BASE_NAME=globalArrayXML - -TOOL_DIR=/usr/bin - -CC=$(TOOL_DIR)/g++ # Compiling with mpicc for now -MPICC:=/usr/local/bin/mpic++ -AR=$(TOOL_DIR)/ar - -#ADIOS LOCATION -ADIOS_DIR=../.. -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include - - -#FLAGS -CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 - -all: mpi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME)_mpi $(ADIOS_LIB) - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME)_nompi $(ADIOS_NOMPI_LIB) - -clean: - rm -f *_mpi *_nompi *.o - rm -rf *.dSYM - diff --git a/examples/groupless/basic/Makefile b/examples/groupless/basic/Makefile deleted file mode 100644 index 1fc69407c..000000000 --- a/examples/groupless/basic/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile for testing purposes, will build writer_mpi (make or make mpi) or writer_nompi (make nompi) -# Created on: Feb 13, 2017 -# Author: pnorbert - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -Woverloaded-virtual -std=c++11 -O0 -g -LDFLAGS= - -all: writer reader - -writer reader: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $@.cpp -o $@ $(ADIOS_LIB) $(LDFLAGS) -lpthread \ - -clean: - rm -f writer reader - diff --git a/examples/groupless/compound/Makefile b/examples/groupless/compound/Makefile deleted file mode 100644 index 1fc69407c..000000000 --- a/examples/groupless/compound/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile for testing purposes, will build writer_mpi (make or make mpi) or writer_nompi (make nompi) -# Created on: Feb 13, 2017 -# Author: pnorbert - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -Woverloaded-virtual -std=c++11 -O0 -g -LDFLAGS= - -all: writer reader - -writer reader: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $@.cpp -o $@ $(ADIOS_LIB) $(LDFLAGS) -lpthread \ - -clean: - rm -f writer reader - diff --git a/examples/groupless/multistep/Makefile b/examples/groupless/multistep/Makefile deleted file mode 100644 index 1498091ae..000000000 --- a/examples/groupless/multistep/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile for testing purposes, will build writer_mpi (make or make mpi) or writer_nompi (make nompi) -# Created on: Feb 13, 2017 -# Author: pnorbert - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -Woverloaded-virtual -std=c++11 -O0 -g -LDFLAGS= - -all: writer_multistep reader_allsteps reader_stepping - -writer_multistep reader_allsteps reader_stepping: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $@.cpp -o $@ $(ADIOS_LIB) $(LDFLAGS) -lpthread \ - -clean: - rm -f writer_multistep reader_allsteps reader_stepping - diff --git a/examples/heatTransfer/Makefile b/examples/heatTransfer/Makefile deleted file mode 100644 index ca8361a41..000000000 --- a/examples/heatTransfer/Makefile +++ /dev/null @@ -1,66 +0,0 @@ -# Makefile -# Created on: Feb 13, 2017 -# Author: pnorbert - -# -# SYSTEM SPECIFIC SETTINGS -# -#COMPILERS -CC=g++ -MPICC=mpic++ - -#FLAGS -CFLAGS=-Wall -Wpedantic -Woverloaded-virtual -std=c++11 -O0 -g -LDFLAGS=-lpthread - -#ADIOS1 LOCATION -ADIOS1_DIR=/opt/adios/1.11 - -#ADIOS2 LOCATION -ADIOS2_DIR=../.. - -# SEQUENTIAL HDF5 LOCATION -HDF5_DIR=/opt/hdf5-1.8.17 -HDF5_INCLUDE=-I$(HDF5_DIR)/include -HDF5_LIB=$(HDF5_DIR)/lib/libhdf5.la - -# -# SHOULD NOT NEED TO CHANGE ANYTHING BELOW -# - -ADIOS1_INCLUDE=-I$(ADIOS1_DIR)/include -ADIOS1_LIB=`${ADIOS1_DIR}/bin/adios_config -l` - - -ADIOS2_INCLUDE= -DHAVE_MPI -I$(ADIOS2_DIR)/include -ADIOS2_LIB=$(ADIOS2_DIR)/lib/libadios.a - -default: - @echo "Make targets: ascii hdf5_a hdf5_b phdf5 adios1 adios2" - @echo " ascii: build example with text output(IO_ascii.cpp)" - @echo " hdf5_a: build example with HDF5, separate timesteps (IO_hdf5_a.cpp)" - @echo " hdf5_b: build example with HDF5, combined timesteps (IO_hdf5_b.cpp)" - @echo " phdf5: build example with Parallel HDF5 (IO_phdf5.cpp)" - @echo " adios1: build example with ADIOS 1.x (IO_adios1.cpp)" - @echo " adios2: build example with ADIOS2 (IO_adios2.cpp)" - - -all: default -help: default - - -ascii: main.cpp HeatTransfer.cpp Settings.cpp IO_ascii.cpp - $(MPICC) $(CFLAGS) -o heatTransfer_ascii $^ $(LDFLAGS) - -hdf5_a: main.cpp HeatTransfer.cpp Settings.cpp IO_hdf5_a.cpp - libtool --mode=link --tag=CC $(MPICC) $(CFLAGS) $(HDF5_INCLUDE) -o heatTransfer_hdf5_a $^ $(HDF5_LIB) $(LDFLAGS) - -adios1: main.cpp HeatTransfer.cpp Settings.cpp IO_adios1.cpp - $(MPICC) $(CFLAGS) $(ADIOS1_INCLUDE) -o heatTransfer_adios1 $^ $(ADIOS1_LIB) $(LDFLAGS) - -adios2: main.cpp HeatTransfer.cpp Settings.cpp IO_adios2.cpp - $(MPICC) $(CFLAGS) $(ADIOS2_INCLUDE) -o heatTransfer_adios2 $^ $(ADIOS2_LIB) $(LDFLAGS) - -clean: - rm -f heatTransfer_ascii heatTransfer_hdf5_a heatTransfer_adios1 heatTransfer_adios2 - diff --git a/examples/hello/Makefile b/examples/hello/Makefile deleted file mode 100644 index 62588a062..000000000 --- a/examples/hello/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# Makefile for testing purposes, will build libadios.a -# Created on: Oct 4, 2016 -# Author: wfg - - -BASE_NAME=helloADIOSNoXML_OOP - -TOOL_DIR=/usr/bin - -CC=$(TOOL_DIR)/g++ # Compiling with mpicc for now -MPICC=$(TOOL_DIR)/mpic++ -AR=$(TOOL_DIR)/ar - -#ADIOS LOCATION -ADIOS_DIR=../.. -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include - - -#FLAGS -CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 - -all: mpi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME)_mpi $(ADIOS_LIB) - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME)_nompi $(ADIOS_NOMPI_LIB) - -clean: - rm *_mpi; rm *_nompi - diff --git a/examples/hello/adios1Writer/Makefile b/examples/hello/adios1Writer/Makefile deleted file mode 100644 index 43e252235..000000000 --- a/examples/hello/adios1Writer/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# Makefile for testing purposes, will build helloADIOS1Writer (make or make mpi) or helloADIOS1Writer_nompi (make nompi) -# Created on: Mar 27, 2017 -# Author: pnb - -BASE_NAME=helloADIOS1Writer - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS 1.x LOCATION -ADIOS1_DIR=/opt/adios/1.11 -ADIOS1_LIB=$(shell ${ADIOS1_DIR}/bin/adios_config -l) -ADIOS1_NOMPI_LIB=$(shell ${ADIOS1_DIR}/bin/adios_config -ls) - -#ADIOS 2.x LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -std=c++11 -O0 -g -LDFLAGS= - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) $(ADIOS1_LIB) $(LDFLAGS) -lpthread - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) -DADIOS_NOMPI $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) $(ADIOS1_NOMPI_LIB) $(LDFLAGS) -lpthread - -clean: - rm *.exe - diff --git a/examples/hello/bpReader/Makefile b/examples/hello/bpReader/Makefile deleted file mode 100644 index b5705da1c..000000000 --- a/examples/hello/bpReader/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Makefile for testing purposes, will build helloWriter_OOP_mpi (make or make mpi) or helloWriter_OOP_nompi (make nompi) -# Created on: Oct 4, 2016 -# Author: wfg - -BASE_NAME=helloBPReader - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -std=c++11 -O0 -g -LDFLAGS= - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) $(LDFLAGS) -lpthread - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) $(LDFLAGS) -lpthread - -clean: - rm *.exe - \ No newline at end of file diff --git a/examples/hello/bpWriter/Makefile b/examples/hello/bpWriter/Makefile deleted file mode 100644 index 215bdf5e6..000000000 --- a/examples/hello/bpWriter/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Makefile for testing purposes, will build helloWriter_OOP_mpi (make or make mpi) or helloWriter_OOP_nompi (make nompi) -# Created on: Oct 4, 2016 -# Author: wfg - -BASE_NAME=helloBPWriter - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -std=c++11 -O0 -g -LDFLAGS= - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) $(LDFLAGS) -lpthread - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) -DADIOS_NOMPI $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) $(LDFLAGS) -lpthread - -clean: - rm *.exe - \ No newline at end of file diff --git a/examples/hello/compound/Makefile b/examples/hello/compound/Makefile deleted file mode 100644 index 60eac2012..000000000 --- a/examples/hello/compound/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Makefile for testing purposes, will build helloWriter_OOP_mpi (make or make mpi) or helloWriter_OOP_nompi (make nompi) -# Created on: Oct 4, 2016 -# Author: wfg - -BASE_NAME=helloCompound - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -std=c++11 -O0 -g -LDFLAGS= - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) $(LDFLAGS) -lpthread - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) $(LDFLAGS) -lpthread - -clean: - rm *.exe - \ No newline at end of file diff --git a/examples/hello/datamanReader/Makefile b/examples/hello/datamanReader/Makefile deleted file mode 100644 index 3a5d6007d..000000000 --- a/examples/hello/datamanReader/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# Makefile for testing purposes, will build libadios.a -# Created on: Oct 4, 2016 -# Author: wfg - - -BASE_NAME=helloDataManReader - -CC=g++ # Compiling with defaults -MPICC=mpic++ -INC= -LIB= -LIB_NOMPI= - -#ADIOS -ADIOS_DIR=../../.. -LIB+= $(ADIOS_DIR)/lib/libadios.a -LIB_NOMPI+= $(ADIOS_DIR)/lib/libadios_nompi.a -INC+= -I$(ADIOS_DIR)/include - -#DATAMAN -DATAMAN_LOC=/Users/w4g/Dropbox/lib/DataMan -INC+= -I$(DATAMAN_LOC)/include -LIB+= -L$(DATAMAN_LOC)/lib -ldataman # -lcacheman -lstreamman -lzmqman -LIB_NOMPI+= -L$(DATAMAN_LOC)/lib -ldataman - -#COMPILER FLAGS -CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 - -#SYSTEM LIBS -LIB+= -lpthread -LIB_NOMPI+= -ldl -lpthread - - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(INC) $(BASE_NAME).cpp -o $(BASE_NAME).exe $(LIB) - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(INC) -DADIOS_NOMPI $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(LIB_NOMPI) - -clean: - rm *.exe; - diff --git a/examples/hello/datamanWriter/Makefile b/examples/hello/datamanWriter/Makefile deleted file mode 100644 index 45f28cd17..000000000 --- a/examples/hello/datamanWriter/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# Makefile for testing purposes, will build libadios.a -# Created on: Oct 4, 2016 -# Author: wfg - - -BASE_NAME=helloDataManWriter - -CC=g++ # Compiling with defaults -MPICC=mpic++ -INC= -LIB= -LIB_NOMPI= - -#ADIOS -ADIOS_DIR=../../.. -LIB+= $(ADIOS_DIR)/lib/libadios.a -LIB_NOMPI+= $(ADIOS_DIR)/lib/libadios_nompi.a -INC+= -I$(ADIOS_DIR)/include - -#DATAMAN -DATAMAN_LOC=/Users/w4g/Dropbox/lib/DataMan -INC+= -I$(DATAMAN_LOC)/include -LIB+= -L$(DATAMAN_LOC)/lib -ldataman # -lcacheman -lstreamman -lzmqman -LIB_NOMPI+= -L$(DATAMAN_LOC)/lib -ldataman # -lcacheman -lstreamman -lzmqman - -#COMPILER FLAGS -CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 - -#SYSTEM LIBS -LIB+= -lpthread -LIB_NOMPI+= -ldl -lpthread - - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(INC) $(BASE_NAME).cpp -o $(BASE_NAME).exe $(LIB) - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(INC) -DADIOS_NOMPI $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(LIB_NOMPI) - -clean: - rm *.exe; - diff --git a/examples/hello/timeBP/Makefile b/examples/hello/timeBP/Makefile deleted file mode 100644 index 2c80ba83a..000000000 --- a/examples/hello/timeBP/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Makefile for testing purposes, will build helloWriter_OOP_mpi (make or make mpi) or helloWriter_OOP_nompi (make nompi) -# Created on: Oct 4, 2016 -# Author: wfg - -BASE_NAME=timeBPWriter - -#COMPILERS -CC=g++ -MPICC=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../../.. -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -#FLAGS -CFLAGS=-Wall -Wpedantic -std=c++11 -O0 -g -LDFLAGS= - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) $(LDFLAGS) -lpthread - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) -DADIOS_NOMPI $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) $(LDFLAGS) -lpthread - -clean: - rm *.exe - \ No newline at end of file diff --git a/examples/hello/timeBP/test.sh b/examples/hello/timeBP/test.sh deleted file mode 100755 index ef262a74c..000000000 --- a/examples/hello/timeBP/test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -rm -fr *.bp -make clean -make -j4 diff --git a/examples/solidfluid/Makefile b/examples/solidfluid/Makefile deleted file mode 100644 index f4acbc655..000000000 --- a/examples/solidfluid/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# Makefile for testing purposes, will build libadios.a -# Created on: Oct 31, 2016 -# Author: pnorbert - - -BASE_NAME=solidfluid_write - -CC=g++ # Compiling with mpicc for now -MPICC:=mpic++ - -#ADIOS LOCATION -ADIOS_DIR=../.. -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include - - -#FLAGS -CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 - -all: mpi nompi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) -lpthread - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) -lpthread - -clean: - rm -f *.exe - rm -rf *.dSYM - diff --git a/examples/xmlParser/Makefile b/examples/xmlParser/Makefile deleted file mode 100644 index 12d521a34..000000000 --- a/examples/xmlParser/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# Makefile for testing purposes, will build libadios.a -# Created on: Oct 4, 2016 -# Author: wfg - - -BASE_NAME=xmlParser - -TOOL_DIR=/usr/bin - -CC=$(TOOL_DIR)/g++ -MPICC=$(TOOL_DIR)/mpic++ -AR=$(TOOL_DIR)/ar - -#ADIOS LOCATION -ADIOS_DIR=../../ -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a - -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include - - -#FLAGS -CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 - -all: mpi - -mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME)_mpi $(ADIOS_LIB) - -nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME)_nompi $(ADIOS_NOMPI_LIB) - -clean: - rm *_mpi; rm *_nompi - diff --git a/source/ADIOS.cpp b/source/ADIOS.cpp new file mode 100644 index 000000000..be1644396 --- /dev/null +++ b/source/ADIOS.cpp @@ -0,0 +1,346 @@ +/* + * ADIOS.cpp + * + * Created on: Sep 29, 2016 + * Author: William F Godoy + */ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <fstream> +#include <iostream> +#include <sstream> +#include <utility> +/// \endcond + +#include "ADIOS.h" +#include "functions/adiosFunctions.h" + +// Engines +#include "engine/bp/BPFileReader.h" +#include "engine/bp/BPFileWriter.h" + +#ifdef HAVE_DATAMAN // external dependencies +#include "engine/dataman/DataManReader.h" +#include "engine/dataman/DataManWriter.h" +#endif + +#ifdef HAVE_ADIOS1 // external dependencies +#include "engine/adios1/ADIOS1Reader.h" +#include "engine/adios1/ADIOS1Writer.h" +#endif + +namespace adios +{ + +ADIOS::ADIOS(const Verbose verbose, const bool debugMode) + : m_DebugMode{debugMode} +{ + InitMPI(); +} + +ADIOS::ADIOS(const std::string configFileName, const Verbose verbose, + const bool debugMode) + : m_ConfigFile{configFileName}, m_DebugMode{debugMode} +{ + InitMPI(); + // InitXML( m_ConfigFile, m_MPIComm, m_DebugMode, m_Transforms ); +} + +ADIOS::ADIOS(const std::string xmlConfigFile, MPI_Comm mpiComm, + const Verbose verbose, const bool debugMode) + : m_MPIComm{mpiComm}, m_ConfigFile{xmlConfigFile}, m_DebugMode{debugMode} +{ + InitMPI(); + // InitXML( m_XMLConfigFile, m_MPIComm, m_DebugMode, m_HostLanguage, + // m_Transforms, m_Groups ); +} + +ADIOS::ADIOS(MPI_Comm mpiComm, const Verbose verbose, const bool debugMode) + : m_MPIComm{mpiComm}, m_DebugMode{debugMode} +{ + InitMPI(); +} + +ADIOS::~ADIOS() {} + +void ADIOS::InitMPI() +{ + if (m_DebugMode == true) + { + if (m_MPIComm == MPI_COMM_NULL) + throw std::ios_base::failure( + "ERROR: engine communicator is MPI_COMM_NULL," + " in call to ADIOS Open or Constructor\n"); + } + + MPI_Comm_rank(m_MPIComm, &m_RankMPI); + MPI_Comm_size(m_MPIComm, &m_SizeMPI); +} + +Method &ADIOS::DeclareMethod(const std::string methodName) +{ + if (m_DebugMode == true) + { + if (m_Methods.count(methodName) == 1) + throw std::invalid_argument("ERROR: method " + methodName + + " already declared, from DeclareMethod\n"); + } + m_Methods.emplace(methodName, Method(methodName, m_DebugMode)); + return m_Methods.at(methodName); +} + +std::shared_ptr<Engine> ADIOS::Open(const std::string name, + const std::string accessMode, + MPI_Comm mpiComm, const Method &method, + const IOMode iomode, + const float timeout_sec) +{ + if (m_DebugMode == true) + { + if (m_EngineNames.count(name) == 1) // Check if Engine already exists + throw std::invalid_argument( + "ERROR: engine name " + name + + " already created by Open, in call from Open.\n"); + } + + m_EngineNames.insert(name); + + const std::string type(method.m_Type); + + const bool isDefaultWriter = (accessMode == "w" || accessMode == "write" || + accessMode == "a" || accessMode == "append") && + type.empty() + ? true + : false; + + const bool isDefaultReader = + (accessMode == "r" || accessMode == "read") && type.empty() ? true + : false; + + if (isDefaultWriter || type == "BPFileWriter" || type == "bpfilewriter") + { + return std::make_shared<BPFileWriter>(*this, name, accessMode, mpiComm, + method, iomode, timeout_sec, + m_DebugMode, method.m_nThreads); + } + else if (isDefaultReader || type == "BPReader" || type == "bpreader") + { + return std::make_shared<BPFileReader>(*this, name, accessMode, mpiComm, + method, iomode, timeout_sec, + m_DebugMode, method.m_nThreads); + } + else if (type == "SIRIUS" || type == "sirius" || type == "Sirius") + { + // not yet supported + // return std::make_shared<engine::DataMan>( *this, name, accessMode, + // mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); + } + else if (type == "DataManWriter") + { +#ifdef HAVE_DATAMAN + return std::make_shared<DataManWriter>(*this, name, accessMode, mpiComm, + method, iomode, timeout_sec, + m_DebugMode, method.m_nThreads); +#else + throw std::invalid_argument("ERROR: this version didn't compile with " + "Dataman library, can't Open DataManWriter\n"); +#endif + } + else if (type == "DataManReader") + { +#ifdef HAVE_DATAMAN + return std::make_shared<DataManReader>(*this, name, accessMode, mpiComm, + method, iomode, timeout_sec, + m_DebugMode, method.m_nThreads); +#else + throw std::invalid_argument("ERROR: this version didn't compile with " + "Dataman library, can't Open DataManReader\n"); +#endif + } + else if (type == "ADIOS1Writer") + { +#ifdef HAVE_ADIOS1 + return std::make_shared<ADIOS1Writer>(*this, name, accessMode, mpiComm, + method, iomode, timeout_sec, + m_DebugMode, method.m_nThreads); +#else + throw std::invalid_argument("ERROR: this version didn't compile with ADIOS " + "1.x library, can't Open ADIOS1Writer\n"); +#endif + } + else if (type == "Vis") + { + // return std::make_shared<Vis>( *this, name, accessMode, mpiComm, method, + // iomode, timeout_sec, m_DebugMode, method.m_nThreads ); + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: method type " + type + + " not supported for " + name + + ", in call to Open\n"); + } + + return nullptr; // if debug mode is off +} + +std::shared_ptr<Engine> ADIOS::Open(const std::string streamName, + const std::string accessMode, + const Method &method, const IOMode iomode, + const float timeout_sec) +{ + return Open(streamName, accessMode, m_MPIComm, method, iomode, timeout_sec); +} + +std::shared_ptr<Engine> +ADIOS::Open(const std::string name, const std::string accessMode, + MPI_Comm mpiComm, const std::string methodName, const IOMode iomode, + const float timeout_sec) +{ + auto itMethod = m_Methods.find(methodName); + + if (m_DebugMode == true) + { + CheckMethod(itMethod, methodName, " in call to Open\n"); + } + + return Open(name, accessMode, mpiComm, itMethod->second, iomode, timeout_sec); +} + +std::shared_ptr<Engine> ADIOS::Open(const std::string name, + const std::string accessMode, + const std::string methodName, + const IOMode iomode, + const float timeout_sec) +{ + return Open(name, accessMode, m_MPIComm, methodName, iomode, timeout_sec); +} + +std::shared_ptr<Engine> ADIOS::OpenFileReader(const std::string name, + MPI_Comm mpiComm, + const Method &method, + const IOMode iomode) +{ + return Open(name, "r", m_MPIComm, method, iomode); +} + +std::shared_ptr<Engine> ADIOS::OpenFileReader(const std::string name, + MPI_Comm mpiComm, + const std::string methodName, + const IOMode iomode) +{ + auto itMethod = m_Methods.find(methodName); + + if (m_DebugMode == true) + { + CheckMethod(itMethod, methodName, " in call to Open\n"); + } + + return Open(name, "r", m_MPIComm, itMethod->second, iomode); +} + +VariableCompound &ADIOS::GetVariableCompound(const std::string name) +{ + return m_Compound.at(GetVariableIndex<void>(name)); +} + +void ADIOS::MonitorVariables(std::ostream &logStream) +{ + logStream << "\tVariable \t Type\n"; + + for (auto &variablePair : m_Variables) + { + const std::string name(variablePair.first); + const std::string type(variablePair.second.first); + + if (type == GetType<char>()) + GetVariable<char>(name).Monitor(logStream); + + else if (type == GetType<unsigned char>()) + GetVariable<unsigned char>(name).Monitor(logStream); + + else if (type == GetType<short>()) + GetVariable<short>(name).Monitor(logStream); + + else if (type == GetType<unsigned short>()) + GetVariable<unsigned short>(name).Monitor(logStream); + + else if (type == GetType<int>()) + GetVariable<int>(name).Monitor(logStream); + + else if (type == GetType<unsigned int>()) + GetVariable<unsigned int>(name).Monitor(logStream); + + else if (type == GetType<long int>()) + GetVariable<long int>(name).Monitor(logStream); + + else if (type == GetType<unsigned long int>()) + GetVariable<unsigned long int>(name).Monitor(logStream); + + else if (type == GetType<long long int>()) + GetVariable<long long int>(name).Monitor(logStream); + + else if (type == GetType<unsigned long long int>()) + GetVariable<unsigned long long int>(name).Monitor(logStream); + + else if (type == GetType<float>()) + GetVariable<float>(name).Monitor(logStream); + + else if (type == GetType<double>()) + GetVariable<double>(name).Monitor(logStream); + + else if (type == GetType<long double>()) + GetVariable<long double>(name).Monitor(logStream); + + else if (type == GetType<std::complex<float>>()) + GetVariable<std::complex<float>>(name).Monitor(logStream); + + else if (type == GetType<std::complex<double>>()) + GetVariable<std::complex<double>>(name).Monitor(logStream); + + else if (type == GetType<std::complex<long double>>()) + GetVariable<std::complex<long double>>(name).Monitor(logStream); + } +} + +// PRIVATE FUNCTIONS BELOW +void ADIOS::CheckVariableInput(const std::string name, + const Dims &dimensions) const +{ + if (m_DebugMode == true) + { + if (m_Variables.count(name) == 1) + throw std::invalid_argument( + "ERROR: variable " + name + + " already exists, in call to DefineVariable\n"); + + if (dimensions.empty() == true) + throw std::invalid_argument( + "ERROR: variable " + name + + " dimensions can't be empty, in call to DefineVariable\n"); + } +} + +void ADIOS::CheckVariableName( + std::map<std::string, std::pair<std::string, unsigned int>>::const_iterator + itVariable, + const std::string name, const std::string hint) const +{ + if (m_DebugMode == true) + { + if (itVariable == m_Variables.end()) + throw std::invalid_argument("ERROR: variable " + name + + " does not exist " + hint + "\n"); + } +} + +void ADIOS::CheckMethod(std::map<std::string, Method>::const_iterator itMethod, + const std::string methodName, + const std::string hint) const +{ + if (itMethod == m_Methods.end()) + throw std::invalid_argument("ERROR: method " + methodName + " not found " + + hint + "\n"); +} + +} // end namespace diff --git a/source/ADIOS_C.cpp b/source/ADIOS_C.cpp new file mode 100644 index 000000000..36f9e4b29 --- /dev/null +++ b/source/ADIOS_C.cpp @@ -0,0 +1,250 @@ +/* + * ADIOS_C.cpp + * + * Created on: Oct 31, 2016 + * Author: wfg + */ + +#include <cstring> +#include <fstream> +#include <iostream> +#include <string> + +#include "ADIOS.h" +#include "ADIOS_C.h" + +adios::ADIOS *adios; + +#ifdef __cplusplus +extern "C" { +#endif + +void adios_init(const char *xmlConfigFile, const MPI_Comm mpiComm) +{ + + int rank; + MPI_Comm_rank(mpiComm, &rank); + + try + { + adios = new adios::ADIOS(std::string(xmlConfigFile), mpiComm); + } + catch (std::bad_alloc &e) + { + if (rank == 0) + std::cout << "Bad allocation exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::invalid_argument &e) + { + if (rank == 0) + std::cout << "Invalid argument exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::exception &e) + { + if (rank == 0) + std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; + } + + // return ( ADIOS* ) ( adios ); +} + +ADIOS *adios_init_debug(const char *xmlConfigFile, const MPI_Comm mpiComm) +{ + adios::ADIOS *adios; + int rank; + MPI_Comm_rank(mpiComm, &rank); + + try + { + adios = new adios::ADIOS(std::string(xmlConfigFile), mpiComm, true); + } + catch (std::bad_alloc &e) + { + if (rank == 0) + std::cout << "Bad allocation exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::invalid_argument &e) + { + if (rank == 0) + std::cout << "Invalid argument exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::exception &e) + { + if (rank == 0) + std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; + } + + return (ADIOS *)(adios); +} + +void adios_open(const ADIOS *adiosC, const char *groupName, + const char *fileName, const char *accessMode) +{ + adios::ADIOS *adios = (adios::ADIOS *)adiosC; + int rank; + MPI_Comm_rank(adios->m_MPIComm, &rank); + + try + { + adios::ADIOS *adios = (adios::ADIOS *)adiosC; + adios->Open(std::string(groupName), std::string(fileName), + std::string(accessMode)); + } + catch (std::bad_alloc &e) + { + if (rank == 0) + std::cout << "Bad allocation exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::invalid_argument &e) + { + if (rank == 0) + std::cout << "Invalid argument exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::exception &e) + { + if (rank == 0) + std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; + } +} + +void adios_write(const ADIOS *adiosC, const char *groupName, + const char *variableName, const void *values) +{ + adios::ADIOS *adios = (adios::ADIOS *)adiosC; + int rank; + MPI_Comm_rank(adios->m_MPIComm, &rank); + + try + { + adios->Write(const std::string(groupName), const std::string(variableName), + values); + } + catch (std::bad_alloc &e) + { + if (rank == 0) + std::cout << "Bad allocation exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::invalid_argument &e) + { + if (rank == 0) + std::cout << "Invalid argument exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::exception &e) + { + if (rank == 0) + std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; + } +} + +void adios_close(const ADIOS *adiosC, const char *groupName) +{ + adios::ADIOS *adios = (adios::ADIOS *)adiosC; + int rank; + MPI_Comm_rank(adios->m_MPIComm, &rank); + + try + { + adios->Close(std::string(groupName)); + } + catch (std::bad_alloc &e) + { + if (rank == 0) + std::cout << "Bad allocation exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::invalid_argument &e) + { + if (rank == 0) + std::cout << "Invalid argument exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::exception &e) + { + if (rank == 0) + std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; + } +} + +void adios_free(const ADIOS *adiosC) +{ + adios::ADIOS *adios = (adios::ADIOS *)adiosC; + delete adios; +} + +void adios_monitor_groups(const ADIOS *adiosC) +{ + adios::ADIOS *adios = (adios::ADIOS *)adiosC; + int rank; + MPI_Comm_rank(adios->m_MPIComm, &rank); + + try + { + adios->MonitorGroups(std::cout); + } + catch (std::bad_alloc &e) + { + if (rank == 0) + std::cout << "Bad allocation exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::invalid_argument &e) + { + if (rank == 0) + std::cout << "Invalid argument exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::exception &e) + { + if (rank == 0) + std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; + } +} + +void adios_monitor_groups_file(const ADIOS *adiosC, const char *fileName, + const char *mode) +{ + adios::ADIOS *adios = (adios::ADIOS *)adiosC; + int rank; + MPI_Comm_rank(adios->m_MPIComm, &rank); + + try + { + std::ofstream fileStream; + + if (strcmp(mode, "a") == 0 || strcmp(mode, "append") == 0) + fileStream.open(fileName, std::ostream::app); + else if (strcmp(mode, "w") == 0 || strcmp(mode, "write") == 0) + fileStream.open(fileName); + + adios->MonitorGroups(fileStream); + } + catch (std::bad_alloc &e) + { + if (rank == 0) + std::cout << "Bad allocation exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::invalid_argument &e) + { + if (rank == 0) + std::cout << "Invalid argument exception, STOPPING PROGRAM\n" + << e.what() << "\n"; + } + catch (std::exception &e) + { + if (rank == 0) + std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; + } +} + +#ifdef __cplusplus +} // end extern C +#endif diff --git a/source/capsule/heap/STLVector.cpp b/source/capsule/heap/STLVector.cpp new file mode 100644 index 000000000..b8735c04d --- /dev/null +++ b/source/capsule/heap/STLVector.cpp @@ -0,0 +1,80 @@ +/* + * Heap.cpp + * + * Created on: Dec 22, 2016 + * Author: wfg + */ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <new> //std::bad_alloc +#include <stdexcept> //std::runtime_error +/// \endcond + +#include "capsule/heap/STLVector.h" + +namespace adios +{ +namespace capsule +{ + +STLVector::STLVector(const std::string accessMode, const int rankMPI, + const bool debugMode) + : Capsule("Heap", accessMode, rankMPI, debugMode) +{ + m_Data.reserve(16777216); +} + +STLVector::~STLVector() {} + +char *STLVector::GetData() { return m_Data.data(); } + +char *STLVector::GetMetadata() { return m_Metadata.data(); } + +std::size_t STLVector::GetDataSize() const { return m_Data.size(); } + +std::size_t STLVector::GetMetadataSize() const { return m_Metadata.size(); } + +void STLVector::ResizeData(const std::size_t size) +{ + if (m_DebugMode == true) + { + try + { + m_Data.resize(size); + } + catch (std::bad_alloc &e) + { + throw std::runtime_error( + "ERROR: bad_alloc detected when resizing data buffer with size " + + std::to_string(size) + "\n"); + } + } + else + { + m_Data.resize(size); + } +} + +void STLVector::ResizeMetadata(const std::size_t size) +{ + if (m_DebugMode == true) + { + try + { + m_Metadata.resize(size); + } + catch (std::bad_alloc &e) + { + throw std::runtime_error( + "ERROR: bad_alloc detected when resizing metadata buffer with size " + + std::to_string(size) + "\n"); + } + } + else + { + m_Metadata.resize(size); + } +} + +} // end namespace heap +} // end namespace diff --git a/source/capsule/shmem/ShmSystemV.cpp b/source/capsule/shmem/ShmSystemV.cpp new file mode 100644 index 000000000..1b414a327 --- /dev/null +++ b/source/capsule/shmem/ShmSystemV.cpp @@ -0,0 +1,80 @@ +/* + * ShmSystemV.cpp + * + * Created on: Dec 22, 2016 + * Author: wfg + */ +/// \cond EXCLUDE_FROM_DOXYGEN +#include <ios> //std::ios_base::failure +#include <sys/shm.h> +/// \endcond + +#include "capsule/shmem/ShmSystemV.h" + +namespace adios +{ + +ShmSystemV::ShmSystemV(const std::string accessMode, const int rankMPI, + const std::string pathName, const size_t dataSize, + const size_t metadataSize, const bool debugMode) + : Capsule("ShmSystemV", accessMode, rankMPI, debugMode), + m_DataSize{dataSize}, m_MetadataSize{metadataSize} +{ + // Data Shared memory sector + const std::string dataPath(pathName + "/adios.shm.data." + + std::to_string(m_RankMPI)); + m_DataKey = ftok(dataPath.c_str(), m_RankMPI + 1); + m_DataShmID = shmget(m_DataKey, m_DataSize, IPC_CREAT | 0666); + m_Data = (char *)shmat(m_DataShmID, NULL, 0); + + // Metadata Shared memory sector + const std::string metadataPath(pathName + "/adios.shm.metadata." + + std::to_string(m_RankMPI)); + m_MetadataKey = + ftok(metadataPath.c_str(), + m_RankMPI + 1); // 2nd field must be greater than zero and unique + m_MetadataShmID = shmget(m_MetadataKey, m_MetadataSize, IPC_CREAT | 0666); + m_Metadata = (char *)shmat(m_MetadataShmID, NULL, 0); + + if (m_DebugMode == true) + CheckShm(); +} + +ShmSystemV::~ShmSystemV() {} + +char *ShmSystemV::GetData() { return m_Data; } + +char *ShmSystemV::GetMetadata() { return m_Metadata; } + +std::size_t ShmSystemV::GetDataSize() const { return m_DataSize; } + +std::size_t ShmSystemV::GetMetadataSize() const { return m_MetadataSize; } + +void ShmSystemV::CheckShm() const +{ + if (m_DataShmID < 0) + throw std::ios_base::failure( + "ERROR: Failed to create data shm segment of size " + + std::to_string(m_DataSize) + " from call to ShmSystemV constructor\n"); + + if (m_Data == nullptr) + throw std::ios_base::failure( + "ERROR: Failed to attach to data shm segment of size " + + std::to_string(m_DataSize) + " and id " + std::to_string(m_DataShmID) + + ", from call to ShmSystemV constructor\n"); + + if (m_DataShmID < 0) + throw std::ios_base::failure( + "ERROR: Failed to create metadata shm segment of size " + + std::to_string(m_MetadataSize) + + " from call to ShmSystemV constructor\n"); + + if (m_Metadata == nullptr) + throw std::ios_base::failure( + "ERROR: Failed to attach to metadata shm segment of size " + + std::to_string(m_MetadataSize) + " and id " + + std::to_string(m_MetadataShmID) + + " from call to ShmSystemV constructor\n"); +} + +} // end namespace diff --git a/source/core/Capsule.cpp b/source/core/Capsule.cpp new file mode 100644 index 000000000..9325119df --- /dev/null +++ b/source/core/Capsule.cpp @@ -0,0 +1,26 @@ +/* + * Capsule.cpp + * + * Created on: Nov 11, 2016 + * Author: wfg + */ + +#include "core/Capsule.h" + +namespace adios +{ + +Capsule::Capsule(const std::string type, const std::string accessMode, + const int rankMPI, const bool debugMode) + : m_Type{type}, m_AccessMode{accessMode}, m_RankMPI{rankMPI}, + m_DebugMode{debugMode} +{ +} + +Capsule::~Capsule() {} + +void Capsule::ResizeData(const std::size_t size) {} + +void Capsule::ResizeMetadata(const std::size_t size) {} + +} // end namespace diff --git a/source/core/Engine.cpp b/source/core/Engine.cpp new file mode 100644 index 000000000..8e4de6658 --- /dev/null +++ b/source/core/Engine.cpp @@ -0,0 +1,305 @@ +/* + * Engine.cpp + * + * Created on: Dec 19, 2016 + * Author: wfg + */ + +#include "core/Engine.h" +#include "core/Support.h" +#include "functions/adiosFunctions.h" + +namespace adios +{ + +Engine::Engine(ADIOS &adios, const std::string engineType, + const std::string name, const std::string accessMode, + MPI_Comm mpiComm, const Method &method, const bool debugMode, + const unsigned int nthreads, const std::string endMessage) + : m_MPIComm{mpiComm}, m_EngineType{engineType}, m_Name{name}, + m_AccessMode{accessMode}, m_Method{method}, m_ADIOS{adios}, + m_DebugMode{debugMode}, m_nThreads{nthreads}, m_EndMessage(endMessage) +{ + if (m_DebugMode == true) + { + if (m_MPIComm == MPI_COMM_NULL) + throw std::ios_base::failure( + "ERROR: engine communicator is MPI_COMM_NULL," + " in call to ADIOS Open or Constructor\n"); + } + + MPI_Comm_rank(m_MPIComm, &m_RankMPI); + MPI_Comm_size(m_MPIComm, &m_SizeMPI); +} + +Engine::~Engine() {} + +void Engine::SetCallBack(std::function<void(const void *, std::string, + std::string, std::string, Dims)> + callback) +{ +} + +// should these functions throw an exception? +void Engine::Write(Variable<char> &variable, const char *values) {} +void Engine::Write(Variable<unsigned char> &variable, + const unsigned char *values) +{ +} +void Engine::Write(Variable<short> &variable, const short *values) {} +void Engine::Write(Variable<unsigned short> &variable, + const unsigned short *values) +{ +} +void Engine::Write(Variable<int> &variable, const int *values) {} +void Engine::Write(Variable<unsigned int> &variable, const unsigned int *values) +{ +} +void Engine::Write(Variable<long int> &variable, const long int *values) {} +void Engine::Write(Variable<unsigned long int> &variable, + const unsigned long int *values) +{ +} +void Engine::Write(Variable<long long int> &variable, + const long long int *values) +{ +} +void Engine::Write(Variable<unsigned long long int> &variable, + const unsigned long long int *values) +{ +} +void Engine::Write(Variable<float> &variable, const float *values) {} +void Engine::Write(Variable<double> &variable, const double *values) {} +void Engine::Write(Variable<long double> &variable, const long double *values) +{ +} +void Engine::Write(Variable<std::complex<float>> &variable, + const std::complex<float> *values) +{ +} +void Engine::Write(Variable<std::complex<double>> &variable, + const std::complex<double> *values) +{ +} +void Engine::Write(Variable<std::complex<long double>> &variable, + const std::complex<long double> *values) +{ +} +void Engine::Write(VariableCompound &variable, const void *values) {} + +void Engine::Write(const std::string variableName, const char *values) {} +void Engine::Write(const std::string variableName, const unsigned char *values) +{ +} +void Engine::Write(const std::string variableName, const short *values) {} +void Engine::Write(const std::string variableName, const unsigned short *values) +{ +} +void Engine::Write(const std::string variableName, const int *values) {} +void Engine::Write(const std::string variableName, const unsigned int *values) +{ +} +void Engine::Write(const std::string variableName, const long int *values) {} +void Engine::Write(const std::string variableName, + const unsigned long int *values) +{ +} +void Engine::Write(const std::string variableName, const long long int *values) +{ +} +void Engine::Write(const std::string variableName, + const unsigned long long int *values) +{ +} +void Engine::Write(const std::string variableName, const float *values) {} +void Engine::Write(const std::string variableName, const double *values) {} +void Engine::Write(const std::string variableName, const long double *values) {} +void Engine::Write(const std::string variableName, + const std::complex<float> *values) +{ +} +void Engine::Write(const std::string variableName, + const std::complex<double> *values) +{ +} +void Engine::Write(const std::string variableName, + const std::complex<long double> *values) +{ +} +void Engine::Write(const std::string variableName, const void *values) {} + +void Engine::Advance(float timeout_sec) {} +void Engine::Advance(AdvanceMode mode, float timeout_sec) {} +void Engine::AdvanceAsync( + AdvanceMode mode, + std::function<void(std::shared_ptr<adios::Engine>)> callback) +{ +} + +void Engine::Close(const int transportIndex) {} + +// READ +Variable<void> *Engine::InquireVariable(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<char> *Engine::InquireVariableChar(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<unsigned char> *Engine::InquireVariableUChar(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<short> *Engine::InquireVariableShort(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<unsigned short> *Engine::InquireVariableUShort(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<int> *Engine::InquireVariableInt(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<unsigned int> *Engine::InquireVariableUInt(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<long int> *Engine::InquireVariableLInt(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<unsigned long int> * +Engine::InquireVariableULInt(const std::string name, const bool readIn) +{ + return nullptr; +} +Variable<long long int> *Engine::InquireVariableLLInt(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<unsigned long long int> * +Engine::InquireVariableULLInt(const std::string name, const bool readIn) +{ + return nullptr; +} +Variable<float> *Engine::InquireVariableFloat(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<double> *Engine::InquireVariableDouble(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<long double> *Engine::InquireVariableLDouble(const std::string name, + const bool readIn) +{ + return nullptr; +} +Variable<std::complex<float>> * +Engine::InquireVariableCFloat(const std::string name, const bool readIn) +{ + return nullptr; +} +Variable<std::complex<double>> * +Engine::InquireVariableCDouble(const std::string name, const bool readIn) +{ + return nullptr; +} +Variable<std::complex<long double>> * +Engine::InquireVariableCLDouble(const std::string name, const bool readIn) +{ + return nullptr; +} +VariableCompound *Engine::InquireVariableCompound(const std::string name, + const bool readIn) +{ + return nullptr; +} + +void Engine::Read(Variable<double> &variable, const double *values) {} +void Engine::ScheduleRead(Variable<double> &variable, const double *values) {} +void Engine::Release() {} + +// PROTECTED +void Engine::Init() {} + +void Engine::InitParameters() {} + +void Engine::InitTransports() {} + +void Engine::CheckParameter( + const std::map<std::string, std::string>::const_iterator itParam, + const std::map<std::string, std::string> ¶meters, + const std::string parameterName, const std::string hint) const +{ + if (itParam == parameters.end()) + throw std::invalid_argument("ERROR: parameter name " + parameterName + + " not found " + hint); +} + +bool Engine::TransportNamesUniqueness() const +{ + auto lf_CheckTransportsType = + [&](const std::set<std::string> &specificType) -> bool { + std::set<std::string> transportNames; + + for (const auto ¶meters : m_Method.m_TransportParameters) + { + auto itTransport = parameters.find("transport"); + if (m_DebugMode == true) + { + if (itTransport == parameters.end()) + throw std::invalid_argument( + "ERROR: transport not defined in Method input to Engine " + + m_Name); + } + + const std::string type(itTransport->second); + if (specificType.count(type) == 1) // file transports type + { + std::string name(m_Name); + auto itName = parameters.find("name"); + if (itName != parameters.end()) + name = itName->second; + + if (transportNames.count(name) == 0) + transportNames.insert(name); + else + return false; + } + } + return true; + }; + + return lf_CheckTransportsType(Support::FileTransports); +} + +void Engine::CheckTransportIndex(const int transportIndex) +{ + if (m_DebugMode == true) + { + if (transportIndex >= static_cast<int>(m_Transports.size()) || + transportIndex < -1) + { + throw std::invalid_argument( + "ERROR: transport index " + std::to_string(transportIndex) + + " is out of range, in call to " + m_Name + "Close \n"); + } + } +} + +} // end namespace diff --git a/source/core/Method.cpp b/source/core/Method.cpp new file mode 100644 index 000000000..0d88459d6 --- /dev/null +++ b/source/core/Method.cpp @@ -0,0 +1,63 @@ +/* + * Method.cpp + * + * Created on: Jan 6, 2017 + * Author: wfg + */ + +#include "core/Method.h" +#include "functions/adiosFunctions.h" + +namespace adios +{ + +Method::Method(const std::string name, const bool debugMode) + : m_Name{name}, m_DebugMode{debugMode} +{ + // m_Type can stay empty (forcing the choice of the default engine) + m_nThreads = 1; +} + +Method::~Method() {} + +bool Method::isUserDefined() +{ + return false; // TODO: check if XML has the method defined +} + +void Method::SetEngine(const std::string type) { m_Type = type; } + +void Method::AllowThreads(const int nThreads) +{ + if (nThreads > 1) + m_nThreads = nThreads; + else + m_nThreads = 1; +} + +// PRIVATE Functions +void Method::AddTransportParameters(const std::string type, + const std::vector<std::string> ¶meters) +{ + if (m_DebugMode == true) + { + if (type.empty() || type.find("=") != type.npos) + throw std::invalid_argument("ERROR: first argument in AddTransport must " + "be a single word for transport\n"); + } + + std::map<std::string, std::string> mapParameters = + BuildParametersMap(parameters, m_DebugMode); + if (m_DebugMode == true) + { + if (mapParameters.count("transport") == 1) + std::invalid_argument( + "ERROR: transport can't be redefined with \"transport=type\", " + "type must be the first argument\n"); + } + + mapParameters["transport"] = type; + m_TransportParameters.push_back(mapParameters); +} + +} // end namespace diff --git a/source/core/Support.cpp b/source/core/Support.cpp new file mode 100644 index 000000000..1a8bdf254 --- /dev/null +++ b/source/core/Support.cpp @@ -0,0 +1,90 @@ +/* + * Support.cpp + * + * Created on: Oct 18, 2016 + * Author: wfg + */ + +#include "core/Support.h" +#include "functions/adiosTemplates.h" + +namespace adios +{ + +const std::string Support::Version{"2.00"}; + +const std::set<std::string> Support::HostLanguages{{"C++", "C", "Fortran"}}; + +const std::set<std::string> Support::Transports{ + {"NULL", "POSIX", "FStream", + "MdtmMan"} // "MPI", "MPI_LUSTRE", "MPI_AGGREGATE", "DATASPACES", "DIMES", + // "FLEXPATH", "PHDF5", "NC4", "ICEE" } +}; + +const std::set<std::string> Support::Transforms{ + {"none", "identity", "bzip2", "isobar", "szip", "zlib"}}; + +const std::map<std::string, std::set<std::string>> Support::Datatypes{ + {"C++", {"char", + "std::string", + "string", + "unsigned char", + "short", + "unsigned short", + "int", + "integer", + "unsigned int", + "long int", + "long", + "unsigned long int", + "unsigned long", + "long long int", + "long long", + "unsigned long long int", + "unsigned long long", + "float", + "float complex", + "double", + "long double", + "double complex", + "std::complex<double>", + "complex<double>"}}, + {"C", + {"char", "unsigned char", "short", "unsigned short", "int", "integer" + "unsigned int", + "unsigned integer", "long int", "long", "long integer", + "unsigned long int", "unsigned long", "unsigned long integer", + "long long int", "long long", "long long integer", + "unsigned long long int", "unsigned long long", + "unsigned long long integer", "float", "float complex" + "double", + "long double", "double complex"}}, + {"Fortran", + {"character", "integer*2", "integer", "real*2", "real", "real*4", + "double precision", "real*8", "complex", "double complex"}}}; + +const std::map<std::string, std::set<std::string>> Support::DatatypesAliases{ + {GetType<char>(), {GetType<char>(), "character"}}, + {GetType<unsigned char>(), + {GetType<unsigned char>(), "unsigned character"}}, + {GetType<short>(), {GetType<short>(), "integer*2"}}, + {GetType<unsigned short>(), {GetType<unsigned short>()}}, + {GetType<int>(), {GetType<int>(), "integer"}}, + {GetType<unsigned int>(), {GetType<unsigned int>(), "unsigned integer"}}, + {GetType<long int>(), {GetType<long int>(), "long", "long integer"}}, + {GetType<unsigned long int>(), + {GetType<unsigned long int>(), "unsigned long", "unsigned long integer"}}, + {GetType<long long int>(), + {GetType<long long int>(), "long long", "long long integer"}}, + {GetType<unsigned long long int>(), + {GetType<unsigned long long int>(), "unsigned long long", + "unsigned long long integer"}}, + {GetType<float>(), {GetType<float>(), "real", "real*4"}}, + {GetType<double>(), {GetType<double>(), "double precision", "real*8"}}, + {GetType<long double>(), + {GetType<long double>(), "long double precision", "real*16"}}}; + +const std::set<std::string> Support::FileTransports{ + {"POSIX", "File", "FStream", "MPIFile"}}; + +} // end namespace diff --git a/source/core/Transform.cpp b/source/core/Transform.cpp new file mode 100644 index 000000000..288715626 --- /dev/null +++ b/source/core/Transform.cpp @@ -0,0 +1,27 @@ +/* + * Transform.cpp + * + * Created on: Dec 5, 2016 + * Author: wfg + */ + +#include "core/Transform.h" + +namespace adios +{ + +Transform::Transform(const std::string method) : m_Method(method) {} + +Transform::~Transform() {} + +void Transform::Compress(const std::vector<char> &bufferIn, + std::vector<char> &bufferOut) +{ +} + +void Transform::Decompress(const std::vector<char> &bufferIn, + std::vector<char> &bufferOut) +{ +} + +} // end namespace diff --git a/source/core/Transport.cpp b/source/core/Transport.cpp new file mode 100644 index 000000000..1de1339a0 --- /dev/null +++ b/source/core/Transport.cpp @@ -0,0 +1,49 @@ +/* + * Transport.cpp + * + * Created on: Dec 5, 2016 + * Author: wfg + */ + +#include "core/Transport.h" + +namespace adios +{ + +Transport::Transport(const std::string type, MPI_Comm mpiComm, + const bool debugMode) + : m_Type{type}, m_MPIComm{mpiComm}, m_DebugMode{debugMode} +{ + MPI_Comm_rank(m_MPIComm, &m_RankMPI); + MPI_Comm_size(m_MPIComm, &m_SizeMPI); +} + +Transport::~Transport() {} + +void Transport::SetBuffer(char *buffer, size_t size) {} + +void Transport::Flush() {} + +void Transport::Close() {} + +void Transport::InitProfiler(const std::string accessMode, + const Support::Resolutions resolution) +{ + m_Profiler.m_Timers.emplace_back("open", Support::Resolutions::mus); + + if (accessMode == "w" || accessMode == "write") + m_Profiler.m_Timers.emplace_back("write", resolution); + + else if (accessMode == "a" || accessMode == "append") + m_Profiler.m_Timers.emplace_back("append", resolution); + + else if (accessMode == "r" || accessMode == "read") + m_Profiler.m_Timers.emplace_back("read", resolution); + + m_Profiler.m_Timers.emplace_back("close", Support::Resolutions::mus); + + m_Profiler.m_TotalBytes.push_back(0); + m_Profiler.m_IsActive = true; +} + +} // end namespace diff --git a/source/engine/adios1/ADIOS1Reader.cpp b/source/engine/adios1/ADIOS1Reader.cpp new file mode 100644 index 000000000..5f2ea1420 --- /dev/null +++ b/source/engine/adios1/ADIOS1Reader.cpp @@ -0,0 +1,230 @@ +/* + * BPFileReader.cpp + * + * Created on: Feb 27, 2017 + * Author: wfg + */ + +#include "engine/bp/BPFileReader.h" + +#include "core/Support.h" +#include "functions/adiosFunctions.h" //CSVToVector +#include "transport/file/FileDescriptor.h" // uses POSIX +#include "transport/file/FilePointer.h" // uses C FILE* + +// supported transports +#include "transport/file/FStream.h" // uses C++ fstream + +namespace adios +{ + +BPFileReader::BPFileReader(ADIOS &adios, const std::string name, + const std::string accessMode, MPI_Comm mpiComm, + const Method &method, const IOMode iomode, + const float timeout_sec, const bool debugMode, + const unsigned int nthreads) + : Engine(adios, "BPFileReader", name, accessMode, mpiComm, method, + debugMode, nthreads, + " BPFileReader constructor (or call to ADIOS Open).\n"), + m_Buffer(accessMode, m_RankMPI, m_DebugMode) +{ + Init(); +} + +BPFileReader::~BPFileReader() {} + +Variable<void> * +BPFileReader::InquireVariable(const std::string name, + const bool readIn) // not yet implemented +{ + return nullptr; +} + +Variable<char> *BPFileReader::InquireVariableChar(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<char>(name, readIn); +} + +Variable<unsigned char> * +BPFileReader::InquireVariableUChar(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned char>(name, readIn); +} + +Variable<short> *BPFileReader::InquireVariableShort(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<short>(name, readIn); +} + +Variable<unsigned short> * +BPFileReader::InquireVariableUShort(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned short>(name, readIn); +} + +Variable<int> *BPFileReader::InquireVariableInt(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<int>(name, readIn); +} + +Variable<unsigned int> * +BPFileReader::InquireVariableUInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned int>(name, readIn); +} + +Variable<long int> *BPFileReader::InquireVariableLInt(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<long int>(name, readIn); +} + +Variable<unsigned long int> * +BPFileReader::InquireVariableULInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned long int>(name, readIn); +} + +Variable<long long int> * +BPFileReader::InquireVariableLLInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<long long int>(name, readIn); +} + +Variable<unsigned long long int> * +BPFileReader::InquireVariableULLInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned long long int>(name, readIn); +} + +Variable<float> *BPFileReader::InquireVariableFloat(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<float>(name, readIn); +} + +Variable<double> *BPFileReader::InquireVariableDouble(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<double>(name, readIn); +} + +Variable<long double> * +BPFileReader::InquireVariableLDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<long double>(name, readIn); +} + +Variable<std::complex<float>> * +BPFileReader::InquireVariableCFloat(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<float>>(name, readIn); +} + +Variable<std::complex<double>> * +BPFileReader::InquireVariableCDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<double>>(name, readIn); +} + +Variable<std::complex<long double>> * +BPFileReader::InquireVariableCLDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<long double>>(name, readIn); +} + +VariableCompound *BPFileReader::InquireVariableCompound(const std::string name, + const bool readIn) +{ + return nullptr; +} + +void BPFileReader::Close(const int transportIndex) {} + +// PRIVATE +void BPFileReader::Init() +{ + if (m_DebugMode == true) + { + if (m_AccessMode != "r" && m_AccessMode != "read") + throw std::invalid_argument( + "ERROR: BPFileReader doesn't support access mode " + m_AccessMode + + ", in call to ADIOS Open or BPFileReader constructor\n"); + } + + InitCapsules(); + InitTransports(); +} + +void BPFileReader::InitCapsules() +{ + // here init memory capsules +} + +void BPFileReader::InitTransports() // maybe move this? +{ + if (m_DebugMode == true) + { + if (TransportNamesUniqueness() == false) + { + throw std::invalid_argument( + "ERROR: two transports of the same kind (e.g file IO) " + "can't have the same name, modify with name= in Method " + "AddTransport\n"); + } + } + + for (const auto ¶meters : m_Method.m_TransportParameters) + { + auto itTransport = parameters.find("transport"); + if (itTransport->second == "file" || itTransport->second == "File") + { + auto itLibrary = parameters.find("library"); + if (itLibrary == parameters.end() || + itLibrary->second == "POSIX") // use default POSIX + { + auto file = + std::make_shared<transport::FileDescriptor>(m_MPIComm, m_DebugMode); + // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "FILE*" || itLibrary->second == "stdio.h") + { + auto file = + std::make_shared<transport::FilePointer>(m_MPIComm, m_DebugMode); + // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "fstream" || + itLibrary->second == "std::fstream") + { + auto file = + std::make_shared<transport::FStream>(m_MPIComm, m_DebugMode); + // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "MPI-IO") + { + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument( + "ERROR: file transport library " + itLibrary->second + + " not supported, in " + m_Name + m_EndMessage); + } + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: transport " + itTransport->second + + " (you mean File?) not supported, in " + + m_Name + m_EndMessage); + } + } +} + +} // end namespace diff --git a/source/engine/adios1/ADIOS1Writer.cpp b/source/engine/adios1/ADIOS1Writer.cpp new file mode 100644 index 000000000..304dd31fc --- /dev/null +++ b/source/engine/adios1/ADIOS1Writer.cpp @@ -0,0 +1,449 @@ +/* + * ADIOS1Writer.cpp + * Class to write files using old adios 1.x library. + * It requires adios 1.x installed + * + * Created on: Mar 27, 2017 + * Author: pnb + */ + +#include "engine/adios1/ADIOS1Writer.h" +#include "ADIOS.h" + +extern int adios_verbose_level; +extern int adios_errno; + +namespace adios +{ + +ADIOS1Writer::ADIOS1Writer(ADIOS &adios, const std::string name, + const std::string accessMode, MPI_Comm mpiComm, + const Method &method, const IOMode iomode, + const float timeout_sec, const bool debugMode, + const unsigned int nthreads) + : Engine(adios, "ADIOS1Writer", name, accessMode, mpiComm, method, + debugMode, nthreads, + " ADIOS1Writer constructor (or call to ADIOS Open).\n"), + m_groupname{method.m_Name.c_str()}, m_filename{name.c_str()}, + m_comm{mpiComm} +{ + Init(); + adios_open(&m_adios_file, m_groupname, m_filename, accessMode.c_str(), + m_comm); + if (adios_errno == err_no_error) + { + m_IsFileOpen = true; + } +} + +ADIOS1Writer::~ADIOS1Writer() +{ + if (m_IsFileOpen) + { + adios_close(m_adios_file); + m_IsFileOpen = false; + } +} + +void ADIOS1Writer::Init() +{ + if (!m_initialized) + { + adios_init_noxml(m_comm); + m_initialized = true; + } + adios_declare_group(&m_adios_group, m_groupname, "", adios_stat_default); + + InitParameters(); + InitTransports(); +} + +bool ADIOS1Writer::ReOpenAsNeeded() +{ + if (!m_IsFileOpen) + { + adios_open(&m_adios_file, m_groupname, m_filename, "a", m_comm); + if (adios_errno == err_no_error) + { + m_IsFileOpen = true; + adios_delete_vardefs(m_adios_group); + } + } + return m_IsFileOpen; +} + +void ADIOS1Writer::DefineVariable(std::string name, bool isScalar, + enum ADIOS_DATATYPES vartype, + std::string ldims, std::string gdims, + std::string offs) +{ + if (isScalar) + { + adios_define_var(m_adios_group, name.c_str(), "", vartype, "", "", ""); + } + else + { + adios_define_var(m_adios_group, name.c_str(), "", vartype, ldims.c_str(), + gdims.c_str(), offs.c_str()); + } +} + +void ADIOS1Writer::WriteVariable(std::string name, bool isScalar, + enum ADIOS_DATATYPES vartype, + std::string ldims, std::string gdims, + std::string offs, const void *values) +{ + if (ReOpenAsNeeded()) + { + DefineVariable(name, isScalar, vartype, ldims, gdims, offs); + adios_write(m_adios_file, name.c_str(), values); + } +} + +void ADIOS1Writer::Write(Variable<char> &variable, const char *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_byte, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<unsigned char> &variable, + const unsigned char *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_unsigned_byte, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<short> &variable, const short *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_short, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<unsigned short> &variable, + const unsigned short *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_unsigned_short, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<int> &variable, const int *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_integer, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<unsigned int> &variable, + const unsigned int *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_unsigned_integer, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<long int> &variable, const long int *values) +{ + enum ADIOS_DATATYPES type = + adios_integer; // long int is usually 4 bytes which is adios_integer + if (sizeof(long int) == 8) + { + type = adios_long; + } + WriteVariable(variable.m_Name, variable.m_IsScalar, type, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<unsigned long int> &variable, + const unsigned long int *values) +{ + enum ADIOS_DATATYPES type = + adios_unsigned_integer; // long int is usually 4 bytes + if (sizeof(long int) == 8) + { + type = adios_unsigned_long; + } + WriteVariable(variable.m_Name, variable.m_IsScalar, type, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<long long int> &variable, + const long long int *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_long, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<unsigned long long int> &variable, + const unsigned long long int *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_unsigned_long, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<float> &variable, const float *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_real, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<double> &variable, const double *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_double, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<long double> &variable, + const long double *values) +{ + /* TODO: This is faulty: adios_long_double expects 16 bytes per elements, but + * long double is compiler dependent */ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_long_double, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<std::complex<float>> &variable, + const std::complex<float> *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_complex, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<std::complex<double>> &variable, + const std::complex<double> *values) +{ + WriteVariable(variable.m_Name, variable.m_IsScalar, adios_double_complex, + variable.GetDimensionAsString(), + variable.GetGlobalDimensionAsString(), + variable.GetOffsetsAsString(), values); +} + +void ADIOS1Writer::Write(Variable<std::complex<long double>> &variable, + const std::complex<long double> *values) +{ + throw std::invalid_argument("ERROR: Adios 1.x does not support complex<long " + "double> type, so it cannot write variable " + + variable.m_Name + "\n"); +} + +void ADIOS1Writer::Write(VariableCompound &variable, const void *values) +{ + throw std::invalid_argument("ERROR: Adios 1.x does not support compound " + "types, so it cannot write variable " + + variable.m_Name + "\n"); +} + +// String version +void ADIOS1Writer::Write(const std::string variableName, const char *values) +{ + Write(m_ADIOS.GetVariable<char>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const unsigned char *values) +{ + Write(m_ADIOS.GetVariable<unsigned char>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, const short *values) +{ + Write(m_ADIOS.GetVariable<short>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const unsigned short *values) +{ + Write(m_ADIOS.GetVariable<unsigned short>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, const int *values) +{ + Write(m_ADIOS.GetVariable<int>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const unsigned int *values) +{ + Write(m_ADIOS.GetVariable<unsigned int>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, const long int *values) +{ + Write(m_ADIOS.GetVariable<long int>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const unsigned long int *values) +{ + Write(m_ADIOS.GetVariable<unsigned long int>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const long long int *values) +{ + Write(m_ADIOS.GetVariable<long long int>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const unsigned long long int *values) +{ + Write(m_ADIOS.GetVariable<unsigned long long int>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, const float *values) +{ + Write(m_ADIOS.GetVariable<float>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, const double *values) +{ + Write(m_ADIOS.GetVariable<double>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const long double *values) +{ + Write(m_ADIOS.GetVariable<long double>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const std::complex<float> *values) +{ + Write(m_ADIOS.GetVariable<std::complex<float>>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const std::complex<double> *values) +{ + Write(m_ADIOS.GetVariable<std::complex<double>>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const std::complex<long double> *values) +{ + Write(m_ADIOS.GetVariable<std::complex<long double>>(variableName), values); +} + +void ADIOS1Writer::Write(const std::string variableName, + const void *values) // Compound type +{ + throw std::invalid_argument("ERROR: Adios 1.x does not support compound " + "types, so it cannot write variable " + + variableName + "\n"); +} + +void ADIOS1Writer::Advance() +{ + if (m_IsFileOpen) + { + adios_close(m_adios_file); + m_IsFileOpen = false; + } +} + +void ADIOS1Writer::Close(const int transportIndex) +{ + if (m_IsFileOpen) + { + adios_close(m_adios_file); + m_IsFileOpen = false; + } +} + +// PRIVATE FUNCTIONS +void ADIOS1Writer::InitParameters() +{ + auto itMaxBufferSize = m_Method.m_Parameters.find("max_size_MB"); + if (itMaxBufferSize != m_Method.m_Parameters.end()) + { + adios_set_max_buffer_size(std::stoul(itMaxBufferSize->second)); + } + + auto itVerbosity = m_Method.m_Parameters.find("verbose"); + if (itVerbosity != m_Method.m_Parameters.end()) + { + int verbosity = std::stoi(itVerbosity->second); + if (m_DebugMode == true) + { + if (verbosity < 0 || verbosity > 5) + throw std::invalid_argument("ERROR: Method verbose argument must be an " + "integer in the range [0,5], in call to " + "Open or Engine constructor\n"); + } + adios_verbose_level = verbosity; + } +} + +void ADIOS1Writer::InitTransports() +{ + if (m_DebugMode == true) + { + if (TransportNamesUniqueness() == false) + { + throw std::invalid_argument( + "ERROR: two transports of the same kind (e.g file IO) " + "can't have the same name, modify with name= in Method " + "AddTransport\n"); + } + } + + for (const auto ¶meters : m_Method.m_TransportParameters) + { + auto itTransport = parameters.find("transport"); + + if (itTransport->second == "file" || itTransport->second == "File") + { + auto itLibrary = parameters.find("library"); + if (itLibrary == parameters.end() || + itLibrary->second == "POSIX") // use default POSIX + { + adios_select_method(m_adios_group, "POSIX", "", ""); + } + else if (itLibrary->second == "MPI_File" || itLibrary->second == "MPI-IO") + { + adios_select_method(m_adios_group, "MPI", "", ""); + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument( + "ERROR: file transport library " + itLibrary->second + + " not supported, in " + m_Name + m_EndMessage); + } + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: transport " + itTransport->second + + " (you mean File?) not supported, in " + + m_Name + m_EndMessage); + } + } +} + +} // end namespace adios diff --git a/source/engine/bp/BPFileReader.cpp b/source/engine/bp/BPFileReader.cpp new file mode 100644 index 000000000..5f2ea1420 --- /dev/null +++ b/source/engine/bp/BPFileReader.cpp @@ -0,0 +1,230 @@ +/* + * BPFileReader.cpp + * + * Created on: Feb 27, 2017 + * Author: wfg + */ + +#include "engine/bp/BPFileReader.h" + +#include "core/Support.h" +#include "functions/adiosFunctions.h" //CSVToVector +#include "transport/file/FileDescriptor.h" // uses POSIX +#include "transport/file/FilePointer.h" // uses C FILE* + +// supported transports +#include "transport/file/FStream.h" // uses C++ fstream + +namespace adios +{ + +BPFileReader::BPFileReader(ADIOS &adios, const std::string name, + const std::string accessMode, MPI_Comm mpiComm, + const Method &method, const IOMode iomode, + const float timeout_sec, const bool debugMode, + const unsigned int nthreads) + : Engine(adios, "BPFileReader", name, accessMode, mpiComm, method, + debugMode, nthreads, + " BPFileReader constructor (or call to ADIOS Open).\n"), + m_Buffer(accessMode, m_RankMPI, m_DebugMode) +{ + Init(); +} + +BPFileReader::~BPFileReader() {} + +Variable<void> * +BPFileReader::InquireVariable(const std::string name, + const bool readIn) // not yet implemented +{ + return nullptr; +} + +Variable<char> *BPFileReader::InquireVariableChar(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<char>(name, readIn); +} + +Variable<unsigned char> * +BPFileReader::InquireVariableUChar(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned char>(name, readIn); +} + +Variable<short> *BPFileReader::InquireVariableShort(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<short>(name, readIn); +} + +Variable<unsigned short> * +BPFileReader::InquireVariableUShort(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned short>(name, readIn); +} + +Variable<int> *BPFileReader::InquireVariableInt(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<int>(name, readIn); +} + +Variable<unsigned int> * +BPFileReader::InquireVariableUInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned int>(name, readIn); +} + +Variable<long int> *BPFileReader::InquireVariableLInt(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<long int>(name, readIn); +} + +Variable<unsigned long int> * +BPFileReader::InquireVariableULInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned long int>(name, readIn); +} + +Variable<long long int> * +BPFileReader::InquireVariableLLInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<long long int>(name, readIn); +} + +Variable<unsigned long long int> * +BPFileReader::InquireVariableULLInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned long long int>(name, readIn); +} + +Variable<float> *BPFileReader::InquireVariableFloat(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<float>(name, readIn); +} + +Variable<double> *BPFileReader::InquireVariableDouble(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<double>(name, readIn); +} + +Variable<long double> * +BPFileReader::InquireVariableLDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<long double>(name, readIn); +} + +Variable<std::complex<float>> * +BPFileReader::InquireVariableCFloat(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<float>>(name, readIn); +} + +Variable<std::complex<double>> * +BPFileReader::InquireVariableCDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<double>>(name, readIn); +} + +Variable<std::complex<long double>> * +BPFileReader::InquireVariableCLDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<long double>>(name, readIn); +} + +VariableCompound *BPFileReader::InquireVariableCompound(const std::string name, + const bool readIn) +{ + return nullptr; +} + +void BPFileReader::Close(const int transportIndex) {} + +// PRIVATE +void BPFileReader::Init() +{ + if (m_DebugMode == true) + { + if (m_AccessMode != "r" && m_AccessMode != "read") + throw std::invalid_argument( + "ERROR: BPFileReader doesn't support access mode " + m_AccessMode + + ", in call to ADIOS Open or BPFileReader constructor\n"); + } + + InitCapsules(); + InitTransports(); +} + +void BPFileReader::InitCapsules() +{ + // here init memory capsules +} + +void BPFileReader::InitTransports() // maybe move this? +{ + if (m_DebugMode == true) + { + if (TransportNamesUniqueness() == false) + { + throw std::invalid_argument( + "ERROR: two transports of the same kind (e.g file IO) " + "can't have the same name, modify with name= in Method " + "AddTransport\n"); + } + } + + for (const auto ¶meters : m_Method.m_TransportParameters) + { + auto itTransport = parameters.find("transport"); + if (itTransport->second == "file" || itTransport->second == "File") + { + auto itLibrary = parameters.find("library"); + if (itLibrary == parameters.end() || + itLibrary->second == "POSIX") // use default POSIX + { + auto file = + std::make_shared<transport::FileDescriptor>(m_MPIComm, m_DebugMode); + // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "FILE*" || itLibrary->second == "stdio.h") + { + auto file = + std::make_shared<transport::FilePointer>(m_MPIComm, m_DebugMode); + // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "fstream" || + itLibrary->second == "std::fstream") + { + auto file = + std::make_shared<transport::FStream>(m_MPIComm, m_DebugMode); + // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "MPI-IO") + { + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument( + "ERROR: file transport library " + itLibrary->second + + " not supported, in " + m_Name + m_EndMessage); + } + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: transport " + itTransport->second + + " (you mean File?) not supported, in " + + m_Name + m_EndMessage); + } + } +} + +} // end namespace diff --git a/source/engine/bp/BPFileWriter.cpp b/source/engine/bp/BPFileWriter.cpp new file mode 100644 index 000000000..f272a586a --- /dev/null +++ b/source/engine/bp/BPFileWriter.cpp @@ -0,0 +1,508 @@ +/* + * BPFileWriter.cpp + * + * Created on: Dec 19, 2016 + * Author: wfg + */ + +#include "engine/bp/BPFileWriter.h" +#include "ADIOS.h" + +// supported transports +#include "transport/file/FStream.h" +#include "transport/file/FileDescriptor.h" +#include "transport/file/FilePointer.h" + +namespace adios +{ + +BPFileWriter::BPFileWriter(ADIOS &adios, const std::string name, + const std::string accessMode, MPI_Comm mpiComm, + const Method &method, const IOMode iomode, + const float timeout_sec, const bool debugMode, + const unsigned int nthreads) + : Engine(adios, "BPFileWriter", name, accessMode, mpiComm, method, + debugMode, nthreads, + " BPFileWriter constructor (or call to ADIOS Open).\n"), + m_Buffer{capsule::STLVector(accessMode, m_RankMPI, m_DebugMode)}, + m_BP1Aggregator{format::BP1Aggregator(m_MPIComm, debugMode)}, + m_MaxBufferSize{m_Buffer.m_Data.max_size()} +{ + m_MetadataSet.TimeStep = 1; // starting at one to be compatible with ADIOS1.x + Init(); +} + +BPFileWriter::~BPFileWriter() {} + +void BPFileWriter::Init() +{ + InitParameters(); + InitTransports(); + InitProcessGroup(); +} + +void BPFileWriter::Write(Variable<char> &variable, const char *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<unsigned char> &variable, + const unsigned char *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<short> &variable, const short *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<unsigned short> &variable, + const unsigned short *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<int> &variable, const int *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<unsigned int> &variable, + const unsigned int *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<long int> &variable, const long int *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<unsigned long int> &variable, + const unsigned long int *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<long long int> &variable, + const long long int *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<unsigned long long int> &variable, + const unsigned long long int *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<float> &variable, const float *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<double> &variable, const double *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<long double> &variable, + const long double *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<std::complex<float>> &variable, + const std::complex<float> *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<std::complex<double>> &variable, + const std::complex<double> *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(Variable<std::complex<long double>> &variable, + const std::complex<long double> *values) +{ + WriteVariableCommon(variable, values); +} + +void BPFileWriter::Write(VariableCompound &variable, const void *values) {} + +// String version +void BPFileWriter::Write(const std::string variableName, const char *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<char>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const unsigned char *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned char>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, const short *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<short>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const unsigned short *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned short>(variableName), + values); +} + +void BPFileWriter::Write(const std::string variableName, const int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<int>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const unsigned int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned int>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, const long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<long int>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const unsigned long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned long int>(variableName), + values); +} + +void BPFileWriter::Write(const std::string variableName, + const long long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<long long int>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const unsigned long long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned long long int>(variableName), + values); +} + +void BPFileWriter::Write(const std::string variableName, const float *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<float>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, const double *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<double>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const long double *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<long double>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const std::complex<float> *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<std::complex<float>>(variableName), + values); +} + +void BPFileWriter::Write(const std::string variableName, + const std::complex<double> *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<std::complex<double>>(variableName), + values); +} + +void BPFileWriter::Write(const std::string variableName, + const std::complex<long double> *values) +{ + WriteVariableCommon( + m_ADIOS.GetVariable<std::complex<long double>>(variableName), values); +} + +void BPFileWriter::Write(const std::string variableName, + const void *values) // Compound type +{ +} + +void BPFileWriter::Advance(float timeout_sec) +{ + m_BP1Writer.Advance(m_MetadataSet, m_Buffer); +} + +void BPFileWriter::Close(const int transportIndex) +{ + CheckTransportIndex(transportIndex); + if (transportIndex == -1) + { + for (auto &transport : + m_Transports) // by reference or value or it doesn't matter? + m_BP1Writer.Close(m_MetadataSet, m_Buffer, *transport, m_IsFirstClose, + false); // false: not using aggregation for now + } + else + { + m_BP1Writer.Close(m_MetadataSet, m_Buffer, *m_Transports[transportIndex], + m_IsFirstClose, + false); // false: not using aggregation for now + } + + if (m_MetadataSet.Log.m_IsActive == true) + { + bool allClose = true; + for (auto &transport : m_Transports) + { + if (transport->m_IsOpen == true) + { + allClose = false; + break; + } + } + if (allClose == true) // aggregate and write profiling.log + { + const std::string rankLog = m_BP1Writer.GetRankProfilingLog( + m_RankMPI, m_MetadataSet, m_Transports); + + const std::string fileName(m_BP1Writer.GetDirectoryName(m_Name) + + "/profiling.log"); + m_BP1Aggregator.WriteProfilingLog(fileName, rankLog); + } + } +} + +// PRIVATE FUNCTIONS +void BPFileWriter::InitParameters() +{ + auto itGrowthFactor = m_Method.m_Parameters.find("buffer_growth"); + if (itGrowthFactor != m_Method.m_Parameters.end()) + { + const float growthFactor = std::stof(itGrowthFactor->second); + if (m_DebugMode == true) + { + if (growthFactor == 1.f) + throw std::invalid_argument( + "ERROR: buffer_growth argument can't be less of equal than 1, in " + + m_EndMessage + "\n"); + } + + m_BP1Writer.m_GrowthFactor = growthFactor; + m_GrowthFactor = growthFactor; // float + } + + auto itMaxBufferSize = m_Method.m_Parameters.find("max_size_MB"); + if (itMaxBufferSize != m_Method.m_Parameters.end()) + { + if (m_DebugMode == true) + { + if (m_GrowthFactor <= 1.f) + throw std::invalid_argument("ERROR: Method buffer_growth argument " + "can't be less of equal than 1, in " + + m_EndMessage + "\n"); + } + + m_MaxBufferSize = std::stoul(itMaxBufferSize->second) * + 1048576; // convert from MB to bytes + } + + auto itVerbosity = m_Method.m_Parameters.find("verbose"); + if (itVerbosity != m_Method.m_Parameters.end()) + { + int verbosity = std::stoi(itVerbosity->second); + if (m_DebugMode == true) + { + if (verbosity < 0 || verbosity > 5) + throw std::invalid_argument("ERROR: Method verbose argument must be an " + "integer in the range [0,5], in call to " + "Open or Engine constructor\n"); + } + m_BP1Writer.m_Verbosity = verbosity; + } + + auto itProfile = m_Method.m_Parameters.find("profile_units"); + if (itProfile != m_Method.m_Parameters.end()) + { + auto &profiler = m_MetadataSet.Log; + + if (itProfile->second == "mus" || itProfile->second == "microseconds") + profiler.m_Timers.emplace_back("buffering", Support::Resolutions::mus); + + else if (itProfile->second == "ms" || itProfile->second == "milliseconds") + profiler.m_Timers.emplace_back("buffering", Support::Resolutions::ms); + + else if (itProfile->second == "s" || itProfile->second == "seconds") + profiler.m_Timers.emplace_back("buffering", Support::Resolutions::s); + + else if (itProfile->second == "min" || itProfile->second == "minutes") + profiler.m_Timers.emplace_back("buffering", Support::Resolutions::m); + + else if (itProfile->second == "h" || itProfile->second == "hours") + profiler.m_Timers.emplace_back("buffering", Support::Resolutions::h); + else + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: Method profile_buffering_units " + "argument must be mus, ms, s, min or h, in " + "call to Open or Engine constructor\n"); + } + + profiler.m_IsActive = true; + } +} + +void BPFileWriter::InitTransports() +{ + if (m_DebugMode == true) + { + if (TransportNamesUniqueness() == false) + { + throw std::invalid_argument( + "ERROR: two transports of the same kind (e.g file IO) " + "can't have the same name, modify with name= in Method " + "AddTransport\n"); + } + } + + for (const auto ¶meters : m_Method.m_TransportParameters) + { + auto itProfile = parameters.find("profile_units"); + bool doProfiling = false; + Support::Resolutions resolution = + Support::Resolutions::s; // default is seconds + if (itProfile != parameters.end()) + { + if (itProfile->second == "mus" || itProfile->second == "microseconds") + resolution = Support::Resolutions::mus; + + else if (itProfile->second == "ms" || itProfile->second == "milliseconds") + resolution = Support::Resolutions::ms; + + else if (itProfile->second == "s" || itProfile->second == "seconds") + resolution = Support::Resolutions::s; + + else if (itProfile->second == "min" || itProfile->second == "minutes") + resolution = Support::Resolutions::m; + + else if (itProfile->second == "h" || itProfile->second == "hours") + resolution = Support::Resolutions::h; + + else + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: Transport profile_units argument " + "must be mus, ms, s, min or h " + + m_EndMessage); + } + doProfiling = true; + } + + auto itTransport = parameters.find("transport"); + + if (itTransport->second == "file" || itTransport->second == "File") + { + auto itLibrary = parameters.find("library"); + if (itLibrary == parameters.end() || + itLibrary->second == "POSIX") // use default POSIX + { + auto file = + std::make_shared<transport::FileDescriptor>(m_MPIComm, m_DebugMode); + if (doProfiling == true) + file->InitProfiler(m_AccessMode, resolution); + + m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "FILE*" || itLibrary->second == "stdio") + { + auto file = + std::make_shared<transport::FilePointer>(m_MPIComm, m_DebugMode); + if (doProfiling == true) + file->InitProfiler(m_AccessMode, resolution); + + m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "fstream" || + itLibrary->second == "std::fstream") + { + auto file = + std::make_shared<transport::FStream>(m_MPIComm, m_DebugMode); + + if (doProfiling == true) + file->InitProfiler(m_AccessMode, resolution); + + m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); + m_Transports.push_back(std::move(file)); + } + else if (itLibrary->second == "MPI_File" || itLibrary->second == "MPI-IO") + { + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument( + "ERROR: file transport library " + itLibrary->second + + " not supported, in " + m_Name + m_EndMessage); + } + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: transport " + itTransport->second + + " (you mean File?) not supported, in " + + m_Name + m_EndMessage); + } + } +} + +void BPFileWriter::InitProcessGroup() +{ + if (m_MetadataSet.Log.m_IsActive == true) + m_MetadataSet.Log.m_Timers[0].SetInitialTime(); + + if (m_AccessMode == "a") + { + // Get last pg timestep and update timestep counter in + // format::BP1MetadataSet + } + + WriteProcessGroupIndex(); + + if (m_MetadataSet.Log.m_IsActive == true) + m_MetadataSet.Log.m_Timers[0].SetTime(); +} + +void BPFileWriter::WriteProcessGroupIndex() +{ + // pg = process group + // const std::size_t pgIndexSize = m_BP1Writer.GetProcessGroupIndexSize( + // std::to_string( m_RankMPI ), + // std::to_string( + // m_MetadataSet.TimeStep + // ), + // m_Transports.size() + // ); + // metadata + // GrowBuffer( pgIndexSize, m_GrowthFactor, m_MetadataSet.PGIndex ); + + // data? Need to be careful, maybe add some trailing tolerance in variable + // ???? + // GrowBuffer( pgIndexSize, m_GrowthFactor, m_Buffer.m_Data ); + + const bool isFortran = (m_HostLanguage == "Fortran") ? true : false; + + m_BP1Writer.WriteProcessGroupIndex(isFortran, std::to_string(m_RankMPI), + static_cast<std::uint32_t>(m_RankMPI), + m_Transports, m_Buffer, m_MetadataSet); +} + +} // end namespace adios diff --git a/source/engine/dataman/DataManReader.cpp b/source/engine/dataman/DataManReader.cpp new file mode 100644 index 000000000..103178eff --- /dev/null +++ b/source/engine/dataman/DataManReader.cpp @@ -0,0 +1,318 @@ +/* + * DataManReader.cpp + * + * Created on: Feb 21, 2017 + * Author: wfg + */ + +#include "engine/dataman/DataManReader.h" + +#include "core/Support.h" +#include "functions/adiosFunctions.h" //CSVToVector + +// supported transports +#include "transport/file/FStream.h" // uses C++ fstream +#include "transport/wan/MdtmMan.h" //uses Mdtm library + +#include "../../../include/transport/file/FileDescriptor.h" // uses POSIX +#include "../../../include/transport/file/FilePointer.h" // uses C FILE* +#include "DataMan.h" //here comes your DataMan header from external dataman library + +namespace adios +{ + +DataManReader::DataManReader(ADIOS &adios, const std::string name, + const std::string accessMode, MPI_Comm mpiComm, + const Method &method, const IOMode iomode, + const float timeout_sec, const bool debugMode, + const unsigned int nthreads) + : Engine(adios, "DataManReader", name, accessMode, mpiComm, method, + debugMode, nthreads, + " DataManReader constructor (or call to ADIOS Open).\n"), + m_Buffer(accessMode, m_RankMPI, m_DebugMode) +{ + Init(); +} + +DataManReader::~DataManReader() {} + +void DataManReader::SetCallBack( + std::function<void(const void *, std::string, std::string, std::string, + Dims)> + callback) +{ + m_CallBack = callback; + m_Man.reg_callback(callback); +} + +Variable<void> * +DataManReader::InquireVariable(const std::string name, + const bool readIn) // not yet implemented +{ + return nullptr; +} + +Variable<char> *DataManReader::InquireVariableChar(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<char>(name, readIn); +} + +Variable<unsigned char> * +DataManReader::InquireVariableUChar(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned char>(name, readIn); +} + +Variable<short> *DataManReader::InquireVariableShort(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<short>(name, readIn); +} + +Variable<unsigned short> * +DataManReader::InquireVariableUShort(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned short>(name, readIn); +} + +Variable<int> *DataManReader::InquireVariableInt(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<int>(name, readIn); +} + +Variable<unsigned int> * +DataManReader::InquireVariableUInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned int>(name, readIn); +} + +Variable<long int> *DataManReader::InquireVariableLInt(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<long int>(name, readIn); +} + +Variable<unsigned long int> * +DataManReader::InquireVariableULInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned long int>(name, readIn); +} + +Variable<long long int> * +DataManReader::InquireVariableLLInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<long long int>(name, readIn); +} + +Variable<unsigned long long int> * +DataManReader::InquireVariableULLInt(const std::string name, const bool readIn) +{ + return InquireVariableCommon<unsigned long long int>(name, readIn); +} + +Variable<float> *DataManReader::InquireVariableFloat(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<float>(name, readIn); +} + +Variable<double> *DataManReader::InquireVariableDouble(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<double>(name, readIn); +} + +Variable<long double> * +DataManReader::InquireVariableLDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<long double>(name, readIn); +} + +Variable<std::complex<float>> * +DataManReader::InquireVariableCFloat(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<float>>(name, readIn); +} + +Variable<std::complex<double>> * +DataManReader::InquireVariableCDouble(const std::string name, const bool readIn) +{ + return InquireVariableCommon<std::complex<double>>(name, readIn); +} + +Variable<std::complex<long double>> * +DataManReader::InquireVariableCLDouble(const std::string name, + const bool readIn) +{ + return InquireVariableCommon<std::complex<long double>>(name, readIn); +} + +VariableCompound *DataManReader::InquireVariableCompound(const std::string name, + const bool readIn) +{ + return nullptr; +} + +void DataManReader::Close(const int transportIndex) {} + +// PRIVATE +void DataManReader::Init() +{ + if (m_DebugMode == true) + { + if (m_AccessMode != "r" && m_AccessMode != "read") + throw std::invalid_argument( + "ERROR: DataManReader doesn't support access mode " + m_AccessMode + + ", in call to ADIOS Open or DataManReader constructor\n"); + } + + auto itRealTime = m_Method.m_Parameters.find("real_time"); + if (itRealTime != m_Method.m_Parameters.end()) + { + if (itRealTime->second == "yes" || itRealTime->second == "true") + m_DoRealTime = true; + } + + if (m_DoRealTime) + { + /** + * Lambda function that assigns a parameter in m_Method to a localVariable + * of type std::string + */ + auto lf_AssignString = [this](const std::string parameter, + std::string &localVariable) { + auto it = m_Method.m_Parameters.find(parameter); + if (it != m_Method.m_Parameters.end()) + { + localVariable = it->second; + } + }; + + /** + * Lambda function that assigns a parameter in m_Method to a localVariable + * of type int + */ + auto lf_AssignInt = [this](const std::string parameter, + int &localVariable) { + auto it = m_Method.m_Parameters.find(parameter); + if (it != m_Method.m_Parameters.end()) + { + localVariable = std::stoi(it->second); + } + }; + + auto is_number = [](const std::string &s) { + return !s.empty() && std::find_if(s.begin(), s.end(), [](char c) { + return !std::isdigit(c); + }) == s.end(); + }; + + json jmsg; + for (auto &i : m_Method.m_Parameters) + { + if (is_number(i.second)) + { + jmsg[i.first] = std::stoi(i.second); + } + else + { + jmsg[i.first] = i.second; + } + } + jmsg["stream_mode"] = "receiver"; + m_Man.add_stream(jmsg); + + std::string method_type; + int num_channels = 0; + lf_AssignString("method_type", method_type); + lf_AssignInt("num_channels", num_channels); + } + else + { + InitCapsules(); + InitTransports(); + } +} + +void DataManReader::InitCapsules() +{ + // here init memory capsules +} + +void DataManReader::InitTransports() // maybe move this? +{ + TransportNamesUniqueness(); + + for (const auto ¶meters : m_Method.m_TransportParameters) + { + auto itTransport = parameters.find("transport"); + + if (itTransport->second == "Mdtm" || itTransport->second == "MdtmMan") + { + const std::string localIP( + GetMdtmParameter("localIP", parameters)); // mandatory + const std::string remoteIP( + GetMdtmParameter("remoteIP", parameters)); // mandatory + const std::string prefix(GetMdtmParameter("prefix", parameters)); + const int numberOfPipes = + std::stoi(GetMdtmParameter("pipes", parameters)); + const std::vector<int> tolerances = + CSVToVectorInt(GetMdtmParameter("tolerances", parameters)); + const std::vector<int> priorities = + CSVToVectorInt(GetMdtmParameter("priorities", parameters)); + + m_Transports.push_back(std::make_shared<transport::MdtmMan>( + localIP, remoteIP, m_AccessMode, prefix, numberOfPipes, tolerances, + priorities, m_MPIComm, m_DebugMode)); + } + else if (itTransport->second == "Zmq") + { + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument( + "ERROR: transport + " + itTransport->second + + " not supported, in " + m_Name + m_EndMessage); + } + } +} + +std::string DataManReader::GetMdtmParameter( + const std::string parameter, + const std::map<std::string, std::string> &mdtmParameters) +{ + auto itParam = mdtmParameters.find(parameter); + if (itParam != mdtmParameters.end()) // found + { + return itParam->second; // return value + } + // if not found + // mandatory ones + if (parameter == "localIP" || parameter == "remoteIP") + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: " + parameter + + " parameter not found in Method, in call to " + "DataManWriter constructor\n"); + } + else if (parameter == "prefix") + { + return ""; + } + else if (parameter == "pipes") + { + return "0"; // or 1? + } + else if (parameter == "tolerances") // so far empty string + { + } + else if (parameter == "priority") + { + } + + return ""; // return empty string +} +} diff --git a/source/engine/dataman/DataManWriter.cpp b/source/engine/dataman/DataManWriter.cpp new file mode 100644 index 000000000..8cd653c96 --- /dev/null +++ b/source/engine/dataman/DataManWriter.cpp @@ -0,0 +1,408 @@ +/* + * DataMan.cpp + * + * Created on: Jan 10, 2017 + * Author: wfg + */ + +#include <iostream> //needs to go away, this is just for demo purposes + +#include "engine/dataman/DataManWriter.h" + +#include "core/Support.h" +#include "functions/adiosFunctions.h" //CSVToVector + +// supported transports +#include "transport/file/FStream.h" // uses C++ fstream +#include "transport/wan/MdtmMan.h" //uses Mdtm library + +namespace adios +{ + +DataManWriter::DataManWriter(ADIOS &adios, const std::string name, + const std::string accessMode, MPI_Comm mpiComm, + const Method &method, const IOMode iomode, + const float timeout_sec, const bool debugMode, + const unsigned int nthreads) + : Engine(adios, "DataManWriter", name, accessMode, mpiComm, method, + debugMode, nthreads, + " DataManWriter constructor (or call to ADIOS Open).\n"), + m_Buffer(accessMode, m_RankMPI, m_DebugMode) +{ + Init(); +} + +DataManWriter::~DataManWriter() {} + +void DataManWriter::SetCallBack( + std::function<void(const void *, std::string, std::string, std::string, + Dims)> + callback) +{ + m_CallBack = callback; + m_Man.reg_callback(callback); +} + +void DataManWriter::Write(Variable<char> &variable, const char *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<unsigned char> &variable, + const unsigned char *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<short> &variable, const short *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<unsigned short> &variable, + const unsigned short *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<int> &variable, const int *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<unsigned int> &variable, + const unsigned int *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<long int> &variable, const long int *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<unsigned long int> &variable, + const unsigned long int *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<long long int> &variable, + const long long int *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<unsigned long long int> &variable, + const unsigned long long int *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<float> &variable, const float *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<double> &variable, const double *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<long double> &variable, + const long double *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<std::complex<float>> &variable, + const std::complex<float> *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<std::complex<double>> &variable, + const std::complex<double> *values) +{ + WriteVariableCommon(variable, values); +} + +void DataManWriter::Write(Variable<std::complex<long double>> &variable, + const std::complex<long double> *values) +{ + WriteVariableCommon(variable, values); +} + +// String version +void DataManWriter::Write(const std::string variableName, const char *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<char>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const unsigned char *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned char>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, const short *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<short>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const unsigned short *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned short>(variableName), + values); +} + +void DataManWriter::Write(const std::string variableName, const int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<int>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const unsigned int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned int>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<long int>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const unsigned long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned long int>(variableName), + values); +} + +void DataManWriter::Write(const std::string variableName, + const long long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<long long int>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const unsigned long long int *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<unsigned long long int>(variableName), + values); +} + +void DataManWriter::Write(const std::string variableName, const float *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<float>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, const double *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<double>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const long double *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<long double>(variableName), values); +} + +void DataManWriter::Write(const std::string variableName, + const std::complex<float> *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<std::complex<float>>(variableName), + values); +} + +void DataManWriter::Write(const std::string variableName, + const std::complex<double> *values) +{ + WriteVariableCommon(m_ADIOS.GetVariable<std::complex<double>>(variableName), + values); +} + +void DataManWriter::Write(const std::string variableName, + const std::complex<long double> *values) +{ + WriteVariableCommon( + m_ADIOS.GetVariable<std::complex<long double>>(variableName), values); +} + +void DataManWriter::Close(const int transportIndex) +{ + m_Man.flush(); + // here close IPs and deallocate or free/close resources (if using STL no need + // for memory deallocation) +} + +// PRIVATE functions below +void DataManWriter::Init() +{ + if (m_DebugMode == true) + { + if (m_AccessMode != "w" && m_AccessMode != "write" && m_AccessMode != "a" && + m_AccessMode != "append") + throw std::invalid_argument( + "ERROR: DataManWriter doesn't support access mode " + m_AccessMode + + ", in call to ADIOS Open or DataManWriter constructor\n"); + } + + auto itRealTime = m_Method.m_Parameters.find("real_time"); + if (itRealTime != m_Method.m_Parameters.end()) + { + if (itRealTime->second == "yes" || itRealTime->second == "true") + m_DoRealTime = true; + } + + itRealTime = m_Method.m_Parameters.find("monitoring"); + if (itRealTime != m_Method.m_Parameters.end()) + { + if (itRealTime->second == "yes" || itRealTime->second == "true") + m_DoMonitor = true; + } + + if (m_DoRealTime) + { + /** + * Lambda function that assigns a parameter in m_Method to a localVariable + * of type std::string + */ + auto lf_AssignString = [this](const std::string parameter, + std::string &localVariable) { + auto it = m_Method.m_Parameters.find(parameter); + if (it != m_Method.m_Parameters.end()) + { + localVariable = it->second; + } + }; + + /** + * Lambda function that assigns a parameter in m_Method to a localVariable + * of type int + */ + auto lf_AssignInt = [this](const std::string parameter, + int &localVariable) { + auto it = m_Method.m_Parameters.find(parameter); + if (it != m_Method.m_Parameters.end()) + { + localVariable = std::stoi(it->second); + } + }; + + auto is_number = [](const std::string &s) { + return !s.empty() && std::find_if(s.begin(), s.end(), [](char c) { + return !std::isdigit(c); + }) == s.end(); + }; + + json jmsg; + for (auto &i : m_Method.m_Parameters) + { + if (is_number(i.second)) + { + jmsg[i.first] = std::stoi(i.second); + } + else + { + jmsg[i.first] = i.second; + } + } + jmsg["stream_mode"] = "sender"; + m_Man.add_stream(jmsg); + + std::string method_type; + int num_channels = 0; + lf_AssignString("method_type", method_type); + lf_AssignInt("num_channels", num_channels); + } + else + { + InitCapsules(); + InitTransports(); + } +} + +void DataManWriter::InitCapsules() +{ + // here init memory capsules +} + +void DataManWriter::InitTransports() // maybe move this? +{ + TransportNamesUniqueness(); + + for (const auto ¶meters : m_Method.m_TransportParameters) + { + auto itTransport = parameters.find("transport"); + + if (itTransport->second == "Mdtm" || itTransport->second == "MdtmMan") + { + const std::string localIP( + GetMdtmParameter("localIP", parameters)); // mandatory + const std::string remoteIP( + GetMdtmParameter("remoteIP", parameters)); // mandatory + const std::string prefix(GetMdtmParameter("prefix", parameters)); + const int numberOfPipes = + std::stoi(GetMdtmParameter("pipes", parameters)); + const std::vector<int> tolerances = + CSVToVectorInt(GetMdtmParameter("tolerances", parameters)); + const std::vector<int> priorities = + CSVToVectorInt(GetMdtmParameter("priorities", parameters)); + + m_Transports.push_back(std::make_shared<transport::MdtmMan>( + localIP, remoteIP, m_AccessMode, prefix, numberOfPipes, tolerances, + priorities, m_MPIComm, m_DebugMode)); + } + else if (itTransport->second == "Zmq") + { + } + else + { + if (m_DebugMode == true) + throw std::invalid_argument( + "ERROR: transport + " + itTransport->second + + " not supported, in " + m_Name + m_EndMessage); + } + } +} + +std::string DataManWriter::GetMdtmParameter( + const std::string parameter, + const std::map<std::string, std::string> &mdtmParameters) +{ + auto itParam = mdtmParameters.find(parameter); + if (itParam != mdtmParameters.end()) // found + { + return itParam->second; // return value + } + // if not found + // mandatory ones + if (parameter == "localIP" || parameter == "remoteIP") + { + if (m_DebugMode == true) + throw std::invalid_argument("ERROR: " + parameter + + " parameter not found in Method, in call to " + "DataManWriter constructor\n"); + } + else if (parameter == "prefix") + { + return ""; + } + else if (parameter == "pipes") + { + return "0"; // or 1? + } + else if (parameter == "tolerances") // so far empty string + { + } + else if (parameter == "priority") + { + } + + return ""; // return empty string +} + +} // end namespace adios diff --git a/source/format/BP1.cpp b/source/format/BP1.cpp new file mode 100644 index 000000000..8272e1d76 --- /dev/null +++ b/source/format/BP1.cpp @@ -0,0 +1,71 @@ +/* + * BP1.cpp + * + * Created on: Feb 7, 2017 + * Author: wfg + */ + +#include "format/BP1.h" +#include "functions/adiosFunctions.h" + +namespace adios +{ +namespace format +{ + +std::string BP1::GetDirectoryName(const std::string name) const noexcept +{ + std::string directory; + + if (name.find(".bp") == name.size() - 3) + directory = name; + else + directory = name + ".bp"; + + return directory; +} + +void BP1::OpenRankFiles(const std::string name, const std::string accessMode, + Transport &file) const +{ + const std::string directory = GetDirectoryName(name); + CreateDirectory( + directory); // creates a directory and sub-directories recursively + + std::string fileName(directory + "/" + directory + "." + + std::to_string(file.m_RankMPI)); + file.Open(fileName, accessMode); // opens a file transport under + // name.bp.dir/name.bp.rank reserve that + // location fro writing +} + +std::vector<std::uint8_t> BP1::GetMethodIDs( + const std::vector<std::shared_ptr<Transport>> &transports) const noexcept +{ + auto lf_GetMethodID = [](const std::string method) -> std::uint8_t { + int id = METHOD_UNKNOWN; + if (method == "NULL") + id = METHOD_NULL; + else if (method == "POSIX") + id = METHOD_POSIX; + else if (method == "FStream") + id = METHOD_FSTREAM; + else if (method == "File") + id = METHOD_FILE; + else if (method == "MPI") + id = METHOD_MPI; + + return id; + }; + + std::vector<std::uint8_t> methodIDs; + methodIDs.reserve(transports.size()); + + for (const auto &transport : transports) + methodIDs.push_back(lf_GetMethodID(transport->m_Type)); + + return methodIDs; +} + +} // end namespace format +} // end namespace adios diff --git a/source/format/BP1Aggregator.cpp b/source/format/BP1Aggregator.cpp new file mode 100644 index 000000000..c105d5ede --- /dev/null +++ b/source/format/BP1Aggregator.cpp @@ -0,0 +1,95 @@ +/* + * BP1Aggregator.cpp + * + * Created on: Mar 21, 2017 + * Author: wfg + */ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <fstream> +#include <vector> +/// \endcond + +#include "format/BP1Aggregator.h" + +namespace adios +{ +namespace format +{ + +BP1Aggregator::BP1Aggregator(MPI_Comm mpiComm, const bool debugMode) + : m_MPIComm{mpiComm}, m_DebugMode{debugMode} +{ + MPI_Comm_rank(m_MPIComm, &m_RankMPI); + MPI_Comm_size(m_MPIComm, &m_SizeMPI); +} + +BP1Aggregator::~BP1Aggregator() {} + +void BP1Aggregator::WriteProfilingLog(const std::string fileName, + const std::string &rankLog) +{ + if (m_RankMPI == 0) + { + unsigned int sizeMPI = static_cast<unsigned int>(m_SizeMPI); + std::vector<std::vector<char>> rankLogs(sizeMPI - + 1); // rankLogs from other processes + std::vector<int> rankLogsSizes(sizeMPI - 1, -1); // init with -1 + std::vector<MPI_Request> requests(sizeMPI); + std::vector<MPI_Status> statuses(sizeMPI); + + // first receive sizes + for (unsigned int i = 1; i < sizeMPI; ++i) + MPI_Irecv(&rankLogsSizes[i - 1], 1, MPI_INT, i, 0, m_MPIComm, + &requests[i]); + + for (unsigned int i = 1; i < sizeMPI; ++i) + { + MPI_Wait(&requests[i], &statuses[i]); + if (m_DebugMode == true) + { + if (rankLogsSizes[i - 1] == -1) + throw std::runtime_error("ERROR: couldn't get size from rank " + + std::to_string(i) + + ", in ADIOS aggregator for Profiling.log\n"); + } + rankLogs[i - 1].resize(rankLogsSizes[i - 1]); // allocate with zeros + } + + // receive rankLog from other ranks + for (unsigned int i = 1; i < sizeMPI; ++i) + MPI_Irecv(rankLogs[i - 1].data(), rankLogsSizes[i - 1], MPI_CHAR, i, 1, + m_MPIComm, &requests[i]); + + for (unsigned int i = 1; i < sizeMPI; ++i) + MPI_Wait(&requests[i], &statuses[i]); + + // write file + std::string logFile("log = { \n"); + logFile += rankLog + "\n"; + for (unsigned int i = 1; i < sizeMPI; ++i) + { + const std::string rankLogStr(rankLogs[i - 1].data(), + rankLogs[i - 1].size()); + logFile += rankLogStr + "\n"; + } + logFile += " }\n"; + + std::ofstream logStream(fileName); + logStream.write(logFile.c_str(), logFile.size()); + logStream.close(); + } + else + { + int rankLogSize = static_cast<int>(rankLog.size()); + MPI_Request requestSize; + MPI_Isend(&rankLogSize, 1, MPI_INT, 0, 0, m_MPIComm, &requestSize); + + MPI_Request requestRankLog; + MPI_Isend(const_cast<char *>(rankLog.c_str()), rankLogSize, MPI_CHAR, 0, 1, + m_MPIComm, &requestRankLog); + } +} + +} // end namespace format +} // end namespace adios diff --git a/source/format/BP1Writer.cpp b/source/format/BP1Writer.cpp new file mode 100644 index 000000000..20dbace5f --- /dev/null +++ b/source/format/BP1Writer.cpp @@ -0,0 +1,394 @@ +/* + * BP1Writer.cpp + * + * Created on: Feb 1, 2017 + * Author: wfg + */ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <string> +/// \endcond + +#include "core/Profiler.h" +#include "format/BP1Writer.h" + +namespace adios +{ +namespace format +{ + +std::size_t BP1Writer::GetProcessGroupIndexSize( + const std::string name, const std::string timeStepName, + const std::size_t numberOfTransports) const noexcept +{ + // pgIndex + list of methods (transports) + return (name.length() + timeStepName.length() + 23) + + (3 + numberOfTransports); // should be sufficient for data and metadata + // pgindices +} + +void BP1Writer::WriteProcessGroupIndex( + const bool isFortran, const std::string name, const std::uint32_t processID, + const std::vector<std::shared_ptr<Transport>> &transports, + capsule::STLVector &heap, BP1MetadataSet &metadataSet) const noexcept +{ + std::vector<char> &metadataBuffer = metadataSet.PGIndex.Buffer; + std::vector<char> &dataBuffer = heap.m_Data; + + metadataSet.DataPGLengthPosition = dataBuffer.size(); + dataBuffer.insert(dataBuffer.end(), 8, 0); // skip pg length (8) + + const std::size_t metadataPGLengthPosition = metadataBuffer.size(); + metadataBuffer.insert(metadataBuffer.end(), 2, 0); // skip pg length (2) + + // write name to metadata + WriteNameRecord(name, metadataBuffer); + // write if host language Fortran in metadata and data + const char hostFortran = + (isFortran) ? 'y' : 'n'; // if host language is fortran + CopyToBuffer(metadataBuffer, &hostFortran); + CopyToBuffer(dataBuffer, &hostFortran); + // write name in data + WriteNameRecord(name, dataBuffer); + + // processID in metadata, + CopyToBuffer(metadataBuffer, &processID); + // skip coordination var in data ....what is coordination var? + dataBuffer.insert(dataBuffer.end(), 4, 0); + + // time step name to metadata and data + const std::string timeStepName(std::to_string(metadataSet.TimeStep)); + WriteNameRecord(timeStepName, metadataBuffer); + WriteNameRecord(timeStepName, dataBuffer); + + // time step to metadata and data + CopyToBuffer(metadataBuffer, &metadataSet.TimeStep); + CopyToBuffer(dataBuffer, &metadataSet.TimeStep); + + // offset to pg in data in metadata which is the current absolute position + CopyToBuffer(metadataBuffer, + reinterpret_cast<std::uint64_t *>(&heap.m_DataAbsolutePosition)); + + // Back to writing metadata pg index length (length of group) + const std::uint16_t metadataPGIndexLength = + metadataBuffer.size() - metadataPGLengthPosition - + 2; // without length of group record + CopyToBuffer(metadataBuffer, metadataPGLengthPosition, + &metadataPGIndexLength); + // DONE With metadataBuffer + + // here write method in data + const std::vector<std::uint8_t> methodIDs = GetMethodIDs(transports); + const std::uint8_t methodsCount = methodIDs.size(); + CopyToBuffer(dataBuffer, &methodsCount); // count + const std::uint16_t methodsLength = + methodIDs.size() * + 3; // methodID (1) + method params length(2), no parameters for now + CopyToBuffer(dataBuffer, &methodsLength); // length + + for (const auto methodID : methodIDs) + { + CopyToBuffer(dataBuffer, &methodID); // method ID, + dataBuffer.insert(dataBuffer.end(), 2, + 0); // skip method params length = 0 (2 bytes) for now + } + + // update absolute position + heap.m_DataAbsolutePosition += + dataBuffer.size() - metadataSet.DataPGLengthPosition; + // pg vars count and position + metadataSet.DataPGVarsCount = 0; + metadataSet.DataPGVarsCountPosition = dataBuffer.size(); + // add vars count and length + dataBuffer.insert(dataBuffer.end(), 12, 0); + heap.m_DataAbsolutePosition += 12; // add vars count and length + + ++metadataSet.DataPGCount; + metadataSet.DataPGIsOpen = true; +} + +void BP1Writer::Advance(BP1MetadataSet &metadataSet, capsule::STLVector &buffer) +{ + FlattenData(metadataSet, buffer); +} + +void BP1Writer::Close(BP1MetadataSet &metadataSet, capsule::STLVector &heap, + Transport &transport, bool &isFirstClose, + const bool doAggregation) const noexcept +{ + if (metadataSet.Log.m_IsActive == true) + metadataSet.Log.m_Timers[0].SetInitialTime(); + + if (isFirstClose == true) + { + if (metadataSet.DataPGIsOpen == true) + FlattenData(metadataSet, heap); + + FlattenMetadata(metadataSet, heap); + + if (metadataSet.Log.m_IsActive == true) + metadataSet.Log.m_Timers[0].SetInitialTime(); + + if (doAggregation == true) // N-to-M where 1 <= M <= N-1, might need a new + // Log metadataSet.Log.m_Timers just for + // aggregation + { + // here call aggregator + } + isFirstClose = false; + } + + if (doAggregation == true) // N-to-M where 1 <= M <= N-1 + { + // here call aggregator to select transports for Write and Close + } + else // N-to-N + { + transport.Write(heap.m_Data.data(), heap.m_Data.size()); // single write + transport.Close(); + } +} + +std::string BP1Writer::GetRankProfilingLog( + const int rank, const BP1MetadataSet &metadataSet, + const std::vector<std::shared_ptr<Transport>> &transports) const noexcept +{ + auto lf_WriterTimer = [](std::string &rankLog, const Timer &timer) { + rankLog += "'" + timer.Process + "_" + timer.GetUnits() + "': " + + std::to_string(timer.ProcessTime) + ", "; + }; + + // prepare string dictionary per rank + std::string rankLog("'rank_" + std::to_string(rank) + "': { "); + + auto &profiler = metadataSet.Log; + rankLog += "'bytes': " + std::to_string(profiler.m_TotalBytes[0]) + ", "; + lf_WriterTimer(rankLog, profiler.m_Timers[0]); + + for (unsigned int t = 0; t < transports.size(); ++t) + { + auto &timers = transports[t]->m_Profiler.m_Timers; + + rankLog += "'transport_" + std::to_string(t) + "': { "; + rankLog += "'lib': " + transports[t]->m_Type + ", "; + + for (unsigned int i = 0; i < 3; ++i) + lf_WriterTimer(rankLog, timers[i]); + + rankLog += "}, "; + } + rankLog += "}, "; + + return rankLog; +} + +// PRIVATE FUNCTIONS +void BP1Writer::WriteDimensionsRecord( + std::vector<char> &buffer, const std::vector<std::size_t> &localDimensions, + const std::vector<std::size_t> &globalDimensions, + const std::vector<std::size_t> &globalOffsets, const unsigned int skip, + const bool addType) const noexcept +{ + auto lf_WriteFlaggedDim = [](std::vector<char> &buffer, const char no, + const std::size_t dimension) { + CopyToBuffer(buffer, &no); + CopyToBuffer(buffer, reinterpret_cast<const std::uint64_t *>(&dimension)); + }; + + // BODY Starts here + if (globalDimensions.empty()) + { + if (addType == true) + { + constexpr char no = 'n'; // dimension format unsigned int value (not using + // memberID for now) + for (const auto &localDimension : localDimensions) + { + lf_WriteFlaggedDim(buffer, no, localDimension); + buffer.insert(buffer.end(), skip, 0); + } + } + else + { + for (const auto &localDimension : localDimensions) + { + CopyToBuffer(buffer, + reinterpret_cast<const std::uint64_t *>(&localDimension)); + buffer.insert(buffer.end(), skip, 0); + } + } + } + else + { + if (addType == true) + { + constexpr char no = 'n'; // dimension format unsigned int value for now + for (unsigned int d = 0; d < localDimensions.size(); ++d) + { + lf_WriteFlaggedDim(buffer, no, localDimensions[d]); + lf_WriteFlaggedDim(buffer, no, globalDimensions[d]); + lf_WriteFlaggedDim(buffer, no, globalOffsets[d]); + } + } + else + { + for (unsigned int d = 0; d < localDimensions.size(); ++d) + { + CopyToBuffer(buffer, reinterpret_cast<const std::uint64_t *>( + &localDimensions[d])); + CopyToBuffer(buffer, reinterpret_cast<const std::uint64_t *>( + &globalDimensions[d])); + CopyToBuffer( + buffer, reinterpret_cast<const std::uint64_t *>(&globalOffsets[d])); + } + } + } +} + +void BP1Writer::WriteNameRecord(const std::string name, + std::vector<char> &buffer) const noexcept +{ + const std::uint16_t length = name.length(); + CopyToBuffer(buffer, &length); + CopyToBuffer(buffer, name.c_str(), length); +} + +BP1Index & +BP1Writer::GetBP1Index(const std::string name, + std::unordered_map<std::string, BP1Index> &indices, + bool &isNew) const noexcept +{ + auto itName = indices.find(name); + if (itName == indices.end()) + { + indices.emplace(name, BP1Index(indices.size())); + isNew = true; + return indices.at(name); + } + + isNew = false; + return itName->second; +} + +void BP1Writer::FlattenData(BP1MetadataSet &metadataSet, + capsule::STLVector &heap) const noexcept +{ + auto &buffer = heap.m_Data; + // vars count and Length (only for PG) + CopyToBuffer(buffer, metadataSet.DataPGVarsCountPosition, + &metadataSet.DataPGVarsCount); + const std::uint64_t varsLength = buffer.size() - + metadataSet.DataPGVarsCountPosition - 8 - + 4; // without record itself and vars count + CopyToBuffer(buffer, metadataSet.DataPGVarsCountPosition + 4, &varsLength); + + // attributes (empty for now) count (4) and length (8) are zero by moving + // positions in time step zero + buffer.insert(buffer.end(), 12, 0); + heap.m_DataAbsolutePosition += 12; + + // Finish writing pg group length + const std::uint64_t dataPGLength = + buffer.size() - metadataSet.DataPGLengthPosition - + 8; // without record itself, 12 due to empty attributes + CopyToBuffer(buffer, metadataSet.DataPGLengthPosition, &dataPGLength); + + ++metadataSet.TimeStep; + metadataSet.DataPGIsOpen = false; +} + +void BP1Writer::FlattenMetadata(BP1MetadataSet &metadataSet, + capsule::STLVector &heap) const noexcept +{ + auto lf_IndexCountLength = + [](std::unordered_map<std::string, BP1Index> &indices, + std::uint32_t &count, std::uint64_t &length) { + count = indices.size(); + length = 0; + for (auto &indexPair : indices) // set each index length + { + auto &indexBuffer = indexPair.second.Buffer; + const std::uint32_t indexLength = indexBuffer.size() - 4; + CopyToBuffer(indexBuffer, 0, &indexLength); + + length += indexBuffer.size(); // overall length + } + }; + + auto lf_FlattenIndices = + [](const std::uint32_t count, const std::uint64_t length, + const std::unordered_map<std::string, BP1Index> &indices, + std::vector<char> &buffer) { + CopyToBuffer(buffer, &count); + CopyToBuffer(buffer, &length); + + for (const auto &indexPair : indices) // set each index length + { + const auto &indexBuffer = indexPair.second.Buffer; + CopyToBuffer(buffer, indexBuffer.data(), indexBuffer.size()); + } + }; + + // Finish writing metadata counts and lengths + // PG Index + const std::uint64_t pgCount = metadataSet.DataPGCount; + const std::uint64_t pgLength = metadataSet.PGIndex.Buffer.size(); + + // var index count and length (total), and each index length + std::uint32_t varsCount; + std::uint64_t varsLength; + lf_IndexCountLength(metadataSet.VarsIndices, varsCount, varsLength); + // attribute index count and length, and each index length + std::uint32_t attributesCount; + std::uint64_t attributesLength; + lf_IndexCountLength(metadataSet.AttributesIndices, attributesCount, + attributesLength); + + const std::size_t footerSize = (pgLength + 16) + (varsLength + 12) + + (attributesLength + 12) + + metadataSet.MiniFooterSize; + auto &buffer = heap.m_Data; + buffer.reserve(buffer.size() + footerSize); // reserve data to fit metadata, + // must replace with growth buffer + // strategy + + // write pg index + CopyToBuffer(buffer, &pgCount); + CopyToBuffer(buffer, &pgLength); + CopyToBuffer(buffer, metadataSet.PGIndex.Buffer.data(), pgLength); + // Vars indices + lf_FlattenIndices(varsCount, varsLength, metadataSet.VarsIndices, buffer); + // Attribute indices + lf_FlattenIndices(attributesCount, attributesLength, + metadataSet.AttributesIndices, buffer); + + // getting absolute offsets, minifooter is 28 bytes for now + const std::uint64_t offsetPGIndex = heap.m_DataAbsolutePosition; + const std::uint64_t offsetVarsIndex = offsetPGIndex + (pgLength + 16); + const std::uint64_t offsetAttributeIndex = + offsetVarsIndex + (varsLength + 12); + + CopyToBuffer(buffer, &offsetPGIndex); + CopyToBuffer(buffer, &offsetVarsIndex); + CopyToBuffer(buffer, &offsetAttributeIndex); + + // version + if (IsLittleEndian()) + { + const std::uint8_t endian = 0; + CopyToBuffer(buffer, &endian); + buffer.insert(buffer.end(), 2, 0); + CopyToBuffer(buffer, &m_Version); + } + else + { + } + + heap.m_DataAbsolutePosition += footerSize; + + if (metadataSet.Log.m_IsActive == true) + metadataSet.Log.m_TotalBytes.push_back(heap.m_DataAbsolutePosition); +} + +} // end namespace format +} // end namespace adios diff --git a/source/functions/adiosFunctions.cpp b/source/functions/adiosFunctions.cpp new file mode 100644 index 000000000..22c362467 --- /dev/null +++ b/source/functions/adiosFunctions.cpp @@ -0,0 +1,643 @@ +/* + * adiosFunctions.cpp + * + * Created on: Oct 10, 2016 + * Author: wfg + */ + +/// \cond EXCLUDED_FROM_DOXYGEN +#include <algorithm> //std::count +#include <cmath> // std::ceil, std::pow, std::log +#include <cstring> //std::memcpy +#include <fstream> +#include <ios> //std::ios_base::failure +#include <sstream> +#include <stdexcept> +#include <thread> //std::thread + +#include <sys/stat.h> //stat +#include <sys/types.h> //CreateDirectory +#include <unistd.h> //CreateDirectory +/// \endcond + +#include "core/Support.h" +#include "functions/adiosFunctions.h" + +#ifdef HAVE_BZIP2 +#include "transform/BZIP2.h" +#endif + +namespace adios +{ + +void DumpFileToString(const std::string fileName, std::string &fileContent) +{ + std::ifstream fileStream(fileName); + + if (fileStream.good() == false) // check file + throw std::ios_base::failure( + "ERROR: file " + fileName + + " could not be opened. Check permissions or file existence\n"); + + std::ostringstream fileSS; + fileSS << fileStream.rdbuf(); + fileStream.close(); + fileContent = fileSS.str(); // convert to string and check + + if (fileContent.empty()) + throw std::invalid_argument("ERROR: file " + fileName + " is empty\n"); +} + +void GetSubString(const std::string initialTag, const std::string finalTag, + const std::string content, std::string &subString, + std::string::size_type ¤tPosition) +{ + auto lf_Wipe = [](std::string &subString, + std::string::size_type ¤tPosition) { + subString.clear(); + currentPosition = std::string::npos; + }; + + auto lf_SetPositions = + [](const char quote, const std::string::size_type quotePosition, + const std::string &content, std::string::size_type ¤tPosition, + std::string::size_type &closingQuotePosition) { + currentPosition = quotePosition; + closingQuotePosition = content.find(quote, currentPosition + 1); + }; + + // BODY OF FUNCTION STARTS HERE + std::string::size_type start(content.find(initialTag, currentPosition)); + if (start == content.npos) + { + lf_Wipe(subString, currentPosition); + return; + } + currentPosition = start; + + std::string::size_type end(content.find(finalTag, currentPosition)); + if (end == content.npos) + { + lf_Wipe(subString, currentPosition); + return; + } + + // here make sure the finalTag is not a value surrounded by " " or ' ', if so + // find next + bool isValue = true; + + while (isValue == true) + { + std::string::size_type singleQuotePosition = + content.find('\'', currentPosition); + std::string::size_type doubleQuotePosition = + content.find('\"', currentPosition); + + if ((singleQuotePosition == content.npos && + doubleQuotePosition == content.npos) || + (singleQuotePosition == content.npos && end < doubleQuotePosition) || + (doubleQuotePosition == content.npos && end < singleQuotePosition) || + (end < singleQuotePosition && end < doubleQuotePosition)) + break; + + // find the closing corresponding quote + std::string::size_type closingQuotePosition; + + if (singleQuotePosition == content.npos) // no ' anywhere + lf_SetPositions('\"', doubleQuotePosition, content, currentPosition, + closingQuotePosition); + else if (doubleQuotePosition == content.npos) // no " anywhere + lf_SetPositions('\'', singleQuotePosition, content, currentPosition, + closingQuotePosition); + else + { + if (singleQuotePosition < doubleQuotePosition) + lf_SetPositions('\'', singleQuotePosition, content, currentPosition, + closingQuotePosition); + else // find the closing " + lf_SetPositions('\"', doubleQuotePosition, content, currentPosition, + closingQuotePosition); + } + + if (closingQuotePosition == + content.npos) // if can't find closing it's open until the end + { + lf_Wipe(subString, currentPosition); + return; + } + + currentPosition = closingQuotePosition + 1; + + if (closingQuotePosition < end) + continue; + + // if this point is reached it means it's a value inside " " or ' ', move to + // the next end + end = content.find(finalTag, currentPosition); + } + + subString = content.substr(start, end - start + finalTag.size()); + currentPosition = end; +} + +void GetQuotedValue(const char quote, + const std::string::size_type "ePosition, + std::string ¤tTag, std::string &value) +{ + currentTag = currentTag.substr(quotePosition + 1); + auto nextQuotePosition = currentTag.find(quote); + + if (nextQuotePosition == currentTag.npos) + throw std::invalid_argument("ERROR: Invalid attribute in..." + currentTag + + "...check XML file\n"); + + value = currentTag.substr(0, nextQuotePosition); + currentTag = currentTag.substr(nextQuotePosition + 1); +} + +void GetPairs(const std::string tag, + std::vector<std::pair<const std::string, const std::string>> + &pairs) noexcept +{ + std::string currentTag( + tag.substr(tag.find_first_of(" \t\n"))); // initialize current tag + + while (currentTag.find('=') != currentTag.npos) // equalPosition + { + currentTag = currentTag.substr(currentTag.find_first_not_of(" \t\n")); + auto equalPosition = currentTag.find('='); + const std::string field(currentTag.substr(0, equalPosition)); // get field + std::string value; + + const char quote = currentTag[equalPosition + 1]; + if (quote == '\'' || quote == '"') // single quotes + { + GetQuotedValue(quote, equalPosition + 1, currentTag, value); + } + + pairs.push_back( + std::pair<const std::string, const std::string>(field, value)); + } +} + +void GetPairsFromTag( + const std::string &fileContent, const std::string tag, + std::vector<std::pair<const std::string, const std::string>> &pairs) +{ + if (tag.back() == '/') // last char is / --> "XML empty tag" + { + GetPairs(tag, pairs); + } + else if (tag[0] == '/') // first char is / ---> closing tag + { + } + else // opening tag + { + const std::string tagName(tag.substr(0, tag.find_first_of(" \t\n\r"))); + const std::string closingTagName("</" + tagName + + ">"); // check for closing tagName + + if (fileContent.find(closingTagName) == fileContent.npos) + throw std::invalid_argument("ERROR: closing tag " + closingTagName + + " missing, check XML file\n"); + + GetPairs(tag, pairs); + } +} + +// void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, +// const bool debugMode, +// std::string& hostLanguage, std::vector< +// std::shared_ptr<Transform> >& transforms, +// std::map< std::string, Group >& groups ) +//{ +// //adios-config +// std::string currentContent; +// std::string::size_type currentPosition( 0 ); +// GetSubString( "<adios-config ", "</adios-config>", fileContent, +// currentContent, currentPosition ); +// +// //remove comment sections +// std::string::size_type startComment ( currentContent.find( "<!--" ) ); +// +// while( startComment != currentContent.npos ) +// { +// std::string::size_type endComment( currentContent.find( "-->") ); +// currentContent.erase( startComment, endComment-startComment+3 ); +// startComment = currentContent.find( "<!--" ); +// } +// +// //Tag <adios-config +// currentPosition = 0; +// +// std::string tag; //use for < > tags +// GetSubString( "<adios-config", ">", currentContent, tag, currentPosition +// ); +// tag = tag.substr( 1, tag.size() - 2 ); //eliminate < > +// +// std::vector< std::pair<const std::string, const std::string> > pairs; // +// pairs in tag +// GetPairsFromTag( currentContent, tag, pairs ); +// +// for( auto& pair : pairs ) +// if( pair.first == "host-language" ) +// hostLanguage = pair.second; +// +// if( debugMode == true ) +// { +// if( Support::HostLanguages.count( hostLanguage ) == 0 ) +// throw std::invalid_argument("ERROR: host language " + hostLanguage +// + " not supported.\n" ); +// +// if( hostLanguage.empty() == true ) +// throw std::invalid_argument("ERROR: host language is empty.\n" ); +// } +// +// //adios-group +// currentPosition = 0; +// +// while( currentPosition != std::string::npos ) +// { +// std::string xmlGroup; +// GetSubString("<adios-group ", "</adios-group>", currentContent, +// xmlGroup, currentPosition ); //Get all group contents +// +// if( xmlGroup.empty() ) //no more groups to find +// break; +// +// //get group name +// std::string::size_type groupPosition( 0 ); +// GetSubString( "<adios-group ", ">", xmlGroup, tag, groupPosition ); +// if( debugMode == true ) +// { +// if( tag.size() < 2 ) +// throw std::invalid_argument( "ERROR: wrong tag " + tag + " in +// adios-group\n" ); //check < or <= +// } +// +// tag = tag.substr( 1, tag.size() - 2 ); //eliminate < > +// GetPairsFromTag( xmlGroup, tag, pairs ); +// std::string groupName; +// +// for( auto& pair : pairs ) +// { +// if( pair.first == "name") +// groupName = pair.second; +// } +// +// if( debugMode == true ) +// { +// if( groupName.empty() ) +// throw std::invalid_argument( "ERROR: group name not found. \n" +// ); +// +// if( groups.count( groupName ) == 1 ) //group exists +// throw std::invalid_argument( "ERROR: group " + groupName + " +// defined twice.\n" ); +// } +// +// groups.emplace( groupName, Group( groupName, xmlGroup, transforms, +// debugMode ) ); +// +// currentContent.erase( currentContent.find( xmlGroup ), xmlGroup.size() +// ); +// currentPosition = 0; +// } +// +// //transport +// //lambda function to check priority and iteration casting to unsigned int +// auto lf_UIntCheck = []( const std::string method, const std::string +// fieldStr, const std::string fieldName, +// const bool debugMode, int& field ) +// { +// field = 0; +// if( fieldStr.empty() == false ) +// { +// field = std::stoi( fieldStr ); //throws invalid_argument +// +// if( debugMode == true ) +// { +// if( field < 0 ) +// throw std::invalid_argument("ERROR: " + fieldName + " in +// transport " + method + " can't be negative\n" ); +// } +// } +// }; +// +// //this section will have to change, doing nothing for now +// currentPosition = 0; +// while( currentPosition != std::string::npos ) +// { +// GetSubString( "<transport ", ">", currentContent, tag, currentPosition +// ); +// if( tag.empty() ) break; +// tag = tag.substr( 1, tag.size() - 2 ); //eliminate < > +// pairs.clear(); +// GetPairsFromTag( currentContent, tag, pairs ); +// +// std::string groupName, method, priorityStr, iterationStr; +// for( auto& pair : pairs ) +// { +// if( pair.first == "group" ) groupName = pair.second; +// else if( pair.first == "method" ) method = pair.second; +// else if( pair.first == "priority" ) priorityStr = pair.second; +// else if( pair.first == "iteration" ) iterationStr = pair.second; +// } +// +// auto itGroup = groups.find( groupName ); +// if( debugMode == true ) +// { +// if( itGroup == groups.end() ) //not found +// throw std::invalid_argument( "ERROR: in transport " + method + +// " group " + groupName + " not found.\n" ); +// } +// +// int priority, iteration; +// lf_UIntCheck( method, priorityStr, "priority", debugMode, priority ); +// lf_UIntCheck( method, iterationStr, "iteration", debugMode, iteration +// ); +// //here do something with the capsule +// } +//} + +// void InitXML( const std::string xmlConfigFile, const MPI_Comm mpiComm, const +// bool debugMode, +// std::string& hostLanguage, std::vector< +// std::shared_ptr<Transform> >& transforms, +// std::map< std::string, Group >& groups ) +//{ +// int xmlFileContentSize; +// std::string xmlFileContent; +// +// int rank; +// MPI_Comm_rank( mpiComm, &rank ); +// +// if( rank == 0 ) //serial part +// { +// DumpFileToString( xmlConfigFile, xmlFileContent ); //in +// ADIOSFunctions.h dumps all XML Config File to xmlFileContent +// xmlFileContentSize = xmlFileContent.size( ) + 1; // add one for the +// null character +// +// MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, mpiComm ); //broadcast +// size for allocation +// MPI_Bcast( (char*)xmlFileContent.c_str(), xmlFileContentSize, +// MPI_CHAR, 0, mpiComm ); //broadcast contents +// } +// else +// { +// MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, mpiComm ); //receive +// size +// +// char* xmlFileContentMPI = new char[ xmlFileContentSize ]; //allocate +// xml C-char +// MPI_Bcast( xmlFileContentMPI, xmlFileContentSize, MPI_CHAR, 0, mpiComm +// ); //receive xml C-char +// xmlFileContent.assign( xmlFileContentMPI ); //copy to a string +// +// delete []( xmlFileContentMPI ); //delete char* needed for MPI, might +// add size is moving to C++14 for optimization, avoid memory leak +// } +// +// SetMembers( xmlFileContent, mpiComm, debugMode, hostLanguage, transforms, +// groups ); +//} + +std::size_t GetTotalSize(const std::vector<std::size_t> &dimensions) +{ + std::size_t product = 1; + + for (const auto dimension : dimensions) + product *= dimension; + + return product; +} + +void CreateDirectory(const std::string fullPath) noexcept +{ + auto lf_Mkdir = [](const std::string directory, struct stat &st) { + if (stat(directory.c_str(), &st) == -1) + mkdir(directory.c_str(), 0777); + }; + + auto directoryPosition = fullPath.find("/"); + + if (fullPath[0] == '/' || fullPath[0] == '.') // find the second '/' + directoryPosition = fullPath.find("/", directoryPosition + 1); + + struct stat st = {0}; + if (directoryPosition == fullPath.npos) // no subdirectories + { + lf_Mkdir(fullPath.c_str(), st); + return; + } + + std::string directory(fullPath.substr(0, directoryPosition)); + lf_Mkdir(directory.c_str(), st); + + while (directoryPosition != fullPath.npos) + { + directoryPosition = fullPath.find("/", directoryPosition + 1); + directory = fullPath.substr(0, directoryPosition); + lf_Mkdir(directory.c_str(), st); + } +} + +void SetTransformsHelper(const std::vector<std::string> &transformNames, + std::vector<std::shared_ptr<Transform>> &transforms, + const bool debugMode, + std::vector<short> &transformIndices, + std::vector<short> ¶meters) +{ + // function to get a parameter from "method:parameter" + auto lf_GetParameter = [](const std::string transformName, + std::string &transformMethod, + const bool debugMode) -> short { + short parameter = -1; + auto colonPosition = transformName.find(":"); + + if (colonPosition != transformName.npos) + { + if (debugMode == true) + { + if (colonPosition == transformName.size() - 1) + throw std::invalid_argument("ERROR: wrong format for transform " + + transformName + + ", in call to SetTransform\n"); + } + + transformMethod = transformName.substr(0, colonPosition); + parameter = + std::stoi(transformName.substr(colonPosition + 1)); // need to test + } + return parameter; + }; + + // Get transform index from transforms, if not found return -1 + auto lf_GetTransformIndex = + [](const std::string transformMethod, + const std::vector<std::shared_ptr<Transform>> &transforms) -> short { + short transformIndex = -1; + for (unsigned int i = 0; i < transforms.size(); ++i) + { + if (transforms[i]->m_Method == transformMethod) + { + transformIndex = i; + break; + } + } + return transformIndex; + }; + + // BODY of FUNCTION STARTS HERE + for (const std::string transformName : transformNames) + { + std::string transformMethod(transformName); + short parameter = + lf_GetParameter(transformName, transformMethod, + debugMode); // from transform = "method:parameter" + short transformIndex = lf_GetTransformIndex(transformMethod, transforms); + + if (transformIndex == -1) // not found, then create a new transform + { + if (transformMethod == "bzip2") + { +#ifdef HAVE_BZIP2 + transforms.push_back(std::make_shared<CBZIP2>()); +#endif + } + + transformIndex = static_cast<short>(transforms.size() - 1); + } + transformIndices.push_back(transformIndex); + parameters.push_back(parameter); + } +} + +std::map<std::string, std::string> +BuildParametersMap(const std::vector<std::string> ¶meters, + const bool debugMode) +{ + auto lf_GetFieldValue = [](const std::string parameter, std::string &field, + std::string &value, const bool debugMode) { + auto equalPosition = parameter.find("="); + + if (debugMode == true) + { + if (equalPosition == parameter.npos) + throw std::invalid_argument("ERROR: wrong format for parameter " + + parameter + + ", format must be field=value \n"); + + if (equalPosition == parameter.size() - 1) + throw std::invalid_argument("ERROR: empty value in parameter " + + parameter + + ", format must be field=value \n"); + } + + field = parameter.substr(0, equalPosition); + value = parameter.substr(equalPosition + 1); // need to test + }; + + // BODY OF FUNCTION STARTS HERE + std::map<std::string, std::string> parametersOutput; + + for (const auto parameter : parameters) + { + std::string field, value; + lf_GetFieldValue(parameter, field, value, debugMode); + + if (debugMode == true) + { + if (parametersOutput.count(field) == 1) + throw std::invalid_argument("ERROR: parameter " + field + + " already exists, must be unique\n"); + } + + parametersOutput[field] = value; + } + + return parametersOutput; +} + +std::vector<int> CSVToVectorInt(const std::string csv) +{ + std::vector<int> numbers; + if (csv.empty()) + return numbers; + + if (csv.find(",") == csv.npos) // check if no commas, one int + { + numbers.push_back(std::stoi(csv)); // might need to be checked + } + else + { + int count = std::count(csv.begin(), csv.end(), ','); + numbers.reserve(count); + + std::istringstream csvSS(csv); + std::string value; + while (std::getline(csvSS, value, ',')) // need to test + { + numbers.push_back(std::stoi(csv)); + } + } + + return numbers; +} + +bool CheckBufferAllocation(const std::size_t newSize, const float growthFactor, + const std::size_t maxBufferSize, + std::vector<char> &buffer) +{ + // Check if data in buffer needs to be reallocated + const std::size_t requiredDataSize = + buffer.size() + newSize + 100; // adding some bytes for tolerance + // might need to write payload in batches + bool doTransportsFlush = (requiredDataSize > maxBufferSize) ? true : false; + + if (GrowBuffer(requiredDataSize, growthFactor, buffer) == -1) + doTransportsFlush = true; + + return doTransportsFlush; +} + +int GrowBuffer(const std::size_t incomingDataSize, const float growthFactor, + std::vector<char> &buffer) +{ + const std::size_t currentCapacity = buffer.capacity(); + const std::size_t availableSpace = currentCapacity - buffer.size(); + const double gf = static_cast<double>(growthFactor); + + if (incomingDataSize > availableSpace) + { + const std::size_t neededCapacity = incomingDataSize + buffer.size(); + const double numerator = std::log(static_cast<double>(neededCapacity) / + static_cast<double>(currentCapacity)); + const double denominator = std::log(gf); + + double n = std::ceil(numerator / denominator); + const std::size_t newSize = + static_cast<std::size_t>(std::ceil(std::pow(gf, n) * currentCapacity)); + + try + { + buffer.reserve(newSize); + } + catch (std::bad_alloc &e) + { + return -1; + } + + return 1; + } + return 0; +} + +bool IsLittleEndian() noexcept +{ + std::uint16_t hexa = 0x1234; + return *reinterpret_cast<std::uint8_t *>(&hexa) != 0x12; +} + +} // end namespace diff --git a/source/mpidummy.cpp b/source/mpidummy.cpp new file mode 100644 index 000000000..cf2539fed --- /dev/null +++ b/source/mpidummy.cpp @@ -0,0 +1,320 @@ +/* + * ADIOS is freely available under the terms of the BSD license described + * in the COPYING file in the top level directory of this source distribution. + * + * Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved. + */ + +/* + A dummy MPI implementation for the BP READ API, to have an MPI-free version + of the API +*/ +/// \cond EXCLUDE_FROM_DOXYGEN +#define __STDC_FORMAT_MACROS +#include <cstdint> +#include <inttypes.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> +//#define _LARGEFILE64_SOURCE +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> +/// \endcond + +#include "mpidummy.h" + +#if defined(__APPLE__) || defined(__WIN32__) || defined(__CYGWIN__) +#define lseek64 lseek +#define open64 open +#endif + +namespace adios +{ + +static char mpierrmsg[MPI_MAX_ERROR_STRING]; + +int MPI_Init(int *argc, char ***argv) +{ + mpierrmsg[0] = '\0'; + return MPI_SUCCESS; +} + +int MPI_Finalize() +{ + mpierrmsg[0] = '\0'; + return MPI_SUCCESS; +} + +int MPI_Initialized(int *flag) +{ + *flag = 1; + return MPI_SUCCESS; +} + +int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out) +{ + return MPI_SUCCESS; +} + +int MPI_Barrier(MPI_Comm comm) { return MPI_SUCCESS; } +int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, + MPI_Comm comm) +{ + return MPI_SUCCESS; +} + +int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm) +{ + *newcomm = comm; + return MPI_SUCCESS; +} +int MPI_Comm_rank(MPI_Comm comm, int *rank) +{ + *rank = 0; + return MPI_SUCCESS; +} +int MPI_Comm_size(MPI_Comm comm, int *size) +{ + *size = 1; + return MPI_SUCCESS; +} +int MPI_Comm_free(MPI_Comm *comm) +{ + *comm = 0; + return MPI_SUCCESS; +} +MPI_Comm MPI_Comm_f2c(MPI_Fint comm) { return comm; } + +int MPI_Gather(void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, + int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm) +{ + int ier = MPI_SUCCESS; + size_t n = 0, nsent = 0, nrecv = 0; + if (!sendbuf || !recvbuf) + ier = MPI_ERR_BUFFER; + if (comm == MPI_COMM_NULL || root) + ier = MPI_ERR_COMM; + + switch (sendtype) + { + case MPI_INT: + n = sizeof(int); + break; + default: + return MPI_ERR_TYPE; + } + nsent = n * sendcnt; + + switch (recvtype) + { + case MPI_INT: + nrecv = sizeof(int); + break; + default: + return MPI_ERR_TYPE; + } + nrecv = n * recvcnt; + + if (nrecv != nsent) + ier = MPI_ERR_COUNT; + + if (ier == MPI_SUCCESS) + memcpy(recvbuf, sendbuf, nsent); + else + snprintf(mpierrmsg, ier, "could not gather data\n"); + + return ier; +} + +int MPI_Gatherv(void *sendbuf, int sendcnt, MPI_Datatype sendtype, + void *recvbuf, int *recvcnts, int *displs, + MPI_Datatype recvtype, int root, MPI_Comm comm) +{ + int ier = MPI_SUCCESS; + if (!recvcnts || !displs) + ier = MPI_ERR_BUFFER; + + if (ier == MPI_SUCCESS) + ier = MPI_Gather(sendbuf, sendcnt, sendtype, recvbuf, recvcnts[0], recvtype, + root, comm); + + return ier; +} + +int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, int recvcount, MPI_Datatype recvtype, + MPI_Comm comm) +{ + return MPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, + 0, comm); +} + +int MPI_Scatter(void *sendbuf, int sendcnt, MPI_Datatype sendtype, + void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, + MPI_Comm comm) +{ + int ier = MPI_SUCCESS; + size_t n = 0, nsent = 0, nrecv = 0; + if (!sendbuf || !recvbuf) + ier = MPI_ERR_BUFFER; + if (comm == MPI_COMM_NULL || root) + ier = MPI_ERR_COMM; + + switch (sendtype) + { + case MPI_INT: + n = sizeof(int); + break; + default: + return MPI_ERR_TYPE; + } + nsent = n * sendcnt; + + switch (recvtype) + { + case MPI_INT: + nrecv = sizeof(int); + break; + default: + return MPI_ERR_TYPE; + } + nrecv = n * recvcnt; + + if (nrecv != nsent) + ier = MPI_ERR_COUNT; + + if (ier == MPI_SUCCESS) + memcpy(sendbuf, recvbuf, nsent); + else + snprintf(mpierrmsg, ier, "could not scatter data\n"); + + return ier; +} + +int MPI_Scatterv(void *sendbuf, int *sendcnts, int *displs, + MPI_Datatype sendtype, void *recvbuf, int recvcnt, + MPI_Datatype recvtype, int root, MPI_Comm comm) +{ + int ier = MPI_SUCCESS; + if (!sendcnts || !displs) + ier = MPI_ERR_BUFFER; + + if (ier == MPI_SUCCESS) + ier = MPI_Scatter(sendbuf, sendcnts[0], sendtype, recvbuf, recvcnt, + recvtype, root, comm); + + return ier; +} + +int MPI_Recv(void *recvbuffer, int count, MPI_Datatype type, int source, + int tag, MPI_Comm comm, MPI_Status *status) +{ + return 0; +} + +int MPI_Irecv(void *recvbuffer, int count, MPI_Datatype type, int source, + int tag, MPI_Comm comm, MPI_Request *request) +{ + return 0; +} + +int MPI_Send(void *sendbuffer, int count, MPI_Datatype type, int destination, + int tag, MPI_Comm comm) +{ + return 0; +} + +int MPI_Isend(void *recvbuffer, int count, MPI_Datatype type, int source, + int tag, MPI_Comm comm, MPI_Request *request) +{ + return 0; +} + +int MPI_Wait(MPI_Request *request, MPI_Status *status) { return 0; } + +int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, + MPI_File *fh) +{ + *fh = open64(filename, amode); + if (*fh == -1) + { + snprintf(mpierrmsg, MPI_MAX_ERROR_STRING, "File not found: %s", filename); + return -1; + } + return MPI_SUCCESS; +} + +int MPI_File_close(MPI_File *fh) { return close(*fh); } + +int MPI_File_get_size(MPI_File fh, MPI_Offset *size) +{ + uint64_t curpos = lseek64(fh, 0, SEEK_CUR); // get the current seek pos + uint64_t endpos = + lseek64(fh, 0, SEEK_END); // go to end, returned is the size in bytes + lseek64(fh, curpos, SEEK_SET); // go back where we were + *size = (MPI_Offset)endpos; + // printf("MPI_File_get_size: fh=%d, size=%lld\n", fh, *size); + return MPI_SUCCESS; +} + +int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, + MPI_Status *status) +{ + // FIXME: int count can read only 2GB (*datatype size) array at max + std::uint64_t bytes_to_read = + count * datatype; // datatype should hold the size of the type, not an id + std::uint64_t bytes_read; + bytes_read = read(fh, buf, bytes_to_read); + if (bytes_read != bytes_to_read) + { + snprintf(mpierrmsg, MPI_MAX_ERROR_STRING, + "could not read %" PRId64 " bytes. read only: %" PRId64 "\n", + bytes_to_read, bytes_read); + return -2; + } + *status = bytes_read; + // printf("MPI_File_read: fh=%d, count=%d, typesize=%d, bytes read=%lld\n", + // fh, count, datatype, *status); + return MPI_SUCCESS; +} + +int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence) +{ + uint64_t off = (uint64_t)offset; + lseek64(fh, off, whence); + // printf("MPI_File_seek: fh=%d, offset=%lld, whence=%d\n", fh, off, whence); + return MPI_SUCCESS; +} + +int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count) +{ + *count = (int)*status; + return MPI_SUCCESS; +} + +int MPI_Error_string(int errorcode, char *string, int *resultlen) +{ + // sprintf(string, "Dummy lib does not know error strings. + // Code=%d\n",errorcode); + strcpy(string, mpierrmsg); + *resultlen = strlen(string); + return MPI_SUCCESS; +} + +double MPI_Wtime() +{ + // Implementation not tested + struct timeval tv; + gettimeofday(&tv, NULL); + return (double)(tv.tv_sec) + (double)(tv.tv_usec) / 1000000; +} + +int MPI_Get_processor_name(char *name, int *resultlen) +{ + sprintf(name, "0"); + *resultlen = 1; + return 0; +} + +} // end namespace diff --git a/source/transform/BZip2.cpp b/source/transform/BZip2.cpp new file mode 100644 index 000000000..5eafca87f --- /dev/null +++ b/source/transform/BZip2.cpp @@ -0,0 +1,30 @@ +/* + * BZIP2.cpp + * + * Created on: Oct 19, 2016 + * Author: wfg + */ + +#include "../../include/transform/BZip2.h" + +namespace adios +{ +namespace transform +{ + +BZIP2::BZIP2() : Transform("bzip2") {} + +BZIP2::~BZIP2() {} + +void BZIP2::Compress(const std::vector<char> &bufferIn, + std::vector<char> &bufferOut) +{ +} + +void BZIP2::Decompress(const std::vector<char> &bufferIn, + std::vector<char> &bufferOut) +{ +} + +} // end namespace transform +} // end namespace adios diff --git a/source/transport/file/FStream.cpp b/source/transport/file/FStream.cpp new file mode 100644 index 000000000..a01d94220 --- /dev/null +++ b/source/transport/file/FStream.cpp @@ -0,0 +1,71 @@ +/* + * CFStream.cpp + * + * Created on: Oct 24, 2016 + * Author: wfg + */ + +/// \cond EXCLUDED_FROM_DOXYGEN +#include <stdexcept> +/// \endcond + +#include "transport/file/FStream.h" + +namespace adios +{ +namespace transport +{ + +FStream::FStream(MPI_Comm mpiComm, const bool debugMode) + : Transport("fstream", mpiComm, debugMode) +{ +} + +FStream::~FStream() {} + +void FStream::Open(const std::string name, const std::string accessMode) +{ + m_Name = name; + m_AccessMode = accessMode; + + if (accessMode == "w" || accessMode == "write") + m_FStream.open(name, std::fstream::out); + + else if (accessMode == "a" || accessMode == "append") + m_FStream.open(name, std::fstream::out | std::fstream::app); + + else if (accessMode == "r" || accessMode == "read") + m_FStream.open(name, std::fstream::in); + + if (m_DebugMode == true) + { + if (!m_FStream) + throw std::ios_base::failure( + "ERROR: couldn't open file " + name + + ", in call to Open from FStream transport\n"); + } +} + +void FStream::SetBuffer(char *buffer, std::size_t size) +{ + m_FStream.rdbuf()->pubsetbuf(buffer, size); +} + +void FStream::Write(const char *buffer, std::size_t size) +{ + m_FStream.write(buffer, size); + + if (m_DebugMode == true) + { + if (!m_FStream) + throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + + ", in call to FStream write\n"); + } +} + +void FStream::Flush() { m_FStream.flush(); } + +void FStream::Close() { m_FStream.close(); } + +} // end namespace transport +} // end namespace diff --git a/source/transport/file/FileDescriptor.cpp b/source/transport/file/FileDescriptor.cpp new file mode 100644 index 000000000..2d7cb72c4 --- /dev/null +++ b/source/transport/file/FileDescriptor.cpp @@ -0,0 +1,128 @@ +/* + * FileDescriptor.cpp file descriptor + * + * Created on: Oct 6, 2016 + * Author: wfg + */ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <fcntl.h> //open +#include <ios> //std::ios_base::failure +#include <stddef.h> // write output +#include <sys/stat.h> //open +#include <sys/types.h> //open +#include <unistd.h> // write, close +/// \endcond + +#include "transport/file/FileDescriptor.h" + +namespace adios +{ +namespace transport +{ + +FileDescriptor::FileDescriptor(MPI_Comm mpiComm, const bool debugMode) + : Transport("POSIX_IO", mpiComm, debugMode) +{ +} + +FileDescriptor::~FileDescriptor() +{ + if (m_FileDescriptor != -1) + { + close(m_FileDescriptor); + } +} + +void FileDescriptor::Open(const std::string name, const std::string accessMode) +{ + m_Name = name; + m_AccessMode = accessMode; + + if (accessMode == "w" || accessMode == "write") + { + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[0].SetInitialTime(); + + m_FileDescriptor = open(m_Name.c_str(), O_WRONLY | O_CREAT, 0777); + + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[0].SetTime(); + } + else if (accessMode == "a" || accessMode == "append") + { + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[0].SetInitialTime(); + + m_FileDescriptor = + open(m_Name.c_str(), O_WRONLY | O_APPEND); // we need to change this + + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[0].SetTime(); + } + else if (accessMode == "r" || accessMode == "read") + { + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[0].SetInitialTime(); + + m_FileDescriptor = open(m_Name.c_str(), O_RDONLY); + + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[0].SetTime(); + } + + if (m_DebugMode == true) + { + if (m_FileDescriptor == -1) + throw std::ios_base::failure("ERROR: couldn't open file " + m_Name + + ", from call to Open in FD transport using " + "POSIX open. Does file exists?\n"); + } +} + +void FileDescriptor::Write(const char *buffer, std::size_t size) +{ + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[1].SetInitialTime(); + + auto writtenSize = write(m_FileDescriptor, buffer, size); + + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[1].SetTime(); + + if (m_DebugMode == true) + { + if (writtenSize == -1) + throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + + ", in call to POSIX write\n"); + + if (static_cast<std::size_t>(writtenSize) != size) + throw std::ios_base::failure( + "ERROR: written size + " + std::to_string(writtenSize) + + " is not equal to intended size " + std::to_string(size) + + " in file " + m_Name + ", in call to POSIX write\n"); + } +} + +void FileDescriptor::Close() +{ + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[2].SetInitialTime(); + + int status = close(m_FileDescriptor); + + if (m_Profiler.m_IsActive == true) + m_Profiler.m_Timers[2].SetTime(); + + if (m_DebugMode == true) + { + if (status == -1) + throw std::ios_base::failure("ERROR: couldn't close file " + m_Name + + ", in call to POSIX write\n"); + } + + m_IsOpen = false; +} + +} // end namespace transport +} // end namespace diff --git a/source/transport/file/FilePointer.cpp b/source/transport/file/FilePointer.cpp new file mode 100644 index 000000000..a30808381 --- /dev/null +++ b/source/transport/file/FilePointer.cpp @@ -0,0 +1,87 @@ +/* + * FP.cpp + * + * Created on: Jan 6, 2017 + * Author: wfg + */ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <ios> //std::ios_base::failure +/// \endcond + +#include "transport/file/FilePointer.h" + +namespace adios +{ +namespace transport +{ + +FilePointer::FilePointer(MPI_Comm mpiComm, const bool debugMode) + : Transport("FILE*", mpiComm, debugMode) +{ +} + +FilePointer::~FilePointer() +{ + if (m_File != NULL) + fclose(m_File); +} + +void FilePointer::Open(const std::string name, const std::string accessMode) +{ + m_Name = name; + m_AccessMode = accessMode; + + if (accessMode == "w" || accessMode == "write") + m_File = fopen(name.c_str(), "w"); + + else if (accessMode == "a" || accessMode == "append") + m_File = fopen(name.c_str(), "a"); + + else if (accessMode == "r" || accessMode == "read") + m_File = fopen(name.c_str(), "r"); + + if (m_DebugMode == true) + { + if (m_File == NULL) + throw std::ios_base::failure("ERROR: couldn't open file " + name + + ", " + "in call to Open from File* transport\n"); + } +} + +void FilePointer::SetBuffer(char *buffer, std::size_t size) +{ + int status = setvbuf(m_File, buffer, _IOFBF, size); + + if (m_DebugMode == true) + { + if (status == 1) + throw std::ios_base::failure("ERROR: could not set buffer in rank " + + std::to_string(m_RankMPI) + "\n"); + } +} + +void FilePointer::Write(const char *buffer, std::size_t size) +{ + fwrite(buffer, sizeof(char), size, m_File); + + if (m_DebugMode == true) + { + if (ferror(m_File)) + throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + + ", in call to File* write\n"); + } +} + +void FilePointer::Flush() { fflush(m_File); } + +void FilePointer::Close() +{ + fclose(m_File); + + m_IsOpen = false; +} + +} // end namespace transport +} // end namespace diff --git a/source/transport/wan/MdtmMan.cpp b/source/transport/wan/MdtmMan.cpp new file mode 100644 index 000000000..f269d5f1f --- /dev/null +++ b/source/transport/wan/MdtmMan.cpp @@ -0,0 +1,75 @@ +/* + * MdtmMan.cpp + * + * Created on: Jan 22, 2017 + * Author: wfg + */ + +#include "transport/wan/MdtmMan.h" + +namespace adios +{ +namespace transport +{ + +MdtmMan::MdtmMan(const std::string localIP, const std::string remoteIP, + const std::string mode, const std::string prefix, + const int numberOfPipes, const std::vector<int> tolerances, + const std::vector<int> priorities, MPI_Comm mpiComm, + const bool debugMode) + : Transport("File", mpiComm, debugMode), m_LocalIP{localIP}, + m_RemoteIP{remoteIP}, m_Mode{mode}, m_Prefix{prefix}, + m_NumberOfPipes{numberOfPipes}, m_Tolerances{tolerances}, + m_Priorities{priorities} +{ +} + +MdtmMan::~MdtmMan() {} + +void MdtmMan::Open(const std::string name, const std::string accessMode) {} + +void MdtmMan::SetBuffer(char *buffer, std::size_t size) {} + +void MdtmMan::Write(const char *buffer, std::size_t size) {} + +void MdtmMan::Flush() {} + +void MdtmMan::Close() { m_NumberOfPipes = -1; } + +// PRIVATE Functions +int MdtmMan::Put(const void *data, const std::string doid, + const std::string variable, const std::string dType, + const std::vector<std::uint64_t> &putShape, + const std::vector<uint64_t> &varShape, + const std::vector<uint64_t> &offset, + const std::uint64_t timestep, const int tolerance, + const int priority) +{ + + return 0; +} + +int MdtmMan::Get(void *data, const std::string doid, const std::string variable, + const std::string dType, + const std::vector<std::uint64_t> &putShape, + const std::vector<uint64_t> &varShape, + const std::vector<uint64_t> &offset, + const std::uint64_t timestep, const int tolerance, + const int priority) +{ + + return 0; +} + +int MdtmMan::Get(void *data, const std::string doid, const std::string variable, + const std::string dType, std::vector<std::uint64_t> &varShape, + const std::uint64_t timestep) +{ + + return 0; +} + +void MdtmMan::OnReceive(nlohmann::json &jData) {} + +} // end namespace transport +} // end namespace diff --git a/src/ADIOS.cpp b/src/ADIOS.cpp deleted file mode 100644 index bc9889d99..000000000 --- a/src/ADIOS.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* - * ADIOS.cpp - * - * Created on: Sep 29, 2016 - * Author: William F Godoy - */ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <iostream> -#include <fstream> -#include <sstream> -#include <utility> -/// \endcond - -#include "ADIOS.h" -#include "functions/adiosFunctions.h" - -//Engines -#include "engine/bp/BPFileWriter.h" -#include "engine/bp/BPFileReader.h" - -#ifdef HAVE_DATAMAN //external dependencies -#include "engine/dataman/DataManWriter.h" -#include "engine/dataman/DataManReader.h" -#endif - - -#ifdef HAVE_ADIOS1 //external dependencies -#include "engine/adios1/ADIOS1Writer.h" -#include "engine/adios1/ADIOS1Reader.h" -#endif - -namespace adios -{ - - -ADIOS::ADIOS( const Verbose verbose, const bool debugMode ): - m_DebugMode{ debugMode } -{ - InitMPI( ); -} - - -ADIOS::ADIOS( const std::string configFileName, const Verbose verbose, const bool debugMode ): - m_ConfigFile{ configFileName }, - m_DebugMode{ debugMode } -{ - InitMPI( ); - // InitXML( m_ConfigFile, m_MPIComm, m_DebugMode, m_Transforms ); -} - - - -ADIOS::ADIOS( const std::string xmlConfigFile, MPI_Comm mpiComm, const Verbose verbose, const bool debugMode ): - m_MPIComm{ mpiComm }, - m_ConfigFile{ xmlConfigFile }, - m_DebugMode{ debugMode } -{ - InitMPI( ); - //InitXML( m_XMLConfigFile, m_MPIComm, m_DebugMode, m_HostLanguage, m_Transforms, m_Groups ); -} - - -ADIOS::ADIOS( MPI_Comm mpiComm, const Verbose verbose, const bool debugMode ): - m_MPIComm{ mpiComm }, - m_DebugMode{ debugMode } -{ - InitMPI( ); -} - - -ADIOS::~ADIOS( ) -{ } - - -void ADIOS::InitMPI( ) -{ - if( m_DebugMode == true ) - { - if( m_MPIComm == MPI_COMM_NULL ) - throw std::ios_base::failure( "ERROR: engine communicator is MPI_COMM_NULL," - " in call to ADIOS Open or Constructor\n" ); - } - - MPI_Comm_rank( m_MPIComm, &m_RankMPI ); - MPI_Comm_size( m_MPIComm, &m_SizeMPI ); -} - - -Method& ADIOS::DeclareMethod( const std::string methodName ) -{ - if( m_DebugMode == true ) - { - if( m_Methods.count( methodName ) == 1 ) - throw std::invalid_argument( "ERROR: method " + methodName + " already declared, from DeclareMethod\n" ); - } - m_Methods.emplace( methodName, Method( methodName, m_DebugMode ) ); - return m_Methods.at( methodName ); -} - - -std::shared_ptr<Engine> ADIOS::Open( const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method& method, const IOMode iomode, const float timeout_sec ) -{ - if( m_DebugMode == true ) - { - if( m_EngineNames.count( name ) == 1 ) //Check if Engine already exists - throw std::invalid_argument( "ERROR: engine name " + name + " already created by Open, in call from Open.\n" ); - } - - m_EngineNames.insert( name ); - - const std::string type( method.m_Type ); - - const bool isDefaultWriter = ( accessMode == "w" || accessMode == "write" || - accessMode == "a" || accessMode == "append" ) && type.empty() ? true : false; - - const bool isDefaultReader = ( accessMode == "r" || accessMode == "read" ) && type.empty() ? true : false; - - if( isDefaultWriter || type == "BPFileWriter" || type == "bpfilewriter" ) - { - return std::make_shared<BPFileWriter>( *this, name, accessMode, mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); - } - else if( isDefaultReader || type == "BPReader" || type == "bpreader" ) - { - return std::make_shared<BPFileReader>( *this, name, accessMode, mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); - } - else if( type == "SIRIUS" || type == "sirius" || type == "Sirius" ) - { - //not yet supported - //return std::make_shared<engine::DataMan>( *this, name, accessMode, mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); - } - else if( type == "DataManWriter" ) - { - #ifdef HAVE_DATAMAN - return std::make_shared<DataManWriter>( *this, name, accessMode, mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); - #else - throw std::invalid_argument( "ERROR: this version didn't compile with Dataman library, can't Open DataManWriter\n" ); - #endif - - } - else if( type == "DataManReader" ) - { - #ifdef HAVE_DATAMAN - return std::make_shared<DataManReader>( *this, name, accessMode, mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); - #else - throw std::invalid_argument( "ERROR: this version didn't compile with Dataman library, can't Open DataManReader\n" ); - #endif - } - else if( type == "ADIOS1Writer" ) - { - #ifdef HAVE_ADIOS1 - return std::make_shared<ADIOS1Writer>( *this, name, accessMode, mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); - #else - throw std::invalid_argument( "ERROR: this version didn't compile with ADIOS 1.x library, can't Open ADIOS1Writer\n" ); - #endif - } - else if( type == "Vis" ) - { - //return std::make_shared<Vis>( *this, name, accessMode, mpiComm, method, iomode, timeout_sec, m_DebugMode, method.m_nThreads ); - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: method type " + type + " not supported for " + name + ", in call to Open\n" ); - } - - return nullptr; // if debug mode is off -} - - -std::shared_ptr<Engine> ADIOS::Open( const std::string streamName, const std::string accessMode, - const Method& method, const IOMode iomode, const float timeout_sec ) -{ - return Open( streamName, accessMode, m_MPIComm, method, iomode, timeout_sec ); -} - - -std::shared_ptr<Engine> ADIOS::Open( const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const std::string methodName, const IOMode iomode, const float timeout_sec ) -{ - auto itMethod = m_Methods.find( methodName ); - - if( m_DebugMode == true ) - { - CheckMethod( itMethod, methodName, " in call to Open\n" ); - } - - return Open( name, accessMode, mpiComm, itMethod->second, iomode, timeout_sec ); -} - - -std::shared_ptr<Engine> ADIOS::Open( const std::string name, const std::string accessMode, - const std::string methodName, const IOMode iomode, const float timeout_sec ) -{ - return Open( name, accessMode, m_MPIComm, methodName, iomode, timeout_sec ); -} - -std::shared_ptr<Engine> ADIOS::OpenFileReader( const std::string name, MPI_Comm mpiComm, - const Method& method, const IOMode iomode ) -{ - return Open( name, "r", m_MPIComm, method, iomode ); -} - -std::shared_ptr<Engine> ADIOS::OpenFileReader( const std::string name, MPI_Comm mpiComm, - const std::string methodName, const IOMode iomode ) -{ - auto itMethod = m_Methods.find( methodName ); - - if( m_DebugMode == true ) - { - CheckMethod( itMethod, methodName, " in call to Open\n" ); - } - - return Open( name, "r", m_MPIComm, itMethod->second, iomode ); -} - -VariableCompound& ADIOS::GetVariableCompound( const std::string name ) -{ - return m_Compound.at( GetVariableIndex<void>(name) ); -} - - -void ADIOS::MonitorVariables( std::ostream& logStream ) -{ - logStream << "\tVariable \t Type\n"; - - for( auto& variablePair : m_Variables ) - { - const std::string name( variablePair.first ); - const std::string type( variablePair.second.first ); - - if( type == GetType<char>() ) - GetVariable<char>( name ).Monitor( logStream ); - - else if( type == GetType<unsigned char>() ) - GetVariable<unsigned char>( name ).Monitor( logStream ); - - else if( type == GetType<short>() ) - GetVariable<short>( name ).Monitor( logStream ); - - else if( type == GetType<unsigned short>() ) - GetVariable<unsigned short>( name ).Monitor( logStream ); - - else if( type == GetType<int>() ) - GetVariable<int>( name ).Monitor( logStream ); - - else if( type == GetType<unsigned int>() ) - GetVariable<unsigned int>( name ).Monitor( logStream ); - - else if( type == GetType<long int>() ) - GetVariable<long int>( name ).Monitor( logStream ); - - else if( type == GetType<unsigned long int>() ) - GetVariable<unsigned long int>( name ).Monitor( logStream ); - - else if( type == GetType<long long int>() ) - GetVariable<long long int>( name ).Monitor( logStream ); - - else if( type == GetType<unsigned long long int>() ) - GetVariable<unsigned long long int>( name ).Monitor( logStream ); - - else if( type == GetType<float>() ) - GetVariable<float>( name ).Monitor( logStream ); - - else if( type == GetType<double>() ) - GetVariable<double>( name ).Monitor( logStream ); - - else if( type == GetType<long double>() ) - GetVariable<long double>( name ).Monitor( logStream ); - - else if( type == GetType<std::complex<float>>() ) - GetVariable<std::complex<float>>( name ).Monitor( logStream ); - - else if( type == GetType<std::complex<double>>() ) - GetVariable<std::complex<double>>( name ).Monitor( logStream ); - - else if( type == GetType<std::complex<long double>>() ) - GetVariable<std::complex<long double>>( name ).Monitor( logStream ); - } -} - - -//PRIVATE FUNCTIONS BELOW -void ADIOS::CheckVariableInput( const std::string name, const Dims& dimensions ) const -{ - if( m_DebugMode == true ) - { - if( m_Variables.count( name ) == 1 ) - throw std::invalid_argument( "ERROR: variable " + name + " already exists, in call to DefineVariable\n" ); - - if( dimensions.empty() == true ) - throw std::invalid_argument( "ERROR: variable " + name + " dimensions can't be empty, in call to DefineVariable\n" ); - } -} - - -void ADIOS::CheckVariableName( std::map< std::string, std::pair< std::string, unsigned int > >::const_iterator itVariable, - const std::string name, const std::string hint ) const -{ - if( m_DebugMode == true ) - { - if( itVariable == m_Variables.end() ) - throw std::invalid_argument( "ERROR: variable " + name + " does not exist " + hint + "\n" ); - } -} - - -void ADIOS::CheckMethod( std::map< std::string, Method >::const_iterator itMethod, - const std::string methodName, const std::string hint ) const -{ - if( itMethod == m_Methods.end() ) - throw std::invalid_argument( "ERROR: method " + methodName + " not found " + hint + "\n" ); -} - - -} //end namespace diff --git a/src/ADIOS_C.cpp b/src/ADIOS_C.cpp deleted file mode 100644 index b8e738014..000000000 --- a/src/ADIOS_C.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * ADIOS_C.cpp - * - * Created on: Oct 31, 2016 - * Author: wfg - */ - - - -#include <string> -#include <fstream> -#include <iostream> -#include <cstring> - -#include "ADIOS.h" -#include "ADIOS_C.h" - - -adios::ADIOS* adios; - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -void adios_init( const char* xmlConfigFile, const MPI_Comm mpiComm ) -{ - - int rank; - MPI_Comm_rank( mpiComm, &rank ); - - try - { - adios = new adios::ADIOS( std::string( xmlConfigFile ), mpiComm ); - } - catch( std::bad_alloc& e ) - { - if( rank == 0 ) - std::cout << "Bad allocation exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::invalid_argument& e ) - { - if( rank == 0 ) - std::cout << "Invalid argument exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::exception& e ) - { - if( rank == 0 ) - std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - -// return ( ADIOS* ) ( adios ); -} - - -ADIOS* adios_init_debug( const char* xmlConfigFile, const MPI_Comm mpiComm ) -{ - adios::ADIOS* adios; - int rank; - MPI_Comm_rank( mpiComm, &rank ); - - try - { - adios = new adios::ADIOS( std::string( xmlConfigFile ), mpiComm, true ); - } - catch( std::bad_alloc& e ) - { - if( rank == 0 ) - std::cout << "Bad allocation exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::invalid_argument& e ) - { - if( rank == 0 ) - std::cout << "Invalid argument exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::exception& e ) - { - if( rank == 0 ) - std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - - return ( ADIOS* ) ( adios ); -} - - -void adios_open( const ADIOS* adiosC, const char* groupName, const char* fileName, const char* accessMode ) -{ - adios::ADIOS* adios = ( adios::ADIOS* ) adiosC; - int rank; - MPI_Comm_rank( adios->m_MPIComm, &rank ); - - try - { - adios::ADIOS* adios = ( adios::ADIOS * ) adiosC; - adios->Open( std::string( groupName ), std::string( fileName ), std::string( accessMode ) ); - } - catch( std::bad_alloc& e ) - { - if( rank == 0 ) - std::cout << "Bad allocation exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::invalid_argument& e ) - { - if( rank == 0 ) - std::cout << "Invalid argument exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::exception& e ) - { - if( rank == 0 ) - std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } -} - - -void adios_write( const ADIOS* adiosC, const char* groupName, const char* variableName, const void* values ) -{ - adios::ADIOS* adios = ( adios::ADIOS* ) adiosC; - int rank; - MPI_Comm_rank( adios->m_MPIComm, &rank ); - - try - { - adios->Write( const std::string( groupName ), const std::string( variableName ), values ); - } - catch( std::bad_alloc& e ) - { - if( rank == 0 ) - std::cout << "Bad allocation exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::invalid_argument& e ) - { - if( rank == 0 ) - std::cout << "Invalid argument exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::exception& e ) - { - if( rank == 0 ) - std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } -} - - -void adios_close( const ADIOS* adiosC, const char* groupName ) -{ - adios::ADIOS* adios = ( adios::ADIOS * ) adiosC; - int rank; - MPI_Comm_rank( adios->m_MPIComm, &rank ); - - try - { - adios->Close( std::string( groupName ) ); - } - catch( std::bad_alloc& e ) - { - if( rank == 0 ) - std::cout << "Bad allocation exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::invalid_argument& e ) - { - if( rank == 0 ) - std::cout << "Invalid argument exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::exception& e ) - { - if( rank == 0 ) - std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } -} - - -void adios_free( const ADIOS* adiosC ) -{ - adios::ADIOS* adios = ( adios::ADIOS* ) adiosC; - delete adios; -} - - -void adios_monitor_groups( const ADIOS* adiosC ) -{ - adios::ADIOS* adios = ( adios::ADIOS* ) adiosC; - int rank; - MPI_Comm_rank( adios->m_MPIComm, &rank ); - - try - { - adios->MonitorGroups( std::cout ); - } - catch( std::bad_alloc& e ) - { - if( rank == 0 ) - std::cout << "Bad allocation exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::invalid_argument& e ) - { - if( rank == 0 ) - std::cout << "Invalid argument exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::exception& e ) - { - if( rank == 0 ) - std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } -} - - -void adios_monitor_groups_file( const ADIOS* adiosC, const char* fileName, const char* mode ) -{ - adios::ADIOS* adios = ( adios::ADIOS * ) adiosC; - int rank; - MPI_Comm_rank( adios->m_MPIComm, &rank ); - - try - { - std::ofstream fileStream; - - if( strcmp( mode, "a" ) == 0 || strcmp( mode, "append" ) == 0 ) - fileStream.open( fileName, std::ostream::app ); - else if( strcmp( mode, "w" ) == 0 || strcmp( mode, "write" ) == 0 ) - fileStream.open( fileName ); - - adios->MonitorGroups( fileStream ); - - } - catch( std::bad_alloc& e ) - { - if( rank == 0 ) - std::cout << "Bad allocation exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::invalid_argument& e ) - { - if( rank == 0 ) - std::cout << "Invalid argument exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } - catch( std::exception& e ) - { - if( rank == 0 ) - std::cout << "Exception, STOPPING PROGRAM\n" << e.what() << "\n"; - } -} - - -#ifdef __cplusplus -} //end extern C -#endif diff --git a/src/capsule/heap/STLVector.cpp b/src/capsule/heap/STLVector.cpp deleted file mode 100644 index dafae7a7b..000000000 --- a/src/capsule/heap/STLVector.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Heap.cpp - * - * Created on: Dec 22, 2016 - * Author: wfg - */ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <new> //std::bad_alloc -#include <stdexcept> //std::runtime_error -/// \endcond - -#include "capsule/heap/STLVector.h" - - -namespace adios -{ -namespace capsule -{ - - -STLVector::STLVector( const std::string accessMode, const int rankMPI, const bool debugMode ): - Capsule( "Heap", accessMode, rankMPI, debugMode ) -{ - m_Data.reserve( 16777216 ); -} - - -STLVector::~STLVector( ) -{ } - - -char* STLVector::GetData( ) -{ - return m_Data.data( ); -} - - -char* STLVector::GetMetadata( ) -{ - return m_Metadata.data( ); -} - - -std::size_t STLVector::GetDataSize( ) const -{ - return m_Data.size( ); -} - - -std::size_t STLVector::GetMetadataSize( ) const -{ - return m_Metadata.size( ); -} - - -void STLVector::ResizeData( const std::size_t size ) -{ - if( m_DebugMode == true ) - { - try { m_Data.resize( size ); } - catch( std::bad_alloc& e ){ throw std::runtime_error( "ERROR: bad_alloc detected when resizing data buffer with size " + - std::to_string( size ) + "\n" ); } - } - else - { - m_Data.resize( size ); - } -} - -void STLVector::ResizeMetadata( const std::size_t size ) -{ - if( m_DebugMode == true ) - { - try { m_Metadata.resize( size ); } - catch( std::bad_alloc& e ){ throw std::runtime_error( "ERROR: bad_alloc detected when resizing metadata buffer with size " + - std::to_string( size ) + "\n" ); } - } - else - { - m_Metadata.resize( size ); - } -} - - -} //end namespace heap -} //end namespace diff --git a/src/capsule/shmem/ShmSystemV.cpp b/src/capsule/shmem/ShmSystemV.cpp deleted file mode 100644 index 8d3d508ac..000000000 --- a/src/capsule/shmem/ShmSystemV.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ShmSystemV.cpp - * - * Created on: Dec 22, 2016 - * Author: wfg - */ -/// \cond EXCLUDE_FROM_DOXYGEN -#include <sys/shm.h> -#include <ios> //std::ios_base::failure -/// \endcond - - -#include "capsule/shmem/ShmSystemV.h" - - -namespace adios -{ - - -ShmSystemV::ShmSystemV( const std::string accessMode, const int rankMPI, const std::string pathName, - const size_t dataSize, const size_t metadataSize, const bool debugMode ): - Capsule( "ShmSystemV", accessMode, rankMPI, debugMode ), - m_DataSize{ dataSize }, - m_MetadataSize{ metadataSize } -{ - // Data Shared memory sector - const std::string dataPath( pathName + "/adios.shm.data." + std::to_string( m_RankMPI ) ); - m_DataKey = ftok( dataPath.c_str(), m_RankMPI+1 ); - m_DataShmID = shmget( m_DataKey, m_DataSize, IPC_CREAT | 0666 ); - m_Data = (char*)shmat( m_DataShmID, NULL, 0 ); - - - // Metadata Shared memory sector - const std::string metadataPath( pathName + "/adios.shm.metadata." + std::to_string( m_RankMPI ) ); - m_MetadataKey = ftok( metadataPath.c_str(), m_RankMPI+1 ); //2nd field must be greater than zero and unique - m_MetadataShmID = shmget( m_MetadataKey, m_MetadataSize, IPC_CREAT | 0666 ); - m_Metadata = (char*)shmat( m_MetadataShmID, NULL, 0 ); - - if( m_DebugMode == true ) - CheckShm( ); -} - - -ShmSystemV::~ShmSystemV( ) -{ } - - -char* ShmSystemV::GetData( ) -{ - return m_Data; -} - - -char* ShmSystemV::GetMetadata( ) -{ - return m_Metadata; -} - - -std::size_t ShmSystemV::GetDataSize( ) const -{ - return m_DataSize; -} - - -std::size_t ShmSystemV::GetMetadataSize( ) const -{ - return m_MetadataSize; -} - - -void ShmSystemV::CheckShm( ) const -{ - if( m_DataShmID < 0) - throw std::ios_base::failure( "ERROR: Failed to create data shm segment of size " + std::to_string( m_DataSize ) + - " from call to ShmSystemV constructor\n" ); - - if( m_Data == nullptr ) - throw std::ios_base::failure( "ERROR: Failed to attach to data shm segment of size " + std::to_string( m_DataSize ) + - " and id " + std::to_string( m_DataShmID ) + - ", from call to ShmSystemV constructor\n" ); - - if( m_DataShmID < 0) - throw std::ios_base::failure( "ERROR: Failed to create metadata shm segment of size " + std::to_string( m_MetadataSize ) + - " from call to ShmSystemV constructor\n" ); - - - if( m_Metadata == nullptr ) - throw std::ios_base::failure( "ERROR: Failed to attach to metadata shm segment of size " + std::to_string( m_MetadataSize ) + - " and id " + std::to_string( m_MetadataShmID ) + - " from call to ShmSystemV constructor\n" ); -} - - - -} //end namespace diff --git a/src/core/Capsule.cpp b/src/core/Capsule.cpp deleted file mode 100644 index 98c933ca7..000000000 --- a/src/core/Capsule.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Capsule.cpp - * - * Created on: Nov 11, 2016 - * Author: wfg - */ - - -#include "core/Capsule.h" - - -namespace adios -{ - - -Capsule::Capsule( const std::string type, const std::string accessMode, const int rankMPI, - const bool debugMode ): - m_Type{ type }, - m_AccessMode{ accessMode }, - m_RankMPI{ rankMPI }, - m_DebugMode{ debugMode } -{ } - - -Capsule::~Capsule( ) -{ } - - -void Capsule::ResizeData( const std::size_t size ) -{ } - - -void Capsule::ResizeMetadata( const std::size_t size ) -{ } - - -} //end namespace diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp deleted file mode 100644 index db6002cf5..000000000 --- a/src/core/Engine.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Engine.cpp - * - * Created on: Dec 19, 2016 - * Author: wfg - */ - - -#include "core/Engine.h" -#include "core/Support.h" -#include "functions/adiosFunctions.h" - - -namespace adios -{ - - -Engine::Engine( ADIOS& adios, const std::string engineType, const std::string name, const std::string accessMode, - MPI_Comm mpiComm, const Method& method, const bool debugMode, const unsigned int nthreads, - const std::string endMessage ): - m_MPIComm{ mpiComm }, - m_EngineType{ engineType }, - m_Name{ name }, - m_AccessMode{ accessMode }, - m_Method{ method }, - m_ADIOS{ adios }, - m_DebugMode{ debugMode }, - m_nThreads{ nthreads }, - m_EndMessage( endMessage ) -{ - if( m_DebugMode == true ) - { - if( m_MPIComm == MPI_COMM_NULL ) - throw std::ios_base::failure( "ERROR: engine communicator is MPI_COMM_NULL," - " in call to ADIOS Open or Constructor\n" ); - } - - MPI_Comm_rank( m_MPIComm, &m_RankMPI ); - MPI_Comm_size( m_MPIComm, &m_SizeMPI ); -} - - -Engine::~Engine( ) -{ } - -void Engine::SetCallBack( std::function<void( const void*, std::string, std::string, std::string, Dims )> callback ){ } - -//should these functions throw an exception? -void Engine::Write( Variable<char>& variable, const char* values ){ } -void Engine::Write( Variable<unsigned char>& variable, const unsigned char* values ){ } -void Engine::Write( Variable<short>& variable, const short* values ){ } -void Engine::Write( Variable<unsigned short>& variable, const unsigned short* values ){ } -void Engine::Write( Variable<int>& variable, const int* values ){ } -void Engine::Write( Variable<unsigned int>& variable, const unsigned int* values ){ } -void Engine::Write( Variable<long int>& variable, const long int* values ){ } -void Engine::Write( Variable<unsigned long int>& variable, const unsigned long int* values ){ } -void Engine::Write( Variable<long long int>& variable, const long long int* values ){ } -void Engine::Write( Variable<unsigned long long int>& variable, const unsigned long long int* values ){ } -void Engine::Write( Variable<float>& variable, const float* values ){ } -void Engine::Write( Variable<double>& variable, const double* values ){ } -void Engine::Write( Variable<long double>& variable, const long double* values ){ } -void Engine::Write( Variable<std::complex<float>>& variable, const std::complex<float>* values ){ } -void Engine::Write( Variable<std::complex<double>>& variable, const std::complex<double>* values ){ } -void Engine::Write( Variable<std::complex<long double>>& variable, const std::complex<long double>* values ){ } -void Engine::Write( VariableCompound& variable, const void* values ){ } - -void Engine::Write( const std::string variableName, const char* values ){ } -void Engine::Write( const std::string variableName, const unsigned char* values ){ } -void Engine::Write( const std::string variableName, const short* values ){ } -void Engine::Write( const std::string variableName, const unsigned short* values ){ } -void Engine::Write( const std::string variableName, const int* values ){ } -void Engine::Write( const std::string variableName, const unsigned int* values ){ } -void Engine::Write( const std::string variableName, const long int* values ){ } -void Engine::Write( const std::string variableName, const unsigned long int* values ){ } -void Engine::Write( const std::string variableName, const long long int* values ){ } -void Engine::Write( const std::string variableName, const unsigned long long int* values ){ } -void Engine::Write( const std::string variableName, const float* values ){ } -void Engine::Write( const std::string variableName, const double* values ){ } -void Engine::Write( const std::string variableName, const long double* values ){ } -void Engine::Write( const std::string variableName, const std::complex<float>* values ){ } -void Engine::Write( const std::string variableName, const std::complex<double>* values ){ } -void Engine::Write( const std::string variableName, const std::complex<long double>* values ){ } -void Engine::Write( const std::string variableName, const void* values ){ } - -void Engine::Advance( float timeout_sec ){ } -void Engine::Advance( AdvanceMode mode, float timeout_sec ){ } -void Engine::AdvanceAsync ( AdvanceMode mode, std::function<void( std::shared_ptr<adios::Engine> )> callback ){ } - - -void Engine::Close( const int transportIndex ){ } - -//READ -Variable<void>* Engine::InquireVariable( const std::string name, const bool readIn ){ return nullptr; } -Variable<char>* Engine::InquireVariableChar( const std::string name, const bool readIn ){ return nullptr; } -Variable<unsigned char>* Engine::InquireVariableUChar( const std::string name, const bool readIn ){ return nullptr; } -Variable<short>* Engine::InquireVariableShort( const std::string name, const bool readIn ){ return nullptr; } -Variable<unsigned short>* Engine::InquireVariableUShort( const std::string name, const bool readIn ){ return nullptr; } -Variable<int>* Engine::InquireVariableInt( const std::string name, const bool readIn ){ return nullptr; } -Variable<unsigned int>* Engine::InquireVariableUInt( const std::string name, const bool readIn ){ return nullptr; } -Variable<long int>* Engine::InquireVariableLInt( const std::string name, const bool readIn ){ return nullptr; } -Variable<unsigned long int>* Engine::InquireVariableULInt( const std::string name, const bool readIn ){ return nullptr; } -Variable<long long int>* Engine::InquireVariableLLInt( const std::string name, const bool readIn ){ return nullptr; } -Variable<unsigned long long int>* Engine::InquireVariableULLInt( const std::string name, const bool readIn ){ return nullptr; } -Variable<float>* Engine::InquireVariableFloat( const std::string name, const bool readIn ){ return nullptr; } -Variable<double>* Engine::InquireVariableDouble( const std::string name, const bool readIn ){ return nullptr; } -Variable<long double>* Engine::InquireVariableLDouble( const std::string name, const bool readIn ){ return nullptr; } -Variable<std::complex<float>>* Engine::InquireVariableCFloat( const std::string name, const bool readIn ){ return nullptr; } -Variable<std::complex<double>>* Engine::InquireVariableCDouble( const std::string name, const bool readIn ){ return nullptr; } -Variable<std::complex<long double>>* Engine::InquireVariableCLDouble( const std::string name, const bool readIn ){ return nullptr; } -VariableCompound* Engine::InquireVariableCompound( const std::string name, const bool readIn ){ return nullptr; } - -void Engine::Read( Variable<double>& variable, const double* values ){ } -void Engine::ScheduleRead( Variable<double>& variable, const double* values ){ } -void Engine::Release( ){ } - -//PROTECTED -void Engine::Init( ) -{ } - -void Engine::InitParameters( ) -{ } - -void Engine::InitTransports( ) -{ } - - -void Engine::CheckParameter( const std::map<std::string, std::string>::const_iterator itParam, - const std::map<std::string, std::string>& parameters, - const std::string parameterName, const std::string hint ) const -{ - if( itParam == parameters.end() ) - throw std::invalid_argument( "ERROR: parameter name " + parameterName + " not found " + hint ); -} - - -bool Engine::TransportNamesUniqueness( ) const -{ - auto lf_CheckTransportsType = [&]( const std::set<std::string>& specificType ) -> bool - { - std::set<std::string> transportNames; - - for( const auto& parameters : m_Method.m_TransportParameters ) - { - auto itTransport = parameters.find( "transport" ); - if( m_DebugMode == true ) - { - if( itTransport == parameters.end() ) - throw std::invalid_argument( "ERROR: transport not defined in Method input to Engine " + m_Name ); - } - - const std::string type( itTransport->second ); - if( specificType.count( type ) == 1 ) //file transports type - { - std::string name( m_Name ); - auto itName = parameters.find("name"); - if( itName != parameters.end() ) - name = itName->second; - - if( transportNames.count( name ) == 0 ) - transportNames.insert( name ); - else - return false; - } - } - return true; - }; - - return lf_CheckTransportsType( Support::FileTransports ); -} - - -void Engine::CheckTransportIndex( const int transportIndex ) -{ - if( m_DebugMode == true ) - { - if( transportIndex >= static_cast<int>( m_Transports.size() ) || transportIndex < -1 ) - { - throw std::invalid_argument( "ERROR: transport index " + std::to_string( transportIndex ) + - " is out of range, in call to " + m_Name + "Close \n"); - } - } -} - - -} //end namespace diff --git a/src/core/Method.cpp b/src/core/Method.cpp deleted file mode 100644 index 08660e782..000000000 --- a/src/core/Method.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Method.cpp - * - * Created on: Jan 6, 2017 - * Author: wfg - */ - - -#include "core/Method.h" -#include "functions/adiosFunctions.h" - - -namespace adios -{ - - -Method::Method( const std::string name, const bool debugMode ): - m_Name{ name }, - m_DebugMode{ debugMode } -{ - // m_Type can stay empty (forcing the choice of the default engine) - m_nThreads = 1; -} - - -Method::~Method( ) -{ } - -bool Method::isUserDefined() -{ - return false; //TODO: check if XML has the method defined -} - -void Method::SetEngine( const std::string type ) -{ - m_Type = type; -} - -void Method::AllowThreads( const int nThreads ) -{ - if (nThreads > 1) - m_nThreads = nThreads; - else - m_nThreads = 1; -} - - -//PRIVATE Functions -void Method::AddTransportParameters( const std::string type, const std::vector<std::string>& parameters ) -{ - if( m_DebugMode == true ) - { - if( type.empty() || type.find("=") != type.npos ) - throw std::invalid_argument( "ERROR: first argument in AddTransport must be a single word for transport\n" ); - } - - std::map<std::string, std::string> mapParameters = BuildParametersMap( parameters, m_DebugMode ); - if( m_DebugMode == true ) - { - if( mapParameters.count("transport") == 1 ) - std::invalid_argument( "ERROR: transport can't be redefined with \"transport=type\", " - "type must be the first argument\n" ); - } - - mapParameters["transport"] = type; - m_TransportParameters.push_back( mapParameters ); -} - - - -} //end namespace - - diff --git a/src/core/Support.cpp b/src/core/Support.cpp deleted file mode 100644 index 670838cda..000000000 --- a/src/core/Support.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Support.cpp - * - * Created on: Oct 18, 2016 - * Author: wfg - */ - - -#include "core/Support.h" -#include "functions/adiosTemplates.h" - - -namespace adios -{ - - -const std::string Support::Version{ "2.00" }; - - -const std::set<std::string> Support::HostLanguages{ - { "C++", "C", "Fortran" } -}; - - -const std::set<std::string> Support::Transports{ - { "NULL", "POSIX", "FStream", "MdtmMan" } // "MPI", "MPI_LUSTRE", "MPI_AGGREGATE", "DATASPACES", "DIMES", "FLEXPATH", "PHDF5", "NC4", "ICEE" } -}; - - -const std::set<std::string> Support::Transforms{ - { "none", "identity", "bzip2", "isobar", "szip" , "zlib" } -}; - - -const std::map<std::string, std::set<std::string> > Support::Datatypes -{ - { "C++", - { - "char", "std::string", "string", - "unsigned char", - "short", - "unsigned short", - "int", "integer", - "unsigned int", - "long int", "long", - "unsigned long int", "unsigned long", - "long long int", "long long", - "unsigned long long int", "unsigned long long", - "float", - "float complex", - "double", - "long double", - "double complex", "std::complex<double>", "complex<double>" - } - }, - { "C", - { - "char", - "unsigned char", - "short", - "unsigned short", - "int", "integer" - "unsigned int", "unsigned integer", - "long int", "long", "long integer", - "unsigned long int", "unsigned long", "unsigned long integer", - "long long int", "long long", "long long integer", - "unsigned long long int", "unsigned long long", "unsigned long long integer", - "float", - "float complex" - "double", - "long double", - "double complex" - } - }, - { "Fortran", - { - "character", - "integer*2", - "integer", "real*2", - "real", "real*4", - "double precision", "real*8", - "complex", - "double complex" - } - } -}; - - -const std::map<std::string, std::set<std::string> > Support::DatatypesAliases -{ - { GetType<char>(), { GetType<char>(), "character" } }, - { GetType<unsigned char>(), { GetType<unsigned char>(), "unsigned character" } }, - { GetType<short>(), { GetType<short>(), "integer*2" } }, - { GetType<unsigned short>(), { GetType<unsigned short>() } }, - { GetType<int>(), { GetType<int>(), "integer" } }, - { GetType<unsigned int>(), { GetType<unsigned int>(), "unsigned integer" } }, - { GetType<long int>(), { GetType<long int>(), "long", "long integer" } }, - { GetType<unsigned long int>(), { GetType<unsigned long int>(), "unsigned long", "unsigned long integer" } }, - { GetType<long long int>(), { GetType<long long int>(), "long long", "long long integer" } }, - { GetType<unsigned long long int>(), { GetType<unsigned long long int>(), "unsigned long long", "unsigned long long integer" } }, - { GetType<float>(), { GetType<float>(), "real", "real*4" } }, - { GetType<double>(), { GetType<double>(), "double precision", "real*8" } }, - { GetType<long double>(), { GetType<long double>(), "long double precision", "real*16" } } -}; - - -const std::set<std::string> Support::FileTransports{ - { "POSIX", "File", "FStream", "MPIFile" } -}; - - - - -} //end namespace - diff --git a/src/core/Transform.cpp b/src/core/Transform.cpp deleted file mode 100644 index 89b882e55..000000000 --- a/src/core/Transform.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Transform.cpp - * - * Created on: Dec 5, 2016 - * Author: wfg - */ - -#include "core/Transform.h" - - -namespace adios -{ - - -Transform::Transform( const std::string method ): - m_Method( method ) -{ } - - -Transform::~Transform( ) -{ } - - -void Transform::Compress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) -{ } - - -void Transform::Decompress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) -{ } - - -} //end namespace diff --git a/src/core/Transport.cpp b/src/core/Transport.cpp deleted file mode 100644 index 4bbc1f743..000000000 --- a/src/core/Transport.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Transport.cpp - * - * Created on: Dec 5, 2016 - * Author: wfg - */ - -#include "core/Transport.h" - - -namespace adios -{ - -Transport::Transport( const std::string type, MPI_Comm mpiComm, const bool debugMode ): - m_Type{ type }, - m_MPIComm{ mpiComm }, - m_DebugMode{ debugMode } -{ - MPI_Comm_rank( m_MPIComm, &m_RankMPI ); - MPI_Comm_size( m_MPIComm, &m_SizeMPI ); -} - - -Transport::~Transport( ) -{ } - - -void Transport::SetBuffer( char* buffer, size_t size ) -{ } - - -void Transport::Flush( ) -{ } - - -void Transport::Close( ) -{ } - - -void Transport::InitProfiler( const std::string accessMode, const Support::Resolutions resolution ) -{ - m_Profiler.m_Timers.emplace_back( "open", Support::Resolutions::mus ); - - if( accessMode == "w" || accessMode == "write" ) - m_Profiler.m_Timers.emplace_back( "write", resolution ); - - else if( accessMode == "a" || accessMode == "append" ) - m_Profiler.m_Timers.emplace_back( "append", resolution ); - - else if( accessMode == "r" || accessMode == "read" ) - m_Profiler.m_Timers.emplace_back( "read", resolution ); - - m_Profiler.m_Timers.emplace_back( "close", Support::Resolutions::mus ); - - m_Profiler.m_TotalBytes.push_back( 0 ); - m_Profiler.m_IsActive = true; -} - - - -} //end namespace - diff --git a/src/engine/adios1/ADIOS1Reader.cpp b/src/engine/adios1/ADIOS1Reader.cpp deleted file mode 100644 index edff32aad..000000000 --- a/src/engine/adios1/ADIOS1Reader.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * BPFileReader.cpp - * - * Created on: Feb 27, 2017 - * Author: wfg - */ - - - -#include "engine/bp/BPFileReader.h" - -#include "transport/file/FileDescriptor.h" // uses POSIX -#include "transport/file/FilePointer.h" // uses C FILE* -#include "core/Support.h" -#include "functions/adiosFunctions.h" //CSVToVector - -//supported transports -#include "transport/file/FStream.h" // uses C++ fstream - - -namespace adios -{ - -BPFileReader::BPFileReader( ADIOS& adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method& method, const IOMode iomode, const float timeout_sec, - const bool debugMode, const unsigned int nthreads ): - Engine( adios, "BPFileReader", name, accessMode, mpiComm, method, debugMode, nthreads, " BPFileReader constructor (or call to ADIOS Open).\n" ), - m_Buffer( accessMode, m_RankMPI, m_DebugMode ) -{ - Init( ); -} - -BPFileReader::~BPFileReader( ) -{ } - - -Variable<void>* BPFileReader::InquireVariable( const std::string name, const bool readIn ) //not yet implemented -{ return nullptr; } - -Variable<char>* BPFileReader::InquireVariableChar( const std::string name, const bool readIn ) -{ return InquireVariableCommon<char>( name, readIn ); } - -Variable<unsigned char>* BPFileReader::InquireVariableUChar( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned char>( name, readIn ); } - -Variable<short>* BPFileReader::InquireVariableShort( const std::string name, const bool readIn ) -{ return InquireVariableCommon<short>( name, readIn ); } - -Variable<unsigned short>* BPFileReader::InquireVariableUShort( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned short>( name, readIn ); } - -Variable<int>* BPFileReader::InquireVariableInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<int>( name, readIn ); } - -Variable<unsigned int>* BPFileReader::InquireVariableUInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned int>( name, readIn ); } - -Variable<long int>* BPFileReader::InquireVariableLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long int>( name, readIn ); } - -Variable<unsigned long int>* BPFileReader::InquireVariableULInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned long int>( name, readIn ); } - -Variable<long long int>* BPFileReader::InquireVariableLLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long long int>( name, readIn ); } - -Variable<unsigned long long int>* BPFileReader::InquireVariableULLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned long long int>( name, readIn ); } - -Variable<float>* BPFileReader::InquireVariableFloat( const std::string name, const bool readIn ) -{ return InquireVariableCommon<float>( name, readIn ); } - -Variable<double>* BPFileReader::InquireVariableDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<double>( name, readIn ); } - -Variable<long double>* BPFileReader::InquireVariableLDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long double>( name, readIn ); } - -Variable<std::complex<float>>* BPFileReader::InquireVariableCFloat( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<float>>( name, readIn ); } - -Variable<std::complex<double>>* BPFileReader::InquireVariableCDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<double>>( name, readIn ); } - -Variable<std::complex<long double>>* BPFileReader::InquireVariableCLDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<long double>>( name, readIn ); } - -VariableCompound* BPFileReader::InquireVariableCompound( const std::string name, const bool readIn ) -{ return nullptr; } - - -void BPFileReader::Close( const int transportIndex ) -{ - -} - - -//PRIVATE -void BPFileReader::Init( ) -{ - if( m_DebugMode == true ) - { - if( m_AccessMode != "r" && m_AccessMode != "read" ) - throw std::invalid_argument( "ERROR: BPFileReader doesn't support access mode " + m_AccessMode + - ", in call to ADIOS Open or BPFileReader constructor\n" ); - } - - InitCapsules( ); - InitTransports( ); -} - - -void BPFileReader::InitCapsules( ) -{ - //here init memory capsules -} - - -void BPFileReader::InitTransports( ) //maybe move this? -{ - if( m_DebugMode == true ) - { - if( TransportNamesUniqueness( ) == false ) - { - throw std::invalid_argument( "ERROR: two transports of the same kind (e.g file IO) " - "can't have the same name, modify with name= in Method AddTransport\n" ); - } - } - - for( const auto& parameters : m_Method.m_TransportParameters ) - { - auto itTransport = parameters.find( "transport" ); - if( itTransport->second == "file" || itTransport->second == "File" ) - { - auto itLibrary = parameters.find( "library" ); - if( itLibrary == parameters.end() || itLibrary->second == "POSIX" ) //use default POSIX - { - auto file = std::make_shared<transport::FileDescriptor>( m_MPIComm, m_DebugMode ); - //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - } - else if( itLibrary->second == "FILE*" || itLibrary->second == "stdio.h" ) - { - auto file = std::make_shared<transport::FilePointer>( m_MPIComm, m_DebugMode ); - //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - - } - else if( itLibrary->second == "fstream" || itLibrary->second == "std::fstream" ) - { - auto file = std::make_shared<transport::FStream>( m_MPIComm, m_DebugMode ); - //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - } - else if( itLibrary->second == "MPI-IO" ) - { - - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: file transport library " + itLibrary->second + " not supported, in " + - m_Name + m_EndMessage ); - } - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: transport " + itTransport->second + " (you mean File?) not supported, in " + - m_Name + m_EndMessage ); - } - } -} - - -} //end namespace - - diff --git a/src/engine/adios1/ADIOS1Writer.cpp b/src/engine/adios1/ADIOS1Writer.cpp deleted file mode 100644 index 0adc032e6..000000000 --- a/src/engine/adios1/ADIOS1Writer.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* - * ADIOS1Writer.cpp - * Class to write files using old adios 1.x library. - * It requires adios 1.x installed - * - * Created on: Mar 27, 2017 - * Author: pnb - */ - -#include "engine/adios1/ADIOS1Writer.h" -#include "ADIOS.h" - -extern int adios_verbose_level; -extern int adios_errno; - -namespace adios -{ - - -ADIOS1Writer::ADIOS1Writer( ADIOS& adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method& method, const IOMode iomode, const float timeout_sec, - const bool debugMode, const unsigned int nthreads ): - Engine( adios, "ADIOS1Writer", name, accessMode, mpiComm, method, debugMode, nthreads, " ADIOS1Writer constructor (or call to ADIOS Open).\n" ), - m_groupname{method.m_Name.c_str()}, - m_filename{name.c_str()}, - m_comm{mpiComm} -{ - Init( ); - adios_open( &m_adios_file, m_groupname, m_filename, accessMode.c_str(), m_comm ); - if( adios_errno == err_no_error ) - { - m_IsFileOpen = true; - } -} - - -ADIOS1Writer::~ADIOS1Writer( ) -{ - if (m_IsFileOpen ) - { - adios_close( m_adios_file ); - m_IsFileOpen = false; - } -} - - -void ADIOS1Writer::Init( ) -{ - if( !m_initialized ) - { - adios_init_noxml( m_comm ); - m_initialized = true; - } - adios_declare_group( &m_adios_group, m_groupname, "", adios_stat_default ); - - InitParameters( ); - InitTransports( ); -} - -bool ADIOS1Writer::ReOpenAsNeeded( ) -{ - if( !m_IsFileOpen ) - { - adios_open( &m_adios_file, m_groupname, m_filename, "a", m_comm ); - if( adios_errno == err_no_error ) - { - m_IsFileOpen = true; - adios_delete_vardefs( m_adios_group ); - } - } - return m_IsFileOpen; -} - -void ADIOS1Writer::DefineVariable ( std::string name, bool isScalar, enum ADIOS_DATATYPES vartype, - std::string ldims, std::string gdims, std::string offs ) -{ - if( isScalar ) - { - adios_define_var( m_adios_group, name.c_str(), "", vartype, "", "", "" ); - } - else - { - adios_define_var( m_adios_group, name.c_str(), "", vartype, ldims.c_str(), gdims.c_str(), offs.c_str()); - } -} - -void ADIOS1Writer::WriteVariable ( std::string name, bool isScalar, enum ADIOS_DATATYPES vartype, - std::string ldims, std::string gdims, std::string offs, const void * values ) -{ - if( ReOpenAsNeeded() ) - { - DefineVariable( name, isScalar, vartype, ldims, gdims, offs ); - adios_write( m_adios_file, name.c_str(), values ); - } -} - - -void ADIOS1Writer::Write( Variable<char>& variable, const char* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_byte, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<unsigned char>& variable, const unsigned char* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_unsigned_byte, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<short>& variable, const short* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_short, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<unsigned short>& variable, const unsigned short* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_unsigned_short, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<int>& variable, const int* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_integer, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<unsigned int>& variable, const unsigned int* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_unsigned_integer, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<long int>& variable, const long int* values ) -{ - enum ADIOS_DATATYPES type = adios_integer; // long int is usually 4 bytes which is adios_integer - if( sizeof(long int) == 8 ) - { - type = adios_long; - } - WriteVariable( variable.m_Name, variable.m_IsScalar, type, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<unsigned long int>& variable, const unsigned long int* values ) -{ - enum ADIOS_DATATYPES type = adios_unsigned_integer; // long int is usually 4 bytes - if( sizeof(long int) == 8 ) - { - type = adios_unsigned_long; - } - WriteVariable( variable.m_Name, variable.m_IsScalar, type, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<long long int>& variable, const long long int* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_long, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<unsigned long long int>& variable, const unsigned long long int* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_unsigned_long, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<float>& variable, const float* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_real, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<double>& variable, const double* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_double, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<long double>& variable, const long double* values ) -{ - /* TODO: This is faulty: adios_long_double expects 16 bytes per elements, but long double is compiler dependent */ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_long_double, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<std::complex<float>>& variable, const std::complex<float>* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_complex, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<std::complex<double>>& variable, const std::complex<double>* values ) -{ - WriteVariable( variable.m_Name, variable.m_IsScalar, adios_double_complex, - variable.GetDimensionAsString(), variable.GetGlobalDimensionAsString(), variable.GetOffsetsAsString(), - values); -} - -void ADIOS1Writer::Write( Variable<std::complex<long double>>& variable, const std::complex<long double>* values ) -{ - throw std::invalid_argument( "ERROR: Adios 1.x does not support complex<long double> type, so it cannot write variable " + - variable.m_Name + "\n"); -} - -void ADIOS1Writer::Write( VariableCompound& variable, const void* values ) -{ - throw std::invalid_argument( "ERROR: Adios 1.x does not support compound types, so it cannot write variable " + - variable.m_Name + "\n"); -} - -//String version -void ADIOS1Writer::Write( const std::string variableName, const char* values ) -{ Write( m_ADIOS.GetVariable<char>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const unsigned char* values ) -{ Write( m_ADIOS.GetVariable<unsigned char>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const short* values ) -{ Write( m_ADIOS.GetVariable<short>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const unsigned short* values ) -{ Write( m_ADIOS.GetVariable<unsigned short>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const int* values ) -{ Write( m_ADIOS.GetVariable<int>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const unsigned int* values ) -{ Write( m_ADIOS.GetVariable<unsigned int>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const long int* values ) -{ Write( m_ADIOS.GetVariable<long int>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const unsigned long int* values ) -{ Write( m_ADIOS.GetVariable<unsigned long int>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const long long int* values ) -{ Write( m_ADIOS.GetVariable<long long int>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const unsigned long long int* values ) -{ Write( m_ADIOS.GetVariable<unsigned long long int>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const float* values ) -{ Write( m_ADIOS.GetVariable<float>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const double* values ) -{ Write( m_ADIOS.GetVariable<double>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const long double* values ) -{ Write( m_ADIOS.GetVariable<long double>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const std::complex<float>* values ) -{ Write( m_ADIOS.GetVariable<std::complex<float>>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const std::complex<double>* values ) -{ Write( m_ADIOS.GetVariable<std::complex<double>>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const std::complex<long double>* values ) -{ Write( m_ADIOS.GetVariable<std::complex<long double>>( variableName ), values ); } - -void ADIOS1Writer::Write( const std::string variableName, const void* values ) //Compound type -{ - throw std::invalid_argument( "ERROR: Adios 1.x does not support compound types, so it cannot write variable " + - variableName + "\n"); -} - - -void ADIOS1Writer::Advance( ) -{ - if (m_IsFileOpen ) - { - adios_close( m_adios_file ); - m_IsFileOpen = false; - } -} - - -void ADIOS1Writer::Close( const int transportIndex ) -{ - if (m_IsFileOpen ) - { - adios_close( m_adios_file ); - m_IsFileOpen = false; - } -} - - -//PRIVATE FUNCTIONS -void ADIOS1Writer::InitParameters( ) -{ - auto itMaxBufferSize = m_Method.m_Parameters.find( "max_size_MB" ); - if( itMaxBufferSize != m_Method.m_Parameters.end() ) - { - adios_set_max_buffer_size( std::stoul( itMaxBufferSize->second ) ); - } - - auto itVerbosity = m_Method.m_Parameters.find( "verbose" ); - if( itVerbosity != m_Method.m_Parameters.end() ) - { - int verbosity = std::stoi( itVerbosity->second ); - if( m_DebugMode == true ) - { - if( verbosity < 0 || verbosity > 5 ) - throw std::invalid_argument( "ERROR: Method verbose argument must be an integer in the range [0,5], in call to Open or Engine constructor\n" ); - } - adios_verbose_level = verbosity; - } -} - - -void ADIOS1Writer::InitTransports( ) -{ - if( m_DebugMode == true ) - { - if( TransportNamesUniqueness( ) == false ) - { - throw std::invalid_argument( "ERROR: two transports of the same kind (e.g file IO) " - "can't have the same name, modify with name= in Method AddTransport\n" ); - } - } - - for( const auto& parameters : m_Method.m_TransportParameters ) - { - auto itTransport = parameters.find( "transport" ); - - if( itTransport->second == "file" || itTransport->second == "File" ) - { - auto itLibrary = parameters.find( "library" ); - if( itLibrary == parameters.end() || itLibrary->second == "POSIX" ) //use default POSIX - { - adios_select_method( m_adios_group, "POSIX", "", "" ); - } - else if( itLibrary->second == "MPI_File" || itLibrary->second == "MPI-IO" ) - { - adios_select_method( m_adios_group, "MPI", "", "" ); - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: file transport library " + itLibrary->second + " not supported, in " + - m_Name + m_EndMessage ); - } - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: transport " + itTransport->second + " (you mean File?) not supported, in " + - m_Name + m_EndMessage ); - } - } -} - - - -} //end namespace adios diff --git a/src/engine/bp/BPFileReader.cpp b/src/engine/bp/BPFileReader.cpp deleted file mode 100644 index edff32aad..000000000 --- a/src/engine/bp/BPFileReader.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * BPFileReader.cpp - * - * Created on: Feb 27, 2017 - * Author: wfg - */ - - - -#include "engine/bp/BPFileReader.h" - -#include "transport/file/FileDescriptor.h" // uses POSIX -#include "transport/file/FilePointer.h" // uses C FILE* -#include "core/Support.h" -#include "functions/adiosFunctions.h" //CSVToVector - -//supported transports -#include "transport/file/FStream.h" // uses C++ fstream - - -namespace adios -{ - -BPFileReader::BPFileReader( ADIOS& adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method& method, const IOMode iomode, const float timeout_sec, - const bool debugMode, const unsigned int nthreads ): - Engine( adios, "BPFileReader", name, accessMode, mpiComm, method, debugMode, nthreads, " BPFileReader constructor (or call to ADIOS Open).\n" ), - m_Buffer( accessMode, m_RankMPI, m_DebugMode ) -{ - Init( ); -} - -BPFileReader::~BPFileReader( ) -{ } - - -Variable<void>* BPFileReader::InquireVariable( const std::string name, const bool readIn ) //not yet implemented -{ return nullptr; } - -Variable<char>* BPFileReader::InquireVariableChar( const std::string name, const bool readIn ) -{ return InquireVariableCommon<char>( name, readIn ); } - -Variable<unsigned char>* BPFileReader::InquireVariableUChar( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned char>( name, readIn ); } - -Variable<short>* BPFileReader::InquireVariableShort( const std::string name, const bool readIn ) -{ return InquireVariableCommon<short>( name, readIn ); } - -Variable<unsigned short>* BPFileReader::InquireVariableUShort( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned short>( name, readIn ); } - -Variable<int>* BPFileReader::InquireVariableInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<int>( name, readIn ); } - -Variable<unsigned int>* BPFileReader::InquireVariableUInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned int>( name, readIn ); } - -Variable<long int>* BPFileReader::InquireVariableLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long int>( name, readIn ); } - -Variable<unsigned long int>* BPFileReader::InquireVariableULInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned long int>( name, readIn ); } - -Variable<long long int>* BPFileReader::InquireVariableLLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long long int>( name, readIn ); } - -Variable<unsigned long long int>* BPFileReader::InquireVariableULLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned long long int>( name, readIn ); } - -Variable<float>* BPFileReader::InquireVariableFloat( const std::string name, const bool readIn ) -{ return InquireVariableCommon<float>( name, readIn ); } - -Variable<double>* BPFileReader::InquireVariableDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<double>( name, readIn ); } - -Variable<long double>* BPFileReader::InquireVariableLDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long double>( name, readIn ); } - -Variable<std::complex<float>>* BPFileReader::InquireVariableCFloat( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<float>>( name, readIn ); } - -Variable<std::complex<double>>* BPFileReader::InquireVariableCDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<double>>( name, readIn ); } - -Variable<std::complex<long double>>* BPFileReader::InquireVariableCLDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<long double>>( name, readIn ); } - -VariableCompound* BPFileReader::InquireVariableCompound( const std::string name, const bool readIn ) -{ return nullptr; } - - -void BPFileReader::Close( const int transportIndex ) -{ - -} - - -//PRIVATE -void BPFileReader::Init( ) -{ - if( m_DebugMode == true ) - { - if( m_AccessMode != "r" && m_AccessMode != "read" ) - throw std::invalid_argument( "ERROR: BPFileReader doesn't support access mode " + m_AccessMode + - ", in call to ADIOS Open or BPFileReader constructor\n" ); - } - - InitCapsules( ); - InitTransports( ); -} - - -void BPFileReader::InitCapsules( ) -{ - //here init memory capsules -} - - -void BPFileReader::InitTransports( ) //maybe move this? -{ - if( m_DebugMode == true ) - { - if( TransportNamesUniqueness( ) == false ) - { - throw std::invalid_argument( "ERROR: two transports of the same kind (e.g file IO) " - "can't have the same name, modify with name= in Method AddTransport\n" ); - } - } - - for( const auto& parameters : m_Method.m_TransportParameters ) - { - auto itTransport = parameters.find( "transport" ); - if( itTransport->second == "file" || itTransport->second == "File" ) - { - auto itLibrary = parameters.find( "library" ); - if( itLibrary == parameters.end() || itLibrary->second == "POSIX" ) //use default POSIX - { - auto file = std::make_shared<transport::FileDescriptor>( m_MPIComm, m_DebugMode ); - //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - } - else if( itLibrary->second == "FILE*" || itLibrary->second == "stdio.h" ) - { - auto file = std::make_shared<transport::FilePointer>( m_MPIComm, m_DebugMode ); - //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - - } - else if( itLibrary->second == "fstream" || itLibrary->second == "std::fstream" ) - { - auto file = std::make_shared<transport::FStream>( m_MPIComm, m_DebugMode ); - //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - } - else if( itLibrary->second == "MPI-IO" ) - { - - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: file transport library " + itLibrary->second + " not supported, in " + - m_Name + m_EndMessage ); - } - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: transport " + itTransport->second + " (you mean File?) not supported, in " + - m_Name + m_EndMessage ); - } - } -} - - -} //end namespace - - diff --git a/src/engine/bp/BPFileWriter.cpp b/src/engine/bp/BPFileWriter.cpp deleted file mode 100644 index 775fbe44a..000000000 --- a/src/engine/bp/BPFileWriter.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - * BPFileWriter.cpp - * - * Created on: Dec 19, 2016 - * Author: wfg - */ - -#include "engine/bp/BPFileWriter.h" -#include "ADIOS.h" - -//supported transports -#include "transport/file/FileDescriptor.h" -#include "transport/file/FilePointer.h" -#include "transport/file/FStream.h" - -namespace adios -{ - - -BPFileWriter::BPFileWriter( ADIOS& adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method& method, const IOMode iomode, const float timeout_sec, - const bool debugMode, const unsigned int nthreads ): - Engine( adios, "BPFileWriter", name, accessMode, mpiComm, method, debugMode, nthreads, " BPFileWriter constructor (or call to ADIOS Open).\n" ), - m_Buffer{ capsule::STLVector( accessMode, m_RankMPI, m_DebugMode ) }, - m_BP1Aggregator{ format::BP1Aggregator( m_MPIComm, debugMode ) }, - m_MaxBufferSize{ m_Buffer.m_Data.max_size() } -{ - m_MetadataSet.TimeStep = 1; //starting at one to be compatible with ADIOS1.x - Init( ); -} - - -BPFileWriter::~BPFileWriter( ) -{ } - - -void BPFileWriter::Init( ) -{ - InitParameters( ); - InitTransports( ); - InitProcessGroup( ); -} - - -void BPFileWriter::Write( Variable<char>& variable, const char* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<unsigned char>& variable, const unsigned char* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<short>& variable, const short* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<unsigned short>& variable, const unsigned short* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<int>& variable, const int* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<unsigned int>& variable, const unsigned int* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<long int>& variable, const long int* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<unsigned long int>& variable, const unsigned long int* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<long long int>& variable, const long long int* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<unsigned long long int>& variable, const unsigned long long int* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<float>& variable, const float* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<double>& variable, const double* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<long double>& variable, const long double* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<std::complex<float>>& variable, const std::complex<float>* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<std::complex<double>>& variable, const std::complex<double>* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( Variable<std::complex<long double>>& variable, const std::complex<long double>* values ) -{ WriteVariableCommon( variable, values ); } - -void BPFileWriter::Write( VariableCompound& variable, const void* values ) -{ } - -//String version -void BPFileWriter::Write( const std::string variableName, const char* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<char>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const unsigned char* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned char>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const short* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<short>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const unsigned short* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned short>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<int>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const unsigned int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned int>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<long int>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const unsigned long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned long int>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const long long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<long long int>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const unsigned long long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned long long int>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const float* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<float>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const double* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<double>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const long double* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<long double>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const std::complex<float>* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<float>>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const std::complex<double>* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<double>>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const std::complex<long double>* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<long double>>( variableName ), values ); } - -void BPFileWriter::Write( const std::string variableName, const void* values ) //Compound type -{ } - - -void BPFileWriter::Advance( float timeout_sec ) -{ - m_BP1Writer.Advance( m_MetadataSet, m_Buffer ); -} - - -void BPFileWriter::Close( const int transportIndex ) -{ - CheckTransportIndex( transportIndex ); - if( transportIndex == -1 ) - { - for( auto& transport : m_Transports ) //by reference or value or it doesn't matter? - m_BP1Writer.Close( m_MetadataSet, m_Buffer, *transport, m_IsFirstClose, false ); //false: not using aggregation for now - } - else - { - m_BP1Writer.Close( m_MetadataSet, m_Buffer, *m_Transports[transportIndex], m_IsFirstClose, false ); //false: not using aggregation for now - } - - if( m_MetadataSet.Log.m_IsActive == true ) - { - bool allClose = true; - for( auto& transport : m_Transports ) - { - if( transport->m_IsOpen == true ) - { - allClose = false; - break; - } - } - if( allClose == true ) //aggregate and write profiling.log - { - const std::string rankLog = m_BP1Writer.GetRankProfilingLog( m_RankMPI, m_MetadataSet, m_Transports ); - - const std::string fileName( m_BP1Writer.GetDirectoryName(m_Name) + "/profiling.log" ); - m_BP1Aggregator.WriteProfilingLog( fileName, rankLog ); - } - } - -} - - -//PRIVATE FUNCTIONS -void BPFileWriter::InitParameters( ) -{ - auto itGrowthFactor = m_Method.m_Parameters.find( "buffer_growth" ); - if( itGrowthFactor != m_Method.m_Parameters.end() ) - { - const float growthFactor = std::stof( itGrowthFactor->second ); - if( m_DebugMode == true ) - { - if( growthFactor == 1.f ) - throw std::invalid_argument( "ERROR: buffer_growth argument can't be less of equal than 1, in " + m_EndMessage + "\n" ); - } - - m_BP1Writer.m_GrowthFactor = growthFactor; - m_GrowthFactor = growthFactor; //float - } - - auto itMaxBufferSize = m_Method.m_Parameters.find( "max_size_MB" ); - if( itMaxBufferSize != m_Method.m_Parameters.end() ) - { - if( m_DebugMode == true ) - { - if( m_GrowthFactor <= 1.f ) - throw std::invalid_argument( "ERROR: Method buffer_growth argument can't be less of equal than 1, in " + m_EndMessage + "\n" ); - } - - m_MaxBufferSize = std::stoul( itMaxBufferSize->second ) * 1048576; //convert from MB to bytes - } - - auto itVerbosity = m_Method.m_Parameters.find( "verbose" ); - if( itVerbosity != m_Method.m_Parameters.end() ) - { - int verbosity = std::stoi( itVerbosity->second ); - if( m_DebugMode == true ) - { - if( verbosity < 0 || verbosity > 5 ) - throw std::invalid_argument( "ERROR: Method verbose argument must be an integer in the range [0,5], in call to Open or Engine constructor\n" ); - } - m_BP1Writer.m_Verbosity = verbosity; - } - - auto itProfile = m_Method.m_Parameters.find( "profile_units" ); - if( itProfile != m_Method.m_Parameters.end() ) - { - auto& profiler = m_MetadataSet.Log; - - if( itProfile->second == "mus" || itProfile->second == "microseconds" ) - profiler.m_Timers.emplace_back( "buffering", Support::Resolutions::mus ); - - else if( itProfile->second == "ms" || itProfile->second == "milliseconds" ) - profiler.m_Timers.emplace_back( "buffering", Support::Resolutions::ms ); - - else if( itProfile->second == "s" || itProfile->second == "seconds" ) - profiler.m_Timers.emplace_back( "buffering", Support::Resolutions::s ); - - else if( itProfile->second == "min" || itProfile->second == "minutes" ) - profiler.m_Timers.emplace_back( "buffering", Support::Resolutions::m ); - - else if( itProfile->second == "h" || itProfile->second == "hours" ) - profiler.m_Timers.emplace_back( "buffering", Support::Resolutions::h ); - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: Method profile_buffering_units argument must be mus, ms, s, min or h, in call to Open or Engine constructor\n" ); - } - - profiler.m_IsActive = true; - } -} - - -void BPFileWriter::InitTransports( ) -{ - if( m_DebugMode == true ) - { - if( TransportNamesUniqueness( ) == false ) - { - throw std::invalid_argument( "ERROR: two transports of the same kind (e.g file IO) " - "can't have the same name, modify with name= in Method AddTransport\n" ); - } - } - - for( const auto& parameters : m_Method.m_TransportParameters ) - { - auto itProfile = parameters.find( "profile_units" ); - bool doProfiling = false; - Support::Resolutions resolution = Support::Resolutions::s; //default is seconds - if( itProfile != parameters.end() ) - { - if( itProfile->second == "mus" || itProfile->second == "microseconds" ) - resolution = Support::Resolutions::mus; - - else if( itProfile->second == "ms" || itProfile->second == "milliseconds" ) - resolution = Support::Resolutions::ms; - - else if( itProfile->second == "s" || itProfile->second == "seconds" ) - resolution = Support::Resolutions::s; - - else if( itProfile->second == "min" || itProfile->second == "minutes" ) - resolution = Support::Resolutions::m; - - else if( itProfile->second == "h" || itProfile->second == "hours" ) - resolution = Support::Resolutions::h; - - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: Transport profile_units argument must be mus, ms, s, min or h " + m_EndMessage ); - } - doProfiling = true; - } - - auto itTransport = parameters.find( "transport" ); - - if( itTransport->second == "file" || itTransport->second == "File" ) - { - auto itLibrary = parameters.find( "library" ); - if( itLibrary == parameters.end() || itLibrary->second == "POSIX" ) //use default POSIX - { - auto file = std::make_shared<transport::FileDescriptor>( m_MPIComm, m_DebugMode ); - if( doProfiling == true ) - file->InitProfiler( m_AccessMode, resolution ); - - m_BP1Writer.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - - } - else if( itLibrary->second == "FILE*" || itLibrary->second == "stdio" ) - { - auto file = std::make_shared<transport::FilePointer>( m_MPIComm, m_DebugMode ); - if( doProfiling == true ) - file->InitProfiler( m_AccessMode, resolution ); - - m_BP1Writer.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - } - else if( itLibrary->second == "fstream" || itLibrary->second == "std::fstream" ) - { - auto file = std::make_shared<transport::FStream>( m_MPIComm, m_DebugMode ); - - if( doProfiling == true ) - file->InitProfiler( m_AccessMode, resolution ); - - m_BP1Writer.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back( std::move( file ) ); - } - else if( itLibrary->second == "MPI_File" || itLibrary->second == "MPI-IO" ) - { - - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: file transport library " + itLibrary->second + " not supported, in " + - m_Name + m_EndMessage ); - } - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: transport " + itTransport->second + " (you mean File?) not supported, in " + - m_Name + m_EndMessage ); - } - } -} - - -void BPFileWriter::InitProcessGroup( ) -{ - if( m_MetadataSet.Log.m_IsActive == true ) - m_MetadataSet.Log.m_Timers[0].SetInitialTime(); - - if( m_AccessMode == "a" ) - { - //Get last pg timestep and update timestep counter in format::BP1MetadataSet - } - - WriteProcessGroupIndex( ); - - if( m_MetadataSet.Log.m_IsActive == true ) - m_MetadataSet.Log.m_Timers[0].SetTime(); -} - - - -void BPFileWriter::WriteProcessGroupIndex( ) -{ - //pg = process group -// const std::size_t pgIndexSize = m_BP1Writer.GetProcessGroupIndexSize( std::to_string( m_RankMPI ), -// std::to_string( m_MetadataSet.TimeStep ), -// m_Transports.size() ); - //metadata - //GrowBuffer( pgIndexSize, m_GrowthFactor, m_MetadataSet.PGIndex ); - - //data? Need to be careful, maybe add some trailing tolerance in variable ???? - //GrowBuffer( pgIndexSize, m_GrowthFactor, m_Buffer.m_Data ); - - const bool isFortran = ( m_HostLanguage == "Fortran" ) ? true : false; - - m_BP1Writer.WriteProcessGroupIndex( isFortran, std::to_string( m_RankMPI ), static_cast<std::uint32_t>( m_RankMPI ), - m_Transports, m_Buffer, m_MetadataSet ); - -} - - - -} //end namespace adios diff --git a/src/engine/dataman/DataManReader.cpp b/src/engine/dataman/DataManReader.cpp deleted file mode 100644 index 062bfaa50..000000000 --- a/src/engine/dataman/DataManReader.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - * DataManReader.cpp - * - * Created on: Feb 21, 2017 - * Author: wfg - */ - - -#include "engine/dataman/DataManReader.h" - -#include "core/Support.h" -#include "functions/adiosFunctions.h" //CSVToVector - -//supported transports -#include "transport/file/FStream.h" // uses C++ fstream -#include "transport/wan/MdtmMan.h" //uses Mdtm library - -#include "DataMan.h" //here comes your DataMan header from external dataman library -#include "../../../include/transport/file/FileDescriptor.h" // uses POSIX -#include "../../../include/transport/file/FilePointer.h" // uses C FILE* - -namespace adios -{ - -DataManReader::DataManReader( ADIOS& adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method& method, const IOMode iomode, const float timeout_sec, - const bool debugMode, const unsigned int nthreads ): - Engine( adios, "DataManReader", name, accessMode, mpiComm, method, debugMode, nthreads, " DataManReader constructor (or call to ADIOS Open).\n" ), - m_Buffer( accessMode, m_RankMPI, m_DebugMode ) -{ - Init( ); -} - -DataManReader::~DataManReader( ) -{ } - -void DataManReader::SetCallBack( std::function<void( const void*, std::string, std::string, std::string, Dims )> callback ) -{ - m_CallBack = callback; - m_Man.reg_callback(callback); -} - -Variable<void>* DataManReader::InquireVariable( const std::string name, const bool readIn ) //not yet implemented -{ return nullptr; } - -Variable<char>* DataManReader::InquireVariableChar( const std::string name, const bool readIn ) -{ return InquireVariableCommon<char>( name, readIn ); } - -Variable<unsigned char>* DataManReader::InquireVariableUChar( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned char>( name, readIn ); } - -Variable<short>* DataManReader::InquireVariableShort( const std::string name, const bool readIn ) -{ return InquireVariableCommon<short>( name, readIn ); } - -Variable<unsigned short>* DataManReader::InquireVariableUShort( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned short>( name, readIn ); } - -Variable<int>* DataManReader::InquireVariableInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<int>( name, readIn ); } - -Variable<unsigned int>* DataManReader::InquireVariableUInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned int>( name, readIn ); } - -Variable<long int>* DataManReader::InquireVariableLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long int>( name, readIn ); } - -Variable<unsigned long int>* DataManReader::InquireVariableULInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned long int>( name, readIn ); } - -Variable<long long int>* DataManReader::InquireVariableLLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long long int>( name, readIn ); } - -Variable<unsigned long long int>* DataManReader::InquireVariableULLInt( const std::string name, const bool readIn ) -{ return InquireVariableCommon<unsigned long long int>( name, readIn ); } - -Variable<float>* DataManReader::InquireVariableFloat( const std::string name, const bool readIn ) -{ return InquireVariableCommon<float>( name, readIn ); } - -Variable<double>* DataManReader::InquireVariableDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<double>( name, readIn ); } - -Variable<long double>* DataManReader::InquireVariableLDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<long double>( name, readIn ); } - -Variable<std::complex<float>>* DataManReader::InquireVariableCFloat( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<float>>( name, readIn ); } - -Variable<std::complex<double>>* DataManReader::InquireVariableCDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<double>>( name, readIn ); } - -Variable<std::complex<long double>>* DataManReader::InquireVariableCLDouble( const std::string name, const bool readIn ) -{ return InquireVariableCommon<std::complex<long double>>( name, readIn ); } - -VariableCompound* DataManReader::InquireVariableCompound( const std::string name, const bool readIn ) -{ return nullptr; } - - -void DataManReader::Close( const int transportIndex ) -{ - -} - - -//PRIVATE -void DataManReader::Init( ) -{ - if( m_DebugMode == true ) - { - if( m_AccessMode != "r" && m_AccessMode != "read" ) - throw std::invalid_argument( "ERROR: DataManReader doesn't support access mode " + m_AccessMode + - ", in call to ADIOS Open or DataManReader constructor\n" ); - } - - auto itRealTime = m_Method.m_Parameters.find( "real_time" ); - if( itRealTime != m_Method.m_Parameters.end() ) - { - if( itRealTime->second == "yes" || itRealTime->second == "true" ) - m_DoRealTime = true; - } - - if(m_DoRealTime) - { - /** - * Lambda function that assigns a parameter in m_Method to a localVariable of type std::string - */ - auto lf_AssignString = [this]( const std::string parameter, std::string& localVariable ) - { - auto it = m_Method.m_Parameters.find( parameter ); - if( it != m_Method.m_Parameters.end() ) - { - localVariable = it->second; - } - }; - - /** - * Lambda function that assigns a parameter in m_Method to a localVariable of type int - */ - auto lf_AssignInt = [this]( const std::string parameter, int& localVariable ) - { - auto it = m_Method.m_Parameters.find( parameter ); - if( it != m_Method.m_Parameters.end() ) - { - localVariable = std::stoi( it->second ); - } - }; - - auto is_number = [] (const std::string& s) - { - return !s.empty() && std::find_if(s.begin(), s.end(), [](char c) { return !std::isdigit(c); }) == s.end(); - }; - - json jmsg; - for(auto &i : m_Method.m_Parameters){ - if( is_number(i.second) ){ - jmsg[i.first] = std::stoi(i.second); - } - else{ - jmsg[i.first] = i.second; - } - } - jmsg["stream_mode"] = "receiver"; - m_Man.add_stream(jmsg); - - std::string method_type; - int num_channels=0; - lf_AssignString( "method_type", method_type ); - lf_AssignInt( "num_channels", num_channels ); - } - else - { - InitCapsules( ); - InitTransports( ); - } -} - - -void DataManReader::InitCapsules( ) -{ - //here init memory capsules -} - - -void DataManReader::InitTransports( ) //maybe move this? -{ - TransportNamesUniqueness( ); - - for( const auto& parameters : m_Method.m_TransportParameters ) - { - auto itTransport = parameters.find( "transport" ); - - if( itTransport->second == "Mdtm" || itTransport->second == "MdtmMan" ) - { - const std::string localIP( GetMdtmParameter( "localIP", parameters ) ); //mandatory - const std::string remoteIP( GetMdtmParameter( "remoteIP", parameters ) ); //mandatory - const std::string prefix( GetMdtmParameter( "prefix", parameters ) ); - const int numberOfPipes = std::stoi( GetMdtmParameter( "pipes", parameters ) ); - const std::vector<int> tolerances = CSVToVectorInt( GetMdtmParameter( "tolerances", parameters ) ); - const std::vector<int> priorities = CSVToVectorInt( GetMdtmParameter( "priorities", parameters ) ); - - m_Transports.push_back( std::make_shared<transport::MdtmMan>( localIP, remoteIP, m_AccessMode, prefix, numberOfPipes, - tolerances, priorities, m_MPIComm, m_DebugMode ) ); - } - else if( itTransport->second == "Zmq" ) - { - - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: transport + " + itTransport->second + " not supported, in " + - m_Name + m_EndMessage ); - } - } -} - - -std::string DataManReader::GetMdtmParameter( const std::string parameter, const std::map<std::string,std::string>& mdtmParameters ) -{ - auto itParam = mdtmParameters.find( parameter ); - if( itParam != mdtmParameters.end() ) //found - { - return itParam->second; //return value - } - // if not found - //mandatory ones - if( parameter == "localIP" || parameter == "remoteIP" ) - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: " + parameter + " parameter not found in Method, in call to DataManWriter constructor\n" ); - } - else if( parameter == "prefix" ) - { - return ""; - } - else if( parameter == "pipes" ) - { - return "0"; // or 1? - } - else if( parameter == "tolerances" ) //so far empty string - { - - } - else if( parameter == "priority" ) - { - - } - - return ""; //return empty string -} - - - -} diff --git a/src/engine/dataman/DataManWriter.cpp b/src/engine/dataman/DataManWriter.cpp deleted file mode 100644 index c4b431ee7..000000000 --- a/src/engine/dataman/DataManWriter.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * DataMan.cpp - * - * Created on: Jan 10, 2017 - * Author: wfg - */ - -#include <iostream> //needs to go away, this is just for demo purposes - -#include "engine/dataman/DataManWriter.h" - -#include "core/Support.h" -#include "functions/adiosFunctions.h" //CSVToVector - -//supported transports -#include "transport/file/FStream.h" // uses C++ fstream -#include "transport/wan/MdtmMan.h" //uses Mdtm library - - - -namespace adios -{ - - -DataManWriter::DataManWriter( ADIOS& adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method& method, const IOMode iomode, const float timeout_sec, - const bool debugMode, const unsigned int nthreads ): - Engine( adios, "DataManWriter", name, accessMode, mpiComm, method, debugMode, nthreads, " DataManWriter constructor (or call to ADIOS Open).\n" ), - m_Buffer( accessMode, m_RankMPI, m_DebugMode ) -{ - Init( ); -} - - -DataManWriter::~DataManWriter( ) -{ } - -void DataManWriter::SetCallBack( std::function<void( const void*, std::string, std::string, std::string, Dims )> callback ) -{ - m_CallBack = callback; - m_Man.reg_callback(callback); -} - -void DataManWriter::Write( Variable<char>& variable, const char* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<unsigned char>& variable, const unsigned char* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<short>& variable, const short* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<unsigned short>& variable, const unsigned short* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<int>& variable, const int* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<unsigned int>& variable, const unsigned int* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<long int>& variable, const long int* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<unsigned long int>& variable, const unsigned long int* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<long long int>& variable, const long long int* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<unsigned long long int>& variable, const unsigned long long int* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<float>& variable, const float* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<double>& variable, const double* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<long double>& variable, const long double* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<std::complex<float>>& variable, const std::complex<float>* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<std::complex<double>>& variable, const std::complex<double>* values ) -{ WriteVariableCommon( variable, values ); } - -void DataManWriter::Write( Variable<std::complex<long double>>& variable, const std::complex<long double>* values ) -{ WriteVariableCommon( variable, values ); } - -//String version -void DataManWriter::Write( const std::string variableName, const char* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<char>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const unsigned char* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned char>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const short* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<short>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const unsigned short* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned short>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<int>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const unsigned int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned int>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<long int>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const unsigned long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned long int>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const long long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<long long int>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const unsigned long long int* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned long long int>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const float* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<float>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const double* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<double>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const long double* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<long double>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const std::complex<float>* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<float>>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const std::complex<double>* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<double>>( variableName ), values ); } - -void DataManWriter::Write( const std::string variableName, const std::complex<long double>* values ) -{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<long double>>( variableName ), values ); } - - -void DataManWriter::Close( const int transportIndex ) -{ - m_Man.flush(); - //here close IPs and deallocate or free/close resources (if using STL no need for memory deallocation) -} - - - -//PRIVATE functions below -void DataManWriter::Init( ) -{ - if( m_DebugMode == true ) - { - if( m_AccessMode != "w" && m_AccessMode != "write" && m_AccessMode != "a" && m_AccessMode != "append" ) - throw std::invalid_argument( "ERROR: DataManWriter doesn't support access mode " + m_AccessMode + - ", in call to ADIOS Open or DataManWriter constructor\n" ); - } - - auto itRealTime = m_Method.m_Parameters.find( "real_time" ); - if( itRealTime != m_Method.m_Parameters.end() ) - { - if( itRealTime->second == "yes" || itRealTime->second == "true" ) - m_DoRealTime = true; - } - - itRealTime = m_Method.m_Parameters.find( "monitoring" ); - if( itRealTime != m_Method.m_Parameters.end() ) - { - if( itRealTime->second == "yes" || itRealTime->second == "true" ) - m_DoMonitor = true; - } - - if(m_DoRealTime) - { - /** - * Lambda function that assigns a parameter in m_Method to a localVariable of type std::string - */ - auto lf_AssignString = [this]( const std::string parameter, std::string& localVariable ) - { - auto it = m_Method.m_Parameters.find( parameter ); - if( it != m_Method.m_Parameters.end() ) - { - localVariable = it->second; - } - }; - - /** - * Lambda function that assigns a parameter in m_Method to a localVariable of type int - */ - auto lf_AssignInt = [this]( const std::string parameter, int& localVariable ) - { - auto it = m_Method.m_Parameters.find( parameter ); - if( it != m_Method.m_Parameters.end() ) - { - localVariable = std::stoi( it->second ); - } - }; - - auto is_number = [] (const std::string& s) - { - return !s.empty() && std::find_if(s.begin(), s.end(), [](char c) { return !std::isdigit(c); }) == s.end(); - }; - - json jmsg; - for(auto &i : m_Method.m_Parameters){ - if( is_number(i.second) ){ - jmsg[i.first] = std::stoi(i.second); - } - else{ - jmsg[i.first] = i.second; - } - } - jmsg["stream_mode"] = "sender"; - m_Man.add_stream(jmsg); - - std::string method_type; - int num_channels=0; - lf_AssignString( "method_type", method_type ); - lf_AssignInt( "num_channels", num_channels ); - } - else - { - InitCapsules( ); - InitTransports( ); - } -} - -void DataManWriter::InitCapsules( ) -{ - //here init memory capsules -} - - -void DataManWriter::InitTransports( ) //maybe move this? -{ - TransportNamesUniqueness( ); - - for( const auto& parameters : m_Method.m_TransportParameters ) - { - auto itTransport = parameters.find( "transport" ); - - if( itTransport->second == "Mdtm" || itTransport->second == "MdtmMan" ) - { - const std::string localIP( GetMdtmParameter( "localIP", parameters ) ); //mandatory - const std::string remoteIP( GetMdtmParameter( "remoteIP", parameters ) ); //mandatory - const std::string prefix( GetMdtmParameter( "prefix", parameters ) ); - const int numberOfPipes = std::stoi( GetMdtmParameter( "pipes", parameters ) ); - const std::vector<int> tolerances = CSVToVectorInt( GetMdtmParameter( "tolerances", parameters ) ); - const std::vector<int> priorities = CSVToVectorInt( GetMdtmParameter( "priorities", parameters ) ); - - m_Transports.push_back( std::make_shared<transport::MdtmMan>( localIP, remoteIP, m_AccessMode, prefix, numberOfPipes, - tolerances, priorities, m_MPIComm, m_DebugMode ) ); - } - else if( itTransport->second == "Zmq" ) - { - - } - else - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: transport + " + itTransport->second + " not supported, in " + - m_Name + m_EndMessage ); - } - } -} - - -std::string DataManWriter::GetMdtmParameter( const std::string parameter, const std::map<std::string,std::string>& mdtmParameters ) -{ - auto itParam = mdtmParameters.find( parameter ); - if( itParam != mdtmParameters.end() ) //found - { - return itParam->second; //return value - } - // if not found - //mandatory ones - if( parameter == "localIP" || parameter == "remoteIP" ) - { - if( m_DebugMode == true ) - throw std::invalid_argument( "ERROR: " + parameter + " parameter not found in Method, in call to DataManWriter constructor\n" ); - } - else if( parameter == "prefix" ) - { - return ""; - } - else if( parameter == "pipes" ) - { - return "0"; // or 1? - } - else if( parameter == "tolerances" ) //so far empty string - { - - } - else if( parameter == "priority" ) - { - - } - - return ""; //return empty string -} - - -} //end namespace adios diff --git a/src/format/BP1.cpp b/src/format/BP1.cpp deleted file mode 100644 index eb70ff6d2..000000000 --- a/src/format/BP1.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * BP1.cpp - * - * Created on: Feb 7, 2017 - * Author: wfg - */ - - -#include "format/BP1.h" -#include "functions/adiosFunctions.h" - - -namespace adios -{ -namespace format -{ - - -std::string BP1::GetDirectoryName( const std::string name ) const noexcept -{ - std::string directory; - - if( name.find(".bp") == name.size()-3 ) - directory = name; - else - directory = name + ".bp"; - - return directory; -} - - -void BP1::OpenRankFiles( const std::string name, const std::string accessMode, Transport& file ) const -{ - const std::string directory = GetDirectoryName( name ); - CreateDirectory( directory ); //creates a directory and sub-directories recursively - - std::string fileName( directory + "/" + directory + "." + std::to_string( file.m_RankMPI ) ); - file.Open( fileName, accessMode ); // opens a file transport under name.bp.dir/name.bp.rank reserve that location fro writing -} - - -std::vector<std::uint8_t> BP1::GetMethodIDs( const std::vector< std::shared_ptr<Transport> >& transports ) const noexcept -{ - auto lf_GetMethodID = []( const std::string method ) -> std::uint8_t - { - int id = METHOD_UNKNOWN; - if( method == "NULL" ) id = METHOD_NULL; - else if( method == "POSIX" ) id = METHOD_POSIX; - else if( method == "FStream" ) id = METHOD_FSTREAM; - else if( method == "File" ) id = METHOD_FILE; - else if( method == "MPI" ) id = METHOD_MPI; - - return id; - }; - - std::vector<std::uint8_t> methodIDs; - methodIDs.reserve( transports.size() ); - - for( const auto& transport : transports ) - methodIDs.push_back( lf_GetMethodID( transport->m_Type ) ); - - return methodIDs; -} - - -} //end namespace format -} //end namespace adios diff --git a/src/format/BP1Aggregator.cpp b/src/format/BP1Aggregator.cpp deleted file mode 100644 index 89a067e7a..000000000 --- a/src/format/BP1Aggregator.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * BP1Aggregator.cpp - * - * Created on: Mar 21, 2017 - * Author: wfg - */ - - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <vector> -#include <fstream> -/// \endcond - -#include "format/BP1Aggregator.h" - - -namespace adios -{ -namespace format -{ - - -BP1Aggregator::BP1Aggregator( MPI_Comm mpiComm, const bool debugMode ): - m_MPIComm{ mpiComm }, - m_DebugMode{ debugMode } -{ - MPI_Comm_rank( m_MPIComm, &m_RankMPI ); - MPI_Comm_size( m_MPIComm, &m_SizeMPI ); -} - - -BP1Aggregator::~BP1Aggregator( ) -{ } - - -void BP1Aggregator::WriteProfilingLog( const std::string fileName, const std::string& rankLog ) -{ - if( m_RankMPI == 0 ) - { - unsigned int sizeMPI = static_cast<unsigned int>( m_SizeMPI ); - std::vector< std::vector<char> > rankLogs( sizeMPI - 1 ); //rankLogs from other processes - std::vector< int > rankLogsSizes( sizeMPI-1, -1 ); //init with -1 - std::vector<MPI_Request> requests( sizeMPI ); - std::vector<MPI_Status> statuses( sizeMPI ); - - //first receive sizes - for( unsigned int i = 1; i < sizeMPI; ++i ) - MPI_Irecv( &rankLogsSizes[i-1], 1, MPI_INT, i, 0, m_MPIComm, &requests[i] ); - - for( unsigned int i = 1; i < sizeMPI; ++i ) - { - MPI_Wait( &requests[i], &statuses[i] ); - if( m_DebugMode == true ) - { - if( rankLogsSizes[i-1] == -1 ) - throw std::runtime_error( "ERROR: couldn't get size from rank " + std::to_string(i) + ", in ADIOS aggregator for Profiling.log\n" ); - } - rankLogs[i-1].resize( rankLogsSizes[i-1] ); //allocate with zeros - } - - //receive rankLog from other ranks - for( unsigned int i = 1; i < sizeMPI; ++i ) - MPI_Irecv( rankLogs[i-1].data(), rankLogsSizes[i-1], MPI_CHAR, i, 1, m_MPIComm, &requests[i] ); - - for( unsigned int i = 1; i < sizeMPI; ++i ) - MPI_Wait( &requests[i], &statuses[i] ); - - //write file - std::string logFile( "log = { \n" ); - logFile += rankLog + "\n"; - for( unsigned int i = 1; i < sizeMPI; ++i ) - { - const std::string rankLogStr( rankLogs[i-1].data(), rankLogs[i-1].size() ); - logFile += rankLogStr + "\n"; - } - logFile += " }\n"; - - std::ofstream logStream( fileName ); - logStream.write( logFile.c_str(), logFile.size() ); - logStream.close(); - } - else - { - int rankLogSize = static_cast<int>( rankLog.size() ); - MPI_Request requestSize; - MPI_Isend( &rankLogSize, 1, MPI_INT, 0, 0, m_MPIComm, &requestSize ); - - MPI_Request requestRankLog; - MPI_Isend( const_cast<char*>( rankLog.c_str() ), rankLogSize, MPI_CHAR, 0, 1, m_MPIComm, &requestRankLog ); - } -} - - - -} //end namespace format -} //end namespace adios - diff --git a/src/format/BP1Writer.cpp b/src/format/BP1Writer.cpp deleted file mode 100644 index a441e6392..000000000 --- a/src/format/BP1Writer.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/* - * BP1Writer.cpp - * - * Created on: Feb 1, 2017 - * Author: wfg - */ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <string> -/// \endcond - -#include "format/BP1Writer.h" -#include "core/Profiler.h" - - - - -namespace adios -{ -namespace format -{ - - -std::size_t BP1Writer::GetProcessGroupIndexSize( const std::string name, const std::string timeStepName, - const std::size_t numberOfTransports ) const noexcept -{ - //pgIndex + list of methods (transports) - return ( name.length() + timeStepName.length() + 23 ) + ( 3 + numberOfTransports ); //should be sufficient for data and metadata pgindices -} - - -void BP1Writer::WriteProcessGroupIndex( const bool isFortran, const std::string name, const std::uint32_t processID, - const std::vector< std::shared_ptr<Transport> >& transports, - capsule::STLVector& heap, BP1MetadataSet& metadataSet ) const noexcept -{ - std::vector<char>& metadataBuffer = metadataSet.PGIndex.Buffer; - std::vector<char>& dataBuffer = heap.m_Data; - - metadataSet.DataPGLengthPosition = dataBuffer.size(); - dataBuffer.insert( dataBuffer.end(), 8, 0 ); //skip pg length (8) - - const std::size_t metadataPGLengthPosition = metadataBuffer.size(); - metadataBuffer.insert( metadataBuffer.end(), 2, 0 ); //skip pg length (2) - - //write name to metadata - WriteNameRecord( name, metadataBuffer ); - //write if host language Fortran in metadata and data - const char hostFortran = ( isFortran ) ? 'y' : 'n'; //if host language is fortran - CopyToBuffer( metadataBuffer, &hostFortran ); - CopyToBuffer( dataBuffer, &hostFortran ); - //write name in data - WriteNameRecord( name, dataBuffer ); - - //processID in metadata, - CopyToBuffer( metadataBuffer, &processID ); - //skip coordination var in data ....what is coordination var? - dataBuffer.insert( dataBuffer.end(), 4, 0 ); - - //time step name to metadata and data - const std::string timeStepName( std::to_string( metadataSet.TimeStep ) ); - WriteNameRecord( timeStepName, metadataBuffer ); - WriteNameRecord( timeStepName, dataBuffer ); - - //time step to metadata and data - CopyToBuffer( metadataBuffer, &metadataSet.TimeStep ); - CopyToBuffer( dataBuffer, &metadataSet.TimeStep ); - - //offset to pg in data in metadata which is the current absolute position - CopyToBuffer( metadataBuffer, reinterpret_cast<std::uint64_t*>( &heap.m_DataAbsolutePosition ) ); - - //Back to writing metadata pg index length (length of group) - const std::uint16_t metadataPGIndexLength = metadataBuffer.size() - metadataPGLengthPosition - 2; //without length of group record - CopyToBuffer( metadataBuffer, metadataPGLengthPosition, &metadataPGIndexLength ); - //DONE With metadataBuffer - - //here write method in data - const std::vector<std::uint8_t> methodIDs = GetMethodIDs( transports ); - const std::uint8_t methodsCount = methodIDs.size(); - CopyToBuffer( dataBuffer, &methodsCount ); //count - const std::uint16_t methodsLength = methodIDs.size() * 3; //methodID (1) + method params length(2), no parameters for now - CopyToBuffer( dataBuffer, &methodsLength );//length - - for( const auto methodID : methodIDs ) - { - CopyToBuffer( dataBuffer, &methodID ); //method ID, - dataBuffer.insert( dataBuffer.end(), 2, 0 ); //skip method params length = 0 (2 bytes) for now - } - - //update absolute position - heap.m_DataAbsolutePosition += dataBuffer.size() - metadataSet.DataPGLengthPosition; - //pg vars count and position - metadataSet.DataPGVarsCount = 0; - metadataSet.DataPGVarsCountPosition = dataBuffer.size(); - //add vars count and length - dataBuffer.insert( dataBuffer.end(), 12, 0 ); - heap.m_DataAbsolutePosition += 12; //add vars count and length - - ++metadataSet.DataPGCount; - metadataSet.DataPGIsOpen = true; -} - - - -void BP1Writer::Advance( BP1MetadataSet& metadataSet, capsule::STLVector& buffer ) -{ - FlattenData( metadataSet, buffer ); -} - - - -void BP1Writer::Close( BP1MetadataSet& metadataSet, capsule::STLVector& heap, Transport& transport, bool& isFirstClose, - const bool doAggregation ) const noexcept -{ - if( metadataSet.Log.m_IsActive == true ) - metadataSet.Log.m_Timers[0].SetInitialTime(); - - if( isFirstClose == true ) - { - if( metadataSet.DataPGIsOpen == true ) - FlattenData( metadataSet, heap ); - - FlattenMetadata( metadataSet, heap ); - - if( metadataSet.Log.m_IsActive == true ) - metadataSet.Log.m_Timers[0].SetInitialTime(); - - if( doAggregation == true ) //N-to-M where 1 <= M <= N-1, might need a new Log metadataSet.Log.m_Timers just for aggregation - { - //here call aggregator - } - isFirstClose = false; - } - - if( doAggregation == true ) //N-to-M where 1 <= M <= N-1 - { - //here call aggregator to select transports for Write and Close - } - else // N-to-N - { - transport.Write( heap.m_Data.data(), heap.m_Data.size() ); //single write - transport.Close(); - } -} - - -std::string BP1Writer::GetRankProfilingLog( const int rank, const BP1MetadataSet& metadataSet, - const std::vector< std::shared_ptr<Transport> >& transports ) const noexcept -{ - auto lf_WriterTimer = []( std::string& rankLog, const Timer& timer ) - { - rankLog += "'" + timer.Process + "_" + timer.GetUnits() + "': " + std::to_string( timer.ProcessTime ) + ", "; - }; - - //prepare string dictionary per rank - std::string rankLog( "'rank_" + std::to_string( rank ) + "': { " ); - - auto& profiler = metadataSet.Log; - rankLog += "'bytes': " + std::to_string( profiler.m_TotalBytes[0] ) + ", "; - lf_WriterTimer( rankLog, profiler.m_Timers[0] ); - - for( unsigned int t = 0; t < transports.size(); ++t ) - { - auto& timers = transports[t]->m_Profiler.m_Timers; - - rankLog += "'transport_" + std::to_string(t) + "': { "; - rankLog += "'lib': " + transports[t]->m_Type + ", "; - - for( unsigned int i = 0; i < 3; ++i ) - lf_WriterTimer( rankLog, timers[i] ); - - rankLog += "}, "; - } - rankLog += "}, "; - - return rankLog; -} - - - -//PRIVATE FUNCTIONS -void BP1Writer::WriteDimensionsRecord( std::vector<char>& buffer, - const std::vector<std::size_t>& localDimensions, - const std::vector<std::size_t>& globalDimensions, - const std::vector<std::size_t>& globalOffsets, - const unsigned int skip, - const bool addType ) const noexcept -{ - auto lf_WriteFlaggedDim = []( std::vector<char>& buffer, const char no, - const std::size_t dimension ) - { - CopyToBuffer( buffer, &no ); - CopyToBuffer( buffer, reinterpret_cast<const std::uint64_t*>( &dimension ) ); - }; - - //BODY Starts here - if( globalDimensions.empty() ) - { - if( addType == true ) - { - constexpr char no = 'n'; //dimension format unsigned int value (not using memberID for now) - for( const auto& localDimension : localDimensions ) - { - lf_WriteFlaggedDim( buffer, no, localDimension ); - buffer.insert( buffer.end(), skip, 0 ); - } - } - else - { - for( const auto& localDimension : localDimensions ) - { - CopyToBuffer( buffer, reinterpret_cast<const std::uint64_t*>( &localDimension ) ); - buffer.insert( buffer.end(), skip, 0 ); - } - } - } - else - { - if( addType == true ) - { - constexpr char no = 'n'; //dimension format unsigned int value for now - for( unsigned int d = 0; d < localDimensions.size(); ++d ) - { - lf_WriteFlaggedDim( buffer, no, localDimensions[d] ); - lf_WriteFlaggedDim( buffer, no, globalDimensions[d] ); - lf_WriteFlaggedDim( buffer, no, globalOffsets[d] ); - } - } - else - { - for( unsigned int d = 0; d < localDimensions.size(); ++d ) - { - CopyToBuffer( buffer, reinterpret_cast<const std::uint64_t*>( &localDimensions[d] ) ); - CopyToBuffer( buffer, reinterpret_cast<const std::uint64_t*>( &globalDimensions[d] ) ); - CopyToBuffer( buffer, reinterpret_cast<const std::uint64_t*>( &globalOffsets[d] ) ); - } - } - } -} - - -void BP1Writer::WriteNameRecord( const std::string name, std::vector<char>& buffer ) const noexcept -{ - const std::uint16_t length = name.length( ); - CopyToBuffer( buffer, &length ); - CopyToBuffer( buffer, name.c_str(), length ); -} - - - -BP1Index& BP1Writer::GetBP1Index( const std::string name, std::unordered_map<std::string, BP1Index>& indices, - bool& isNew ) const noexcept -{ - auto itName = indices.find( name ); - if( itName == indices.end() ) - { - indices.emplace( name, BP1Index( indices.size() ) ); - isNew = true; - return indices.at( name ); - } - - isNew = false; - return itName->second; -} - - -void BP1Writer::FlattenData( BP1MetadataSet& metadataSet, capsule::STLVector& heap ) const noexcept -{ - auto& buffer = heap.m_Data; - //vars count and Length (only for PG) - CopyToBuffer( buffer, metadataSet.DataPGVarsCountPosition, &metadataSet.DataPGVarsCount ); - const std::uint64_t varsLength = buffer.size() - metadataSet.DataPGVarsCountPosition - 8 - 4; //without record itself and vars count - CopyToBuffer( buffer, metadataSet.DataPGVarsCountPosition + 4, &varsLength ); - - //attributes (empty for now) count (4) and length (8) are zero by moving positions in time step zero - buffer.insert( buffer.end(), 12, 0 ); - heap.m_DataAbsolutePosition += 12; - - //Finish writing pg group length - const std::uint64_t dataPGLength = buffer.size() - metadataSet.DataPGLengthPosition - 8; //without record itself, 12 due to empty attributes - CopyToBuffer( buffer, metadataSet.DataPGLengthPosition, &dataPGLength ); - - ++metadataSet.TimeStep; - metadataSet.DataPGIsOpen = false; -} - - -void BP1Writer::FlattenMetadata( BP1MetadataSet& metadataSet, capsule::STLVector& heap ) const noexcept -{ - auto lf_IndexCountLength = []( std::unordered_map<std::string, BP1Index>& indices, - std::uint32_t& count, std::uint64_t& length ) - { - count = indices.size(); - length = 0; - for( auto& indexPair : indices ) //set each index length - { - auto& indexBuffer = indexPair.second.Buffer; - const std::uint32_t indexLength = indexBuffer.size()-4; - CopyToBuffer( indexBuffer, 0, &indexLength ); - - length += indexBuffer.size(); //overall length - } - }; - - auto lf_FlattenIndices = []( const std::uint32_t count, const std::uint64_t length, - const std::unordered_map<std::string, BP1Index>& indices, - std::vector<char>& buffer ) - { - CopyToBuffer( buffer, &count ); - CopyToBuffer( buffer, &length ); - - for( const auto& indexPair : indices ) //set each index length - { - const auto& indexBuffer = indexPair.second.Buffer; - CopyToBuffer( buffer, indexBuffer.data(), indexBuffer.size() ); - } - }; - - - //Finish writing metadata counts and lengths - //PG Index - const std::uint64_t pgCount = metadataSet.DataPGCount; - const std::uint64_t pgLength = metadataSet.PGIndex.Buffer.size(); - - //var index count and length (total), and each index length - std::uint32_t varsCount; - std::uint64_t varsLength; - lf_IndexCountLength( metadataSet.VarsIndices, varsCount, varsLength ); - //attribute index count and length, and each index length - std::uint32_t attributesCount; - std::uint64_t attributesLength; - lf_IndexCountLength( metadataSet.AttributesIndices, attributesCount, attributesLength ); - - const std::size_t footerSize = (pgLength+16) + (varsLength+12) + (attributesLength+12) + metadataSet.MiniFooterSize; - auto& buffer = heap.m_Data; - buffer.reserve( buffer.size() + footerSize ); //reserve data to fit metadata, must replace with growth buffer strategy - - //write pg index - CopyToBuffer( buffer, &pgCount ); - CopyToBuffer( buffer, &pgLength ); - CopyToBuffer( buffer, metadataSet.PGIndex.Buffer.data(), pgLength ); - //Vars indices - lf_FlattenIndices( varsCount, varsLength, metadataSet.VarsIndices, buffer ); - //Attribute indices - lf_FlattenIndices( attributesCount, attributesLength, metadataSet.AttributesIndices, buffer ); - - //getting absolute offsets, minifooter is 28 bytes for now - const std::uint64_t offsetPGIndex = heap.m_DataAbsolutePosition; - const std::uint64_t offsetVarsIndex = offsetPGIndex + (pgLength+16); - const std::uint64_t offsetAttributeIndex = offsetVarsIndex + (varsLength+12); - - CopyToBuffer( buffer, &offsetPGIndex ); - CopyToBuffer( buffer, &offsetVarsIndex ); - CopyToBuffer( buffer, &offsetAttributeIndex ); - - //version - if( IsLittleEndian( ) ) - { - const std::uint8_t endian = 0; - CopyToBuffer( buffer, &endian ); - buffer.insert( buffer.end(), 2, 0 ); - CopyToBuffer( buffer, &m_Version ); - } - else - { - - } - - heap.m_DataAbsolutePosition += footerSize; - - if( metadataSet.Log.m_IsActive == true ) - metadataSet.Log.m_TotalBytes.push_back( heap.m_DataAbsolutePosition ); - -} - - - - -} //end namespace format -} //end namespace adios diff --git a/src/functions/adiosFunctions.cpp b/src/functions/adiosFunctions.cpp deleted file mode 100644 index 11e92b07b..000000000 --- a/src/functions/adiosFunctions.cpp +++ /dev/null @@ -1,595 +0,0 @@ -/* - * adiosFunctions.cpp - * - * Created on: Oct 10, 2016 - * Author: wfg - */ - -/// \cond EXCLUDED_FROM_DOXYGEN -#include <fstream> -#include <sstream> -#include <stdexcept> -#include <ios> //std::ios_base::failure -#include <thread> //std::thread -#include <cstring> //std::memcpy -#include <algorithm> //std::count -#include <cmath> // std::ceil, std::pow, std::log - -#include <sys/types.h> //CreateDirectory -#include <sys/stat.h> //stat -#include <unistd.h> //CreateDirectory -/// \endcond - -#include "functions/adiosFunctions.h" -#include "core/Support.h" - -#ifdef HAVE_BZIP2 -#include "transform/BZIP2.h" -#endif - - -namespace adios -{ - - -void DumpFileToString( const std::string fileName, std::string& fileContent ) -{ - std::ifstream fileStream( fileName ); - - if( fileStream.good() == false ) //check file - throw std::ios_base::failure( "ERROR: file " + fileName + - " could not be opened. Check permissions or file existence\n" ); - - std::ostringstream fileSS; - fileSS << fileStream.rdbuf(); - fileStream.close(); - fileContent = fileSS.str(); //convert to string and check - - if( fileContent.empty() ) - throw std::invalid_argument( "ERROR: file " + fileName + " is empty\n" ); -} - - -void GetSubString( const std::string initialTag, const std::string finalTag, const std::string content, - std::string& subString, std::string::size_type& currentPosition ) -{ - auto lf_Wipe = []( std::string& subString, std::string::size_type& currentPosition ) - { - subString.clear(); - currentPosition = std::string::npos; - }; - - auto lf_SetPositions = []( const char quote, const std::string::size_type quotePosition, const std::string& content, - std::string::size_type& currentPosition, std::string::size_type& closingQuotePosition ) - { - currentPosition = quotePosition; - closingQuotePosition = content.find( quote, currentPosition+1 ); - }; - - - //BODY OF FUNCTION STARTS HERE - std::string::size_type start( content.find( initialTag, currentPosition ) ); - if( start == content.npos ) - { - lf_Wipe( subString, currentPosition ); - return; - } - currentPosition = start; - - std::string::size_type end( content.find( finalTag, currentPosition ) ); - if( end == content.npos ) - { - lf_Wipe( subString, currentPosition ); - return; - } - - //here make sure the finalTag is not a value surrounded by " " or ' ', if so find next - bool isValue = true; - - while( isValue == true ) - { - std::string::size_type singleQuotePosition = content.find( '\'', currentPosition ); - std::string::size_type doubleQuotePosition = content.find( '\"', currentPosition ); - - if( ( singleQuotePosition == content.npos && doubleQuotePosition == content.npos ) || - ( singleQuotePosition == content.npos && end < doubleQuotePosition ) || - ( doubleQuotePosition == content.npos && end < singleQuotePosition ) || - ( end < singleQuotePosition && end < doubleQuotePosition ) - ) break; - - //find the closing corresponding quote - std::string::size_type closingQuotePosition; - - if( singleQuotePosition == content.npos ) //no ' anywhere - lf_SetPositions( '\"', doubleQuotePosition, content, currentPosition, closingQuotePosition ); - else if( doubleQuotePosition == content.npos ) //no " anywhere - lf_SetPositions( '\'', singleQuotePosition, content, currentPosition, closingQuotePosition ); - else - { - if( singleQuotePosition < doubleQuotePosition ) - lf_SetPositions( '\'', singleQuotePosition, content, currentPosition, closingQuotePosition ); - else //find the closing " - lf_SetPositions( '\"', doubleQuotePosition, content, currentPosition, closingQuotePosition ); - } - - if( closingQuotePosition == content.npos ) //if can't find closing it's open until the end - { - lf_Wipe( subString, currentPosition ); - return; - } - - currentPosition = closingQuotePosition+1; - - if( closingQuotePosition < end ) - continue; - - //if this point is reached it means it's a value inside " " or ' ', move to the next end - end = content.find( finalTag, currentPosition ); - } - - subString = content.substr( start, end-start+finalTag.size() ); - currentPosition = end; -} - - -void GetQuotedValue( const char quote, const std::string::size_type& quotePosition, - std::string& currentTag, std::string& value ) -{ - currentTag = currentTag.substr( quotePosition + 1 ); - auto nextQuotePosition = currentTag.find( quote ); - - if( nextQuotePosition == currentTag.npos ) - throw std::invalid_argument( "ERROR: Invalid attribute in..." + currentTag + "...check XML file\n"); - - value = currentTag.substr( 0, nextQuotePosition ); - currentTag = currentTag.substr( nextQuotePosition+1 ); -} - - -void GetPairs( const std::string tag, std::vector< std::pair<const std::string, const std::string> >& pairs ) noexcept -{ - std::string currentTag( tag.substr( tag.find_first_of(" \t\n") ) ); //initialize current tag - - while( currentTag.find('=') != currentTag.npos ) //equalPosition - { - currentTag = currentTag.substr( currentTag.find_first_not_of(" \t\n") ); - auto equalPosition = currentTag.find('='); - const std::string field( currentTag.substr( 0, equalPosition) ); //get field - std::string value; - - const char quote = currentTag[equalPosition+1]; - if( quote == '\'' || quote == '"') //single quotes - { - GetQuotedValue( quote, equalPosition+1, currentTag, value ); - } - - pairs.push_back( std::pair<const std::string, const std::string>( field, value ) ); - } -} - - -void GetPairsFromTag( const std::string& fileContent, const std::string tag, - std::vector< std::pair<const std::string, const std::string> >& pairs ) -{ - if( tag.back() == '/' ) //last char is / --> "XML empty tag" - { - GetPairs( tag, pairs ); - } - else if( tag[0] == '/' ) // first char is / ---> closing tag - { } - else // opening tag - { - const std::string tagName( tag.substr( 0, tag.find_first_of(" \t\n\r") ) ); - const std::string closingTagName( "</" + tagName + ">" ); //check for closing tagName - - if( fileContent.find( closingTagName ) == fileContent.npos ) - throw std::invalid_argument( "ERROR: closing tag " + closingTagName + " missing, check XML file\n"); - - GetPairs( tag, pairs ); - } -} - - -//void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, const bool debugMode, -// std::string& hostLanguage, std::vector< std::shared_ptr<Transform> >& transforms, -// std::map< std::string, Group >& groups ) -//{ -// //adios-config -// std::string currentContent; -// std::string::size_type currentPosition( 0 ); -// GetSubString( "<adios-config ", "</adios-config>", fileContent, currentContent, currentPosition ); -// -// //remove comment sections -// std::string::size_type startComment ( currentContent.find( "<!--" ) ); -// -// while( startComment != currentContent.npos ) -// { -// std::string::size_type endComment( currentContent.find( "-->") ); -// currentContent.erase( startComment, endComment-startComment+3 ); -// startComment = currentContent.find( "<!--" ); -// } -// -// //Tag <adios-config -// currentPosition = 0; -// -// std::string tag; //use for < > tags -// GetSubString( "<adios-config", ">", currentContent, tag, currentPosition ); -// tag = tag.substr( 1, tag.size() - 2 ); //eliminate < > -// -// std::vector< std::pair<const std::string, const std::string> > pairs; // pairs in tag -// GetPairsFromTag( currentContent, tag, pairs ); -// -// for( auto& pair : pairs ) -// if( pair.first == "host-language" ) -// hostLanguage = pair.second; -// -// if( debugMode == true ) -// { -// if( Support::HostLanguages.count( hostLanguage ) == 0 ) -// throw std::invalid_argument("ERROR: host language " + hostLanguage + " not supported.\n" ); -// -// if( hostLanguage.empty() == true ) -// throw std::invalid_argument("ERROR: host language is empty.\n" ); -// } -// -// //adios-group -// currentPosition = 0; -// -// while( currentPosition != std::string::npos ) -// { -// std::string xmlGroup; -// GetSubString("<adios-group ", "</adios-group>", currentContent, xmlGroup, currentPosition ); //Get all group contents -// -// if( xmlGroup.empty() ) //no more groups to find -// break; -// -// //get group name -// std::string::size_type groupPosition( 0 ); -// GetSubString( "<adios-group ", ">", xmlGroup, tag, groupPosition ); -// if( debugMode == true ) -// { -// if( tag.size() < 2 ) -// throw std::invalid_argument( "ERROR: wrong tag " + tag + " in adios-group\n" ); //check < or <= -// } -// -// tag = tag.substr( 1, tag.size() - 2 ); //eliminate < > -// GetPairsFromTag( xmlGroup, tag, pairs ); -// std::string groupName; -// -// for( auto& pair : pairs ) -// { -// if( pair.first == "name") -// groupName = pair.second; -// } -// -// if( debugMode == true ) -// { -// if( groupName.empty() ) -// throw std::invalid_argument( "ERROR: group name not found. \n" ); -// -// if( groups.count( groupName ) == 1 ) //group exists -// throw std::invalid_argument( "ERROR: group " + groupName + " defined twice.\n" ); -// } -// -// groups.emplace( groupName, Group( groupName, xmlGroup, transforms, debugMode ) ); -// -// currentContent.erase( currentContent.find( xmlGroup ), xmlGroup.size() ); -// currentPosition = 0; -// } -// -// //transport -// //lambda function to check priority and iteration casting to unsigned int -// auto lf_UIntCheck = []( const std::string method, const std::string fieldStr, const std::string fieldName, -// const bool debugMode, int& field ) -// { -// field = 0; -// if( fieldStr.empty() == false ) -// { -// field = std::stoi( fieldStr ); //throws invalid_argument -// -// if( debugMode == true ) -// { -// if( field < 0 ) -// throw std::invalid_argument("ERROR: " + fieldName + " in transport " + method + " can't be negative\n" ); -// } -// } -// }; -// -// //this section will have to change, doing nothing for now -// currentPosition = 0; -// while( currentPosition != std::string::npos ) -// { -// GetSubString( "<transport ", ">", currentContent, tag, currentPosition ); -// if( tag.empty() ) break; -// tag = tag.substr( 1, tag.size() - 2 ); //eliminate < > -// pairs.clear(); -// GetPairsFromTag( currentContent, tag, pairs ); -// -// std::string groupName, method, priorityStr, iterationStr; -// for( auto& pair : pairs ) -// { -// if( pair.first == "group" ) groupName = pair.second; -// else if( pair.first == "method" ) method = pair.second; -// else if( pair.first == "priority" ) priorityStr = pair.second; -// else if( pair.first == "iteration" ) iterationStr = pair.second; -// } -// -// auto itGroup = groups.find( groupName ); -// if( debugMode == true ) -// { -// if( itGroup == groups.end() ) //not found -// throw std::invalid_argument( "ERROR: in transport " + method + " group " + groupName + " not found.\n" ); -// } -// -// int priority, iteration; -// lf_UIntCheck( method, priorityStr, "priority", debugMode, priority ); -// lf_UIntCheck( method, iterationStr, "iteration", debugMode, iteration ); -// //here do something with the capsule -// } -//} - - -//void InitXML( const std::string xmlConfigFile, const MPI_Comm mpiComm, const bool debugMode, -// std::string& hostLanguage, std::vector< std::shared_ptr<Transform> >& transforms, -// std::map< std::string, Group >& groups ) -//{ -// int xmlFileContentSize; -// std::string xmlFileContent; -// -// int rank; -// MPI_Comm_rank( mpiComm, &rank ); -// -// if( rank == 0 ) //serial part -// { -// DumpFileToString( xmlConfigFile, xmlFileContent ); //in ADIOSFunctions.h dumps all XML Config File to xmlFileContent -// xmlFileContentSize = xmlFileContent.size( ) + 1; // add one for the null character -// -// MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, mpiComm ); //broadcast size for allocation -// MPI_Bcast( (char*)xmlFileContent.c_str(), xmlFileContentSize, MPI_CHAR, 0, mpiComm ); //broadcast contents -// } -// else -// { -// MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, mpiComm ); //receive size -// -// char* xmlFileContentMPI = new char[ xmlFileContentSize ]; //allocate xml C-char -// MPI_Bcast( xmlFileContentMPI, xmlFileContentSize, MPI_CHAR, 0, mpiComm ); //receive xml C-char -// xmlFileContent.assign( xmlFileContentMPI ); //copy to a string -// -// delete []( xmlFileContentMPI ); //delete char* needed for MPI, might add size is moving to C++14 for optimization, avoid memory leak -// } -// -// SetMembers( xmlFileContent, mpiComm, debugMode, hostLanguage, transforms, groups ); -//} - - -std::size_t GetTotalSize( const std::vector<std::size_t>& dimensions ) -{ - std::size_t product = 1; - - for( const auto dimension : dimensions ) - product *= dimension; - - return product; -} - - -void CreateDirectory( const std::string fullPath ) noexcept -{ - auto lf_Mkdir = []( const std::string directory, struct stat& st ) - { - if ( stat( directory.c_str(), &st ) == -1 ) - mkdir( directory.c_str(), 0777 ); - }; - - auto directoryPosition = fullPath.find( "/" ); - - if( fullPath[0] == '/' || fullPath[0] == '.' ) //find the second '/' - directoryPosition = fullPath.find( "/", directoryPosition+1 ); - - struct stat st = {0}; - if( directoryPosition == fullPath.npos ) //no subdirectories - { - lf_Mkdir( fullPath.c_str(), st ); - return; - } - - std::string directory( fullPath.substr( 0, directoryPosition ) ); - lf_Mkdir( directory.c_str(), st ); - - while( directoryPosition != fullPath.npos ) - { - directoryPosition = fullPath.find( "/", directoryPosition+1 ); - directory = fullPath.substr( 0, directoryPosition ); - lf_Mkdir( directory.c_str(), st ); - } -} - - -void SetTransformsHelper( const std::vector<std::string>& transformNames, std::vector< std::shared_ptr<Transform> >& transforms, - const bool debugMode, std::vector<short>& transformIndices, std::vector<short>& parameters ) -{ - //function to get a parameter from "method:parameter" - auto lf_GetParameter = []( const std::string transformName, std::string& transformMethod, const bool debugMode ) -> short - { - short parameter = -1; - auto colonPosition = transformName.find( ":" ); - - if( colonPosition != transformName.npos ) - { - if( debugMode == true ) - { - if( colonPosition == transformName.size() - 1 ) - throw std::invalid_argument( "ERROR: wrong format for transform " + transformName + ", in call to SetTransform\n" ); - } - - transformMethod = transformName.substr( 0, colonPosition ); - parameter = std::stoi( transformName.substr( colonPosition+1 ) ); //need to test - } - return parameter; - }; - - //Get transform index from transforms, if not found return -1 - auto lf_GetTransformIndex = []( const std::string transformMethod, const std::vector< std::shared_ptr<Transform> >& transforms ) - -> short - { - short transformIndex = -1; - for( unsigned int i = 0; i < transforms.size(); ++i ) - { - if( transforms[i]->m_Method == transformMethod ) - { - transformIndex = i; - break; - } - } - return transformIndex; - }; - - //BODY of FUNCTION STARTS HERE - for( const std::string transformName : transformNames ) - { - std::string transformMethod( transformName ); - short parameter = lf_GetParameter( transformName, transformMethod, debugMode ); // from transform = "method:parameter" - short transformIndex = lf_GetTransformIndex( transformMethod, transforms ); - - if( transformIndex == -1 ) //not found, then create a new transform - { - if( transformMethod == "bzip2" ) - { - #ifdef HAVE_BZIP2 - transforms.push_back( std::make_shared<CBZIP2>( ) ); - #endif - } - - transformIndex = static_cast<short>( transforms.size() - 1 ); - } - transformIndices.push_back( transformIndex ); - parameters.push_back( parameter ); - } -} - - - -std::map<std::string, std::string> BuildParametersMap( const std::vector<std::string>& parameters, - const bool debugMode ) -{ - auto lf_GetFieldValue = []( const std::string parameter, std::string& field, std::string& value, const bool debugMode ) - { - auto equalPosition = parameter.find( "=" ); - - if( debugMode == true ) - { - if( equalPosition == parameter.npos ) - throw std::invalid_argument( "ERROR: wrong format for parameter " + parameter + ", format must be field=value \n" ); - - if( equalPosition == parameter.size()-1 ) - throw std::invalid_argument( "ERROR: empty value in parameter " + parameter + ", format must be field=value \n" ); - } - - field = parameter.substr( 0, equalPosition ); - value = parameter.substr( equalPosition+1 ); //need to test - }; - - //BODY OF FUNCTION STARTS HERE - std::map<std::string, std::string> parametersOutput; - - for( const auto parameter : parameters ) - { - std::string field, value; - lf_GetFieldValue( parameter, field, value, debugMode ); - - if( debugMode == true ) - { - if( parametersOutput.count( field ) == 1 ) - throw std::invalid_argument( "ERROR: parameter " + field + " already exists, must be unique\n" ); - } - - parametersOutput[field] = value; - } - - return parametersOutput; -} - - -std::vector<int> CSVToVectorInt( const std::string csv ) -{ - std::vector<int> numbers; - if( csv.empty() ) - return numbers; - - if( csv.find(",") == csv.npos ) //check if no commas, one int - { - numbers.push_back( std::stoi( csv ) ); //might need to be checked - } - else - { - int count = std::count( csv.begin(), csv.end(), ',' ); - numbers.reserve( count ); - - std::istringstream csvSS( csv ); - std::string value; - while( std::getline( csvSS, value, ',' ) ) //need to test - { - numbers.push_back( std::stoi( csv ) ); - } - } - - return numbers; -} - - -bool CheckBufferAllocation( const std::size_t newSize, const float growthFactor, const std::size_t maxBufferSize, - std::vector<char>& buffer ) -{ - //Check if data in buffer needs to be reallocated - const std::size_t requiredDataSize = buffer.size() + newSize + 100; //adding some bytes for tolerance - // might need to write payload in batches - bool doTransportsFlush = ( requiredDataSize > maxBufferSize )? true : false; - - if( GrowBuffer( requiredDataSize, growthFactor, buffer ) == -1 ) - doTransportsFlush = true; - - return doTransportsFlush; -} - - - -int GrowBuffer( const std::size_t incomingDataSize, const float growthFactor, - std::vector<char>& buffer ) -{ - const std::size_t currentCapacity = buffer.capacity(); - const std::size_t availableSpace = currentCapacity - buffer.size(); - const double gf = static_cast<double>( growthFactor ); - - if( incomingDataSize > availableSpace ) - { - const std::size_t neededCapacity = incomingDataSize + buffer.size(); - const double numerator = std::log( static_cast<double>( neededCapacity ) / static_cast<double>( currentCapacity ) ); - const double denominator = std::log( gf ); - - double n = std::ceil( numerator / denominator ); - const std::size_t newSize = static_cast<std::size_t>( std::ceil( std::pow( gf, n ) * currentCapacity ) ); - - try - { - buffer.reserve( newSize ); - } - catch( std::bad_alloc& e ) - { - return -1; - } - - return 1; - } - return 0; -} - - - -bool IsLittleEndian( ) noexcept -{ - std::uint16_t hexa = 0x1234; - return *reinterpret_cast<std::uint8_t*>(&hexa) != 0x12; -} - - -} //end namespace diff --git a/src/mpidummy.cpp b/src/mpidummy.cpp deleted file mode 100644 index e58e1b817..000000000 --- a/src/mpidummy.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * ADIOS is freely available under the terms of the BSD license described - * in the COPYING file in the top level directory of this source distribution. - * - * Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved. - */ - -/* - A dummy MPI implementation for the BP READ API, to have an MPI-free version of the API -*/ -/// \cond EXCLUDE_FROM_DOXYGEN -#define __STDC_FORMAT_MACROS -#include <stdint.h> -#include <inttypes.h> -#include <stdio.h> -#include <string.h> -#include <cstdint> -//#define _LARGEFILE64_SOURCE -#include <sys/types.h> -#include <sys/time.h> -#include <unistd.h> -/// \endcond - -#include "mpidummy.h" - - - -#if defined(__APPLE__) || defined(__WIN32__) || defined(__CYGWIN__) -# define lseek64 lseek -# define open64 open -#endif - - -namespace adios -{ - -static char mpierrmsg[MPI_MAX_ERROR_STRING]; - -int MPI_Init(int *argc, char ***argv) -{ - mpierrmsg[0] = '\0'; - return MPI_SUCCESS; -} - -int MPI_Finalize() -{ - mpierrmsg[0] = '\0'; - return MPI_SUCCESS; -} - -int MPI_Initialized( int* flag ) -{ - *flag = 1 ; - return MPI_SUCCESS; -} - -int MPI_Comm_split ( MPI_Comm comm, int color, int key, MPI_Comm *comm_out ) {return MPI_SUCCESS;} - -int MPI_Barrier(MPI_Comm comm) { return MPI_SUCCESS; } -int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) { return MPI_SUCCESS; } - -int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm) { *newcomm = comm; return MPI_SUCCESS; } -int MPI_Comm_rank(MPI_Comm comm, int *rank) { *rank = 0; return MPI_SUCCESS; } -int MPI_Comm_size(MPI_Comm comm, int *size) { *size = 1; return MPI_SUCCESS; } -int MPI_Comm_free(MPI_Comm *comm) { *comm = 0; return MPI_SUCCESS; } -MPI_Comm MPI_Comm_f2c(MPI_Fint comm) { return comm; } - -int MPI_Gather(void *sendbuf, int sendcnt, MPI_Datatype sendtype, - void *recvbuf, int recvcnt, MPI_Datatype recvtype, - int root, MPI_Comm comm) -{ - int ier = MPI_SUCCESS; - size_t n=0, nsent=0, nrecv=0 ; - if( !sendbuf || !recvbuf ) ier = MPI_ERR_BUFFER ; - if( comm==MPI_COMM_NULL || root ) ier = MPI_ERR_COMM ; - - switch( sendtype ) - { - case MPI_INT : n = sizeof( int ); - break; - default : return MPI_ERR_TYPE ; - } - nsent = n * sendcnt ; - - switch( recvtype ) - { - case MPI_INT : nrecv = sizeof( int ) ; - break; - default : return MPI_ERR_TYPE ; - } - nrecv = n * recvcnt ; - - if( nrecv!=nsent ) ier = MPI_ERR_COUNT ; - - if( ier == MPI_SUCCESS ) memcpy( recvbuf, sendbuf, nsent ); - else snprintf(mpierrmsg, ier, "could not gather data\n" ); - - return ier ; -} - -int MPI_Gatherv(void *sendbuf, int sendcnt, MPI_Datatype sendtype, - void *recvbuf, int *recvcnts, int *displs, - MPI_Datatype recvtype, int root, MPI_Comm comm) -{ - int ier = MPI_SUCCESS; - if( !recvcnts || !displs ) ier = MPI_ERR_BUFFER ; - - if( ier == MPI_SUCCESS ) - ier = MPI_Gather(sendbuf, sendcnt, sendtype, recvbuf, recvcnts[0], recvtype, root, comm ) ; - - return ier ; -} - -int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, - void *recvbuf, int recvcount, MPI_Datatype recvtype, - MPI_Comm comm) -{ - return MPI_Gather (sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, 0, comm); -} - -int MPI_Scatter(void *sendbuf, int sendcnt, MPI_Datatype sendtype, - void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, - MPI_Comm comm) -{ - int ier = MPI_SUCCESS; - size_t n=0, nsent=0, nrecv=0 ; - if( !sendbuf || !recvbuf ) ier = MPI_ERR_BUFFER ; - if( comm==MPI_COMM_NULL || root ) ier = MPI_ERR_COMM ; - - switch( sendtype ) - { - case MPI_INT : n = sizeof( int ) ; - break; - default : return MPI_ERR_TYPE ; - } - nsent = n * sendcnt ; - - switch( recvtype ) - { - case MPI_INT : nrecv = sizeof( int ) ; - break; - default : return MPI_ERR_TYPE ; - } - nrecv = n * recvcnt ; - - if( nrecv!=nsent ) ier = MPI_ERR_COUNT ; - - if( ier == MPI_SUCCESS ) memcpy( sendbuf, recvbuf, nsent ); - else snprintf(mpierrmsg, ier, "could not scatter data\n" ); - - return ier ; -} - -int MPI_Scatterv( void *sendbuf, int *sendcnts, int *displs, - MPI_Datatype sendtype, void *recvbuf, int recvcnt, - MPI_Datatype recvtype, - int root, MPI_Comm comm) -{ - int ier = MPI_SUCCESS; - if( !sendcnts || !displs ) ier = MPI_ERR_BUFFER ; - - if( ier == MPI_SUCCESS ) - ier = MPI_Scatter(sendbuf, sendcnts[0], sendtype, recvbuf, recvcnt, recvtype, root, comm ) ; - - return ier ; -} - -int MPI_Recv( void *recvbuffer, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Status* status ) -{ return 0; } - -int MPI_Irecv( void *recvbuffer, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Request* request ) -{ return 0; } - -int MPI_Send( void *sendbuffer, int count, MPI_Datatype type, int destination, int tag, MPI_Comm comm ) -{ return 0; } - -int MPI_Isend( void *recvbuffer, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Request* request ) -{ return 0; } - -int MPI_Wait( MPI_Request* request, MPI_Status* status ) -{ return 0; } - -int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh) -{ - *fh = open64 (filename, amode); - if (*fh == -1) { - snprintf(mpierrmsg, MPI_MAX_ERROR_STRING, "File not found: %s", filename); - return -1; - } - return MPI_SUCCESS; -} - -int MPI_File_close(MPI_File *fh) { return close(*fh); } - -int MPI_File_get_size(MPI_File fh, MPI_Offset *size) { - uint64_t curpos = lseek64(fh, 0, SEEK_CUR); // get the current seek pos - uint64_t endpos = lseek64(fh, 0, SEEK_END); // go to end, returned is the size in bytes - lseek64(fh, curpos, SEEK_SET); // go back where we were - *size = (MPI_Offset) endpos; - //printf("MPI_File_get_size: fh=%d, size=%lld\n", fh, *size); - return MPI_SUCCESS; -} - -int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status) -{ - // FIXME: int count can read only 2GB (*datatype size) array at max - std::uint64_t bytes_to_read = count * datatype; // datatype should hold the size of the type, not an id - std::uint64_t bytes_read; - bytes_read = read (fh, buf, bytes_to_read); - if (bytes_read != bytes_to_read) { - snprintf(mpierrmsg, MPI_MAX_ERROR_STRING, "could not read %" PRId64 " bytes. read only: %" PRId64 "\n", bytes_to_read, bytes_read); - return -2; - } - *status = bytes_read; - //printf("MPI_File_read: fh=%d, count=%d, typesize=%d, bytes read=%lld\n", fh, count, datatype, *status); - return MPI_SUCCESS; -} - -int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence) -{ - uint64_t off = (uint64_t) offset; - lseek64 (fh, off, whence); - //printf("MPI_File_seek: fh=%d, offset=%lld, whence=%d\n", fh, off, whence); - return MPI_SUCCESS; -} - -int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count) -{ - *count = (int) *status; - return MPI_SUCCESS; -} - -int MPI_Error_string(int errorcode, char *string, int *resultlen) -{ - //sprintf(string, "Dummy lib does not know error strings. Code=%d\n",errorcode); - strcpy(string, mpierrmsg); - *resultlen = strlen(string); - return MPI_SUCCESS; -} - -double MPI_Wtime() -{ - // Implementation not tested - struct timeval tv; - gettimeofday (&tv, NULL); - return (double)(tv.tv_sec) + (double)(tv.tv_usec) / 1000000; -} - -int MPI_Get_processor_name (char *name, int *resultlen) -{ - sprintf(name, "0"); - *resultlen = 1; - return 0; -} - -}//end namespace diff --git a/src/transform/BZip2.cpp b/src/transform/BZip2.cpp deleted file mode 100644 index 36c3bde0b..000000000 --- a/src/transform/BZip2.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * BZIP2.cpp - * - * Created on: Oct 19, 2016 - * Author: wfg - */ - - - -#include "../../include/transform/BZip2.h" - - - -namespace adios -{ -namespace transform -{ - - -BZIP2::BZIP2( ): - Transform( "bzip2" ) -{ } - - -BZIP2::~BZIP2( ) -{ } - - - -void BZIP2::Compress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) -{ - -} - - -void BZIP2::Decompress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) -{ - -} - - -} //end namespace transform -} //end namespace adios - - diff --git a/src/transport/file/FStream.cpp b/src/transport/file/FStream.cpp deleted file mode 100644 index 9d571ebaf..000000000 --- a/src/transport/file/FStream.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CFStream.cpp - * - * Created on: Oct 24, 2016 - * Author: wfg - */ - -/// \cond EXCLUDED_FROM_DOXYGEN -#include <stdexcept> -/// \endcond - -#include "transport/file/FStream.h" - - -namespace adios -{ -namespace transport -{ - - -FStream::FStream( MPI_Comm mpiComm, const bool debugMode ): - Transport( "fstream", mpiComm, debugMode ) -{ } - - -FStream::~FStream( ) -{ } - - -void FStream::Open( const std::string name, const std::string accessMode ) -{ - m_Name = name; - m_AccessMode = accessMode; - - if( accessMode == "w" || accessMode == "write" ) - m_FStream.open( name, std::fstream::out ); - - else if( accessMode == "a" || accessMode == "append" ) - m_FStream.open( name, std::fstream::out | std::fstream::app ); - - else if( accessMode == "r" || accessMode == "read" ) - m_FStream.open( name, std::fstream::in ); - - if( m_DebugMode == true ) - { - if( !m_FStream ) - throw std::ios_base::failure( "ERROR: couldn't open file " + name + ", in call to Open from FStream transport\n" ); - } -} - - -void FStream::SetBuffer( char* buffer, std::size_t size ) -{ - m_FStream.rdbuf()->pubsetbuf( buffer, size ); -} - - -void FStream::Write( const char* buffer, std::size_t size ) -{ - m_FStream.write( buffer, size ); - - if( m_DebugMode == true ) - { - if( !m_FStream ) - throw std::ios_base::failure( "ERROR: couldn't write to file " + m_Name + ", in call to FStream write\n" ); - } -} - - -void FStream::Flush( ) -{ - m_FStream.flush( ); -} - - -void FStream::Close( ) -{ - m_FStream.close(); -} - - -} //end namespace transport -} //end namespace - diff --git a/src/transport/file/FileDescriptor.cpp b/src/transport/file/FileDescriptor.cpp deleted file mode 100644 index dabb4e2a2..000000000 --- a/src/transport/file/FileDescriptor.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * FileDescriptor.cpp file descriptor - * - * Created on: Oct 6, 2016 - * Author: wfg - */ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <fcntl.h> //open -#include <sys/types.h> //open -#include <sys/stat.h> //open -#include <stddef.h> // write output -#include <unistd.h> // write, close -#include <ios> //std::ios_base::failure -/// \endcond - - - -#include "transport/file/FileDescriptor.h" - - -namespace adios -{ -namespace transport -{ - -FileDescriptor::FileDescriptor( MPI_Comm mpiComm, const bool debugMode ): - Transport( "POSIX_IO", mpiComm, debugMode ) -{ } - - -FileDescriptor::~FileDescriptor( ) -{ - if( m_FileDescriptor != -1 ) - { - close( m_FileDescriptor ); - } -} - - -void FileDescriptor::Open( const std::string name, const std::string accessMode ) -{ - m_Name = name; - m_AccessMode = accessMode; - - if( accessMode == "w" || accessMode == "write" ) - { - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[0].SetInitialTime(); - - m_FileDescriptor = open( m_Name.c_str(), O_WRONLY | O_CREAT, 0777 ); - - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[0].SetTime(); - - } - else if( accessMode == "a" || accessMode == "append" ) - { - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[0].SetInitialTime(); - - m_FileDescriptor = open( m_Name.c_str(), O_WRONLY | O_APPEND ); //we need to change this - - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[0].SetTime(); - } - else if( accessMode == "r" || accessMode == "read" ) - { - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[0].SetInitialTime(); - - m_FileDescriptor = open( m_Name.c_str(), O_RDONLY ); - - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[0].SetTime(); - } - - if( m_DebugMode == true ) - { - if( m_FileDescriptor == -1 ) - throw std::ios_base::failure( "ERROR: couldn't open file " + m_Name + - ", from call to Open in FD transport using POSIX open. Does file exists?\n" ); - } -} - - -void FileDescriptor::Write( const char* buffer, std::size_t size ) -{ - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[1].SetInitialTime(); - - auto writtenSize = write( m_FileDescriptor, buffer, size ); - - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[1].SetTime(); - - if( m_DebugMode == true ) - { - if( writtenSize == -1 ) - throw std::ios_base::failure( "ERROR: couldn't write to file " + m_Name + - ", in call to POSIX write\n" ); - - if( static_cast<std::size_t>( writtenSize ) != size ) - throw std::ios_base::failure( "ERROR: written size + " + std::to_string( writtenSize ) + - " is not equal to intended size " + - std::to_string( size ) + " in file " + m_Name + - ", in call to POSIX write\n" ); - } -} - - -void FileDescriptor::Close( ) -{ - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[2].SetInitialTime(); - - int status = close( m_FileDescriptor ); - - if( m_Profiler.m_IsActive == true ) - m_Profiler.m_Timers[2].SetTime(); - - if( m_DebugMode == true ) - { - if( status == -1 ) - throw std::ios_base::failure( "ERROR: couldn't close file " + m_Name + - ", in call to POSIX write\n" ); - } - - m_IsOpen = false; -} - - - -} //end namespace transport -}//end namespace diff --git a/src/transport/file/FilePointer.cpp b/src/transport/file/FilePointer.cpp deleted file mode 100644 index 181af76a9..000000000 --- a/src/transport/file/FilePointer.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * FP.cpp - * - * Created on: Jan 6, 2017 - * Author: wfg - */ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <ios> //std::ios_base::failure -/// \endcond - - -#include "transport/file/FilePointer.h" - - -namespace adios -{ -namespace transport -{ - - -FilePointer::FilePointer( MPI_Comm mpiComm, const bool debugMode ): - Transport( "FILE*", mpiComm, debugMode ) -{ } - - -FilePointer::~FilePointer( ) -{ - if( m_File != NULL ) - fclose( m_File ); -} - - -void FilePointer::Open( const std::string name, const std::string accessMode ) -{ - m_Name = name; - m_AccessMode = accessMode; - - if( accessMode == "w" || accessMode == "write" ) - m_File = fopen( name.c_str(), "w" ); - - else if( accessMode == "a" || accessMode == "append" ) - m_File = fopen( name.c_str(), "a" ); - - else if( accessMode == "r" || accessMode == "read" ) - m_File = fopen( name.c_str(), "r" ); - - if( m_DebugMode == true ) - { - if( m_File == NULL ) - throw std::ios_base::failure( "ERROR: couldn't open file " + name + ", " - "in call to Open from File* transport\n" ); - } -} - - -void FilePointer::SetBuffer( char* buffer, std::size_t size ) -{ - int status = setvbuf( m_File, buffer, _IOFBF, size ); - - if( m_DebugMode == true ) - { - if( status == 1 ) - throw std::ios_base::failure( "ERROR: could not set buffer in rank " - + std::to_string( m_RankMPI ) + "\n" ); - } -} - - -void FilePointer::Write( const char* buffer, std::size_t size ) -{ - fwrite( buffer, sizeof(char), size, m_File ); - - if( m_DebugMode == true ) - { - if( ferror( m_File ) ) - throw std::ios_base::failure( "ERROR: couldn't write to file " + m_Name + - ", in call to File* write\n" ); - } -} - - -void FilePointer::Flush( ) -{ - fflush( m_File ); -} - - -void FilePointer::Close( ) -{ - fclose( m_File ); - - m_IsOpen = false; -} - - -} //end namespace transport -} //end namespace diff --git a/src/transport/wan/MdtmMan.cpp b/src/transport/wan/MdtmMan.cpp deleted file mode 100644 index 6df6b1951..000000000 --- a/src/transport/wan/MdtmMan.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * MdtmMan.cpp - * - * Created on: Jan 22, 2017 - * Author: wfg - */ - - - -#include "transport/wan/MdtmMan.h" - - - -namespace adios -{ -namespace transport -{ - -MdtmMan::MdtmMan( const std::string localIP, const std::string remoteIP, const std::string mode, const std::string prefix, - const int numberOfPipes, const std::vector<int> tolerances, const std::vector<int> priorities, - MPI_Comm mpiComm, const bool debugMode ): - Transport( "File", mpiComm, debugMode ), - m_LocalIP { localIP }, - m_RemoteIP{ remoteIP }, - m_Mode{ mode }, - m_Prefix { prefix }, - m_NumberOfPipes{ numberOfPipes }, - m_Tolerances{ tolerances }, - m_Priorities{ priorities } -{ } - -MdtmMan::~MdtmMan( ) -{ } - - -void MdtmMan::Open( const std::string name, const std::string accessMode ) -{ } - - -void MdtmMan::SetBuffer( char* buffer, std::size_t size ) -{ } - - -void MdtmMan::Write( const char* buffer, std::size_t size ) -{ } - - -void MdtmMan::Flush( ) -{ } - - -void MdtmMan::Close( ) -{ - - m_NumberOfPipes = -1; -} - - -//PRIVATE Functions -int MdtmMan::Put( const void* data, const std::string doid, const std::string variable, const std::string dType, - const std::vector<std::uint64_t>& putShape, const std::vector<uint64_t>& varShape, const std::vector<uint64_t>& offset, - const std::uint64_t timestep, const int tolerance, const int priority ) -{ - - - return 0; -} - - -int MdtmMan::Get( void* data, const std::string doid, const std::string variable, const std::string dType, - const std::vector<std::uint64_t>& putShape, const std::vector<uint64_t>& varShape, const std::vector<uint64_t>& offset, - const std::uint64_t timestep, const int tolerance, const int priority ) -{ - - return 0; -} - - -int MdtmMan::Get( void *data, const std::string doid, const std::string variable, const std::string dType, - std::vector<std::uint64_t>& varShape, const std::uint64_t timestep ) -{ - - return 0; -} - - - -void MdtmMan::OnReceive( nlohmann::json& jData ) -{ - -} - - - -} //end namespace transport -} //end namespace -- GitLab