From 031beadad7fdabe15e1e6fb598fea81006184c7e Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 23 Aug 2023 07:08:00 -0400 Subject: [PATCH 001/126] Reader-side Profiling --- source/adios2/engine/bp5/BP5Reader.cpp | 50 ++++++++++++++++++- source/adios2/engine/bp5/BP5Reader.h | 3 ++ .../toolkit/profiling/iochrono/IOChrono.cpp | 21 ++++++-- .../toolkit/profiling/iochrono/IOChrono.h | 1 + 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index 687570fa87..679a0af97a 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -10,6 +10,7 @@ #include "BP5Reader.tcc" #include "adios2/helper/adiosMath.h" // SetWithinLimit +#include "adios2/toolkit/transport/file/FileFStream.h" #include #include @@ -31,7 +32,7 @@ namespace engine BP5Reader::BP5Reader(IO &io, const std::string &name, const Mode mode, helper::Comm comm) : Engine("BP5Reader", io, name, mode, std::move(comm)), m_MDFileManager(io, m_Comm), m_DataFileManager(io, m_Comm), m_MDIndexFileManager(io, m_Comm), - m_FileMetaMetadataManager(io, m_Comm), m_ActiveFlagFileManager(io, m_Comm), m_Remote() + m_FileMetaMetadataManager(io, m_Comm), m_ActiveFlagFileManager(io, m_Comm), m_Remote(), m_JSONProfiler(m_Comm) { PERFSTUBS_SCOPED_TIMER("BP5Reader::Open"); Init(); @@ -298,6 +299,7 @@ void BP5Reader::PerformLocalGets() // TP start = NOW(); PERFSTUBS_SCOPED_TIMER("BP5Reader::PerformGets"); + m_JSONProfiler.Start("DataRead"); size_t maxReadSize; // TP startGenerate = NOW(); @@ -317,6 +319,9 @@ void BP5Reader::PerformLocalGets() reqidx = nextRequest; ++nextRequest; } + if (reqidx <= nRequest) { + m_JSONProfiler.AddBytes("dataread", ReadRequests[reqidx].ReadLength); + } return reqidx; }; @@ -406,11 +411,13 @@ void BP5Reader::PerformLocalGets() { Req.DestinationAddr = buf.data(); } + m_JSONProfiler.AddBytes("dataread", Req.ReadLength); ReadData(m_DataFileManager, maxOpenFiles, Req.WriterRank, Req.Timestep, Req.StartOffset, Req.ReadLength, Req.DestinationAddr); m_BP5Deserializer->FinalizeGet(Req, false); } } + m_JSONProfiler.Stop("DataRead"); /*TP end = NOW(); double t1 = DURATION(start, end); double t2 = DURATION(startRead, end); @@ -789,16 +796,19 @@ void BP5Reader::UpdateBuffer(const TimePoint &timeoutInstant, const Seconds &pol if (actualFileSize >= expectedMinFileSize) { + m_JSONProfiler.Start("MetaDataRead"); m_Metadata.Resize(fileFilteredSize, "allocating metadata buffer, " "in call to BP5Reader Open"); size_t mempos = 0; for (auto p : m_FilteredMetadataInfo) { + m_JSONProfiler.AddBytes("metadataread", p.second); m_MDFileManager.ReadFile(m_Metadata.m_Buffer.data() + mempos, p.second, p.first); mempos += p.second; } m_MDFileAlreadyReadSize = expectedMinFileSize; + m_JSONProfiler.Stop("MetaDataRead"); } else { @@ -824,12 +834,15 @@ void BP5Reader::UpdateBuffer(const TimePoint &timeoutInstant, const Seconds &pol if (metametadataFileSize > m_MetaMetaDataFileAlreadyReadSize) { const size_t newMMDSize = metametadataFileSize - m_MetaMetaDataFileAlreadyReadSize; + m_JSONProfiler.Start("MetaMetaDataRead"); + m_JSONProfiler.AddBytes("metametadataread", newMMDSize); m_MetaMetadata.Resize(metametadataFileSize, "(re)allocating meta-meta-data buffer, " "in call to BP5Reader Open"); m_FileMetaMetadataManager.ReadFile(m_MetaMetadata.m_Buffer.data() + m_MetaMetaDataFileAlreadyReadSize, newMMDSize, m_MetaMetaDataFileAlreadyReadSize); m_MetaMetaDataFileAlreadyReadSize += newMMDSize; + m_JSONProfiler.Stop("MetaMetaDataRead"); } } @@ -1194,6 +1207,7 @@ void BP5Reader::DoClose(const int transportIndex) { EndStep(); } + FlushProfiler(); m_DataFileManager.CloseFiles(); m_MDFileManager.CloseFiles(); m_MDIndexFileManager.CloseFiles(); @@ -1204,6 +1218,40 @@ void BP5Reader::DoClose(const int transportIndex) } } +#if defined(_WIN32) +# include +# define getpid() GetCurrentProcessId(); +#elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \ + defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ + defined(__CYGWIN__) +#else +# define getpid() (long long) -1; +#endif + +void BP5Reader::FlushProfiler() +{ + + auto LineJSON = m_JSONProfiler.GetRankProfilingJSON({}, {}); + const std::vector profilingJSON(m_JSONProfiler.AggregateProfilingJSON(LineJSON)); + + if (m_RankMPI == 0) + { + std::string profileFileName; + transport::FileFStream profilingJSONStream(m_Comm); + std::string bpBaseName = m_Name; + + auto PID = getpid(); + std::stringstream PIDstr; + PIDstr << std::hex << PID; + // write profile json in /tmp + profileFileName = "/tmp/" + bpBaseName + "_" + PIDstr.str() + "_profiling.json"; + + profilingJSONStream.Open(profileFileName, Mode::Write); + profilingJSONStream.Write(profilingJSON.data(), profilingJSON.size()); + profilingJSONStream.Close(); + } +} + size_t BP5Reader::DoSteps() const { return m_StepsCount; } void BP5Reader::NotifyEngineNoVarsQuery() diff --git a/source/adios2/engine/bp5/BP5Reader.h b/source/adios2/engine/bp5/BP5Reader.h index 7d837184ac..117a05f3c2 100644 --- a/source/adios2/engine/bp5/BP5Reader.h +++ b/source/adios2/engine/bp5/BP5Reader.h @@ -58,6 +58,7 @@ class BP5Reader : public BP5Engine, public Engine MinVarInfo *MinBlocksInfo(const VariableBase &, const size_t Step) const; bool VarShape(const VariableBase &Var, const size_t Step, Dims &Shape) const; bool VariableMinMax(const VariableBase &, const size_t Step, MinMaxStruct &MinMax); + adios2::profiling::JSONProfiler m_JSONProfiler; private: format::BP5Deserializer *m_BP5Deserializer = nullptr; @@ -200,6 +201,8 @@ class BP5Reader : public BP5Engine, public Engine void DoClose(const int transportIndex = -1) final; + void FlushProfiler(); + void GetSyncCommon(VariableBase &variable, void *data); void GetDeferredCommon(VariableBase &variable, void *data); diff --git a/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp b/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp index 40fb740aa2..5c3761f7dc 100644 --- a/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp +++ b/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp @@ -57,6 +57,12 @@ JSONProfiler::JSONProfiler(helper::Comm const &comm) : m_Comm(comm) AddTimerWatch("PDW"); m_Profiler.m_Bytes.emplace("buffering", 0); + AddTimerWatch("DataRead"); + m_Profiler.m_Bytes.emplace("dataread", 0); + AddTimerWatch("MetaDataRead"); + m_Profiler.m_Bytes.emplace("metadataread", 0); + AddTimerWatch("MetaMetaDataRead"); + m_Profiler.m_Bytes.emplace("metadmetaataread", 0); m_RankMPI = m_Comm.Rank(); } @@ -92,11 +98,20 @@ std::string JSONProfiler::GetRankProfilingJSON( for (const auto &timerPair : profiler.m_Timers) { const profiling::Timer &timer = timerPair.second; - // rankLog += "\"" + timer.m_Process + "_" + timer.GetShortUnits() + - // "\": " + std::to_string(timer.m_ProcessTime) + ", "; - timer.AddToJsonStr(rankLog); + if (timer.m_nCalls > 0) { + rankLog += "\"" + timer.m_Process + "_" + timer.GetShortUnits() + + "\": " + std::to_string(timer.m_ProcessTime) + ", "; + timer.AddToJsonStr(rankLog); + } } + size_t DataBytes = m_Profiler.m_Bytes["dataread"]; + size_t MetaDataBytes = m_Profiler.m_Bytes["metadataread"]; + size_t MetaMetaDataBytes = m_Profiler.m_Bytes["metametadataread"]; + rankLog += ", \"databytes\":" + std::to_string(DataBytes); + rankLog += ", \"metadatabytes\":" + std::to_string(MetaDataBytes); + rankLog += ", \"metametadatabytes\":" + std::to_string(MetaMetaDataBytes); + const size_t transportsSize = transportsTypes.size(); for (unsigned int t = 0; t < transportsSize; ++t) diff --git a/source/adios2/toolkit/profiling/iochrono/IOChrono.h b/source/adios2/toolkit/profiling/iochrono/IOChrono.h index 735d4fea1c..a2d410fccd 100644 --- a/source/adios2/toolkit/profiling/iochrono/IOChrono.h +++ b/source/adios2/toolkit/profiling/iochrono/IOChrono.h @@ -68,6 +68,7 @@ class JSONProfiler void Start(const std::string process) { m_Profiler.Start(process); }; void Stop(const std::string process) { m_Profiler.Stop(process); }; + void AddBytes(const std::string process, size_t bytes) { m_Profiler.m_Bytes[process] += bytes ;}; std::string GetRankProfilingJSON( const std::vector &transportsTypes, From cb28597135f12bd8d37082aec7109b5b947a1c50 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 23 Aug 2023 07:12:41 -0400 Subject: [PATCH 002/126] format --- source/adios2/engine/bp5/BP5Reader.cpp | 61 ++++++++++--------- .../toolkit/profiling/iochrono/IOChrono.cpp | 11 ++-- .../toolkit/profiling/iochrono/IOChrono.h | 5 +- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index 679a0af97a..2ce49fd991 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -32,7 +32,8 @@ namespace engine BP5Reader::BP5Reader(IO &io, const std::string &name, const Mode mode, helper::Comm comm) : Engine("BP5Reader", io, name, mode, std::move(comm)), m_MDFileManager(io, m_Comm), m_DataFileManager(io, m_Comm), m_MDIndexFileManager(io, m_Comm), - m_FileMetaMetadataManager(io, m_Comm), m_ActiveFlagFileManager(io, m_Comm), m_Remote(), m_JSONProfiler(m_Comm) + m_FileMetaMetadataManager(io, m_Comm), m_ActiveFlagFileManager(io, m_Comm), m_Remote(), + m_JSONProfiler(m_Comm) { PERFSTUBS_SCOPED_TIMER("BP5Reader::Open"); Init(); @@ -319,9 +320,10 @@ void BP5Reader::PerformLocalGets() reqidx = nextRequest; ++nextRequest; } - if (reqidx <= nRequest) { - m_JSONProfiler.AddBytes("dataread", ReadRequests[reqidx].ReadLength); - } + if (reqidx <= nRequest) + { + m_JSONProfiler.AddBytes("dataread", ReadRequests[reqidx].ReadLength); + } return reqidx; }; @@ -411,7 +413,7 @@ void BP5Reader::PerformLocalGets() { Req.DestinationAddr = buf.data(); } - m_JSONProfiler.AddBytes("dataread", Req.ReadLength); + m_JSONProfiler.AddBytes("dataread", Req.ReadLength); ReadData(m_DataFileManager, maxOpenFiles, Req.WriterRank, Req.Timestep, Req.StartOffset, Req.ReadLength, Req.DestinationAddr); m_BP5Deserializer->FinalizeGet(Req, false); @@ -796,19 +798,19 @@ void BP5Reader::UpdateBuffer(const TimePoint &timeoutInstant, const Seconds &pol if (actualFileSize >= expectedMinFileSize) { - m_JSONProfiler.Start("MetaDataRead"); + m_JSONProfiler.Start("MetaDataRead"); m_Metadata.Resize(fileFilteredSize, "allocating metadata buffer, " "in call to BP5Reader Open"); size_t mempos = 0; for (auto p : m_FilteredMetadataInfo) { - m_JSONProfiler.AddBytes("metadataread", p.second); + m_JSONProfiler.AddBytes("metadataread", p.second); m_MDFileManager.ReadFile(m_Metadata.m_Buffer.data() + mempos, p.second, p.first); mempos += p.second; } m_MDFileAlreadyReadSize = expectedMinFileSize; - m_JSONProfiler.Stop("MetaDataRead"); + m_JSONProfiler.Stop("MetaDataRead"); } else { @@ -834,15 +836,15 @@ void BP5Reader::UpdateBuffer(const TimePoint &timeoutInstant, const Seconds &pol if (metametadataFileSize > m_MetaMetaDataFileAlreadyReadSize) { const size_t newMMDSize = metametadataFileSize - m_MetaMetaDataFileAlreadyReadSize; - m_JSONProfiler.Start("MetaMetaDataRead"); - m_JSONProfiler.AddBytes("metametadataread", newMMDSize); + m_JSONProfiler.Start("MetaMetaDataRead"); + m_JSONProfiler.AddBytes("metametadataread", newMMDSize); m_MetaMetadata.Resize(metametadataFileSize, "(re)allocating meta-meta-data buffer, " "in call to BP5Reader Open"); m_FileMetaMetadataManager.ReadFile(m_MetaMetadata.m_Buffer.data() + m_MetaMetaDataFileAlreadyReadSize, newMMDSize, m_MetaMetaDataFileAlreadyReadSize); m_MetaMetaDataFileAlreadyReadSize += newMMDSize; - m_JSONProfiler.Stop("MetaMetaDataRead"); + m_JSONProfiler.Stop("MetaMetaDataRead"); } } @@ -1219,36 +1221,35 @@ void BP5Reader::DoClose(const int transportIndex) } #if defined(_WIN32) -# include -# define getpid() GetCurrentProcessId(); -#elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \ - defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ - defined(__CYGWIN__) +#include +#define getpid() GetCurrentProcessId(); +#elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ + defined(__NetBSD__) || defined(__DragonFly__) || defined(__CYGWIN__) #else -# define getpid() (long long) -1; +#define getpid() (long long)-1; #endif void BP5Reader::FlushProfiler() { - auto LineJSON = m_JSONProfiler.GetRankProfilingJSON({}, {}); + auto LineJSON = m_JSONProfiler.GetRankProfilingJSON({}, {}); const std::vector profilingJSON(m_JSONProfiler.AggregateProfilingJSON(LineJSON)); if (m_RankMPI == 0) { std::string profileFileName; - transport::FileFStream profilingJSONStream(m_Comm); - std::string bpBaseName = m_Name; - - auto PID = getpid(); - std::stringstream PIDstr; - PIDstr << std::hex << PID; - // write profile json in /tmp - profileFileName = "/tmp/" + bpBaseName + "_" + PIDstr.str() + "_profiling.json"; - - profilingJSONStream.Open(profileFileName, Mode::Write); - profilingJSONStream.Write(profilingJSON.data(), profilingJSON.size()); - profilingJSONStream.Close(); + transport::FileFStream profilingJSONStream(m_Comm); + std::string bpBaseName = m_Name; + + auto PID = getpid(); + std::stringstream PIDstr; + PIDstr << std::hex << PID; + // write profile json in /tmp + profileFileName = "/tmp/" + bpBaseName + "_" + PIDstr.str() + "_profiling.json"; + + profilingJSONStream.Open(profileFileName, Mode::Write); + profilingJSONStream.Write(profilingJSON.data(), profilingJSON.size()); + profilingJSONStream.Close(); } } diff --git a/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp b/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp index 5c3761f7dc..a8713339ed 100644 --- a/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp +++ b/source/adios2/toolkit/profiling/iochrono/IOChrono.cpp @@ -98,11 +98,12 @@ std::string JSONProfiler::GetRankProfilingJSON( for (const auto &timerPair : profiler.m_Timers) { const profiling::Timer &timer = timerPair.second; - if (timer.m_nCalls > 0) { - rankLog += "\"" + timer.m_Process + "_" + timer.GetShortUnits() + - "\": " + std::to_string(timer.m_ProcessTime) + ", "; - timer.AddToJsonStr(rankLog); - } + if (timer.m_nCalls > 0) + { + rankLog += "\"" + timer.m_Process + "_" + timer.GetShortUnits() + + "\": " + std::to_string(timer.m_ProcessTime) + ", "; + timer.AddToJsonStr(rankLog); + } } size_t DataBytes = m_Profiler.m_Bytes["dataread"]; diff --git a/source/adios2/toolkit/profiling/iochrono/IOChrono.h b/source/adios2/toolkit/profiling/iochrono/IOChrono.h index a2d410fccd..9abe786144 100644 --- a/source/adios2/toolkit/profiling/iochrono/IOChrono.h +++ b/source/adios2/toolkit/profiling/iochrono/IOChrono.h @@ -68,7 +68,10 @@ class JSONProfiler void Start(const std::string process) { m_Profiler.Start(process); }; void Stop(const std::string process) { m_Profiler.Stop(process); }; - void AddBytes(const std::string process, size_t bytes) { m_Profiler.m_Bytes[process] += bytes ;}; + void AddBytes(const std::string process, size_t bytes) + { + m_Profiler.m_Bytes[process] += bytes; + }; std::string GetRankProfilingJSON( const std::vector &transportsTypes, From 7f3cecfa40ab25a5b57542067e520c525f4c9134 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 23 Aug 2023 12:51:16 -0400 Subject: [PATCH 003/126] Remove file before writing, catch exceptions --- source/adios2/engine/bp5/BP5Reader.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index 2ce49fd991..8062f9184a 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -14,7 +14,9 @@ #include #include +#include #include +#include #include #include @@ -1247,9 +1249,16 @@ void BP5Reader::FlushProfiler() // write profile json in /tmp profileFileName = "/tmp/" + bpBaseName + "_" + PIDstr.str() + "_profiling.json"; - profilingJSONStream.Open(profileFileName, Mode::Write); - profilingJSONStream.Write(profilingJSON.data(), profilingJSON.size()); - profilingJSONStream.Close(); + try + { + (void)remove(profileFileName.c_str()); + profilingJSONStream.Open(profileFileName, Mode::Write); + profilingJSONStream.Write(profilingJSON.data(), profilingJSON.size()); + profilingJSONStream.Close(); + } + catch (...) + { // do nothing + } } } From 5ae2babca2d84f5a848fa38eed77a86f48244f24 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 23 Aug 2023 18:24:37 -0400 Subject: [PATCH 004/126] reorder --- source/adios2/engine/bp5/BP5Reader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/adios2/engine/bp5/BP5Reader.h b/source/adios2/engine/bp5/BP5Reader.h index 117a05f3c2..3c45b1db2c 100644 --- a/source/adios2/engine/bp5/BP5Reader.h +++ b/source/adios2/engine/bp5/BP5Reader.h @@ -58,7 +58,6 @@ class BP5Reader : public BP5Engine, public Engine MinVarInfo *MinBlocksInfo(const VariableBase &, const size_t Step) const; bool VarShape(const VariableBase &Var, const size_t Step, Dims &Shape) const; bool VariableMinMax(const VariableBase &, const size_t Step, MinMaxStruct &MinMax); - adios2::profiling::JSONProfiler m_JSONProfiler; private: format::BP5Deserializer *m_BP5Deserializer = nullptr; @@ -96,6 +95,7 @@ class BP5Reader : public BP5Engine, public Engine transportman::TransportMan m_ActiveFlagFileManager; Remote m_Remote; bool m_WriterIsActive = true; + adios2::profiling::JSONProfiler m_JSONProfiler; /** used for per-step reads, TODO: to be moved to BP5Deserializer */ size_t m_CurrentStep = 0; From 66f24a3f396732c669db569a73dcdd5dbc98f998 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Thu, 24 Aug 2023 11:11:07 -0400 Subject: [PATCH 005/126] defines --- source/adios2/engine/bp5/BP5Reader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index 8062f9184a..fd2f4c33db 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -1227,6 +1227,8 @@ void BP5Reader::DoClose(const int transportIndex) #define getpid() GetCurrentProcessId(); #elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ defined(__NetBSD__) || defined(__DragonFly__) || defined(__CYGWIN__) +#include +#include #else #define getpid() (long long)-1; #endif From f0d1953a4f9c27f7931f0000e823ab8f194f3e9a Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Mon, 28 Aug 2023 15:30:01 -0400 Subject: [PATCH 006/126] docs,ci: backport fixes for readthedocs --- docs/environment.yml | 13 ++++++------- readthedocs.yml | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/docs/environment.yml b/docs/environment.yml index 998a6d65b4..20b0939ac2 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -2,17 +2,16 @@ name: adios2-python-docs channels: - conda-forge - - williamfgc dependencies: - - adios2-openmpi - - breathe==4.33.0 + - breathe==4.35.0 + - cmake - docutils==0.17 - - python - - sphinx=4 -# - funcparserlib>=0.3.6 + - libpython-static + - numpy - pip + - sphinx=5.3 - pip: - blockdiag==3.0.0 - sphinxcontrib-blockdiag==3.0.0 - - sphinx_rtd_theme==1.0.0 + - sphinx_rtd_theme==1.1.1 diff --git a/readthedocs.yml b/readthedocs.yml index 01daae2c56..e3981630cc 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -1,9 +1,18 @@ # .readthedocs.yml version: 2 -conda: +conda: environment: docs/environment.yml - -python: - version: 3.7 - system_packages: true + +build: + os: "ubuntu-22.04" + tools: + python: "miniconda3-4.7" + jobs: + pre_install: + - cmake -B build -S . -DADIOS2_USE_PYTHON=ON -DBUILD_TESTING=OFF -DADIOS2_BUILD_EXAMPLES=OFF + - cmake --build build + - cmake --install build --prefix "$HOME/.local" +formats: + - pdf + - epub From 947fc27bef3beae3b95b556f6495efbcc2036caf Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Mon, 28 Aug 2023 14:28:29 -0400 Subject: [PATCH 007/126] Fix local values block reading --- .../toolkit/format/bp5/BP5Deserializer.cpp | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp index 7dc7ade910..ddb297eddd 100644 --- a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp @@ -1393,18 +1393,33 @@ bool BP5Deserializer::QueueGetSingle(core::VariableBase &variable, if (VarRec->OrigShapeID == ShapeID::LocalValue) { // Shows up as global array with one element per writer rank - for (size_t WriterRank = variable.m_Start[0]; - WriterRank < variable.m_Count[0] + variable.m_Start[0]; - WriterRank++) - { - (void)GetSingleValueFromMetadata(variable, VarRec, DestData, Step, - WriterRank); - DestData = (char *)DestData + - variable.m_ElementSize; // use variable.m_ElementSize - // because it's the size in local - // memory, VarRec->ElementSize is - // the size in metadata - } + if (variable.m_SelectionType == adios2::SelectionType::BoundingBox) { + for (size_t WriterRank = variable.m_Start[0]; + WriterRank < variable.m_Count[0] + variable.m_Start[0]; + WriterRank++) + { + (void)GetSingleValueFromMetadata(variable, VarRec, DestData, Step, + WriterRank); + DestData = (char *)DestData + + variable.m_ElementSize; // use variable.m_ElementSize + // because it's the size in local + // memory, VarRec->ElementSize is + // the size in metadata + } + + } + else if (variable.m_SelectionType == adios2::SelectionType::WriteBlock) + { + size_t WriterRank = variable.m_BlockID; + (void)GetSingleValueFromMetadata(variable, VarRec, DestData, Step, + WriterRank); + } + else + { + helper::Throw( + "Toolkit", "format::bp::BP5Deserializer", "QueueGetSingle", + "Unexpected selection type"); + } return false; } MemorySpace MemSpace = variable.GetMemorySpace(DestData); From 6f026ffca479c83631eb53fba56782b98a479df8 Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Tue, 1 Aug 2023 17:12:01 -0600 Subject: [PATCH 008/126] ci: Add HDF5 to a windows build --- scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake | 3 +++ .../ci/cmake/ci-win2022-vs2022-serial.cmake | 3 +++ scripts/ci/gh-actions/windows-setup.ps1 | 24 +++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake b/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake index f51d9c438a..321d1d6cae 100644 --- a/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake +++ b/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake @@ -6,6 +6,9 @@ set(ENV{CXXFLAGS} /WX) set(dashboard_cache " ADIOS2_USE_Fortran:BOOL=OFF ADIOS2_USE_MPI:BOOL=ON +ADIOS2_USE_HDF5:STRING=ON +ADIOS2_USE_HDF5_VOL:STRING=OFF +HDF5_DIR:PATH=C:/hdf5/HDF5-1.14.2.1-win64/cmake ") set(CTEST_CMAKE_GENERATOR "Visual Studio 17 2022") diff --git a/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake b/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake index f3b7347e7c..a078f1ee58 100644 --- a/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake +++ b/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake @@ -6,6 +6,9 @@ set(ENV{CXXFLAGS} /WX) set(dashboard_cache " ADIOS2_USE_Fortran:BOOL=OFF ADIOS2_USE_MPI:BOOL=OFF +ADIOS2_USE_HDF5:STRING=ON +ADIOS2_USE_HDF5_VOL:STRING=OFF +HDF5_DIR:PATH=C:/hdf5/HDF5-1.14.2.1-win64/cmake ") set(CTEST_CMAKE_GENERATOR "Visual Studio 17 2022") diff --git a/scripts/ci/gh-actions/windows-setup.ps1 b/scripts/ci/gh-actions/windows-setup.ps1 index 4334327a2b..4bcae1d35a 100644 --- a/scripts/ci/gh-actions/windows-setup.ps1 +++ b/scripts/ci/gh-actions/windows-setup.ps1 @@ -56,3 +56,27 @@ if($Env:GH_YML_MATRIX_PARALLEL -eq "ompi") Write-Host "::endgroup::" } +if ($Env:GH_YML_MATRIX_COMPILER -eq "vs2022") +{ + $url = "https://github.com/HDFGroup/hdf5/releases/download/hdf5-1_14_1-2/hdf5-1_14_1-2-win_vs2022.zip" + + $tempdir = $Env:RUNNER_TEMP + $hdf5Zip = Join-Path $tempdir hdf5-1_14_1-2-win_vs2022.zip + $installDir = "C:\hdf5" + $extractDir = Join-Path $tempdir hdf5 + $innerZip = Join-Path $extractDir HDF5-1.14.2.1-win64.zip + + Write-Host "::group::Downloading windows HDF5 release $url" + Invoke-WebRequest $url -OutFile $hdf5Zip + Write-Host "::endgroup::" + + Write-Host "::group::Extracting outer windows HDF5 release $hdf5Zip" + Expand-Archive $hdf5Zip -DestinationPath $tempDir -Force + Write-Host "::endgroup::" + + Write-Host "::group::Extracting inner windows HDF5 release $innerZip" + Expand-Archive $innerZip -DestinationPath $installDir -Force + Write-Host "::endgroup::" + + # Now the HDF5_DIR can be set to: C:\hdf5\HDF5-1.14.2.1-win64\cmake +} From 89555418ecd1484c9241b76457de43f06586d00a Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Wed, 2 Aug 2023 11:05:56 -0600 Subject: [PATCH 009/126] use documented initial cache variable to find hdf5 on windows --- scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake | 2 +- scripts/ci/cmake/ci-win2022-vs2022-serial.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake b/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake index 321d1d6cae..66ce4ea851 100644 --- a/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake +++ b/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake @@ -8,7 +8,7 @@ ADIOS2_USE_Fortran:BOOL=OFF ADIOS2_USE_MPI:BOOL=ON ADIOS2_USE_HDF5:STRING=ON ADIOS2_USE_HDF5_VOL:STRING=OFF -HDF5_DIR:PATH=C:/hdf5/HDF5-1.14.2.1-win64/cmake +HDF5_ROOT:PATH=C:/hdf5/HDF5-1.14.2.1-win64 ") set(CTEST_CMAKE_GENERATOR "Visual Studio 17 2022") diff --git a/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake b/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake index a078f1ee58..96fb1339b3 100644 --- a/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake +++ b/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake @@ -8,7 +8,7 @@ ADIOS2_USE_Fortran:BOOL=OFF ADIOS2_USE_MPI:BOOL=OFF ADIOS2_USE_HDF5:STRING=ON ADIOS2_USE_HDF5_VOL:STRING=OFF -HDF5_DIR:PATH=C:/hdf5/HDF5-1.14.2.1-win64/cmake +HDF5_ROOT:PATH=C:/hdf5/HDF5-1.14.2.1-win64 ") set(CTEST_CMAKE_GENERATOR "Visual Studio 17 2022") From 6864cc2c881ed778eb4234d88952538915e9f55d Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Tue, 29 Aug 2023 19:50:48 -0400 Subject: [PATCH 010/126] Fixup local var reading by block with test, master branch --- source/adios2/core/Variable.tcc | 22 ++++++++++------ .../toolkit/format/bp5/BP5Deserializer.cpp | 25 ++++++++++++++----- .../bp/TestBPWriteReadLocalVariables.cpp | 21 +++++++++++++--- 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/source/adios2/core/Variable.tcc b/source/adios2/core/Variable.tcc index 849390e4bc..85875a8073 100644 --- a/source/adios2/core/Variable.tcc +++ b/source/adios2/core/Variable.tcc @@ -56,15 +56,23 @@ Dims Variable::DoCount() const ", in call to Variable::Count()"); } - size_t *DimsPtr = (MVI->BlocksInfo)[m_BlockID].Count; - Dims D; - D.resize(MVI->Dims); - for (int i = 0; i < MVI->Dims; i++) + if (!MVI->WasLocalValue) { - D[i] = DimsPtr[i]; + size_t *DimsPtr = (MVI->BlocksInfo)[m_BlockID].Count; + Dims D; + D.resize(MVI->Dims); + for (int i = 0; i < MVI->Dims; i++) + { + D[i] = DimsPtr[i]; + } + delete MVI; + return D; + } + else + { + delete MVI; + return {1}; } - delete MVI; - return D; } const size_t step = !m_FirstStreamingStep ? m_Engine->CurrentStep() : lf_Step(); diff --git a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp index 93f5eb686b..c78fa38ae1 100644 --- a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp @@ -1312,14 +1312,27 @@ bool BP5Deserializer::QueueGetSingle(core::VariableBase &variable, void *DestDat if (VarRec->OrigShapeID == ShapeID::LocalValue) { // Shows up as global array with one element per writer rank - for (size_t WriterRank = variable.m_Start[0]; - WriterRank < variable.m_Count[0] + variable.m_Start[0]; WriterRank++) + if (variable.m_SelectionType == adios2::SelectionType::BoundingBox) + { + for (size_t WriterRank = variable.m_Start[0]; + WriterRank < variable.m_Count[0] + variable.m_Start[0]; WriterRank++) + { + (void)GetSingleValueFromMetadata(variable, VarRec, DestData, AbsStep, WriterRank); + DestData = (char *)DestData + variable.m_ElementSize; // use variable.m_ElementSize + // because it's the size in local + // memory, VarRec->ElementSize is + // the size in metadata + } + } + else if (variable.m_SelectionType == adios2::SelectionType::WriteBlock) { + size_t WriterRank = variable.m_BlockID; (void)GetSingleValueFromMetadata(variable, VarRec, DestData, AbsStep, WriterRank); - DestData = (char *)DestData + variable.m_ElementSize; // use variable.m_ElementSize - // because it's the size in local - // memory, VarRec->ElementSize is - // the size in metadata + } + else + { + helper::Throw("Toolkit", "format::bp::BP5Deserializer", + "QueueGetSingle", "Unexpected selection type"); } return false; } diff --git a/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp b/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp index 0b8093e115..225334a307 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp @@ -210,14 +210,27 @@ TEST_F(BPWriteReadLocalVariables, ADIOS2BPWriteReadLocal1D) EXPECT_EQ(rankLocalValueData[r], static_cast(r)); } + if (mpiSize > 1) + { + for (size_t r = 0; r < rankLocalValueData.size(); ++r) + { + int32_t val; + var_RanksLocalValue.SetBlockSelection(r); + bpReader.Get(var_RanksLocalValue, &val); + EXPECT_EQ(val, static_cast(r)); + } + } + + bpReader.Get(var_RanksLocalValue, rankLocalValueData); + EXPECT_TRUE(var_RanksLocalValueString); EXPECT_EQ(var_RanksLocalValueString.ShapeID(), adios2::ShapeID::GlobalArray); - EXPECT_EQ(var_RanksLocalValue.Shape().size(), 1); - EXPECT_EQ(var_RanksLocalValue.Shape()[0], mpiSize); + EXPECT_EQ(var_RanksLocalValueString.Shape().size(), 1); + EXPECT_EQ(var_RanksLocalValueString.Shape()[0], mpiSize); std::vector rankLocalValueDataString; bpReader.Get(var_RanksLocalValueString, rankLocalValueDataString, adios2::Mode::Sync); - EXPECT_EQ(rankLocalValueData.size(), mpiSize); - for (size_t r = 0; r < rankLocalValueData.size(); ++r) + EXPECT_EQ(rankLocalValueDataString.size(), mpiSize); + for (size_t r = 0; r < rankLocalValueDataString.size(); ++r) { EXPECT_EQ(rankLocalValueDataString[r], std::to_string(r)); } From ea587280ca7c7f3aa68ca8fcada5339f742d656d Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Tue, 29 Aug 2023 18:12:20 -0600 Subject: [PATCH 011/126] Allow building with Visual Studio and HDF5 shared libs --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8836679e75..f0f6941024 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -287,6 +287,11 @@ if(BUILD_SHARED_LIBS AND ADIOS2_RUN_INSTALL_TEST) endif() endif() +if(MSVC AND BUILD_SHARED_LIBS AND ADIOS2_HAVE_HDF5) + # See note about building with visual studio and shared libs, here: + # https://github.com/HDFGroup/hdf5/blob/develop/release_docs/USING_HDF5_VS.txt + add_definitions(-DH5_BUILT_AS_DYNAMIC_LIB=1) +endif() #------------------------------------------------------------------------------# # Third party libraries From 15626a3fa080825a16685c22545faf1c87119789 Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Tue, 29 Aug 2023 18:12:40 -0600 Subject: [PATCH 012/126] Fix size_t -> int conversion warnings --- .../hdf5Reader/helloHDF5Reader_nompi.cpp | 2 +- source/adios2/engine/hdf5/HDF5ReaderP.cpp | 14 +++++++-- .../toolkit/interop/hdf5/HDF5Common.cpp | 31 ++++++++++++------- .../adios2/toolkit/interop/hdf5/HDF5Common.h | 2 +- .../toolkit/interop/hdf5/HDF5Common.tcc | 26 +++++++++++++--- testing/adios2/engine/SmallTestData.h | 24 +++++++------- 6 files changed, 67 insertions(+), 32 deletions(-) diff --git a/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp b/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp index 120c12ebc5..a7645f5298 100644 --- a/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp +++ b/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp @@ -22,7 +22,7 @@ void ReadData(adios2::IO h5IO, adios2::Engine h5Reader, const std::string &name) if (var) { - int nDims = var.Shape().size(); + size_t nDims = var.Shape().size(); size_t totalSize = 1; for (int i = 0; i < nDims; i++) { diff --git a/source/adios2/engine/hdf5/HDF5ReaderP.cpp b/source/adios2/engine/hdf5/HDF5ReaderP.cpp index 0d2a88fc02..1344208d8e 100644 --- a/source/adios2/engine/hdf5/HDF5ReaderP.cpp +++ b/source/adios2/engine/hdf5/HDF5ReaderP.cpp @@ -13,6 +13,8 @@ #include "adios2/helper/adiosFunctions.h" //CSVToVector #include "adios2/helper/adiosFunctions.h" //IsHDF5 +#include +#include #include namespace adios2 @@ -145,10 +147,18 @@ size_t HDF5ReaderP::ReadDataset(hid_t dataSetId, hid_t h5Type, Variable &vari if (ret < 0) return 0; - hid_t memDataSpace = H5Screate_simple(ndims, count.data(), NULL); + size_t max_int = static_cast(std::numeric_limits::max()); + if (ndims > max_int) + { + helper::Throw("Engine", "HDF5ReaderP", "ReadDataset", + "Number of dimensions is too large to be " + "represented by an int"); + } + + hid_t memDataSpace = H5Screate_simple(static_cast(ndims), count.data(), NULL); interop::HDF5TypeGuard g_mds(memDataSpace, interop::E_H5_SPACE); - int elementsRead = 1; + size_t elementsRead = 1; for (size_t i = 0u; i < ndims; i++) { elementsRead *= count[i]; diff --git a/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp b/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp index d19b78e92b..c07360ce2b 100644 --- a/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp +++ b/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp @@ -135,8 +135,17 @@ void HDF5Common::ParseParameters(core::IO &io) m_ChunkPID = H5Pcreate(H5P_DATASET_CREATE); m_ChunkDim = chunkDim.size(); + + size_t max_int = static_cast(std::numeric_limits::max()); + if (m_ChunkDim > max_int) + { + helper::Throw("Toolkit", "interop::hdf5::HDF5Common", + "ParseParameters", "chunkDim.size() is " + "too large to be represented by an int"); + } + if (m_ChunkDim > 0) - H5Pset_chunk(m_ChunkPID, chunkDim.size(), chunkDim.data()); + H5Pset_chunk(m_ChunkPID, static_cast(m_ChunkDim), chunkDim.data()); } } @@ -383,8 +392,8 @@ void HDF5Common::FindVarsFromH5(core::IO &io, hid_t top_id, const char *gname, c char name[100]; for (k = 0; k < numObj; k++) { - ret = H5Gget_objname_by_idx(gid, (hsize_t)k, name, sizeof(name)); - if (ret >= 0) + ssize_t result = H5Gget_objname_by_idx(gid, (hsize_t)k, name, sizeof(name)); + if (result >= 0) { int currType = H5Gget_objtype_by_idx(gid, k); if ((currType == H5G_DATASET) || (currType == H5G_TYPE)) @@ -447,8 +456,8 @@ void HDF5Common::ReadVariables(size_t ts, core::IO &io) char name[50]; for (k = 0; k < numObj; k++) { - ret = H5Gget_objname_by_idx(gid, (hsize_t)k, name, sizeof(name)); - if (ret >= 0) + ssize_t result = H5Gget_objname_by_idx(gid, (hsize_t)k, name, sizeof(name)); + if (result >= 0) { int currType = H5Gget_objtype_by_idx(gid, k); if (currType == H5G_GROUP) @@ -497,8 +506,8 @@ void HDF5Common::AddSingleString(core::IO &io, std::string const &name, hid_t da { // invalid variable, do not define printf("WARNING: IO is not accepting definition of variable: %s. " - "Skipping. \n", - name.c_str()); + "\nException: %s. \nSkipping. \n", + name.c_str(), e.what()); } } @@ -568,9 +577,9 @@ void HDF5Common::AddVarString(core::IO &io, std::string const &name, hid_t datas { // invalid variable, do not define printf("WARNING: IO is not accepting definition of " - "variable: %s. " + "variable: %s. \nException: %s. \n" "Skipping. \n", - name.c_str()); + name.c_str(), e.what()); } } return; @@ -632,8 +641,8 @@ void HDF5Common::AddVar(core::IO &io, std::string const &name, hid_t datasetId, { // invalid variable, do not define printf("WARNING: IO is not accepting definition of variable: %s. " - "Skipping. \n", - name.c_str()); + "\nException: %s. \nSkipping. \n", + name.c_str(), e.what()); } } else diff --git a/source/adios2/toolkit/interop/hdf5/HDF5Common.h b/source/adios2/toolkit/interop/hdf5/HDF5Common.h index 91cfac34b8..1fe2ffa5ca 100644 --- a/source/adios2/toolkit/interop/hdf5/HDF5Common.h +++ b/source/adios2/toolkit/interop/hdf5/HDF5Common.h @@ -261,7 +261,7 @@ class HDF5Common hid_t m_TimeStepH5T = H5T_NATIVE_ULLONG; ; hid_t m_ChunkPID; - int m_ChunkDim; + size_t m_ChunkDim; std::set m_ChunkVarNames; bool m_OrderByC = true; // C or fortran diff --git a/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc b/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc index ed1328e792..f19205f112 100644 --- a/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc +++ b/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc @@ -25,7 +25,7 @@ namespace interop template void HDF5Common::DefineDataset(core::Variable &variable) { - int dimSize = std::max(variable.m_Shape.size(), variable.m_Count.size()); + size_t dimSize = std::max(variable.m_Shape.size(), variable.m_Count.size()); hid_t h5Type = GetHDF5Type(); if (dimSize == 0) @@ -43,7 +43,15 @@ void HDF5Common::DefineDataset(core::Variable &variable) std::vector dimsf, count, offset; GetHDF5SpaceSpec(variable, dimsf, count, offset); - hid_t fileSpace = H5Screate_simple(dimSize, dimsf.data(), NULL); + size_t max_int = static_cast(std::numeric_limits::max()); + if (dimSize > max_int) + { + helper::Throw("Toolkit", "interop::hdf5::HDF5Common", + "DefineDataset", "dimSize is too large " + "to be represented by an int"); + } + + hid_t fileSpace = H5Screate_simple(static_cast(dimSize), dimsf.data(), NULL); HDF5TypeGuard fs(fileSpace, E_H5_SPACE); std::vector chain; @@ -110,7 +118,7 @@ template void HDF5Common::Write(core::Variable &variable, const T *values) { CheckWriteGroup(); - int dimSize = std::max(variable.m_Shape.size(), variable.m_Count.size()); + size_t dimSize = std::max(variable.m_Shape.size(), variable.m_Count.size()); hid_t h5Type = GetHDF5Type(); if (std::is_same::value) @@ -173,7 +181,15 @@ void HDF5Common::Write(core::Variable &variable, const T *values) std::vector dimsf, count, offset; GetHDF5SpaceSpec(variable, dimsf, count, offset); - hid_t fileSpace = H5Screate_simple(dimSize, dimsf.data(), NULL); + size_t max_int = static_cast(std::numeric_limits::max()); + if (dimSize > max_int) + { + helper::Throw("Toolkit", "interop::hdf5::HDF5Common", + "Write", "dimSize is too large " + "to be represented by an int"); + } + + hid_t fileSpace = H5Screate_simple(static_cast(dimSize), dimsf.data(), NULL); #ifndef RELAY_DEFINE_TO_HDF5 // RELAY_DEFINE_TO_HDF5 = variables in io are // created at begin_step std::vector chain; @@ -187,7 +203,7 @@ void HDF5Common::Write(core::Variable &variable, const T *values) { } #endif - hid_t memSpace = H5Screate_simple(dimSize, count.data(), NULL); + hid_t memSpace = H5Screate_simple(static_cast(dimSize), count.data(), NULL); // Select hyperslab fileSpace = H5Dget_space(dsetID); diff --git a/testing/adios2/engine/SmallTestData.h b/testing/adios2/engine/SmallTestData.h index 41a119eb2c..2bbb126aef 100644 --- a/testing/adios2/engine/SmallTestData.h +++ b/testing/adios2/engine/SmallTestData.h @@ -68,19 +68,19 @@ struct SmallTestData std::array TF = {{true, false, true, true, false, false, true, false, false, true}}; }; -SmallTestData generateNewSmallTestData(SmallTestData in, int step, int rank, int size) +SmallTestData generateNewSmallTestData(SmallTestData in, size_t step, size_t rank, size_t size) { - int j = rank + 1 + step * size; - std::for_each(in.I8.begin(), in.I8.end(), [&](int8_t &v) { v += j; }); - std::for_each(in.I16.begin(), in.I16.end(), [&](int16_t &v) { v += j; }); - std::for_each(in.I32.begin(), in.I32.end(), [&](int32_t &v) { v += j; }); - std::for_each(in.I64.begin(), in.I64.end(), [&](int64_t &v) { v += j; }); - std::for_each(in.U8.begin(), in.U8.end(), [&](uint8_t &v) { v += j; }); - std::for_each(in.U16.begin(), in.U16.end(), [&](uint16_t &v) { v += j; }); - std::for_each(in.U32.begin(), in.U32.end(), [&](uint32_t &v) { v += j; }); - std::for_each(in.U64.begin(), in.U64.end(), [&](uint64_t &v) { v += j; }); - std::for_each(in.R32.begin(), in.R32.end(), [&](float &v) { v += j; }); - std::for_each(in.R64.begin(), in.R64.end(), [&](double &v) { v += j; }); + size_t j = rank + 1 + step * size; + std::for_each(in.I8.begin(), in.I8.end(), [&](int8_t &v) { v += static_cast(j); }); + std::for_each(in.I16.begin(), in.I16.end(), [&](int16_t &v) { v += static_cast(j); }); + std::for_each(in.I32.begin(), in.I32.end(), [&](int32_t &v) { v += static_cast(j); }); + std::for_each(in.I64.begin(), in.I64.end(), [&](int64_t &v) { v += static_cast(j); }); + std::for_each(in.U8.begin(), in.U8.end(), [&](uint8_t &v) { v += static_cast(j); }); + std::for_each(in.U16.begin(), in.U16.end(), [&](uint16_t &v) { v += static_cast(j); }); + std::for_each(in.U32.begin(), in.U32.end(), [&](uint32_t &v) { v += static_cast(j); }); + std::for_each(in.U64.begin(), in.U64.end(), [&](uint64_t &v) { v += static_cast(j); }); + std::for_each(in.R32.begin(), in.R32.end(), [&](float &v) { v += static_cast(j); }); + std::for_each(in.R64.begin(), in.R64.end(), [&](double &v) { v += static_cast(j); }); std::for_each(in.R128.begin(), in.R128.end(), [&](long double &v) { v += j; }); std::for_each(in.CR32.begin(), in.CR32.end(), [&](std::complex &v) { From cc807f5768c7dfaed7456c9d8f8e2e48ed6b5667 Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Wed, 30 Aug 2023 09:56:33 -0600 Subject: [PATCH 013/126] clang format --- source/adios2/toolkit/interop/hdf5/HDF5Common.cpp | 5 +++-- source/adios2/toolkit/interop/hdf5/HDF5Common.tcc | 8 ++++---- testing/adios2/engine/SmallTestData.h | 9 ++++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp b/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp index c07360ce2b..e96fc2bdc0 100644 --- a/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp +++ b/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp @@ -139,8 +139,9 @@ void HDF5Common::ParseParameters(core::IO &io) size_t max_int = static_cast(std::numeric_limits::max()); if (m_ChunkDim > max_int) { - helper::Throw("Toolkit", "interop::hdf5::HDF5Common", - "ParseParameters", "chunkDim.size() is " + helper::Throw("Toolkit", "interop::hdf5::HDF5Common", + "ParseParameters", + "chunkDim.size() is " "too large to be represented by an int"); } diff --git a/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc b/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc index f19205f112..77f946f799 100644 --- a/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc +++ b/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc @@ -46,8 +46,8 @@ void HDF5Common::DefineDataset(core::Variable &variable) size_t max_int = static_cast(std::numeric_limits::max()); if (dimSize > max_int) { - helper::Throw("Toolkit", "interop::hdf5::HDF5Common", - "DefineDataset", "dimSize is too large " + helper::Throw("Toolkit", "interop::hdf5::HDF5Common", "DefineDataset", + "dimSize is too large " "to be represented by an int"); } @@ -184,8 +184,8 @@ void HDF5Common::Write(core::Variable &variable, const T *values) size_t max_int = static_cast(std::numeric_limits::max()); if (dimSize > max_int) { - helper::Throw("Toolkit", "interop::hdf5::HDF5Common", - "Write", "dimSize is too large " + helper::Throw("Toolkit", "interop::hdf5::HDF5Common", "Write", + "dimSize is too large " "to be represented by an int"); } diff --git a/testing/adios2/engine/SmallTestData.h b/testing/adios2/engine/SmallTestData.h index 2bbb126aef..c090dd8f89 100644 --- a/testing/adios2/engine/SmallTestData.h +++ b/testing/adios2/engine/SmallTestData.h @@ -76,9 +76,12 @@ SmallTestData generateNewSmallTestData(SmallTestData in, size_t step, size_t ran std::for_each(in.I32.begin(), in.I32.end(), [&](int32_t &v) { v += static_cast(j); }); std::for_each(in.I64.begin(), in.I64.end(), [&](int64_t &v) { v += static_cast(j); }); std::for_each(in.U8.begin(), in.U8.end(), [&](uint8_t &v) { v += static_cast(j); }); - std::for_each(in.U16.begin(), in.U16.end(), [&](uint16_t &v) { v += static_cast(j); }); - std::for_each(in.U32.begin(), in.U32.end(), [&](uint32_t &v) { v += static_cast(j); }); - std::for_each(in.U64.begin(), in.U64.end(), [&](uint64_t &v) { v += static_cast(j); }); + std::for_each(in.U16.begin(), in.U16.end(), + [&](uint16_t &v) { v += static_cast(j); }); + std::for_each(in.U32.begin(), in.U32.end(), + [&](uint32_t &v) { v += static_cast(j); }); + std::for_each(in.U64.begin(), in.U64.end(), + [&](uint64_t &v) { v += static_cast(j); }); std::for_each(in.R32.begin(), in.R32.end(), [&](float &v) { v += static_cast(j); }); std::for_each(in.R64.begin(), in.R64.end(), [&](double &v) { v += static_cast(j); }); std::for_each(in.R128.begin(), in.R128.end(), [&](long double &v) { v += j; }); From 716e52cc8a369ab33fb89f07d0cd3c4e2f0d987a Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Wed, 30 Aug 2023 12:55:51 -0600 Subject: [PATCH 014/126] Fix more compiler warnings from ompi build --- examples/heatTransfer/write/IO_hdf5_a.cpp | 2 +- examples/hello/hdf5Reader/helloHDF5Reader.cpp | 4 ++-- examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/heatTransfer/write/IO_hdf5_a.cpp b/examples/heatTransfer/write/IO_hdf5_a.cpp index 0ebedb1ef0..2546e03e23 100644 --- a/examples/heatTransfer/write/IO_hdf5_a.cpp +++ b/examples/heatTransfer/write/IO_hdf5_a.cpp @@ -49,7 +49,7 @@ void IO::write(int step, const HeatTransfer &ht, const Settings &s, MPI_Comm com double total_time = MPI_Wtime() - time_start; uint64_t adios_totalsize = 2 * sizeof(int) + 2 * s.ndx * s.ndy * sizeof(double); uint64_t sizeMB = adios_totalsize * s.nproc / 1024 / 1024 / 1024; // size in MB - uint64_t mbs = sizeMB / total_time; + double mbs = sizeMB / total_time; if (s.rank == 0) std::cout << "Step " << step << ": " << m_outputfilename << " " << sizeMB << " " << total_time << "" << mbs << std::endl; diff --git a/examples/hello/hdf5Reader/helloHDF5Reader.cpp b/examples/hello/hdf5Reader/helloHDF5Reader.cpp index d5ade54e72..33a2b7fb01 100644 --- a/examples/hello/hdf5Reader/helloHDF5Reader.cpp +++ b/examples/hello/hdf5Reader/helloHDF5Reader.cpp @@ -23,9 +23,9 @@ void ReadData(adios2::IO h5IO, adios2::Engine &h5Reader, const std::string &name if (var) { - int nDims = var.Shape().size(); + size_t nDims = var.Shape().size(); size_t totalSize = 1; - for (int i = 0; i < nDims; i++) + for (size_t i = 0; i < nDims; i++) { totalSize *= var.Shape()[i]; } diff --git a/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp b/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp index a7645f5298..c52d7515e0 100644 --- a/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp +++ b/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp @@ -24,7 +24,7 @@ void ReadData(adios2::IO h5IO, adios2::Engine h5Reader, const std::string &name) { size_t nDims = var.Shape().size(); size_t totalSize = 1; - for (int i = 0; i < nDims; i++) + for (size_t i = 0; i < nDims; i++) { totalSize *= var.Shape()[i]; } From b21d7bdc8c3f462ed2547f833f1531086bdf54ca Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Wed, 30 Aug 2023 14:14:37 -0600 Subject: [PATCH 015/126] Add location of hdf5.dll to PATH for windows tests --- scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake | 3 +++ scripts/ci/cmake/ci-win2022-vs2022-serial.cmake | 3 +++ 2 files changed, 6 insertions(+) diff --git a/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake b/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake index 66ce4ea851..8f161ea2cd 100644 --- a/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake +++ b/scripts/ci/cmake/ci-win2022-vs2022-ompi.cmake @@ -3,6 +3,9 @@ set(ENV{CXX} cl) set(ENV{CFLAGS} /WX) set(ENV{CXXFLAGS} /WX) +# Tests need to find hdf5.dll +set(ENV{PATH} "$ENV{PATH};C:/hdf5/HDF5-1.14.2.1-win64/bin") + set(dashboard_cache " ADIOS2_USE_Fortran:BOOL=OFF ADIOS2_USE_MPI:BOOL=ON diff --git a/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake b/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake index 96fb1339b3..a6d06fc702 100644 --- a/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake +++ b/scripts/ci/cmake/ci-win2022-vs2022-serial.cmake @@ -3,6 +3,9 @@ set(ENV{CXX} cl) set(ENV{CFLAGS} /WX) set(ENV{CXXFLAGS} /WX) +# Tests need to find hdf5.dll +set(ENV{PATH} "$ENV{PATH};C:/hdf5/HDF5-1.14.2.1-win64/bin") + set(dashboard_cache " ADIOS2_USE_Fortran:BOOL=OFF ADIOS2_USE_MPI:BOOL=OFF From 2e37421e23e3211a5dcffa1672b870b82fa54fe6 Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Thu, 31 Aug 2023 12:13:40 -0600 Subject: [PATCH 016/126] tests: fix windows 64bit type issues --- .../engine/hdf5/TestNativeHDF5WriteRead.cpp | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/testing/adios2/engine/hdf5/TestNativeHDF5WriteRead.cpp b/testing/adios2/engine/hdf5/TestNativeHDF5WriteRead.cpp index e75ef25c20..0e2bf580a5 100644 --- a/testing/adios2/engine/hdf5/TestNativeHDF5WriteRead.cpp +++ b/testing/adios2/engine/hdf5/TestNativeHDF5WriteRead.cpp @@ -626,7 +626,11 @@ TEST_F(HDF5WriteReadTest, ADIOS2HDF5WriteHDF5Read1D8) hdf5Reader.ReadVar("i32", I32.data(), offset, count, arraySize); hdf5Reader.GetVarInfo("i64", gDims, h5Type); +#ifdef _WIN32 + ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_LLONG), 1); +#else ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_LONG), 1); +#endif ASSERT_EQ(gDims.size(), 1); ASSERT_EQ(gDims[0], globalArraySize); hdf5Reader.ReadVar("i64", I64.data(), offset, count, arraySize); @@ -650,7 +654,11 @@ TEST_F(HDF5WriteReadTest, ADIOS2HDF5WriteHDF5Read1D8) hdf5Reader.ReadVar("u32", U32.data(), offset, count, arraySize); hdf5Reader.GetVarInfo("u64", gDims, h5Type); +#ifdef _WIN32 + ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_ULLONG), 1); +#else ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_ULONG), 1); +#endif ASSERT_EQ(gDims.size(), 1); ASSERT_EQ(gDims[0], globalArraySize); hdf5Reader.ReadVar("u64", U64.data(), offset, count, arraySize); @@ -1018,16 +1026,26 @@ TEST_F(HDF5WriteReadTest, HDF5WriteADIOS2HDF5Read1D8) currentTestData.I16.data()); h5writer.CreateAndStoreVar("i32", dimSize, H5T_NATIVE_INT, global_dims, offset, count, currentTestData.I32.data()); +#ifdef _WIN32 + h5writer.CreateAndStoreVar("i64", dimSize, H5T_NATIVE_LLONG, global_dims, offset, count, + currentTestData.I64.data()); +#else h5writer.CreateAndStoreVar("i64", dimSize, H5T_NATIVE_LONG, global_dims, offset, count, currentTestData.I64.data()); +#endif h5writer.CreateAndStoreVar("u8", dimSize, H5T_NATIVE_UCHAR, global_dims, offset, count, currentTestData.U8.data()); h5writer.CreateAndStoreVar("u16", dimSize, H5T_NATIVE_USHORT, global_dims, offset, count, currentTestData.U16.data()); h5writer.CreateAndStoreVar("u32", dimSize, H5T_NATIVE_UINT, global_dims, offset, count, currentTestData.U32.data()); +#ifdef _WIN32 + h5writer.CreateAndStoreVar("u64", dimSize, H5T_NATIVE_ULLONG, global_dims, offset, + count, currentTestData.U64.data()); +#else h5writer.CreateAndStoreVar("u64", dimSize, H5T_NATIVE_ULONG, global_dims, offset, count, currentTestData.U64.data()); +#endif h5writer.CreateAndStoreVar("r32", dimSize, H5T_NATIVE_FLOAT, global_dims, offset, count, currentTestData.R32.data()); h5writer.CreateAndStoreVar("r64", dimSize, H5T_NATIVE_DOUBLE, global_dims, offset, @@ -1419,7 +1437,11 @@ TEST_F(HDF5WriteReadTest, ADIOS2HDF5WriteHDF5Read2D2x4) hdf5Reader.ReadVar("i32", I32.data(), offset, count, arraySize); hdf5Reader.GetVarInfo("i64", gDims, h5Type); +#ifdef _WIN32 + ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_LLONG), 1); +#else ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_LONG), 1); +#endif ASSERT_EQ(gDims.size(), 2); ASSERT_EQ(gDims[0], 2); ASSERT_EQ(gDims[1], globalArraySize); @@ -1447,7 +1469,11 @@ TEST_F(HDF5WriteReadTest, ADIOS2HDF5WriteHDF5Read2D2x4) hdf5Reader.ReadVar("u32", U32.data(), offset, count, arraySize); hdf5Reader.GetVarInfo("u64", gDims, h5Type); +#ifdef _WIN32 + ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_ULLONG), 1); +#else ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_ULONG), 1); +#endif ASSERT_EQ(gDims.size(), 2); ASSERT_EQ(gDims[0], 2); ASSERT_EQ(gDims[1], globalArraySize); @@ -1833,16 +1859,26 @@ TEST_F(HDF5WriteReadTest, HDF5WriteADIOS2HDF5Read2D2x4) currentTestData.I16.data()); h5writer.CreateAndStoreVar("i32", dimSize, H5T_NATIVE_INT, global_dims, offset, count, currentTestData.I32.data()); +#ifdef _WIN32 + h5writer.CreateAndStoreVar("i64", dimSize, H5T_NATIVE_LLONG, global_dims, offset, count, + currentTestData.I64.data()); +#else h5writer.CreateAndStoreVar("i64", dimSize, H5T_NATIVE_LONG, global_dims, offset, count, currentTestData.I64.data()); +#endif h5writer.CreateAndStoreVar("u8", dimSize, H5T_NATIVE_UCHAR, global_dims, offset, count, currentTestData.U8.data()); h5writer.CreateAndStoreVar("u16", dimSize, H5T_NATIVE_USHORT, global_dims, offset, count, currentTestData.U16.data()); h5writer.CreateAndStoreVar("u32", dimSize, H5T_NATIVE_UINT, global_dims, offset, count, currentTestData.U32.data()); +#ifdef _WIN32 + h5writer.CreateAndStoreVar("u64", dimSize, H5T_NATIVE_ULLONG, global_dims, offset, + count, currentTestData.U64.data()); +#else h5writer.CreateAndStoreVar("u64", dimSize, H5T_NATIVE_ULONG, global_dims, offset, count, currentTestData.U64.data()); +#endif h5writer.CreateAndStoreVar("r32", dimSize, H5T_NATIVE_FLOAT, global_dims, offset, count, currentTestData.R32.data()); h5writer.CreateAndStoreVar("r64", dimSize, H5T_NATIVE_DOUBLE, global_dims, offset, @@ -2229,7 +2265,11 @@ TEST_F(HDF5WriteReadTest, ADIOS2HDF5WriteHDF5Read2D4x2) hdf5Reader.ReadVar("i32", I32.data(), offset, count, arraySize); hdf5Reader.GetVarInfo("i64", gDims, h5Type); +#ifdef _WIN32 + ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_LLONG), 1); +#else ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_LONG), 1); +#endif ASSERT_EQ(gDims.size(), 2); ASSERT_EQ(gDims[0], 4); ASSERT_EQ(gDims[1], globalArraySize); @@ -2257,7 +2297,11 @@ TEST_F(HDF5WriteReadTest, ADIOS2HDF5WriteHDF5Read2D4x2) hdf5Reader.ReadVar("u32", U32.data(), offset, count, arraySize); hdf5Reader.GetVarInfo("u64", gDims, h5Type); +#ifdef _WIN32 + ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_ULLONG), 1); +#else ASSERT_EQ(H5Tequal(h5Type, H5T_NATIVE_ULONG), 1); +#endif ASSERT_EQ(gDims.size(), 2); ASSERT_EQ(gDims[0], 4); ASSERT_EQ(gDims[1], globalArraySize); @@ -2639,16 +2683,26 @@ TEST_F(HDF5WriteReadTest, HDF5WriteADIOS2HDF5Read2D4x2) currentTestData.I16.data()); h5writer.CreateAndStoreVar("i32", dimSize, H5T_NATIVE_INT, global_dims, offset, count, currentTestData.I32.data()); +#ifdef _WIN32 + h5writer.CreateAndStoreVar("i64", dimSize, H5T_NATIVE_LLONG, global_dims, offset, count, + currentTestData.I64.data()); +#else h5writer.CreateAndStoreVar("i64", dimSize, H5T_NATIVE_LONG, global_dims, offset, count, currentTestData.I64.data()); +#endif h5writer.CreateAndStoreVar("u8", dimSize, H5T_NATIVE_UCHAR, global_dims, offset, count, currentTestData.U8.data()); h5writer.CreateAndStoreVar("u16", dimSize, H5T_NATIVE_USHORT, global_dims, offset, count, currentTestData.U16.data()); h5writer.CreateAndStoreVar("u32", dimSize, H5T_NATIVE_UINT, global_dims, offset, count, currentTestData.U32.data()); +#ifdef _WIN32 + h5writer.CreateAndStoreVar("u64", dimSize, H5T_NATIVE_ULLONG, global_dims, offset, + count, currentTestData.U64.data()); +#else h5writer.CreateAndStoreVar("u64", dimSize, H5T_NATIVE_ULONG, global_dims, offset, count, currentTestData.U64.data()); +#endif h5writer.CreateAndStoreVar("r32", dimSize, H5T_NATIVE_FLOAT, global_dims, offset, count, currentTestData.R32.data()); h5writer.CreateAndStoreVar("r64", dimSize, H5T_NATIVE_DOUBLE, global_dims, offset, From 458fea1615afb8c3660e3afc6b5e9e7187fb9eff Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Fri, 1 Sep 2023 10:28:10 -0400 Subject: [PATCH 017/126] Limit testing changes to BP5 --- .../adios2/engine/bp/TestBPWriteReadLocalVariables.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp b/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp index 225334a307..9fd6c2d71a 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadLocalVariables.cpp @@ -210,8 +210,15 @@ TEST_F(BPWriteReadLocalVariables, ADIOS2BPWriteReadLocal1D) EXPECT_EQ(rankLocalValueData[r], static_cast(r)); } - if (mpiSize > 1) + if ((engineName != "BP3") && (engineName != "BP4") && (mpiSize > 1)) { + // This test exposes a difference in behaviour between + // BP3/4 and BP5. BP5 resets the variables to their + // default state at each BeginStep where prior engines + // do not. Therefore setting the block selection in + // this portion causes failures in future timesteps in + // prior engines, but not in BP5. So we'll just test + // BP5 for the moment. for (size_t r = 0; r < rankLocalValueData.size(); ++r) { int32_t val; From cadc550937fd5e8224d6f7b3713d4f98cbac68b0 Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Mon, 4 Sep 2023 17:20:08 -0400 Subject: [PATCH 018/126] gha,ci: update checkout to v4 --- .github/workflows/everything.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/everything.yml b/.github/workflows/everything.yml index ea3e35d732..9590a845cb 100644 --- a/.github/workflows/everything.yml +++ b/.github/workflows/everything.yml @@ -51,7 +51,7 @@ jobs: outputs: num_code_changes: ${{ steps.get_code_changes.outputs.num_code_changes }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Check for appropriately named topic branch @@ -80,10 +80,10 @@ jobs: image: ghcr.io/ornladios/adios2:ci-formatting steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: gha - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} path: source @@ -153,10 +153,10 @@ jobs: shared: static parallel: serial steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: gha - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} path: source @@ -218,10 +218,10 @@ jobs: parallel: [ompi] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: gha - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} path: source @@ -285,10 +285,10 @@ jobs: compiler: xcode13_4_1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: gha - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} path: source @@ -352,10 +352,10 @@ jobs: shell: bash steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: gha - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} path: source @@ -386,7 +386,7 @@ jobs: baseos: [ubuntu-bionic] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} path: ci-source @@ -465,7 +465,7 @@ jobs: shell: bash -c "docker exec adios2-ci bash --login -e $(echo {0} | sed 's|/home/runner/work|/__w|g')" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ matrix.repo }} ref: ${{ matrix.ref }} @@ -523,10 +523,10 @@ jobs: language: [ 'cpp' ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: gha - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} path: source From 911a97c3c363e8c38b698498ee11704331e0b7e2 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Sat, 9 Sep 2023 07:30:21 -0400 Subject: [PATCH 019/126] Mod to keep MinBlocksInfo private to BP5Writer, not reuse Engine.h API. --- source/adios2/common/ADIOSTypes.cpp | 50 ++++++++++++++ source/adios2/common/ADIOSTypes.h | 3 + source/adios2/engine/bp5/BP5Writer.cpp | 27 +++++++- source/adios2/engine/bp5/BP5Writer.h | 2 + .../toolkit/format/bp5/BP5Serializer.cpp | 69 ++++++++++++++++++- .../adios2/toolkit/format/bp5/BP5Serializer.h | 4 +- source/adios2/toolkit/format/buffer/BufferV.h | 2 + .../toolkit/format/buffer/chunk/ChunkV.cpp | 24 +++++++ .../toolkit/format/buffer/chunk/ChunkV.h | 1 + .../toolkit/format/buffer/malloc/MallocV.cpp | 2 + .../toolkit/format/buffer/malloc/MallocV.h | 1 + 11 files changed, 181 insertions(+), 4 deletions(-) diff --git a/source/adios2/common/ADIOSTypes.cpp b/source/adios2/common/ADIOSTypes.cpp index dd8f1460af..bc507590fa 100644 --- a/source/adios2/common/ADIOSTypes.cpp +++ b/source/adios2/common/ADIOSTypes.cpp @@ -390,4 +390,54 @@ int TypeElementSize(DataType adiosvartype) } } +static void PrintMBI(std::ostream &os, const MinBlockInfo &blk, int Dims) +{ + os << "Writer: " << blk.WriterID << ", Blk: " << blk.BlockID << ", Start: {"; + if ((Dims == 0) || (blk.Start == NULL)) + os << "NULL"; + else + { + for (int i = 0; i < Dims; i++) + { + os << blk.Start[i]; + if (i < Dims - 1) + os << ", "; + } + } + os << "}, Count: {"; + + if ((Dims == 0) || (blk.Count == NULL)) + os << "NULL"; + else + { + for (int i = 0; i < Dims; i++) + { + os << blk.Count[i]; + if (i < Dims - 1) + os << ", "; + } + } + os << "}, Data: " << (void *)blk.BufferP << std::endl; +} + +void PrintMVI(std::ostream &os, const MinVarInfo &mvi) +{ + os << "Step: " << mvi.Step << " Dims: " << mvi.Dims << " Shape: {"; + if ((mvi.Dims == 0) || (mvi.Shape == NULL)) + os << "NULL"; + else + { + for (int i = 0; i < mvi.Dims; i++) + { + os << mvi.Shape[i]; + if (i < mvi.Dims - 1) + os << ", "; + } + } + os << "}, BlockCount: " << mvi.BlocksInfo.size() << " "; + for (const auto &blk : mvi.BlocksInfo) + PrintMBI(os, blk, mvi.Dims); + os << std::endl; +} + } // end namespace adios2 diff --git a/source/adios2/common/ADIOSTypes.h b/source/adios2/common/ADIOSTypes.h index 63a33d1a5c..7697c34624 100644 --- a/source/adios2/common/ADIOSTypes.h +++ b/source/adios2/common/ADIOSTypes.h @@ -214,6 +214,7 @@ struct MinBlockInfo MinMaxStruct MinMax; void *BufferP = NULL; }; + struct MinVarInfo { size_t Step; @@ -229,6 +230,8 @@ struct MinVarInfo } }; +void PrintMVI(std::ostream &os, const MinVarInfo &mvi); + // adios defaults #ifdef _WIN32 const std::string DefaultFileLibrary("fstream"); diff --git a/source/adios2/engine/bp5/BP5Writer.cpp b/source/adios2/engine/bp5/BP5Writer.cpp index c0b6462f7a..6ee1bac5be 100644 --- a/source/adios2/engine/bp5/BP5Writer.cpp +++ b/source/adios2/engine/bp5/BP5Writer.cpp @@ -497,8 +497,6 @@ void BP5Writer::MarshalAttributes() void BP5Writer::EndStep() { - /* Seconds ts = Now() - m_EngineStart; - std::cout << "END STEP starts at: " << ts.count() << std::endl; */ m_BetweenStepPairs = false; PERFSTUBS_SCOPED_TIMER("BP5Writer::EndStep"); m_Profiler.Start("ES"); @@ -506,6 +504,26 @@ void BP5Writer::EndStep() m_Profiler.Start("ES_close"); MarshalAttributes(); +#ifdef NOT_DEF + const auto &vars = m_IO.GetVariables(); + for (const auto &varPair : vars) + { + auto baseVar = varPair.second.get(); + auto mvi = MinBlocksInfo(*baseVar); + if (mvi) + { + std::cout << "Info for Variable " << varPair.first << std::endl; + PrintMVI(std::cout, *mvi); + if (baseVar->m_Type == DataType::Double) + std::cout << "Double value is " << *((double *)mvi->BlocksInfo[0].BufferP) + << std::endl; + delete mvi; + } + else + std::cout << "Variable " << varPair.first << " not written on this step" << std::endl; + } +#endif + // true: advances step auto TSInfo = m_BP5Serializer.CloseTimestep((int)m_WriterStep, m_Parameters.AsyncWrite || m_Parameters.DirectIO); @@ -668,6 +686,11 @@ void BP5Writer::Init() InitBPBuffer(); } +MinVarInfo *BP5Writer::MinBlocksInfo(const core::VariableBase &Var) +{ + return m_BP5Serializer.MinBlocksInfo(Var); +} + void BP5Writer::InitParameters() { ParseParams(m_IO, m_Parameters); diff --git a/source/adios2/engine/bp5/BP5Writer.h b/source/adios2/engine/bp5/BP5Writer.h index 7d6ad47a04..454454c5cf 100644 --- a/source/adios2/engine/bp5/BP5Writer.h +++ b/source/adios2/engine/bp5/BP5Writer.h @@ -115,6 +115,8 @@ class BP5Writer : public BP5Engine, public core::Engine */ void NotifyEngineAttribute(std::string name, AttributeBase *Attr, void *data) noexcept; + MinVarInfo *MinBlocksInfo(const VariableBase &); + void EnterComputationBlock() noexcept; /** Inform about computation block through User->ADIOS->IO */ void ExitComputationBlock() noexcept; diff --git a/source/adios2/toolkit/format/bp5/BP5Serializer.cpp b/source/adios2/toolkit/format/bp5/BP5Serializer.cpp index aad15ae794..8b10c30b46 100644 --- a/source/adios2/toolkit/format/bp5/BP5Serializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Serializer.cpp @@ -80,7 +80,7 @@ void BP5Serializer::Init() ((BP5MetadataInfoStruct *)MetadataBuf)->BitField = (std::size_t *)malloc(sizeof(size_t)); ((BP5MetadataInfoStruct *)MetadataBuf)->DataBlockSize = 0; } -BP5Serializer::BP5WriterRec BP5Serializer::LookupWriterRec(void *Key) +BP5Serializer::BP5WriterRec BP5Serializer::LookupWriterRec(void *Key) const { for (int i = 0; i < Info.RecCount; i++) { @@ -858,6 +858,73 @@ void BP5Serializer::Marshal(void *Variable, const char *Name, const DataType Typ } } +MinVarInfo *BP5Serializer::MinBlocksInfo(const core::VariableBase &Var) +{ + BP5WriterRec VarRec = LookupWriterRec((void *)&Var); + + if (!VarRec) + return NULL; + + MinVarInfo *MV = new MinVarInfo((int)VarRec->DimCount, (size_t *)Var.m_Shape.data()); + + BP5MetadataInfoStruct *MBase = (struct BP5MetadataInfoStruct *)MetadataBuf; + + int AlreadyWritten = BP5BitfieldTest(MBase, VarRec->FieldID); + + if (!AlreadyWritten) + return MV; + + if (Var.m_SingleValue) + { + // single value case + MinBlockInfo Blk; + Blk.MinMax.Init(Var.m_Type); + Blk.WriterID = (int)-1; + Blk.BlockID = 0; + Blk.Start = NULL; + Blk.Count = NULL; + if (Var.m_Type != DataType::String) + { + Blk.BufferP = (char *)(MetadataBuf) + VarRec->MetaOffset; + } + else + { + char **StrPtr = (char **)((char *)(MetadataBuf) + VarRec->MetaOffset); + Blk.BufferP = *StrPtr; + } + MV->BlocksInfo.push_back(Blk); + } + else + { + // everything else + MetaArrayRec *MetaEntry = (MetaArrayRec *)((char *)(MetadataBuf) + VarRec->MetaOffset); + for (size_t b = 0; b < MetaEntry->BlockCount; b++) + { + MinBlockInfo Blk; + Blk.MinMax.Init(Var.m_Type); + Blk.WriterID = (int)-1; + Blk.BlockID = 0; + Blk.Start = NULL; + if (MetaEntry->Offsets) + { + Blk.Start = &(MetaEntry->Offsets[b * MetaEntry->Dims]); + } + Blk.Count = &(MetaEntry->Count[b * MetaEntry->Dims]); + if (MetaEntry->DataBlockLocation[b] < m_PriorDataBufferSizeTotal) + { + Blk.BufferP = (void *)(intptr_t)(-1); // data is out of memory + } + else + { + Blk.BufferP = CurDataBuffer->GetPtr(MetaEntry->DataBlockLocation[b] - + m_PriorDataBufferSizeTotal); + } + MV->BlocksInfo.push_back(Blk); + } + } + return MV; +} + void BP5Serializer::MarshalAttribute(const char *Name, const DataType Type, size_t ElemSize, size_t ElemCount, const void *Data) { diff --git a/source/adios2/toolkit/format/bp5/BP5Serializer.h b/source/adios2/toolkit/format/bp5/BP5Serializer.h index 14c5d3f6e1..1974972ad2 100644 --- a/source/adios2/toolkit/format/bp5/BP5Serializer.h +++ b/source/adios2/toolkit/format/bp5/BP5Serializer.h @@ -127,6 +127,8 @@ class BP5Serializer : virtual public BP5Base size_t DebugGetDataBufferSize() const; + MinVarInfo *MinBlocksInfo(const core::VariableBase &Var); + int m_StatsLevel = 1; /* Variables to help appending to existing file */ @@ -204,7 +206,7 @@ class BP5Serializer : virtual public BP5Base size_t m_PriorDataBufferSizeTotal = 0; - BP5WriterRec LookupWriterRec(void *Key); + BP5WriterRec LookupWriterRec(void *Key) const; BP5WriterRec CreateWriterRec(void *Variable, const char *Name, DataType Type, size_t ElemSize, size_t DimCount); void ValidateWriterRec(BP5WriterRec Rec, void *Variable); diff --git a/source/adios2/toolkit/format/buffer/BufferV.h b/source/adios2/toolkit/format/buffer/BufferV.h index 0436ae363d..0ca1e3eac0 100644 --- a/source/adios2/toolkit/format/buffer/BufferV.h +++ b/source/adios2/toolkit/format/buffer/BufferV.h @@ -63,6 +63,8 @@ class BufferV virtual void *GetPtr(int bufferIdx, size_t posInBuffer) = 0; + virtual void *GetPtr(size_t overallPosInVector) = 0; + protected: std::vector zero; const bool m_AlwaysCopy = false; diff --git a/source/adios2/toolkit/format/buffer/chunk/ChunkV.cpp b/source/adios2/toolkit/format/buffer/chunk/ChunkV.cpp index 30fb427fe0..4f4f04fc05 100644 --- a/source/adios2/toolkit/format/buffer/chunk/ChunkV.cpp +++ b/source/adios2/toolkit/format/buffer/chunk/ChunkV.cpp @@ -255,6 +255,30 @@ void *ChunkV::GetPtr(int bufferIdx, size_t posInBuffer) } } +void *ChunkV::GetPtr(size_t OverallPosInBuffer) +{ + int bufferIdx = 0; + if (DataV.size() == 0) + return nullptr; + while (DataV[bufferIdx].Size <= OverallPosInBuffer) + { + OverallPosInBuffer -= DataV[bufferIdx].Size; + bufferIdx++; + if (static_cast(bufferIdx) > DataV.size()) + { + helper::Throw( + "Toolkit", "format::ChunkV", "GetPtr", + "ChunkV::GetPtr(" + std::to_string(OverallPosInBuffer) + + ") refers to a non-existing or deferred memory chunk."); + return nullptr; + } + } + if (DataV[bufferIdx].External) + return ((char *)DataV[bufferIdx].External) + OverallPosInBuffer; + + return (void *)((char *)DataV[bufferIdx].Base + OverallPosInBuffer); +} + std::vector ChunkV::DataVec() noexcept { std::vector iov(DataV.size()); diff --git a/source/adios2/toolkit/format/buffer/chunk/ChunkV.h b/source/adios2/toolkit/format/buffer/chunk/ChunkV.h index ef65c08665..fc129243fe 100644 --- a/source/adios2/toolkit/format/buffer/chunk/ChunkV.h +++ b/source/adios2/toolkit/format/buffer/chunk/ChunkV.h @@ -38,6 +38,7 @@ class ChunkV : public BufferV virtual void DownsizeLastAlloc(const size_t oldSize, const size_t newSize); virtual void *GetPtr(int bufferIdx, size_t posInBuffer); + virtual void *GetPtr(size_t OverallPosInBuffer); void CopyDataToBuffer(const size_t size, const void *buf, size_t pos, MemorySpace MemSpace); diff --git a/source/adios2/toolkit/format/buffer/malloc/MallocV.cpp b/source/adios2/toolkit/format/buffer/malloc/MallocV.cpp index 2ba21dca80..90359071fb 100644 --- a/source/adios2/toolkit/format/buffer/malloc/MallocV.cpp +++ b/source/adios2/toolkit/format/buffer/malloc/MallocV.cpp @@ -157,6 +157,8 @@ void *MallocV::GetPtr(int bufferIdx, size_t posInBuffer) } } +void *MallocV::GetPtr(size_t posInBuffer) { return m_InternalBlock + posInBuffer; } + std::vector MallocV::DataVec() noexcept { std::vector iov(DataV.size()); diff --git a/source/adios2/toolkit/format/buffer/malloc/MallocV.h b/source/adios2/toolkit/format/buffer/malloc/MallocV.h index 6553271099..eba6ba9d09 100644 --- a/source/adios2/toolkit/format/buffer/malloc/MallocV.h +++ b/source/adios2/toolkit/format/buffer/malloc/MallocV.h @@ -42,6 +42,7 @@ class MallocV : public BufferV void DownsizeLastAlloc(const size_t oldSize, const size_t newSize); virtual void *GetPtr(int bufferIdx, size_t posInBuffer); + virtual void *GetPtr(size_t posInBuffer); private: char *m_InternalBlock = NULL; From 69ac221eefec73239c51d289da78dd4b44fd0b58 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Sat, 9 Sep 2023 07:53:58 -0400 Subject: [PATCH 020/126] Mod not to overload to make some compilers happy --- source/adios2/engine/bp5/BP5Writer.cpp | 4 ++-- source/adios2/engine/bp5/BP5Writer.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Writer.cpp b/source/adios2/engine/bp5/BP5Writer.cpp index 6ee1bac5be..465a44d959 100644 --- a/source/adios2/engine/bp5/BP5Writer.cpp +++ b/source/adios2/engine/bp5/BP5Writer.cpp @@ -509,7 +509,7 @@ void BP5Writer::EndStep() for (const auto &varPair : vars) { auto baseVar = varPair.second.get(); - auto mvi = MinBlocksInfo(*baseVar); + auto mvi = WriterMinBlocksInfo(*baseVar); if (mvi) { std::cout << "Info for Variable " << varPair.first << std::endl; @@ -686,7 +686,7 @@ void BP5Writer::Init() InitBPBuffer(); } -MinVarInfo *BP5Writer::MinBlocksInfo(const core::VariableBase &Var) +MinVarInfo *BP5Writer::WriterMinBlocksInfo(const core::VariableBase &Var) { return m_BP5Serializer.MinBlocksInfo(Var); } diff --git a/source/adios2/engine/bp5/BP5Writer.h b/source/adios2/engine/bp5/BP5Writer.h index 454454c5cf..72d0602217 100644 --- a/source/adios2/engine/bp5/BP5Writer.h +++ b/source/adios2/engine/bp5/BP5Writer.h @@ -115,7 +115,7 @@ class BP5Writer : public BP5Engine, public core::Engine */ void NotifyEngineAttribute(std::string name, AttributeBase *Attr, void *data) noexcept; - MinVarInfo *MinBlocksInfo(const VariableBase &); + MinVarInfo *WriterMinBlocksInfo(const VariableBase &); void EnterComputationBlock() noexcept; /** Inform about computation block through User->ADIOS->IO */ From 9cd8e625ced55eec456404094e90a89214a56a44 Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Mon, 11 Sep 2023 18:50:39 -0400 Subject: [PATCH 021/126] yaml-cpp: support 0.8.0 version --- thirdparty/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 72646b85e9..c184d74d24 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -71,12 +71,20 @@ add_subdirectory(nlohmann_json) adios2_add_thirdparty_target(nlohmann_json nlohmann_json_wrapper) if(ADIOS2_USE_EXTERNAL_YAMLCPP) - find_package(yaml-cpp REQUIRED) + find_package(yaml-cpp 0.7.0 REQUIRED) else() add_subdirectory(yaml-cpp) endif() + adios2_add_thirdparty_target(yaml-cpp yaml-cpp) +# YAML-cpp does not add the incdir/libdir to its target rather it exposes it +# through the cmake variables YAML_CPP_INCLUDE_DIR and YAML_CPP_LIBRARY_DIR +if(yaml-cpp_VERSION VERSION_GREATER_EQUAL 0.8) + target_include_directories(adios2::thirdparty::yaml-cpp INTERFACE ${YAML_CPP_INCLUDE_DIR}) + target_link_directories(adios2::thirdparty::yaml-cpp INTERFACE ${YAML_CPP_LIBRARY_DIR}) +endif() + if(WIN32) add_subdirectory(mingw-w64) endif() From a8b69d8172095d61f86ee013562347a1f5267d4c Mon Sep 17 00:00:00 2001 From: Spiros Tsalikis Date: Tue, 12 Sep 2023 14:55:11 -0400 Subject: [PATCH 022/126] Delete experimental examples They are no longer compiling, and nobody has ever used them over the past 5 years. --- CMakeLists.txt | 1 - bindings/Matlab/README.txt | 2 +- examples/CMakeLists.txt | 3 - examples/experimental/CMakeLists.txt | 6 - .../experimental/runtimeconfig/CMakeLists.txt | 1 - .../runtimeconfig/configs/grandSchema.xml | 76 ------------ .../configs/multipleIOResolutions.xml | 24 ---- .../configs/multipleTransformedVariables.xml | 26 ---- .../runtimeconfig/hello/CMakeLists.txt | 13 -- .../runtimeconfig/hello/helloBPWriter.xml | 26 ---- .../runtimeconfig/hello/helloBPWriterXML.cpp | 112 ------------------ .../runtimeconfig/hello/helloBPWriterXML.py | 36 ------ .../hello/helloBPWriterXML_nompi.cpp | 93 --------------- .../hello/helloBPWriterXML_nompi.py | 30 ----- scripts/runconf/runconf_olcf.sh | 3 - 15 files changed, 1 insertion(+), 451 deletions(-) delete mode 100644 examples/experimental/CMakeLists.txt delete mode 100644 examples/experimental/runtimeconfig/CMakeLists.txt delete mode 100644 examples/experimental/runtimeconfig/configs/grandSchema.xml delete mode 100644 examples/experimental/runtimeconfig/configs/multipleIOResolutions.xml delete mode 100644 examples/experimental/runtimeconfig/configs/multipleTransformedVariables.xml delete mode 100644 examples/experimental/runtimeconfig/hello/CMakeLists.txt delete mode 100644 examples/experimental/runtimeconfig/hello/helloBPWriter.xml delete mode 100644 examples/experimental/runtimeconfig/hello/helloBPWriterXML.cpp delete mode 100644 examples/experimental/runtimeconfig/hello/helloBPWriterXML.py delete mode 100644 examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.cpp delete mode 100644 examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.py diff --git a/CMakeLists.txt b/CMakeLists.txt index f0f6941024..d3f223ed14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,7 +319,6 @@ add_subdirectory(plugins) # Examples #------------------------------------------------------------------------------# option(ADIOS2_BUILD_EXAMPLES "Build examples" ON) -option(ADIOS2_BUILD_EXAMPLES_EXPERIMENTAL "Build experimental examples" OFF) if(ADIOS2_BUILD_EXAMPLES) add_subdirectory(examples) endif() diff --git a/bindings/Matlab/README.txt b/bindings/Matlab/README.txt index 4c43c89ffe..7f19136624 100644 --- a/bindings/Matlab/README.txt +++ b/bindings/Matlab/README.txt @@ -43,5 +43,5 @@ $ cd $ git pull $ mkdir build.lean $ cd build.lean -$ cmake -DCMAKE_INSTALL_PREFIX=/opt/adios/lean -DADIOS2_USE_MPI=OFF -DADIOS2_USE_Fortran=OFF -DADIOS2_USE_Python=OFF -DADIOS2_BUILD_EXAMPLES_EXPERIMENTAL=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DADIOS2_ENABLE_PIC=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF -DADIOS2_USE_SST=OFF -DADIOS2_USE_BZip2=OFF -DADIOS2_USE_DataMan=OFF .. +$ cmake -DCMAKE_INSTALL_PREFIX=/opt/adios/lean -DADIOS2_USE_MPI=OFF -DADIOS2_USE_Fortran=OFF -DADIOS2_USE_Python=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DADIOS2_ENABLE_PIC=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF -DADIOS2_USE_SST=OFF -DADIOS2_USE_BZip2=OFF -DADIOS2_USE_DataMan=OFF .. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e14d76bb05..3187dc3f49 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -15,9 +15,6 @@ if(ADIOS2_HAVE_MPI) add_subdirectory(heatTransfer) endif() -if(ADIOS2_BUILD_EXAMPLES_EXPERIMENTAL) - add_subdirectory(experimental) -endif() if(ADIOS2_HAVE_CUDA OR ADIOS2_HAVE_Kokkos_CUDA) add_subdirectory(cuda) diff --git a/examples/experimental/CMakeLists.txt b/examples/experimental/CMakeLists.txt deleted file mode 100644 index 23240d2bae..0000000000 --- a/examples/experimental/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_subdirectory(runtimeconfig) diff --git a/examples/experimental/runtimeconfig/CMakeLists.txt b/examples/experimental/runtimeconfig/CMakeLists.txt deleted file mode 100644 index 33bde8ad15..0000000000 --- a/examples/experimental/runtimeconfig/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(hello) diff --git a/examples/experimental/runtimeconfig/configs/grandSchema.xml b/examples/experimental/runtimeconfig/configs/grandSchema.xml deleted file mode 100644 index 71d80bd30b..0000000000 --- a/examples/experimental/runtimeconfig/configs/grandSchema.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - BlockSize100K=3; - - - Tolerance=1e-3; - - - - - - - Threads=4; - Verbose=4; - ProfileUnits=Microseconds; - MaxBufferSize=20Mb; - InitialBufferSize=1Mb; - BufferGrowthFactor=2; - - - - ProfileUnits=Microseconds; - Library=stdio; - CacheSize=8192; - CollectiveMetadata=Yes; - - - - ProfileUnits=Microseconds; - Library=hdf5; - Name=data.h5; - - - - ProfileUnits=Microseconds; - Library=SystemV; - Name=data.shmem; - SetSize=10Mb; - - - - ProfileUnits=Microseconds; - Library=POSIX; - Name=/bb_location/data.bb; - SetSize=10Mb; - - - - ProfileUnits=Microseconds; - IPAddress=128.219.4.85; - Port=500; - Library=zmq; - CacheSize=8192; - - - - ProfileUnits=Microseconds; - Library=ibverbs; - Port=18515; - IBPort=1; - SetSize=1Mb; - TXDepth=100; - SocketFD=-1; - ServerName=NULL; - RemoteConnection=NULL; - IBDev=NULL; - - - - - \ No newline at end of file diff --git a/examples/experimental/runtimeconfig/configs/multipleIOResolutions.xml b/examples/experimental/runtimeconfig/configs/multipleIOResolutions.xml deleted file mode 100644 index 28fe854084..0000000000 --- a/examples/experimental/runtimeconfig/configs/multipleIOResolutions.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - Tolerance=1e-2; - - - - - - - - - - Tolerance=1e-5; - - - - - - - \ No newline at end of file diff --git a/examples/experimental/runtimeconfig/configs/multipleTransformedVariables.xml b/examples/experimental/runtimeconfig/configs/multipleTransformedVariables.xml deleted file mode 100644 index 8338320d5c..0000000000 --- a/examples/experimental/runtimeconfig/configs/multipleTransformedVariables.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - Tolerance=1e-2; - - - - - - - - - - - Tolerance=1e-5; - - - - - - - - - diff --git a/examples/experimental/runtimeconfig/hello/CMakeLists.txt b/examples/experimental/runtimeconfig/hello/CMakeLists.txt deleted file mode 100644 index dac3c8499f..0000000000 --- a/examples/experimental/runtimeconfig/hello/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -add_executable(helloBPWriterXML helloBPWriterXML_nompi.cpp) -target_link_libraries(helloBPWriterXML adios2::cxx11) -target_compile_definitions(helloBPWriterXML PRIVATE - -DDEFAULT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/helloBPWriter.xml -) - -if(ADIOS2_HAVE_MPI) - add_executable(helloBPWriterXML_mpi helloBPWriterXML.cpp) - target_link_libraries(helloBPWriterXML_mpi adios2::cxx11_mpi MPI::MPI_C) - target_compile_definitions(helloBPWriterXML_mpi PRIVATE - -DDEFAULT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/helloBPWriter.xml - ) -endif() diff --git a/examples/experimental/runtimeconfig/hello/helloBPWriter.xml b/examples/experimental/runtimeconfig/hello/helloBPWriter.xml deleted file mode 100644 index 27a01d5db8..0000000000 --- a/examples/experimental/runtimeconfig/hello/helloBPWriter.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/experimental/runtimeconfig/hello/helloBPWriterXML.cpp b/examples/experimental/runtimeconfig/hello/helloBPWriterXML.cpp deleted file mode 100644 index f6634b8ac4..0000000000 --- a/examples/experimental/runtimeconfig/hello/helloBPWriterXML.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloBPWriter.cpp: Simple self-descriptive example of how to write a variable - * to a BP File that lives in several MPI processes. - * - * Created on: Feb 16, 2017 - * Author: William F Godoy godoywf@ornl.gov - */ - -#include //std::ios_base::failure -#include //std::cout -#include -#include //std::invalid_argument std::exception -#include - -#include - -#define str_helper(X) #X -#define str(X) str_helper(X) - -#ifndef DEFAULT_CONFIG -#define DEFAULT_CONFIG helloBPWriter.xml -#endif -#define DEFAULT_CONFIG_STR str(DEFAULT_CONFIG) - -int main(int argc, char *argv[]) -{ - int provided; - - // MPI_THREAD_MULTIPLE is only required if you enable the SST MPI_DP - MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - std::string configFile; - if (argc == 1) - { - configFile = DEFAULT_CONFIG_STR; - } - else if (argc == 2) - { - configFile = argv[1]; - } - else - { - if (rank == 0) - { - std::cerr << "Usage: " << argv[0] << " [/path/to/config.xml]" << std::endl; - } - return 1; - } - if (rank == 0) - { - std::cout << "Using config file: " << configFile << std::endl; - } - - /** Application variable */ - std::vector myFloats = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - const std::size_t Nx = myFloats.size(); - - try - { - /** ADIOS class factory of IO class objects */ - adios2::ADIOS adios(configFile, MPI_COMM_WORLD); - - /*** IO class object: settings and factory of Settings: Variables, - * Parameters, Transports, and Execution: Engines */ - adios2::IO bpIO = adios.DeclareIO("BPFile_N2N"); - - /** global array : name, { shape (total) }, { start (local) }, { count - * (local) }, all are constant dimensions */ - adios2::Variable &bpFloats = bpIO.DefineVariable( - "bpFloats", {size * Nx}, {rank * Nx}, {Nx}, adios2::ConstantDims); - - /** Engine derived class, spawned to start IO operations */ - auto bpWriter = bpIO.Open("myVector.bp", adios2::Mode::Write); - - if (!bpWriter) - { - throw std::ios_base::failure("ERROR: bpWriter not created at Open\n"); - } - - /** Write variable for buffering */ - bpWriter->Write(bpFloats, myFloats.data()); - - /** Create bp file, engine becomes unreachable after this*/ - bpWriter->Close(); - } - catch (std::invalid_argument &e) - { - std::cout << "Invalid argument exception, STOPPING PROGRAM from rank " << rank << "\n"; - std::cout << e.what() << "\n"; - } - catch (std::ios_base::failure &e) - { - std::cout << "IO System base failure exception, STOPPING PROGRAM from rank " << rank - << "\n"; - std::cout << e.what() << "\n"; - } - catch (std::exception &e) - { - std::cout << "Exception, STOPPING PROGRAM from rank " << rank << "\n"; - std::cout << e.what() << "\n"; - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/experimental/runtimeconfig/hello/helloBPWriterXML.py b/examples/experimental/runtimeconfig/hello/helloBPWriterXML.py deleted file mode 100644 index a4c2c4b6b0..0000000000 --- a/examples/experimental/runtimeconfig/hello/helloBPWriterXML.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -# -# helloBPWriterXML.py -# Created on: Feb 2, 2017 -# Author: William F Godoy godoywf@ornl.gov - -from mpi4py import MPI -import adios2 -import numpy - -# MPI -comm = MPI.COMM_WORLD -rank = comm.Get_rank() -size = comm.Get_size() - -# User data -myArray = numpy.array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) -Nx = myArray.size - -# ADIOS config file, MPI communicator -adios = adios2.ADIOS("helloBPWriter.xml", comm) - -# ADIOS IO, name must be the same as in helloBPWriter.xml for runtime settings -bpIO = adios.DeclareIO("BPFile_N2N") - -# Variable name, shape, start, count, ConstantDims = True -ioArray = bpIO.DefineVariable( - "bpArray", [size * Nx], [rank * Nx], [Nx], adios2.ConstantDims) - -# Engine name, open mode -bpFileWriter = bpIO.Open("npArray.bp", adios2.OpenModeWrite) -# Write variable, numpy object -bpFileWriter.Write(ioArray, myArray) -bpFileWriter.Close() diff --git a/examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.cpp b/examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.cpp deleted file mode 100644 index 07f5bedc19..0000000000 --- a/examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloBPWriterXML_nompi.cpp: sequential non-mpi version of helloBPWriterXML - * - * Created on: Feb 16, 2017 - * Author: William F Godoy godoywf@ornl.gov - */ - -#include //std::ios_base::failure -#include //std::cout -#include //std::invalid_argument std::exception -#include - -#include - -#define str_helper(X) #X -#define str(X) str_helper(X) - -#ifndef DEFAULT_CONFIG -#define DEFAULT_CONFIG helloBPWriter.xml -#endif -#define DEFAULT_CONFIG_STR str(DEFAULT_CONFIG) - -int main(int argc, char *argv[]) -{ - std::string configFile; - if (argc == 1) - { - configFile = DEFAULT_CONFIG_STR; - } - else if (argc == 2) - { - configFile = argv[1]; - } - else - { - std::cerr << "Usage: " << argv[0] << " [/path/to/config.xml]" << std::endl; - return 1; - } - std::cout << "Using config file: " << configFile << std::endl; - - /** Application variable */ - std::vector myFloats = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - const std::size_t Nx = myFloats.size(); - - try - { - /** ADIOS class factory of IO class objects */ - adios2::ADIOS adios(configFile); - - /*** IO class object: settings and factory of Settings: Variables, - * Parameters, Transports, and Execution: Engines */ - adios2::IO bpIO = adios.DeclareIO("BPFile_N2N"); - - /** global array : name, { shape (total) }, { start (local) }, { count - * (local) }, all are constant dimensions */ - adios2::Variable &bpFloats = - bpIO.DefineVariable("bpFloats", {}, {}, {Nx}, adios2::ConstantDims); - - /** Engine derived class, spawned to start IO operations */ - auto bpWriter = bpIO.Open("myVector.bp", adios2::Mode::Write); - - if (!bpWriter) - { - throw std::ios_base::failure("ERROR: bpWriter not created at Open\n"); - } - - /** Write variable for buffering */ - bpWriter->Write(bpFloats, myFloats.data()); - - /** Create bp file, engine becomes unreachable after this*/ - bpWriter->Close(); - } - catch (std::invalid_argument &e) - { - std::cout << "Invalid argument exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - catch (std::ios_base::failure &e) - { - std::cout << "IO System base failure exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - catch (std::exception &e) - { - std::cout << "Exception, STOPPING PROGRAM from rank\n"; - std::cout << e.what() << "\n"; - } - - return 0; -} diff --git a/examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.py b/examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.py deleted file mode 100644 index 2ef26916ea..0000000000 --- a/examples/experimental/runtimeconfig/hello/helloBPWriterXML_nompi.py +++ /dev/null @@ -1,30 +0,0 @@ -# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -# -# helloBPWriterXML_nompi.py serial non-MPI version of helloBPWriter.py -# Created on: Feb 2, 2017 -# Author: William F Godoy godoywf@ornl.gov - -import numpy -import adios2 - - -# User data -myArray = numpy.array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) -Nx = myArray.size - -# ADIOS config file -adios = adios2.ADIOS("helloBPWriter.xml") - -# ADIOS IO, name must be the same as in helloBPWriter.xml for runtime settings -bpIO = adios.DeclareIO("BPFile_N2N") - -# ADIOS local array: Variable name, shape, start, offset -ioArray = bpIO.DefineVariable( - "bpArray", [], [], [Nx], adios2.ConstantDims) - -# ADIOS Engine -bpFileWriter = bpIO.Open("npArray.bp", adios2.OpenModeWrite) -bpFileWriter.Write(ioArray, myArray) -bpFileWriter.Close() diff --git a/scripts/runconf/runconf_olcf.sh b/scripts/runconf/runconf_olcf.sh index 3d1ea83bc9..a9fc163f5d 100644 --- a/scripts/runconf/runconf_olcf.sh +++ b/scripts/runconf/runconf_olcf.sh @@ -66,7 +66,6 @@ if [ `hostname | cut -c 1-5` == "titan" ]; then -DADIOS2_USE_MPI=${USE_MPI} \ -DADIOS2_USE_Fortran=ON \ -DADIOS2_USE_Python=OFF \ - -DADIOS2_BUILD_EXAMPLES_EXPERIMENTAL=OFF \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_TESTING=OFF \ ${EXTERNAL_OPTS} \ @@ -116,7 +115,6 @@ elif [ `hostname -f | cut -c 1-9` == "summitdev" ]; then -DADIOS2_USE_MPI=${USE_MPI} \ -DADIOS2_USE_Fortran=ON \ -DADIOS2_USE_Python=OFF \ - -DADIOS2_BUILD_EXAMPLES_EXPERIMENTAL=OFF \ -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_TESTING=ON \ -DADIOS2_USE_DataMan=OFF \ @@ -154,7 +152,6 @@ elif [ `hostname -f | cut -c 1-4` == "rhea" ]; then -DADIOS2_USE_Fortran=ON \ -DADIOS2_USE_Python=OFF \ -DADIOS2_USE_SST=OFF \ - -DADIOS2_BUILD_EXAMPLES_EXPERIMENTAL=OFF \ -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_TESTING=ON \ -DADIOS2_USE_DataMan=OFF \ From a4ae05730ef9c5a58b85dafeb18b1fc6352094c3 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Tue, 12 Sep 2023 22:18:40 -0400 Subject: [PATCH 023/126] Remove BP5 BetweenStepPairs variable that hides Engine.h counterpart --- source/adios2/engine/bp5/BP5Writer.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Writer.h b/source/adios2/engine/bp5/BP5Writer.h index 72d0602217..eaddf93b9d 100644 --- a/source/adios2/engine/bp5/BP5Writer.h +++ b/source/adios2/engine/bp5/BP5Writer.h @@ -97,8 +97,6 @@ class BP5Writer : public BP5Engine, public core::Engine std::vector m_DrainMetadataIndexFileNames; std::vector m_ActiveFlagFileNames; - bool m_BetweenStepPairs = false; - void Init() final; /** Parses parameters from IO SetParameters */ From bab5b04e8ee6775a222de0e70df01e16aa0be6e8 Mon Sep 17 00:00:00 2001 From: Norbert Podhorszki Date: Wed, 13 Sep 2023 09:15:31 -0400 Subject: [PATCH 024/126] Set AWS version requirement to 1.10.15 and also turn it OFF by default as it is not a stable feature of ADIOS just yet. --- CMakeLists.txt | 2 +- cmake/DetectOptions.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbaf77516e..436e20c354 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,7 @@ adios_option(Profiling "Enable support for profiling" AUTO) adios_option(Endian_Reverse "Enable support for Little/Big Endian Interoperability" AUTO) adios_option(Sodium "Enable support for Sodium for encryption" AUTO) adios_option(Catalyst "Enable support for in situ visualization plugin using ParaView Catalyst" AUTO) -adios_option(AWSSDK "Enable support for S3 compatible storage using AWS SDK's S3 module" AUTO) +adios_option(AWSSDK "Enable support for S3 compatible storage using AWS SDK's S3 module" OFF) include(${PROJECT_SOURCE_DIR}/cmake/DetectOptions.cmake) if(ADIOS2_HAVE_CUDA OR ADIOS2_HAVE_Kokkos_CUDA) diff --git a/cmake/DetectOptions.cmake b/cmake/DetectOptions.cmake index 871ad0c42f..3466b95ad4 100644 --- a/cmake/DetectOptions.cmake +++ b/cmake/DetectOptions.cmake @@ -502,9 +502,9 @@ endif() # AWS S3 if(ADIOS2_USE_AWSSDK STREQUAL AUTO) - find_package(AWSSDK QUIET COMPONENTS s3) + find_package(AWSSDK 1.10.15 COMPONENTS s3) elseif(ADIOS2_USE_AWSSDK) - find_package(AWSSDK REQUIRED COMPONENTS s3) + find_package(AWSSDK 1.10.15 REQUIRED COMPONENTS s3) endif() if(AWSSDK_FOUND) set(ADIOS2_HAVE_AWSSDK TRUE) From d4efbe0eac736fe6f123e9a551d92742007203fb Mon Sep 17 00:00:00 2001 From: Norbert Podhorszki Date: Wed, 13 Sep 2023 11:59:29 -0400 Subject: [PATCH 025/126] bpls -l with scalar string variable: print the value (since min/max is empty). This changes the code for all types using Engine.Get() to get the value now. --- source/utils/bpls/bpls.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/utils/bpls/bpls.cpp b/source/utils/bpls/bpls.cpp index 714b14f1ff..f378d9ec1e 100644 --- a/source/utils/bpls/bpls.cpp +++ b/source/utils/bpls/bpls.cpp @@ -1286,8 +1286,9 @@ int printVariableInfo(core::Engine *fp, core::IO *io, if (longopt && !timestep) { fprintf(outf, " = "); - auto mm = variable->MinMax(); - print_data(&mm.second, 0, adiosvartype, false); + T value; + fp->Get(*variable, value, adios2::Mode::Sync); + print_data(&value, 0, adiosvartype, false); } fprintf(outf, "\n"); @@ -2941,8 +2942,7 @@ int print_data(const void *data, int item, DataType adiosvartype, fprintf(outf, (f ? fmt : "%hhd"), ((signed char *)data)[item]); break; - case DataType::String: - { + case DataType::String: { // fprintf(outf, (f ? fmt : "\"%s\""), ((char *)data) + item); const std::string *dataStr = reinterpret_cast(data); From 7b0c8764e3e3453eb1f6413fc47ae76f601ed901 Mon Sep 17 00:00:00 2001 From: anagainaru Date: Wed, 13 Sep 2023 13:54:32 -0400 Subject: [PATCH 026/126] Fix the ADIOS_USE_{_} variable names to use ADIOS2 Co-authored-by: Vicente Adolfo Bolea Sanchez --- cmake/ADIOSFunctions.cmake | 2 +- cmake/DetectOptions.cmake | 6 +++--- examples/hello/README.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/ADIOSFunctions.cmake b/cmake/ADIOSFunctions.cmake index 7d26bcc355..71d6ab994c 100644 --- a/cmake/ADIOSFunctions.cmake +++ b/cmake/ADIOSFunctions.cmake @@ -97,7 +97,7 @@ function(GenerateADIOSHeaderConfig) foreach(OPT IN LISTS ARGN) string(TOUPPER ${OPT} OPT_UPPER) string(APPEND ADIOS2_CONFIG_DEFINES " -/* CMake Option: ADIOS_USE_${OPT}=OFF */ +/* CMake Option: ADIOS2_USE_${OPT}=OFF */ #cmakedefine ADIOS2_HAVE_${OPT_UPPER} ") if(ADIOS2_HAVE_${OPT}) diff --git a/cmake/DetectOptions.cmake b/cmake/DetectOptions.cmake index 4044cb822f..c8f277567c 100644 --- a/cmake/DetectOptions.cmake +++ b/cmake/DetectOptions.cmake @@ -193,8 +193,8 @@ endif() set(mpi_find_components C) -if(ADIOS_USE_Kokkos AND ADIOS_USE_CUDA) - message(FATAL_ERROR "ADIOS2_USE_Kokkos is incompatible with ADIOS_USE_CUDA") +if(ADIOS2_USE_Kokkos AND ADIOS2_USE_CUDA) + message(FATAL_ERROR "ADIOS2_USE_Kokkos is incompatible with ADIOS2_USE_CUDA") endif() # Kokkos @@ -239,7 +239,7 @@ if(ADIOS2_USE_CUDA) endif() endif() -if(ADIOS_HAVE_Kokkos AND ADIOS_HAVE_CUDA) +if(ADIOS2_HAVE_Kokkos AND ADIOS2_HAVE_CUDA) message(FATAL_ERROR "The Kokkos and CUDA backends cannot be active concurrently") endif() diff --git a/examples/hello/README.md b/examples/hello/README.md index 01b109ccc7..e02c03c051 100644 --- a/examples/hello/README.md +++ b/examples/hello/README.md @@ -8,11 +8,11 @@ Provides tests and illustrates how to use very basic functionality in adios2 1. bpTimeWriter * Write BP format files for two Variables (one is timestep) using time aggregation -1. datamanReader (to be deprecated, ADIOS_USE_DataMan=ON) +1. datamanReader (to be deprecated, ADIOS2_USE_DataMan=ON) * Read real-time WAN streams using dataman 1. datamanWriter * Write real-time WAN streams using dataman -1. hdf5Writer (-DADIOS_USE_HDF5=ON) +1. hdf5Writer (-DADIOS2_USE_HDF5=ON) * Write HDF5 files using interoperability through the adios2 interface From 17d662a62997dc6d7a21f341d94b3051a524e55a Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Fri, 15 Sep 2023 14:05:42 -0400 Subject: [PATCH 027/126] Pass Array Order of reader to remote server for proper Get() operation --- source/adios2/engine/bp5/BP5Reader.cpp | 6 ++++-- source/adios2/toolkit/remote/Remote.cpp | 3 ++- source/adios2/toolkit/remote/Remote.h | 2 +- source/adios2/toolkit/remote/remote_common.cpp | 12 +++++++----- source/adios2/toolkit/remote/remote_common.h | 1 + source/adios2/toolkit/remote/remote_server.cpp | 9 ++++++--- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index fd2f4c33db..79c32fd0c2 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -467,13 +467,15 @@ void BP5Reader::Init() // This isn't how we'll trigger remote ops in the end, but a temporary // solution + bool RowMajorOrdering = (m_IO.m_ArrayOrder == ArrayOrdering::RowMajor); if (!m_Parameters.RemoteDataPath.empty()) { - m_Remote.Open("localhost", 26200, m_Parameters.RemoteDataPath, m_OpenMode); + m_Remote.Open("localhost", 26200, m_Parameters.RemoteDataPath, m_OpenMode, + RowMajorOrdering); } else if (getenv("DoRemote")) { - m_Remote.Open("localhost", 26200, m_Name, m_OpenMode); + m_Remote.Open("localhost", 26200, m_Name, m_OpenMode, RowMajorOrdering); } } diff --git a/source/adios2/toolkit/remote/Remote.cpp b/source/adios2/toolkit/remote/Remote.cpp index 9f8937e1aa..bc4823b355 100644 --- a/source/adios2/toolkit/remote/Remote.cpp +++ b/source/adios2/toolkit/remote/Remote.cpp @@ -72,7 +72,7 @@ void Remote::InitCMData() } void Remote::Open(const std::string hostname, const int32_t port, const std::string filename, - const Mode mode) + const Mode mode, bool RowMajorOrdering) { RemoteCommon::_OpenFileMsg open_msg; @@ -102,6 +102,7 @@ void Remote::Open(const std::string hostname, const int32_t port, const std::str break; } open_msg.OpenResponseCondition = CMCondition_get(ev_state.cm, m_conn); + open_msg.RowMajorOrder = RowMajorOrdering; CMCondition_set_client_data(ev_state.cm, open_msg.OpenResponseCondition, (void *)this); CMwrite(m_conn, ev_state.OpenFileFormat, &open_msg); CMCondition_wait(ev_state.cm, open_msg.OpenResponseCondition); diff --git a/source/adios2/toolkit/remote/Remote.h b/source/adios2/toolkit/remote/Remote.h index 0858f0654d..f6b16bd304 100644 --- a/source/adios2/toolkit/remote/Remote.h +++ b/source/adios2/toolkit/remote/Remote.h @@ -38,7 +38,7 @@ class Remote explicit operator bool() const { return m_Active; } void Open(const std::string hostname, const int32_t port, const std::string filename, - const Mode mode); + const Mode mode, bool RowMajorOrdering); void OpenSimpleFile(const std::string hostname, const int32_t port, const std::string filename); diff --git a/source/adios2/toolkit/remote/remote_common.cpp b/source/adios2/toolkit/remote/remote_common.cpp index 9bb15a55c7..8e69f4df69 100644 --- a/source/adios2/toolkit/remote/remote_common.cpp +++ b/source/adios2/toolkit/remote/remote_common.cpp @@ -6,11 +6,13 @@ namespace adios2 namespace RemoteCommon { -FMField OpenFileList[] = {{"OpenResponseCondition", "integer", sizeof(long), - FMOffset(OpenFileMsg, OpenResponseCondition)}, - {"FileName", "string", sizeof(char *), FMOffset(OpenFileMsg, FileName)}, - {"Mode", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, Mode)}, - {NULL, NULL, 0, 0}}; +FMField OpenFileList[] = { + {"OpenResponseCondition", "integer", sizeof(long), + FMOffset(OpenFileMsg, OpenResponseCondition)}, + {"FileName", "string", sizeof(char *), FMOffset(OpenFileMsg, FileName)}, + {"Mode", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, Mode)}, + {"RowMajorOrder", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, RowMajorOrder)}, + {NULL, NULL, 0, 0}}; FMStructDescRec OpenFileStructs[] = {{"OpenFile", OpenFileList, sizeof(struct _OpenFileMsg), NULL}, {NULL, NULL, 0, NULL}}; diff --git a/source/adios2/toolkit/remote/remote_common.h b/source/adios2/toolkit/remote/remote_common.h index 81d303f490..48102e7b2d 100644 --- a/source/adios2/toolkit/remote/remote_common.h +++ b/source/adios2/toolkit/remote/remote_common.h @@ -18,6 +18,7 @@ typedef struct _OpenFileMsg int OpenResponseCondition; char *FileName; RemoteFileMode Mode; + int RowMajorOrder; } *OpenFileMsg; typedef struct _OpenResponseMsg diff --git a/source/adios2/toolkit/remote/remote_server.cpp b/source/adios2/toolkit/remote/remote_server.cpp index 9d640017f4..27a070a43a 100644 --- a/source/adios2/toolkit/remote/remote_server.cpp +++ b/source/adios2/toolkit/remote/remote_server.cpp @@ -74,12 +74,14 @@ class AnonADIOSFile size_t m_BytesSent = 0; size_t m_OperationCount = 0; RemoteFileMode m_mode = RemoteCommon::RemoteFileMode::RemoteOpen; - AnonADIOSFile(std::string FileName, RemoteCommon::RemoteFileMode mode) + AnonADIOSFile(std::string FileName, RemoteCommon::RemoteFileMode mode, bool RowMajorArrays) { Mode adios_read_mode = adios2::Mode::Read; m_FileName = FileName; m_IOname = lf_random_string(); - m_io = &adios.DeclareIO(m_IOname); + ArrayOrdering ArrayOrder = + RowMajorArrays ? ArrayOrdering::RowMajor : ArrayOrdering::ColumnMajor; + m_io = &adios.DeclareIO(m_IOname, ArrayOrder); m_mode = mode; if (m_mode == RemoteOpenRandomAccess) adios_read_mode = adios2::Mode::ReadRandomAccess; @@ -163,7 +165,8 @@ static void OpenHandler(CManager cm, CMConnection conn, void *vevent, void *clie struct Remote_evpath_state *ev_state = static_cast(client_data); _OpenResponseMsg open_response_msg; std::cout << "Got an open request for file " << open_msg->FileName << std::endl; - AnonADIOSFile *f = new AnonADIOSFile(open_msg->FileName, open_msg->Mode); + AnonADIOSFile *f = + new AnonADIOSFile(open_msg->FileName, open_msg->Mode, open_msg->RowMajorOrder); memset(&open_response_msg, 0, sizeof(open_response_msg)); open_response_msg.FileHandle = f->m_ID; open_response_msg.OpenResponseCondition = open_msg->OpenResponseCondition; From 810f7944e6529bc7f3cecfb396dca70049b47a3c Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Fri, 15 Sep 2023 14:35:53 -0400 Subject: [PATCH 028/126] fix dummy Win build --- source/adios2/toolkit/remote/Remote.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/adios2/toolkit/remote/Remote.cpp b/source/adios2/toolkit/remote/Remote.cpp index bc4823b355..13f46dbdc7 100644 --- a/source/adios2/toolkit/remote/Remote.cpp +++ b/source/adios2/toolkit/remote/Remote.cpp @@ -172,7 +172,7 @@ bool Remote::WaitForGet(GetHandle handle) { return CMCondition_wait(ev_state.cm, #else void Remote::Open(const std::string hostname, const int32_t port, const std::string filename, - const Mode mode){}; + const Mode mode, bool RowMajorOrdering){}; void Remote::OpenSimpleFile(const std::string hostname, const int32_t port, const std::string filename){}; From 7c44ccfa6d4e0f794536053fc6ca21702e69a511 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Mon, 18 Sep 2023 19:55:18 -0400 Subject: [PATCH 029/126] Fix abs/rel step in BP5 DoCount --- .../toolkit/format/bp5/BP5Deserializer.cpp | 20 ++++++++++++------ .../adios2/toolkit/remote/remote_common.cpp | 2 +- .../adios2/toolkit/remote/remote_server.cpp | 21 +++++++++++++++---- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp index c78fa38ae1..cf9fbefc14 100644 --- a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp @@ -1948,15 +1948,21 @@ void *BP5Deserializer::GetMetadataBase(BP5VarRec *VarRec, size_t Step, size_t Wr return writer_meta_base; } -MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, size_t Step) +MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, size_t RelStep) { BP5VarRec *VarRec = LookupVarByKey((void *)&Var); MinVarInfo *MV = new MinVarInfo((int)VarRec->DimCount, VarRec->GlobalDims); - const size_t writerCohortSize = WriterCohortSize(Step); + size_t AbsStep = RelStep; + + if (m_RandomAccessMode) + { + AbsStep = VarRec->AbsStepFromRel[RelStep]; + } + const size_t writerCohortSize = WriterCohortSize(AbsStep); size_t Id = 0; - MV->Step = Step; + MV->Step = RelStep; MV->Dims = (int)VarRec->DimCount; MV->Shape = NULL; MV->IsReverseDims = ((MV->Dims > 1) && (m_WriterIsRowMajor != m_ReaderIsRowMajor)); @@ -1981,7 +1987,7 @@ MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, size_t Step) for (size_t WriterRank = 0; WriterRank < writerCohortSize; WriterRank++) { MetaArrayRec *writer_meta_base = - (MetaArrayRec *)GetMetadataBase(VarRec, Step, WriterRank); + (MetaArrayRec *)GetMetadataBase(VarRec, AbsStep, WriterRank); if (writer_meta_base) { MinBlockInfo Blk; @@ -2007,7 +2013,8 @@ MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, size_t Step) } for (size_t WriterRank = 0; WriterRank < writerCohortSize; WriterRank++) { - MetaArrayRec *writer_meta_base = (MetaArrayRec *)GetMetadataBase(VarRec, Step, WriterRank); + MetaArrayRec *writer_meta_base = + (MetaArrayRec *)GetMetadataBase(VarRec, AbsStep, WriterRank); if (writer_meta_base) { if (MV->Shape == NULL) @@ -2024,7 +2031,8 @@ MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, size_t Step) Id = 0; for (size_t WriterRank = 0; WriterRank < writerCohortSize; WriterRank++) { - MetaArrayRec *writer_meta_base = (MetaArrayRec *)GetMetadataBase(VarRec, Step, WriterRank); + MetaArrayRec *writer_meta_base = + (MetaArrayRec *)GetMetadataBase(VarRec, AbsStep, WriterRank); if (!writer_meta_base) continue; diff --git a/source/adios2/toolkit/remote/remote_common.cpp b/source/adios2/toolkit/remote/remote_common.cpp index 8e69f4df69..20870815d5 100644 --- a/source/adios2/toolkit/remote/remote_common.cpp +++ b/source/adios2/toolkit/remote/remote_common.cpp @@ -11,7 +11,7 @@ FMField OpenFileList[] = { FMOffset(OpenFileMsg, OpenResponseCondition)}, {"FileName", "string", sizeof(char *), FMOffset(OpenFileMsg, FileName)}, {"Mode", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, Mode)}, - {"RowMajorOrder", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, RowMajorOrder)}, + {"RowMajorOrder", "integer", sizeof(int), FMOffset(OpenFileMsg, RowMajorOrder)}, {NULL, NULL, 0, 0}}; FMStructDescRec OpenFileStructs[] = {{"OpenFile", OpenFileList, sizeof(struct _OpenFileMsg), NULL}, diff --git a/source/adios2/toolkit/remote/remote_server.cpp b/source/adios2/toolkit/remote/remote_server.cpp index 27a070a43a..523ab70c55 100644 --- a/source/adios2/toolkit/remote/remote_server.cpp +++ b/source/adios2/toolkit/remote/remote_server.cpp @@ -164,7 +164,11 @@ static void OpenHandler(CManager cm, CMConnection conn, void *vevent, void *clie OpenFileMsg open_msg = static_cast(vevent); struct Remote_evpath_state *ev_state = static_cast(client_data); _OpenResponseMsg open_response_msg; - std::cout << "Got an open request for file " << open_msg->FileName << std::endl; + std::string strMode = "Streaming"; + if (open_msg->Mode == RemoteOpenRandomAccess) + strMode = "RandomAccess"; + std::cout << "Got an open request (mode " << strMode << ") for file " << open_msg->FileName + << std::endl; AnonADIOSFile *f = new AnonADIOSFile(open_msg->FileName, open_msg->Mode, open_msg->RowMajorOrder); memset(&open_response_msg, 0, sizeof(open_response_msg)); @@ -231,9 +235,11 @@ static void GetRequestHandler(CManager cm, CMConnection conn, void *vevent, void } } - if (TypeOfVar == adios2::DataType::None) + try { - } + if (TypeOfVar == adios2::DataType::None) + { + } #define GET(T) \ else if (TypeOfVar == helper::GetDataType()) \ { \ @@ -259,8 +265,15 @@ static void GetRequestHandler(CManager cm, CMConnection conn, void *vevent, void f->m_OperationCount++; \ CMwrite(conn, ev_state->ReadResponseFormat, &Response); \ } - ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(GET) + ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(GET) #undef GET + } + catch (const std::exception &exc) + { + if (verbose) + std::cout << "Returning exception " << exc.what() << " for Get<" << TypeOfVar << ">(" + << VarName << ")" << std::endl; + } } static void ReadRequestHandler(CManager cm, CMConnection conn, void *vevent, void *client_data, From 44a19784e39048c049d9fdc8854ab14dbc904195 Mon Sep 17 00:00:00 2001 From: ffs Upstream Date: Tue, 19 Sep 2023 14:54:33 -0400 Subject: [PATCH 030/126] ffs 2023-09-19 (67e411c0) Code extracted from: https://github.com/GTkorvo/ffs.git at commit 67e411c0d7ee176a550feb3a9fb9f4e48a8d15bd (master). Upstream Shortlog ----------------- --- cod/cod.l | 2 +- cod/cod.y | 4 +- cod/pregen_source/Linux/cod.l | 82 +++-------------------------- cod/pregen_source/Linux/cod.tab.c | 6 +-- cod/pregen_source/Linux/cod.tab.h | 6 +-- cod/pregen_source/Linux/cod.y | 4 +- cod/pregen_source/Linux/lex.yy.c | 49 ++++++++--------- cod/pregen_source/Windows/cod.l | 2 +- cod/pregen_source/Windows/cod.tab.c | 8 +-- cod/pregen_source/Windows/cod.tab.h | 4 +- cod/pregen_source/Windows/cod.y | 4 +- cod/pregen_source/Windows/lex.yy.c | 2 +- 12 files changed, 52 insertions(+), 121 deletions(-) diff --git a/cod/cod.l b/cod/cod.l index 92d92c81af..6b816a740f 100644 --- a/cod/cod.l +++ b/cod/cod.l @@ -183,7 +183,7 @@ return {RETURN(RETURN_TOKEN);} [A-Za-z_][A-Za-z0-9_]* { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { diff --git a/cod/cod.y b/cod/cod.y index 5d21652bd8..a4d0d17515 100644 --- a/cod/cod.y +++ b/cod/cod.y @@ -286,7 +286,7 @@ cod_dup_list(sm_list list) %token string_constant %token floating_constant %token identifier_ref -%token type_id +%token type_identifier %token enumeration_constant %type struct_or_union; @@ -1039,7 +1039,7 @@ type_specifier: $$->node.type_specifier.lx_srcpos = $1.lx_srcpos; $$->node.type_specifier.token = STRING; } - | type_id { + | type_identifier { $$ = cod_new_identifier(); $$->node.identifier.lx_srcpos = $1.lx_srcpos; $$->node.identifier.id = $1.string; diff --git a/cod/pregen_source/Linux/cod.l b/cod/pregen_source/Linux/cod.l index 1aeba7fb0f..6b816a740f 100644 --- a/cod/pregen_source/Linux/cod.l +++ b/cod/pregen_source/Linux/cod.l @@ -71,8 +71,7 @@ extern int my_yy_input(); #endif static int -is_defined_type(id) -char *id; +is_defined_type(char *id) { int i = 0; while(types && types[i]) { @@ -83,8 +82,7 @@ char *id; } static int -is_enumeration_constant(id) -char *id; +is_enumeration_constant(char *id) { int i = 0; while(enums && enums[i]) { @@ -185,7 +183,7 @@ return {RETURN(RETURN_TOKEN);} [A-Za-z_][A-Za-z0-9_]* { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { @@ -329,7 +327,7 @@ static char *create_string_from_yytext() static void check_strbuf() { - int cur_len = string_buf_ptr - string_buffer; + intptr_t cur_len = string_buf_ptr - string_buffer; if ((cur_len + 1) == buffer_len) { buffer_len += 20; string_buffer = realloc(string_buffer, buffer_len + 1); @@ -361,87 +359,21 @@ yywrap YY_PROTO(( void )) } -#ifndef input /* flex, not lex */ void yy_delete_buffer YY_PROTO((YY_BUFFER_STATE b)); -#ifdef WINNT -/* old Windows code for MKS Toolkit version of flex */ - -static void -terminate_string_parse() -{ - yyrestart(NULL); -} - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -static char* current_input_string; - -int my_yy_input(buf,result,max_size) { - - if (current_input_string == NULL) - { - - result = 0; - } - else - if (max_size < strlen(current_input_string)) - { - memcpy((void*)buf, current_input_string, max_size); - current_input_string += max_size; - result = max_size; - } else { - int n = strlen(current_input_string); - memcpy((void*)buf, current_input_string, n+1); - current_input_string = NULL; - result = n; - } - -/* printf("my_yy_input buf[%s],result[%d]\n",buf,result);*/ - return result; -} - -static void -setup_for_string_parse(string, defined_types, enum_constants) -const char *string; -char **defined_types; -char **enum_constants; -{ - type_count = defined_type_count; - types = defined_types; - enums = enum_constants; - - current_input_string = string; - lex_offset = 1; - line_count = 1; -} -#else static YY_BUFFER_STATE bb = NULL; static void -reset_types_table(defined_types, enumerated_constants) -char **defined_types; -char **enumerated_constants; +reset_types_table(char **defined_types, char **enumerated_constants) { types = defined_types; enums = enumerated_constants; } static void -setup_for_string_parse(string, defined_types, enum_constants) -const char *string; -char **defined_types; -char **enum_constants; +setup_for_string_parse(const char *string, char **defined_types, char **enum_constants) { types = defined_types; enums = enum_constants; @@ -462,5 +394,3 @@ terminate_string_parse() } } -#endif -#endif diff --git a/cod/pregen_source/Linux/cod.tab.c b/cod/pregen_source/Linux/cod.tab.c index 3e09ac5b37..46bcb484ef 100644 --- a/cod/pregen_source/Linux/cod.tab.c +++ b/cod/pregen_source/Linux/cod.tab.c @@ -146,7 +146,7 @@ string_constant = 335, floating_constant = 336, identifier_ref = 337, - type_id = 338, + type_identifier = 338, enumeration_constant = 339 }; #endif @@ -231,7 +231,7 @@ #define string_constant 335 #define floating_constant 336 #define identifier_ref 337 -#define type_id 338 +#define type_identifier 338 #define enumeration_constant 339 @@ -891,7 +891,7 @@ static const char *const yytname[] = "STATIC", "EXTERN_TOKEN", "STRUCT", "ENUM", "UNION", "CONST", "SIZEOF", "TYPEDEF", "RETURN_TOKEN", "CONTINUE", "BREAK", "GOTO", "PRINT", "COMMA", "DOTDOTDOT", "integer_constant", "character_constant", "string_constant", - "floating_constant", "identifier_ref", "type_id", "enumeration_constant", + "floating_constant", "identifier_ref", "type_identifier", "enumeration_constant", "$accept", "start", "primary_expression", "postfix_expression", "argument_expression_list", "unary_expression", "unary_operator", "cast_expression", "multiplicative_expression", "additive_expression", diff --git a/cod/pregen_source/Linux/cod.tab.h b/cod/pregen_source/Linux/cod.tab.h index b431ca0b3e..30d3bb0194 100644 --- a/cod/pregen_source/Linux/cod.tab.h +++ b/cod/pregen_source/Linux/cod.tab.h @@ -119,7 +119,7 @@ string_constant = 335, floating_constant = 336, identifier_ref = 337, - type_id = 338, + type_identifier = 338, enumeration_constant = 339 }; #endif @@ -204,7 +204,7 @@ #define string_constant 335 #define floating_constant 336 #define identifier_ref 337 -#define type_id 338 +#define type_identifier 338 #define enumeration_constant 339 @@ -212,7 +212,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 187 "cod/cod.y" +#line 201 "cod/cod.y" { lx_info info; sm_ref reference; diff --git a/cod/pregen_source/Linux/cod.y b/cod/pregen_source/Linux/cod.y index 5d21652bd8..a4d0d17515 100644 --- a/cod/pregen_source/Linux/cod.y +++ b/cod/pregen_source/Linux/cod.y @@ -286,7 +286,7 @@ cod_dup_list(sm_list list) %token string_constant %token floating_constant %token identifier_ref -%token type_id +%token type_identifier %token enumeration_constant %type struct_or_union; @@ -1039,7 +1039,7 @@ type_specifier: $$->node.type_specifier.lx_srcpos = $1.lx_srcpos; $$->node.type_specifier.token = STRING; } - | type_id { + | type_identifier { $$ = cod_new_identifier(); $$->node.identifier.lx_srcpos = $1.lx_srcpos; $$->node.identifier.id = $1.string; diff --git a/cod/pregen_source/Linux/lex.yy.c b/cod/pregen_source/Linux/lex.yy.c index 87e6fbf9fb..2d4b639dcb 100644 --- a/cod/pregen_source/Linux/lex.yy.c +++ b/cod/pregen_source/Linux/lex.yy.c @@ -1,6 +1,6 @@ -#line 1 "/ccs/home/eisen/ffs/build/lex.yy.c" +#line 1 "/Users/eisen/prog/ffs/build/lex.yy.c" -#line 3 "/ccs/home/eisen/ffs/build/lex.yy.c" +#line 3 "/Users/eisen/prog/ffs/build/lex.yy.c" #define YY_INT_ALIGNED short int @@ -47,6 +47,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -155,7 +156,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern int yyleng; +extern yy_size_t yyleng; extern FILE *yyin, *yyout; @@ -198,7 +199,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -267,8 +268,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +yy_size_t yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = NULL; @@ -295,7 +296,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len ); void *yyalloc ( yy_size_t ); void *yyrealloc ( void *, yy_size_t ); @@ -348,7 +349,7 @@ static void yynoreturn yy_fatal_error ( const char* msg ); */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; @@ -767,9 +768,9 @@ static void check_strbuf(); static int buffer_len; static char *string_buffer; static char *string_buf_ptr; -#line 770 "/ccs/home/eisen/ffs/build/lex.yy.c" +#line 771 "/Users/eisen/prog/ffs/build/lex.yy.c" -#line 772 "/ccs/home/eisen/ffs/build/lex.yy.c" +#line 773 "/Users/eisen/prog/ffs/build/lex.yy.c" #define INITIAL 0 #define string_cond 1 @@ -810,7 +811,7 @@ FILE *yyget_out ( void ); void yyset_out ( FILE * _out_str ); - int yyget_leng ( void ); + yy_size_t yyget_leng ( void ); char *yyget_text ( void ); @@ -879,7 +880,7 @@ static int input ( void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -992,7 +993,7 @@ YY_DECL -#line 995 "/ccs/home/eisen/ffs/build/lex.yy.c" +#line 996 "/Users/eisen/prog/ffs/build/lex.yy.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1430,7 +1431,7 @@ YY_RULE_SETUP { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { @@ -1679,7 +1680,7 @@ YY_RULE_SETUP #line 320 "cod/cod.l" ECHO; YY_BREAK -#line 1682 "/ccs/home/eisen/ffs/build/lex.yy.c" +#line 1683 "/Users/eisen/prog/ffs/build/lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(string_cond): case YY_STATE_EOF(comment): @@ -1868,7 +1869,7 @@ static int yy_get_next_buffer (void) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1882,7 +1883,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1940,7 +1941,7 @@ static int yy_get_next_buffer (void) if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -2029,7 +2030,7 @@ static int yy_get_next_buffer (void) if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = (yy_n_chars) + 2; + yy_size_t number_to_move = (yy_n_chars) + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; char *source = @@ -2080,7 +2081,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -2449,12 +2450,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr ) * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - int i; + yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); @@ -2496,7 +2497,7 @@ static void yynoreturn yy_fatal_error (const char* msg ) do \ { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ + yy_size_t yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ @@ -2536,7 +2537,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -int yyget_leng (void) +yy_size_t yyget_leng (void) { return yyleng; } diff --git a/cod/pregen_source/Windows/cod.l b/cod/pregen_source/Windows/cod.l index fd5517b57a..724916d39c 100644 --- a/cod/pregen_source/Windows/cod.l +++ b/cod/pregen_source/Windows/cod.l @@ -183,7 +183,7 @@ return {RETURN(RETURN_TOKEN);} [A-Za-z_][A-Za-z0-9_]* { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { diff --git a/cod/pregen_source/Windows/cod.tab.c b/cod/pregen_source/Windows/cod.tab.c index 55f7fbfbdb..531a170505 100644 --- a/cod/pregen_source/Windows/cod.tab.c +++ b/cod/pregen_source/Windows/cod.tab.c @@ -387,7 +387,7 @@ extern int yydebug; string_constant = 335, /* string_constant */ floating_constant = 336, /* floating_constant */ identifier_ref = 337, /* identifier_ref */ - type_id = 338, /* type_id */ + type_identifier = 338, /* type_id */ enumeration_constant = 339 /* enumeration_constant */ }; typedef enum yytokentype yytoken_kind_t; @@ -508,7 +508,7 @@ enum yysymbol_kind_t YYSYMBOL_string_constant = 80, /* string_constant */ YYSYMBOL_floating_constant = 81, /* floating_constant */ YYSYMBOL_identifier_ref = 82, /* identifier_ref */ - YYSYMBOL_type_id = 83, /* type_id */ + YYSYMBOL_type_identifier = 83, /* type_id */ YYSYMBOL_enumeration_constant = 84, /* enumeration_constant */ YYSYMBOL_YYACCEPT = 85, /* $accept */ YYSYMBOL_start = 86, /* start */ @@ -1019,7 +1019,7 @@ static const char *const yytname[] = "ENUM", "UNION", "CONST", "SIZEOF", "TYPEDEF", "RETURN_TOKEN", "CONTINUE", "BREAK", "GOTO", "PRINT", "COMMA", "DOTDOTDOT", "integer_constant", "character_constant", "string_constant", - "floating_constant", "identifier_ref", "type_id", "enumeration_constant", + "floating_constant", "identifier_ref", "type_identifier", "enumeration_constant", "$accept", "start", "primary_expression", "postfix_expression", "argument_expression_list", "unary_expression", "unary_operator", "cast_expression", "multiplicative_expression", "additive_expression", @@ -2860,7 +2860,7 @@ yyparse (void) #line 2861 "cod.tab.c" break; - case 104: /* type_specifier: type_id */ + case 104: /* type_specifier: type_identifier */ #line 1042 "cod.y" { (yyval.reference) = cod_new_identifier(); diff --git a/cod/pregen_source/Windows/cod.tab.h b/cod/pregen_source/Windows/cod.tab.h index b431ca0b3e..9dfb351295 100644 --- a/cod/pregen_source/Windows/cod.tab.h +++ b/cod/pregen_source/Windows/cod.tab.h @@ -119,7 +119,7 @@ string_constant = 335, floating_constant = 336, identifier_ref = 337, - type_id = 338, + type_identifier = 338, enumeration_constant = 339 }; #endif @@ -204,7 +204,7 @@ #define string_constant 335 #define floating_constant 336 #define identifier_ref 337 -#define type_id 338 +#define type_identifier 338 #define enumeration_constant 339 diff --git a/cod/pregen_source/Windows/cod.y b/cod/pregen_source/Windows/cod.y index d71e908d4d..264b112904 100644 --- a/cod/pregen_source/Windows/cod.y +++ b/cod/pregen_source/Windows/cod.y @@ -286,7 +286,7 @@ cod_dup_list(sm_list list) %token string_constant %token floating_constant %token identifier_ref -%token type_id +%token type_identifier %token enumeration_constant %type struct_or_union; @@ -1039,7 +1039,7 @@ type_specifier: $$->node.type_specifier.lx_srcpos = $1.lx_srcpos; $$->node.type_specifier.token = STRING; } - | type_id { + | type_identifier { $$ = cod_new_identifier(); $$->node.identifier.lx_srcpos = $1.lx_srcpos; $$->node.identifier.id = $1.string; diff --git a/cod/pregen_source/Windows/lex.yy.c b/cod/pregen_source/Windows/lex.yy.c index b2a48531fa..100cc2fc18 100644 --- a/cod/pregen_source/Windows/lex.yy.c +++ b/cod/pregen_source/Windows/lex.yy.c @@ -1429,7 +1429,7 @@ YY_RULE_SETUP { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { From 17a0e68179d954c446d2ca652c67a549cd7d8e24 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Tue, 19 Sep 2023 15:20:59 -0400 Subject: [PATCH 031/126] Partial FFS Upstream, only changes to type_id --- thirdparty/ffs/ffs/cod/cod.l | 2 +- thirdparty/ffs/ffs/cod/cod.y | 4 ++-- thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.l | 2 +- thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.c | 6 +++--- thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.h | 4 ++-- thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.y | 4 ++-- thirdparty/ffs/ffs/cod/pregen_source/Linux/lex.yy.c | 2 +- thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l | 2 +- thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c | 6 +++--- thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h | 4 ++-- thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y | 4 ++-- thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c | 2 +- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/thirdparty/ffs/ffs/cod/cod.l b/thirdparty/ffs/ffs/cod/cod.l index 1aeba7fb0f..35a978cac4 100644 --- a/thirdparty/ffs/ffs/cod/cod.l +++ b/thirdparty/ffs/ffs/cod/cod.l @@ -185,7 +185,7 @@ return {RETURN(RETURN_TOKEN);} [A-Za-z_][A-Za-z0-9_]* { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { diff --git a/thirdparty/ffs/ffs/cod/cod.y b/thirdparty/ffs/ffs/cod/cod.y index 8ea0b75c73..84346dee86 100644 --- a/thirdparty/ffs/ffs/cod/cod.y +++ b/thirdparty/ffs/ffs/cod/cod.y @@ -278,7 +278,7 @@ cod_dup_list(sm_list list) %token string_constant %token floating_constant %token identifier_ref -%token type_id +%token type_identifier %token enumeration_constant %type struct_or_union; @@ -1031,7 +1031,7 @@ type_specifier: $$->node.type_specifier.lx_srcpos = $1.lx_srcpos; $$->node.type_specifier.token = STRING; } - | type_id { + | type_identifier { $$ = cod_new_identifier(); $$->node.identifier.lx_srcpos = $1.lx_srcpos; $$->node.identifier.id = $1.string; diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.l b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.l index 1aeba7fb0f..35a978cac4 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.l +++ b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.l @@ -185,7 +185,7 @@ return {RETURN(RETURN_TOKEN);} [A-Za-z_][A-Za-z0-9_]* { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.c b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.c index 1d42833f97..3b2bf55be6 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.c +++ b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.c @@ -146,7 +146,7 @@ string_constant = 335, floating_constant = 336, identifier_ref = 337, - type_id = 338, + type_identifier = 338, enumeration_constant = 339 }; #endif @@ -231,7 +231,7 @@ #define string_constant 335 #define floating_constant 336 #define identifier_ref 337 -#define type_id 338 +#define type_identifier 338 #define enumeration_constant 339 @@ -877,7 +877,7 @@ static const char *const yytname[] = "STATIC", "EXTERN_TOKEN", "STRUCT", "ENUM", "UNION", "CONST", "SIZEOF", "TYPEDEF", "RETURN_TOKEN", "CONTINUE", "BREAK", "GOTO", "PRINT", "COMMA", "DOTDOTDOT", "integer_constant", "character_constant", "string_constant", - "floating_constant", "identifier_ref", "type_id", "enumeration_constant", + "floating_constant", "identifier_ref", "type_identifier", "enumeration_constant", "$accept", "start", "primary_expression", "postfix_expression", "argument_expression_list", "unary_expression", "unary_operator", "cast_expression", "multiplicative_expression", "additive_expression", diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.h b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.h index b431ca0b3e..9dfb351295 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.h +++ b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.tab.h @@ -119,7 +119,7 @@ string_constant = 335, floating_constant = 336, identifier_ref = 337, - type_id = 338, + type_identifier = 338, enumeration_constant = 339 }; #endif @@ -204,7 +204,7 @@ #define string_constant 335 #define floating_constant 336 #define identifier_ref 337 -#define type_id 338 +#define type_identifier 338 #define enumeration_constant 339 diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.y b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.y index 6fcf832a75..b378257863 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.y +++ b/thirdparty/ffs/ffs/cod/pregen_source/Linux/cod.y @@ -272,7 +272,7 @@ cod_dup_list(sm_list list) %token string_constant %token floating_constant %token identifier_ref -%token type_id +%token type_identifier %token enumeration_constant %type struct_or_union; @@ -1025,7 +1025,7 @@ type_specifier: $$->node.type_specifier.lx_srcpos = $1.lx_srcpos; $$->node.type_specifier.token = STRING; } - | type_id { + | type_identifier { $$ = cod_new_identifier(); $$->node.identifier.lx_srcpos = $1.lx_srcpos; $$->node.identifier.id = $1.string; diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Linux/lex.yy.c b/thirdparty/ffs/ffs/cod/pregen_source/Linux/lex.yy.c index e754ca5f93..7a21ba4254 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Linux/lex.yy.c +++ b/thirdparty/ffs/ffs/cod/pregen_source/Linux/lex.yy.c @@ -1431,7 +1431,7 @@ YY_RULE_SETUP { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l index 1aeba7fb0f..35a978cac4 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l @@ -185,7 +185,7 @@ return {RETURN(RETURN_TOKEN);} [A-Za-z_][A-Za-z0-9_]* { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c index 1d42833f97..3b2bf55be6 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c @@ -146,7 +146,7 @@ string_constant = 335, floating_constant = 336, identifier_ref = 337, - type_id = 338, + type_identifier = 338, enumeration_constant = 339 }; #endif @@ -231,7 +231,7 @@ #define string_constant 335 #define floating_constant 336 #define identifier_ref 337 -#define type_id 338 +#define type_identifier 338 #define enumeration_constant 339 @@ -877,7 +877,7 @@ static const char *const yytname[] = "STATIC", "EXTERN_TOKEN", "STRUCT", "ENUM", "UNION", "CONST", "SIZEOF", "TYPEDEF", "RETURN_TOKEN", "CONTINUE", "BREAK", "GOTO", "PRINT", "COMMA", "DOTDOTDOT", "integer_constant", "character_constant", "string_constant", - "floating_constant", "identifier_ref", "type_id", "enumeration_constant", + "floating_constant", "identifier_ref", "type_identifier", "enumeration_constant", "$accept", "start", "primary_expression", "postfix_expression", "argument_expression_list", "unary_expression", "unary_operator", "cast_expression", "multiplicative_expression", "additive_expression", diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h index b431ca0b3e..9dfb351295 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h @@ -119,7 +119,7 @@ string_constant = 335, floating_constant = 336, identifier_ref = 337, - type_id = 338, + type_identifier = 338, enumeration_constant = 339 }; #endif @@ -204,7 +204,7 @@ #define string_constant 335 #define floating_constant 336 #define identifier_ref 337 -#define type_id 338 +#define type_identifier 338 #define enumeration_constant 339 diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y index 6fcf832a75..b378257863 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y @@ -272,7 +272,7 @@ cod_dup_list(sm_list list) %token string_constant %token floating_constant %token identifier_ref -%token type_id +%token type_identifier %token enumeration_constant %type struct_or_union; @@ -1025,7 +1025,7 @@ type_specifier: $$->node.type_specifier.lx_srcpos = $1.lx_srcpos; $$->node.type_specifier.token = STRING; } - | type_id { + | type_identifier { $$ = cod_new_identifier(); $$->node.identifier.lx_srcpos = $1.lx_srcpos; $$->node.identifier.id = $1.string; diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c b/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c index e754ca5f93..7a21ba4254 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c @@ -1431,7 +1431,7 @@ YY_RULE_SETUP { yylval.info.string = create_string_from_yytext(); if (is_defined_type(yylval.info.string)) { - RETURN(type_id); + RETURN(type_identifier); } else if (is_enumeration_constant(yylval.info.string)) { RETURN(enumeration_constant); } else { From d5dcb9876b88b75545445df23b539b1e50250bc3 Mon Sep 17 00:00:00 2001 From: Junmin Gu Date: Wed, 20 Sep 2023 05:57:28 -0700 Subject: [PATCH 032/126] added support to query BP5 files (#3809) * added support to query BP5 files * size_type fix * updated python test and added to ctest * moved QueryWorker to the beginstep/endstep loop because bp5 metadata loading pattern deprecate bp3 engine test and replaced with bp5 engine test * clang-format * clang-format * removed some comments * flake8 * correct previous commit. Wrong files changed * furthur formatting * removed comments * added new doc file * Polished query.rst * more touch ups * more clean ups * subblock calculated by the helper function is relative to block so added block start before return to user * clang-format fix * clang-format fix --- bindings/CXX11/adios2/cxx11/Query.cpp | 8 +- bindings/CXX11/adios2/cxx11/Query.h | 8 +- bindings/Python/py11Query.cpp | 3 +- bindings/Python/py11Query.h | 2 - docs/user_guide/source/advanced/query.rst | 93 +++++++++++ examples/query/test.cpp | 63 +++---- source/adios2/toolkit/query/BlockIndex.h | 91 +++++----- source/adios2/toolkit/query/Query.cpp | 2 +- testing/adios2/bindings/python/CMakeLists.txt | 1 + testing/adios2/bindings/python/TestQuery.py | 155 +++++++++++------- .../adios2/performance/query/TestBPQuery.cpp | 18 +- 11 files changed, 299 insertions(+), 145 deletions(-) create mode 100644 docs/user_guide/source/advanced/query.rst diff --git a/bindings/CXX11/adios2/cxx11/Query.cpp b/bindings/CXX11/adios2/cxx11/Query.cpp index 23bbd8c6c6..140d1485c6 100644 --- a/bindings/CXX11/adios2/cxx11/Query.cpp +++ b/bindings/CXX11/adios2/cxx11/Query.cpp @@ -14,7 +14,13 @@ QueryWorker::QueryWorker(const std::string &configFile, adios2::Engine &reader) delete m; } -void QueryWorker::GetResultCoverage(adios2::Box &outputSelection, +void QueryWorker::GetResultCoverage(std::vector> &touched_blocks) +{ + adios2::Box empty; + GetResultCoverage(empty, touched_blocks); +} + +void QueryWorker::GetResultCoverage(const adios2::Box &outputSelection, std::vector> &touched_blocks) { if (m_Worker) diff --git a/bindings/CXX11/adios2/cxx11/Query.h b/bindings/CXX11/adios2/cxx11/Query.h index a4dd046d38..1b26ab62d6 100644 --- a/bindings/CXX11/adios2/cxx11/Query.h +++ b/bindings/CXX11/adios2/cxx11/Query.h @@ -26,9 +26,15 @@ class Worker; class QueryWorker { public: + // configFile has query, can be either xml or json QueryWorker(const std::string &configFile, adios2::Engine &engine); - void GetResultCoverage(adios2::Box &, + // touched_blocks is a list of regions specified by (start, count), + // that contains data that satisfies the query file + void GetResultCoverage(std::vector> &touched_blocks); + + // supply output bound for the results + void GetResultCoverage(const adios2::Box &, std::vector> &touched_blocks); private: diff --git a/bindings/Python/py11Query.cpp b/bindings/Python/py11Query.cpp index 87c2014967..0e82cae6bb 100644 --- a/bindings/Python/py11Query.cpp +++ b/bindings/Python/py11Query.cpp @@ -30,9 +30,8 @@ Query::operator bool() const noexcept { return (m_QueryWorker == nullptr) ? fals std::vector> Query::GetResult() { - // std::cout<<"Do something"< empty; // look into all data std::vector> touched_blocks; + adios2::Box empty; m_QueryWorker->GetResultCoverage(empty, touched_blocks); return touched_blocks; } diff --git a/bindings/Python/py11Query.h b/bindings/Python/py11Query.h index df04fd3e59..b8cd29018b 100644 --- a/bindings/Python/py11Query.h +++ b/bindings/Python/py11Query.h @@ -34,8 +34,6 @@ class Query explicit operator bool() const noexcept; std::vector> GetResult(); - // const Box< Dims > & refinedSelectionIfAny, - // std::vector< Box< Dims > > &touched_blocks private: Query(adios2::query::Worker *qw); diff --git a/docs/user_guide/source/advanced/query.rst b/docs/user_guide/source/advanced/query.rst new file mode 100644 index 0000000000..852e0e52dc --- /dev/null +++ b/docs/user_guide/source/advanced/query.rst @@ -0,0 +1,93 @@ +################# +ADIOS2 query API +################# + +The query API in ADIOS2 allows a client to pass a query in XML or json format, +and get back a list of blocks or subblocks that contains hits. +Both BP4 and BP5 engines are supported. + + +The interface +============= +User is expected to pass a query file (configFile), and init a read engine (engine) +to construct a query and evaluate using the engine. +(note that the engine and query should be using the same ADIOS IO) + +.. code-block:: c++ + + class QueryWorker + { + public: + // configFile has query, can be either xml or json + QueryWorker(const std::string &configFile, adios2::Engine &engine); + + // touched_blocks is a list of regions specified by (start, count), + // that contains data that satisfies the query file + void GetResultCoverage(std::vector> &touched_blocks); + ... + } + +A Sample Compound Query +---------------------- + +This query targets a 1D variable "doubleV", data of interest is (x > 6.6) or (x < -0.17) or (2.8 < x < 2.9) +In addition, this query also specied an output region [start=5,count=80]. + + +.. code-block:: xml + + + + + + + + + + + + + + + + + + +Code EXAMPLES: +============== +C++: +---- +.. code-block:: c++ + + while (reader.BeginStep() == adios2::StepStatus::OK) + { + adios2::QueryWorker w = adios2::QueryWorker(queryFile, reader); + w.GetResultCoverage(touched_blocks); + + std::cout << " ... now can read out touched blocks ... size=" << touched_blocks.size() + << std::endl; + } + + +The Full C++ example is here: + https://github.com/ornladios/ADIOS2/blob/master/examples/query/test.cpp + + +Python: +------- + +.. code-block:: python + + while (reader.BeginStep() == adios2.StepStatus.OK): + # say only rank 0 wants to process result + var = [queryIO.InquireVariable("T")] + + if (rank == 0): + touched_blocks = w.GetResult() + doAnalysis(reader, touched_blocks, var) + +Full python example is here: + https://github.com/ornladios/ADIOS2/blob/master/testing/adios2/bindings/python/TestQuery.py + + This example generates data, the query file (in xml) and runs the query, all in python. + diff --git a/examples/query/test.cpp b/examples/query/test.cpp index 94da39a0dc..b97a2d7714 100644 --- a/examples/query/test.cpp +++ b/examples/query/test.cpp @@ -12,6 +12,36 @@ // #include "adios2/toolkit/query/Worker.h" +void queryWithStreaming(adios2::IO &queryIO, std::string &dataFileName, std::string &queryFile) +{ + adios2::Engine reader = queryIO.Open(dataFileName, adios2::Mode::Read, MPI_COMM_WORLD); + // adios2::QueryWorker* worker = NULL; + queryIO.SetParameter("StreamReader", "true"); + std::vector> touched_blocks; + + while (reader.BeginStep() == adios2::StepStatus::OK) + { + adios2::QueryWorker w = adios2::QueryWorker(queryFile, reader); + w.GetResultCoverage(touched_blocks); + + std::cout << " ... now can read out touched blocks ... size=" << touched_blocks.size() + << std::endl; + for (auto n : touched_blocks) + { + std::ostringstream startStr; + std::ostringstream countStr; + for (size_t k = 0; k < n.first.size(); k++) + { + startStr << n.first[k] << " "; + countStr << n.second[k] << " "; + } + std::cout << "\t[" << startStr.str() << "] [" << countStr.str() << "]" << std::endl; + } + reader.EndStep(); + } + reader.Close(); +} + int main(int argc, char *argv[]) { int provided; @@ -47,43 +77,16 @@ int main(int argc, char *argv[]) adios2::ADIOS ad = adios2::ADIOS(configFileName, MPI_COMM_WORLD); adios2::IO queryIO = ad.DeclareIO("query"); - adios2::Engine reader = queryIO.Open(dataFileName, adios2::Mode::Read, MPI_COMM_WORLD); -#ifdef NEVER - adios2::QueryWorker w = adios2::QueryWorker(configFileName, reader); -#else + std::string queryFile = configFileName; if (argc > 3) { queryFile = argv[3]; } std::cout << "Testing query file ..." << queryFile << std::endl; - adios2::QueryWorker w = adios2::QueryWorker(queryFile, reader); -#endif - std::vector> touched_blocks; - while (reader.BeginStep() == adios2::StepStatus::OK) - { - adios2::Box empty; - w.GetResultCoverage(empty, touched_blocks); - // adios2::Box tt({10,10}, {12,12}); - // w.GetResultCoverage(tt, touched_blocks); - std::cout << " ... now can read out touched blocks ... size=" << touched_blocks.size() - << std::endl; - for (auto n : touched_blocks) - { - std::ostringstream startStr; - std::ostringstream countStr; - for (size_t k = 0; k < n.first.size(); k++) - { - startStr << n.first[k] << " "; - countStr << n.second[k] << " "; - } - std::cout << "\t[" << startStr.str() << "] [" << countStr.str() << "]" - << std::endl; - } - reader.EndStep(); - } - reader.Close(); + queryWithStreaming(queryIO, dataFileName, queryFile); + return 0; } catch (std::exception &e) diff --git a/source/adios2/toolkit/query/BlockIndex.h b/source/adios2/toolkit/query/BlockIndex.h index dc6bb8ee7a..94890de269 100644 --- a/source/adios2/toolkit/query/BlockIndex.h +++ b/source/adios2/toolkit/query/BlockIndex.h @@ -22,9 +22,9 @@ class BlockIndex }; public: - BlockIndex(adios2::core::Variable &var, adios2::core::IO &io, + BlockIndex(adios2::core::Variable *var, adios2::core::IO &io, adios2::core::Engine &reader) - : m_Var(var), m_IdxIO(io), m_IdxReader(reader) + : m_VarPtr(var), m_IdxIO(io), m_IdxReader(reader) { } @@ -32,18 +32,57 @@ class BlockIndex void Evaluate(const QueryVar &query, std::vector> &resultSubBlocks) { - RunBP4Stat(query, resultSubBlocks); + if (m_IdxReader.m_EngineType.find("5") != std::string::npos) // a bp5 reader + RunBP5Stat(query, resultSubBlocks); + else + RunBP4Stat(query, resultSubBlocks); + } + + void RunBP5Stat(const QueryVar &query, std::vector> &hitBlocks) + { + size_t currStep = m_IdxReader.CurrentStep(); + adios2::Dims currShape = m_VarPtr->Shape(); + if (!query.IsSelectionValid(currShape)) + return; + + auto MinBlocksInfo = m_IdxReader.MinBlocksInfo(*m_VarPtr, currStep); + if (!MinBlocksInfo) + { // no info, can't do anything + return; + } + for (auto &blockInfo : MinBlocksInfo->BlocksInfo) + { + Dims ss(MinBlocksInfo->Dims); + Dims cc(MinBlocksInfo->Dims); + for (std::vector::size_type i = 0; i < ss.size(); i++) + { + ss[i] = blockInfo.Start[i]; + cc[i] = blockInfo.Count[i]; + } + if (!query.TouchSelection(ss, cc)) + continue; + + T bmin = *(T *)&blockInfo.MinMax.MinUnion; + T bmax = *(T *)&blockInfo.MinMax.MaxUnion; + bool isHit = query.m_RangeTree.CheckInterval(bmin, bmax); + if (isHit) + { + adios2::Box box = {ss, cc}; + hitBlocks.push_back(box); + } + } + delete MinBlocksInfo; } void RunBP4Stat(const QueryVar &query, std::vector> &hitBlocks) { size_t currStep = m_IdxReader.CurrentStep(); - adios2::Dims currShape = m_Var.Shape(); + adios2::Dims currShape = m_VarPtr->Shape(); if (!query.IsSelectionValid(currShape)) return; std::vector::BPInfo> varBlocksInfo = - m_IdxReader.BlocksInfo(m_Var, currStep); + m_IdxReader.BlocksInfo(*m_VarPtr, currStep); for (auto &blockInfo : varBlocksInfo) { @@ -62,6 +101,10 @@ class BlockIndex { adios2::Box currSubBlock = adios2::helper::GetSubBlock(blockInfo.Count, blockInfo.SubBlockInfo, i); + for (size_t d = 0; d < blockInfo.Count.size(); ++d) + { + currSubBlock.first[d] += blockInfo.Start[d]; + } if (!query.TouchSelection(currSubBlock.first, currSubBlock.second)) continue; hitBlocks.push_back(currSubBlock); @@ -80,40 +123,12 @@ class BlockIndex } } - /* - void RunDefaultBPStat(const QueryVar &query, - std::vector> &hitBlocks) - { - size_t currStep = m_IdxReader.CurrentStep(); - adios2::Dims currShape = m_Var.Shape(); - if (!query.IsSelectionValid(currShape)) - return; - - std::vector::BPInfo> varBlocksInfo = - m_IdxReader.BlocksInfo(m_Var, currStep); - - for (auto &blockInfo : varBlocksInfo) - { - if (!query.TouchSelection(blockInfo.Start, blockInfo.Count)) - continue; - - T min = blockInfo.Min; - T max = blockInfo.Max; - - // std::cout<<" min: "< box = {blockInfo.Start, - blockInfo.Count}; - hitBlocks.push_back(box); - } - } - } - */ - Tree m_Content; - adios2::core::Variable m_Var; + + // can not be unique_ptr as it changes with bp5 through steps + // as BP5Deserializer::SetupForStep calls io.RemoveVariables() + // must use ptr as bp5 associates ptrs with blockinfo, see MinBlocksInfo() in bp5 + adios2::core::Variable *m_VarPtr; private: // diff --git a/source/adios2/toolkit/query/Query.cpp b/source/adios2/toolkit/query/Query.cpp index 97dc3517e6..6dc85b94c5 100644 --- a/source/adios2/toolkit/query/Query.cpp +++ b/source/adios2/toolkit/query/Query.cpp @@ -310,7 +310,7 @@ void QueryVar::BlockIndexEvaluate(adios2::core::IO &io, adios2::core::Engine &re if (varType == adios2::helper::GetDataType()) \ { \ core::Variable *var = io.InquireVariable(m_VarName); \ - BlockIndex idx(*var, io, reader); \ + BlockIndex idx(var, io, reader); \ idx.Evaluate(*this, touchedBlocks); \ } // ADIOS2_FOREACH_ATTRIBUTE_TYPE_1ARG(declare_type) //skip complex types diff --git a/testing/adios2/bindings/python/CMakeLists.txt b/testing/adios2/bindings/python/CMakeLists.txt index b90d79a346..dd3c292a75 100644 --- a/testing/adios2/bindings/python/CMakeLists.txt +++ b/testing/adios2/bindings/python/CMakeLists.txt @@ -25,6 +25,7 @@ if(ADIOS2_HAVE_MPI) add_python_mpi_test(BPBlocksInfo) add_python_mpi_test(BPChangingShapeHighLevelAPI) add_python_mpi_test(NullEngine) + add_python_mpi_test(Query) # Currently hangs in H5Fclose for unknown reasons #if(ADIOS2_HAVE_HDF5) # add_python_mpi_test(BPWriteTypesHighLevelAPI_HDF5) diff --git a/testing/adios2/bindings/python/TestQuery.py b/testing/adios2/bindings/python/TestQuery.py index f53df651f4..e406ce3cf5 100644 --- a/testing/adios2/bindings/python/TestQuery.py +++ b/testing/adios2/bindings/python/TestQuery.py @@ -1,21 +1,88 @@ +# from mpi4py import MPI import numpy as np import adios2 -import os +import sys # MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() -configFile = './defaultConfig.xml' -queryFile = './sampleQuery.xml' -dataPath = './heat.bp' +# ####################################### +# # usage: [bp4 | bp5=default] ## +# ####################################### +numSteps = 5 +queryFile = 'query.xml' +targetVarName = 'var0' + +# User data +myArray = np.array([0, 1., 2., 3., 4., 5., 6., 7., 8., 9.]) +Nx = myArray.size + +# ADIOS MPI Communicator +adios = adios2.ADIOS(comm) + +supportedEngines = ['bp5', 'bp4'] +engineType = 'bp5' +if (len(sys.argv) > 1): + engineType = sys.argv[1].lower() + +if (engineType in supportedEngines): + if (rank == 0): + print('Using engine type:', engineType) +else: + sys.exit('specified engine does not exist') + + +dataFileName = 'test_' + engineType + '.bp' + + +def writeDataFile(): + bpIO = adios.DeclareIO("Writer") + bpIO.SetEngine(engineType) + + ioArray = bpIO.DefineVariable( + targetVarName, myArray, [size * Nx], [rank * Nx], + [Nx], adios2.ConstantDims) + + bpFileWriter = bpIO.Open(dataFileName, adios2.Mode.Write) + + for i in range(numSteps): + bpFileWriter.BeginStep() + bpFileWriter.Put(ioArray, i * 10.0 + myArray / (rank + 1), adios2.Mode.Sync) + bpFileWriter.EndStep() + + bpFileWriter.Close() + + +def createQueryFile(): + print(".. Writing query file to: ", queryFile) + + file1 = open(queryFile, 'w') + queryContent = [ + "\n", "\n", + " \n" + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", "\n" + ] + file1.writelines(queryContent) + file1.close() def doAnalysis(reader, touched_blocks, varList): print(" Step: ", reader.CurrentStep(), " num touched blocks: ", len(touched_blocks)) + if (0 == reader.CurrentStep()): + assert (len(touched_blocks) == min(size, 2)) + if (1 == reader.CurrentStep()): + assert (len(touched_blocks) == size) + if (1 < reader.CurrentStep()): + assert (len(touched_blocks) == 0) + values = [] data = {} @@ -29,79 +96,49 @@ def doAnalysis(reader, touched_blocks, varList): var.SetSelection(n) reader.Get(var, values, adios2.Mode.Sync) data[var].extend(values) - # do analysis with data here -def runQuery(): - adios = adios2.ADIOS(configFile, comm, True) - queryIO = adios.DeclareIO("query") - reader = queryIO.Open(dataPath, adios2.Mode.Read, comm) - w = adios2.Query(queryFile, reader) +def queryDataFile(): + # # use no mpi + adios_nompi = adios2.ADIOS() + queryIO = adios_nompi.DeclareIO("query") + reader = queryIO.Open(dataFileName, adios2.Mode.Read) + print("dataFile=", dataFileName, "queryFile=", queryFile) touched_blocks = [] print("Num steps: ", reader.Steps()) while (reader.BeginStep() == adios2.StepStatus.OK): - # say only rank 0 wants to process result - var = [queryIO.InquireVariable("T")] + # bp5 loads metadata after beginstep(), + # therefore query has to be called per step + w = adios2.Query(queryFile, reader) + # assume only rank 0 wants to process result + var = [queryIO.InquireVariable(targetVarName)] if (rank == 0): touched_blocks = w.GetResult() doAnalysis(reader, touched_blocks, var) - reader.EndStep() + reader.EndStep() reader.Close() -def createConfigFile(): - print(".. Writing config file to: ", configFile) - file1 = open(configFile, 'w') - - xmlContent = ["\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - "\n", "\n"] - - file1.writelines(xmlContent) - file1.close() - - -def createQueryFile(): - print(".. Writing query file to: ", queryFile) +def cleanUp(): + import os + import shutil + os.remove(queryFile) + shutil.rmtree(dataFileName) + print(" Cleanup generated files: ", queryFile, dataFileName) - file1 = open(queryFile, 'w') - queryContent = [ - "\n", "\n", - " \n" - " \n", - " \n", - " \n", - " \n", " \n", - " \n", " \n", "\n" - ] - file1.writelines(queryContent) - file1.close() +# +# actual setup: +# -if (os.path.exists(dataPath) is False): - print("Please generate data file:", dataPath, - " from heat transfer example first.") -else: - # configFile created - createConfigFile() +writeDataFile() - # queryFile Generated +if (0 == rank): createQueryFile() - - print(".. Running query against: ", dataPath) - runQuery() - - print("Now clean up.") - os.remove(queryFile) - os.remove(configFile) + queryDataFile() + cleanUp() diff --git a/testing/adios2/performance/query/TestBPQuery.cpp b/testing/adios2/performance/query/TestBPQuery.cpp index 1ae23c8e87..a3ff5ae4a2 100644 --- a/testing/adios2/performance/query/TestBPQuery.cpp +++ b/testing/adios2/performance/query/TestBPQuery.cpp @@ -14,8 +14,6 @@ #include -// #include "../engine/SmallTestData.h" - // std::string engineName; // comes from command line struct QueryTestData @@ -98,7 +96,6 @@ void BPQueryTest::QueryIntVar(const std::string &fname, adios2::ADIOS &adios, std::string queryFile = "./" + ioName + "test.xml"; //"./test.xml"; std::cout << ioName << std::endl; WriteXmlQuery1D(queryFile, ioName, "intV"); - adios2::QueryWorker w = adios2::QueryWorker(queryFile, bpReader); std::vector rr; if (engineName.compare("BP4") == 0) @@ -108,9 +105,9 @@ void BPQueryTest::QueryIntVar(const std::string &fname, adios2::ADIOS &adios, while (bpReader.BeginStep() == adios2::StepStatus::OK) { + adios2::QueryWorker w = adios2::QueryWorker(queryFile, bpReader); std::vector> touched_blocks; - adios2::Box empty; - w.GetResultCoverage(empty, touched_blocks); + w.GetResultCoverage(touched_blocks); ASSERT_EQ(touched_blocks.size(), rr[bpReader.CurrentStep()]); bpReader.EndStep(); } @@ -135,7 +132,6 @@ void BPQueryTest::QueryDoubleVar(const std::string &fname, adios2::ADIOS &adios, // std::string queryFile = "./.test.xml"; std::string queryFile = "./" + ioName + "test.xml"; WriteXmlQuery1D(queryFile, ioName, "doubleV"); - adios2::QueryWorker w = adios2::QueryWorker(queryFile, bpReader); std::vector rr; //= {0,9,9}; if (engineName.compare("BP4") == 0) @@ -144,9 +140,9 @@ void BPQueryTest::QueryDoubleVar(const std::string &fname, adios2::ADIOS &adios, rr = {0, 1, 1}; while (bpReader.BeginStep() == adios2::StepStatus::OK) { + adios2::QueryWorker w = adios2::QueryWorker(queryFile, bpReader); std::vector> touched_blocks; - adios2::Box empty; - w.GetResultCoverage(empty, touched_blocks); + w.GetResultCoverage(touched_blocks); ASSERT_EQ(touched_blocks.size(), rr[bpReader.CurrentStep()]); bpReader.EndStep(); } @@ -234,9 +230,9 @@ void BPQueryTest::WriteFile(const std::string &fname, adios2::ADIOS &adios, // 1D test data //****************************************************************************** -TEST_F(BPQueryTest, BP3) +TEST_F(BPQueryTest, BP5) { - std::string engineName = "BP3"; + std::string engineName = "BP5"; // Each process would write a 1x8 array and all processes would // form a mpiSize * Nx 1D array const std::string fname(engineName + "Query1D.bp"); @@ -265,7 +261,7 @@ TEST_F(BPQueryTest, BP4) std::string engineName = "BP4"; // Each process would write a 1x8 array and all processes would // form a mpiSize * Nx 1D array - const std::string fname(engineName + "4Query1D.bp"); + const std::string fname(engineName + "Query1D.bp"); #if ADIOS2_USE_MPI adios2::ADIOS adios(MPI_COMM_WORLD); From 49b0eadd5e04f9d0f0d5933751e18c8ba4092016 Mon Sep 17 00:00:00 2001 From: Vicente Bolea Date: Wed, 20 Sep 2023 16:59:47 -0400 Subject: [PATCH 033/126] install: export adios2 device variables (#3819) --- cmake/adios2-config-common.cmake.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/adios2-config-common.cmake.in b/cmake/adios2-config-common.cmake.in index 0d536e8904..04a41531f1 100644 --- a/cmake/adios2-config-common.cmake.in +++ b/cmake/adios2-config-common.cmake.in @@ -12,6 +12,11 @@ endif() set(ADIOS2_HAVE_Fortran @ADIOS2_HAVE_Fortran@) set(ADIOS2_HAVE_MPI @ADIOS2_HAVE_MPI@) +set(ADIOS2_HAVE_CUDA @ADIOS2_HAVE_CUDA@) +set(ADIOS2_HAVE_Kokkos @ADIOS2_HAVE_Kokkos@) +set(ADIOS2_HAVE_Kokkos_CUDA @ADIOS2_HAVE_Kokkos_CUDA@) +set(ADIOS2_HAVE_Kokkos_HIP @ADIOS2_HAVE_Kokkos_HIP@) +set(ADIOS2_HAVE_Kokkos_SYCL @ADIOS2_HAVE_Kokkos_SYCL@) function(adios2_add_thirdparty_target PackageName) add_library(adios2::thirdparty::${PackageName} INTERFACE IMPORTED) From 26391d959ca9d5141ee8692009249e98d6ffcff6 Mon Sep 17 00:00:00 2001 From: Vicente Bolea Date: Thu, 21 Sep 2023 18:24:18 -0400 Subject: [PATCH 034/126] ci: fix codeql ignore path (#3772) * ci: fix codeql ignore path --- .github/workflows/everything.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/everything.yml b/.github/workflows/everything.yml index 9590a845cb..b9ee1d0d32 100644 --- a/.github/workflows/everything.yml +++ b/.github/workflows/everything.yml @@ -535,8 +535,10 @@ jobs: with: languages: ${{ matrix.language }} config: | + paths: + - source paths-ignore: - - source/thirdparty/ + - source/thirdparty - name: Setup run: gha/scripts/ci/gh-actions/linux-setup.sh - name: Update From 2884f713d1376f6b1ee65584c8edb730c6229776 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Fri, 22 Sep 2023 14:52:26 -0400 Subject: [PATCH 035/126] Import tests from bp to staging common, implement memory selection in SST --- source/adios2/engine/sst/SstWriter.tcc | 56 +++++++-- .../bp/TestBPWriteMemorySelectionRead.cpp | 114 ++++++++++++++---- .../engine/staging-common/CMakeLists.txt | 5 + .../engine/staging-common/TestSupp.cmake | 12 ++ 4 files changed, 157 insertions(+), 30 deletions(-) diff --git a/source/adios2/engine/sst/SstWriter.tcc b/source/adios2/engine/sst/SstWriter.tcc index b2e850500f..237c902d8e 100644 --- a/source/adios2/engine/sst/SstWriter.tcc +++ b/source/adios2/engine/sst/SstWriter.tcc @@ -70,19 +70,61 @@ void SstWriter::PutSyncCommon(Variable &variable, const T *values) } else { - if (variable.m_Type == DataType::String) + if (!variable.m_MemoryCount.empty()) { - std::string &source = *(std::string *)values; - void *p = &(source[0]); + size_t ObjSize; + if (variable.m_Type == DataType::Struct) + { + ObjSize = variable.m_ElementSize; + } + else + { + ObjSize = helper::GetDataTypeSize(variable.m_Type); + } + + const bool sourceRowMajor = helper::IsRowMajor(m_IO.m_HostLanguage); + helper::DimsArray MemoryStart(variable.m_MemoryStart); + helper::DimsArray MemoryCount(variable.m_MemoryCount); + helper::DimsArray varCount(variable.m_Count); + + int DimCount = (int)variable.m_Count.size(); + helper::DimsArray ZeroDims(DimCount, (size_t)0); + // get a temporary span then fill with memselection now + format::BufferV::BufferPos bp5span(0, 0, 0); + m_BP5Serializer->Marshal((void *)&variable, variable.m_Name.c_str(), variable.m_Type, variable.m_ElementSize, DimCount, Shape, - Count, Start, &p, true, nullptr); + Count, Start, nullptr, false, &bp5span); + void *ptr = m_BP5Serializer->GetPtr(bp5span.bufferIdx, bp5span.posInBuffer); + + if (!sourceRowMajor) + { + std::reverse(MemoryStart.begin(), MemoryStart.end()); + std::reverse(MemoryCount.begin(), MemoryCount.end()); + std::reverse(varCount.begin(), varCount.end()); + } + helper::NdCopy((const char *)values, helper::CoreDims(ZeroDims), MemoryCount, + sourceRowMajor, false, (char *)ptr, MemoryStart, varCount, + sourceRowMajor, false, (int)ObjSize, helper::CoreDims(), + helper::CoreDims(), helper::CoreDims(), helper::CoreDims(), + false /* safemode */, variable.m_MemSpace); } else { - m_BP5Serializer->Marshal((void *)&variable, variable.m_Name.c_str(), - variable.m_Type, variable.m_ElementSize, DimCount, Shape, - Count, Start, values, true, nullptr); + if (variable.m_Type == DataType::String) + { + std::string &source = *(std::string *)values; + void *p = &(source[0]); + m_BP5Serializer->Marshal((void *)&variable, variable.m_Name.c_str(), + variable.m_Type, variable.m_ElementSize, DimCount, + Shape, Count, Start, &p, true, nullptr); + } + else + { + m_BP5Serializer->Marshal((void *)&variable, variable.m_Name.c_str(), + variable.m_Type, variable.m_ElementSize, DimCount, + Shape, Count, Start, values, true, nullptr); + } } } } diff --git a/testing/adios2/engine/bp/TestBPWriteMemorySelectionRead.cpp b/testing/adios2/engine/bp/TestBPWriteMemorySelectionRead.cpp index ea52b5753d..aa8d516b21 100644 --- a/testing/adios2/engine/bp/TestBPWriteMemorySelectionRead.cpp +++ b/testing/adios2/engine/bp/TestBPWriteMemorySelectionRead.cpp @@ -15,6 +15,8 @@ #include "../SmallTestData.h" std::string engineName; // comes from command line +bool DoWrite = true; +bool DoRead = true; namespace { @@ -166,9 +168,13 @@ void AssignStep3D(const size_t step, std::vector> &vector, } // end anonymous namespace +#if ADIOS2_USE_MPI +MPI_Comm testComm; +#endif + void BPSteps1D(const size_t ghostCells) { - const std::string fname("BPSteps1D_" + std::to_string(ghostCells) + ".bp"); + const std::string fname("BPSteps1D_" + std::to_string(ghostCells)); int mpiRank = 0, mpiSize = 1; // Number of rows @@ -178,15 +184,16 @@ void BPSteps1D(const size_t ghostCells) const size_t NSteps = 3; #if ADIOS2_USE_MPI - MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank); - MPI_Comm_size(MPI_COMM_WORLD, &mpiSize); + MPI_Comm_rank(testComm, &mpiRank); + MPI_Comm_size(testComm, &mpiSize); #endif #if ADIOS2_USE_MPI - adios2::ADIOS adios(MPI_COMM_WORLD); + adios2::ADIOS adios(testComm); #else adios2::ADIOS adios; #endif + if (DoWrite) { adios2::IO io = adios.DeclareIO("WriteIO"); @@ -195,6 +202,7 @@ void BPSteps1D(const size_t ghostCells) io.SetEngine(engineName); } + io.SetParameters("StatsLevel=1"); const adios2::Dims shape{static_cast(Nx * mpiSize)}; const adios2::Dims start{static_cast(Nx * mpiRank)}; const adios2::Dims count{Nx}; @@ -256,9 +264,10 @@ void BPSteps1D(const size_t ghostCells) bpWriter.Close(); } #if ADIOS2_USE_MPI - MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(testComm); #endif // Reader + if (DoRead) { adios2::IO io = adios.DeclareIO("ReadIO"); @@ -377,7 +386,7 @@ void BPSteps1D(const size_t ghostCells) void BPSteps2D4x2(const size_t ghostCells) { - const std::string fname("BPSteps2D4x2_" + std::to_string(ghostCells) + ".bp"); + const std::string fname("BPSteps2D4x2_" + std::to_string(ghostCells)); int mpiRank = 0, mpiSize = 1; // Number of rows @@ -391,15 +400,16 @@ void BPSteps2D4x2(const size_t ghostCells) const size_t NSteps = 3; #if ADIOS2_USE_MPI - MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank); - MPI_Comm_size(MPI_COMM_WORLD, &mpiSize); + MPI_Comm_rank(testComm, &mpiRank); + MPI_Comm_size(testComm, &mpiSize); #endif #if ADIOS2_USE_MPI - adios2::ADIOS adios(MPI_COMM_WORLD); + adios2::ADIOS adios(testComm); #else adios2::ADIOS adios; #endif + if (DoWrite) { adios2::IO io = adios.DeclareIO("WriteIO"); @@ -470,9 +480,10 @@ void BPSteps2D4x2(const size_t ghostCells) bpWriter.Close(); } #if ADIOS2_USE_MPI - MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(testComm); #endif // Reader + if (DoRead) { adios2::IO io = adios.DeclareIO("ReadIO"); @@ -601,7 +612,7 @@ void BPSteps2D4x2(const size_t ghostCells) void BPSteps3D8x2x4(const size_t ghostCells) { - const std::string fname("BPSteps3D8x2x4_" + std::to_string(ghostCells) + ".bp"); + const std::string fname("BPSteps3D8x2x4_" + std::to_string(ghostCells)); int mpiRank = 0, mpiSize = 1; // Number of rows @@ -617,15 +628,16 @@ void BPSteps3D8x2x4(const size_t ghostCells) const size_t NSteps = 3; #if ADIOS2_USE_MPI - MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank); - MPI_Comm_size(MPI_COMM_WORLD, &mpiSize); + MPI_Comm_rank(testComm, &mpiRank); + MPI_Comm_size(testComm, &mpiSize); #endif #if ADIOS2_USE_MPI - adios2::ADIOS adios(MPI_COMM_WORLD); + adios2::ADIOS adios(testComm); #else adios2::ADIOS adios; #endif + if (DoWrite) { adios2::IO io = adios.DeclareIO("WriteIO"); @@ -698,9 +710,10 @@ void BPSteps3D8x2x4(const size_t ghostCells) bpWriter.Close(); } #if ADIOS2_USE_MPI - MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(testComm); #endif // Reader + if (DoRead) { adios2::IO io = adios.DeclareIO("ReadIO"); @@ -878,25 +891,80 @@ INSTANTIATE_TEST_SUITE_P(ghostCells, BPWriteMemSelReadVector, ::testing::Values( int main(int argc, char **argv) { + int result; + ::testing::InitGoogleTest(&argc, argv); + int bare_arg = 0; + + for (int i = 1; i < argc; i++) + { + if (strcmp(argv[i], "-do_write") == 0) + { + DoWrite = true; + DoRead = false; + } + else if (strcmp(argv[i], "-do_read") == 0) + { + DoWrite = false; + DoRead = true; + } + else if (argv[i][0] == '-') + { + std::cerr << "Unknown argument: " << argv[i] << std::endl; + exit(1); + } + else + { + std::string fname; + std::string engineParams; + if (bare_arg == 0) + { + /* first arg without -- is engine */ + engineName = std::string(argv[1]); + bare_arg++; + } + else if (bare_arg == 1) + { + /* second arg without -- is filename */ + // fname = std::string(argv[1]); + bare_arg++; + } + else if (bare_arg == 2) + { + // engineParams = ParseEngineParams(argv[1]); + bare_arg++; + } + else + { + + throw std::invalid_argument("Unknown argument \"" + std::string(argv[1]) + "\""); + } + } + } + #if ADIOS2_USE_MPI int provided; + int thread_support_level = + (engineName == "SST" || engineName == "sst") ? MPI_THREAD_MULTIPLE : MPI_THREAD_SINGLE; // MPI_THREAD_MULTIPLE is only required if you enable the SST MPI_DP - MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided); -#endif + MPI_Init_thread(nullptr, nullptr, thread_support_level, &provided); - int result; - ::testing::InitGoogleTest(&argc, argv); + int key; + MPI_Comm_rank(MPI_COMM_WORLD, &key); - if (argc > 1) - { - engineName = std::string(argv[1]); - } + const unsigned int color = (DoRead & !DoWrite) ? 1 : 0; + + MPI_Comm_split(MPI_COMM_WORLD, color, key, &testComm); +#endif result = RUN_ALL_TESTS(); #if ADIOS2_USE_MPI +#ifdef CRAY_MPICH_VERSION + MPI_Barrier(MPI_COMM_WORLD); +#else MPI_Finalize(); +#endif #endif return result; diff --git a/testing/adios2/engine/staging-common/CMakeLists.txt b/testing/adios2/engine/staging-common/CMakeLists.txt index a5a3f09056..ee20d68b8c 100644 --- a/testing/adios2/engine/staging-common/CMakeLists.txt +++ b/testing/adios2/engine/staging-common/CMakeLists.txt @@ -149,8 +149,13 @@ set (ALL_SIMPLE_TESTS "") list (APPEND ALL_SIMPLE_TESTS ${SIMPLE_TESTS} ${SIMPLE_FORTRAN_TESTS} ${SIMPLE_MPI_TESTS} ${SIMPLE_ZFP_TESTS}) set (SST_SPECIFIC_TESTS "") +import_bp_test(WriteMemorySelectionRead 1 1) +list (APPEND SST_SPECIFIC_TESTS "WriteMemorySelectionRead.1x1") list (APPEND SST_SPECIFIC_TESTS "1x1.SstRUDP;1x1.LocalMultiblock;RoundRobinDistribution.1x1x3;AllToAllDistribution.1x1x3;OnDemandSingle.1x1") + if (ADIOS2_HAVE_MPI) + import_bp_test(WriteMemorySelectionRead 3 3) + list (APPEND SST_SPECIFIC_TESTS "WriteMemorySelectionRead.3x3") list (APPEND SST_SPECIFIC_TESTS "2x3.SstRUDP;2x1.LocalMultiblock;5x3.LocalMultiblock;") endif() diff --git a/testing/adios2/engine/staging-common/TestSupp.cmake b/testing/adios2/engine/staging-common/TestSupp.cmake index 13ce1765a4..ca63109a77 100644 --- a/testing/adios2/engine/staging-common/TestSupp.cmake +++ b/testing/adios2/engine/staging-common/TestSupp.cmake @@ -323,3 +323,15 @@ function(from_hex HEX DEC) set(${DEC} ${_res} PARENT_SCOPE) endfunction() +function(import_bp_test BASENAME WRITE_SCALE READ_SCALE) + set (WRITER_POSTFIX "Serial") + set (READER_POSTFIX "Serial") + if (${WRITE_SCALE} GREATER 1) + set (WRITER_POSTFIX "MPI") + endif() + if (${READ_SCALE} GREATER 1) + set (READER_POSTFIX "MPI") + endif() + set (${BASENAME}.${WRITE_SCALE}x${READ_SCALE}_CMD "run_test.py.$ -nw ${WRITE_SCALE} -nr ${READ_SCALE} --warg=-do_write --rarg=-do_read -w $ -r $" PARENT_SCOPE) + +endfunction() From 51f7b6f2f390d8044b8d4383344198e313fd1f53 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Tue, 26 Sep 2023 16:22:32 -0400 Subject: [PATCH 036/126] Try always using the MPI version --- testing/adios2/engine/staging-common/TestSupp.cmake | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/testing/adios2/engine/staging-common/TestSupp.cmake b/testing/adios2/engine/staging-common/TestSupp.cmake index ca63109a77..7106ae5184 100644 --- a/testing/adios2/engine/staging-common/TestSupp.cmake +++ b/testing/adios2/engine/staging-common/TestSupp.cmake @@ -326,12 +326,6 @@ endfunction() function(import_bp_test BASENAME WRITE_SCALE READ_SCALE) set (WRITER_POSTFIX "Serial") set (READER_POSTFIX "Serial") - if (${WRITE_SCALE} GREATER 1) - set (WRITER_POSTFIX "MPI") - endif() - if (${READ_SCALE} GREATER 1) - set (READER_POSTFIX "MPI") - endif() - set (${BASENAME}.${WRITE_SCALE}x${READ_SCALE}_CMD "run_test.py.$ -nw ${WRITE_SCALE} -nr ${READ_SCALE} --warg=-do_write --rarg=-do_read -w $ -r $" PARENT_SCOPE) + set (${BASENAME}.${WRITE_SCALE}x${READ_SCALE}_CMD "run_test.py.$ -nw ${WRITE_SCALE} -nr ${READ_SCALE} --warg=-do_write --rarg=-do_read -w $ -r $" PARENT_SCOPE) endfunction() From 5bde4908ff3009b02bfe54a404c5f88aed2b24d0 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Tue, 26 Sep 2023 20:25:32 -0400 Subject: [PATCH 037/126] Try always using the MPI version --- testing/adios2/engine/staging-common/TestSupp.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testing/adios2/engine/staging-common/TestSupp.cmake b/testing/adios2/engine/staging-common/TestSupp.cmake index 7106ae5184..dcc9305093 100644 --- a/testing/adios2/engine/staging-common/TestSupp.cmake +++ b/testing/adios2/engine/staging-common/TestSupp.cmake @@ -326,6 +326,12 @@ endfunction() function(import_bp_test BASENAME WRITE_SCALE READ_SCALE) set (WRITER_POSTFIX "Serial") set (READER_POSTFIX "Serial") - set (${BASENAME}.${WRITE_SCALE}x${READ_SCALE}_CMD "run_test.py.$ -nw ${WRITE_SCALE} -nr ${READ_SCALE} --warg=-do_write --rarg=-do_read -w $ -r $" PARENT_SCOPE) + if(ADIOS2_HAVE_MPI) + set (WRITER_POSTFIX "MPI") + endif() + if(ADIOS2_HAVE_MPI) + set (READER_POSTFIX "MPI") + endif() + set (${BASENAME}.${WRITE_SCALE}x${READ_SCALE}_CMD "run_test.py.$ -nw ${WRITE_SCALE} -nr ${READ_SCALE} --warg=-do_write --rarg=-do_read -w $ -r $" PARENT_SCOPE) endfunction() From 700839ddea71270ce05408110872cc340d3606d9 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Sat, 30 Sep 2023 15:22:35 -0400 Subject: [PATCH 038/126] Add prototype testing of remote functionality (#3830) --- source/adios2/toolkit/remote/Remote.cpp | 4 +- source/adios2/toolkit/remote/Remote.h | 20 +-- .../adios2/toolkit/remote/remote_common.cpp | 19 +++ source/adios2/toolkit/remote/remote_common.h | 13 ++ .../adios2/toolkit/remote/remote_server.cpp | 158 +++++++++++++++--- testing/adios2/engine/bp/CMakeLists.txt | 19 +++ 6 files changed, 191 insertions(+), 42 deletions(-) diff --git a/source/adios2/toolkit/remote/Remote.cpp b/source/adios2/toolkit/remote/Remote.cpp index 13f46dbdc7..0fe3199420 100644 --- a/source/adios2/toolkit/remote/Remote.cpp +++ b/source/adios2/toolkit/remote/Remote.cpp @@ -54,8 +54,8 @@ void Remote::InitCMData() { std::lock_guard lockGuard(m_CMInitMutex); bool first = true; - auto &CM = CManagerSingleton::Instance(first); - ev_state.cm = CM.m_cm; + auto CM = CManagerSingleton::Instance(first); + ev_state.cm = CM->m_cm; RegisterFormats(ev_state); if (first) { diff --git a/source/adios2/toolkit/remote/Remote.h b/source/adios2/toolkit/remote/Remote.h index f6b16bd304..75824cdc31 100644 --- a/source/adios2/toolkit/remote/Remote.h +++ b/source/adios2/toolkit/remote/Remote.h @@ -69,28 +69,15 @@ class CManagerSingleton #ifdef ADIOS2_HAVE_SST CManager m_cm = NULL; #endif - static CManagerSingleton &Instance(bool &first) + static CManagerSingleton *Instance(bool &first) { - // Since it's a static variable, if the class has already been created, - // it won't be created again. - // And it **is** thread-safe in C++11. - static CManagerSingleton myInstance; + static CManagerSingleton *ptr = new CManagerSingleton(); static bool internal_first = true; - // Return a reference to our instance. - first = internal_first; internal_first = false; - return myInstance; + return ptr; } - // delete copy and move constructors and assign operators - CManagerSingleton(CManagerSingleton const &) = delete; // Copy construct - CManagerSingleton(CManagerSingleton &&) = delete; // Move construct - CManagerSingleton &operator=(CManagerSingleton const &) = delete; // Copy assign - CManagerSingleton &operator=(CManagerSingleton &&) = delete; // Move assign - - // Any other public methods. - protected: #ifdef ADIOS2_HAVE_SST CManagerSingleton() { m_cm = CManager_create(); } @@ -101,7 +88,6 @@ class CManagerSingleton ~CManagerSingleton() {} #endif - // And any other protected methods. }; } // end namespace adios2 diff --git a/source/adios2/toolkit/remote/remote_common.cpp b/source/adios2/toolkit/remote/remote_common.cpp index 20870815d5..28be359240 100644 --- a/source/adios2/toolkit/remote/remote_common.cpp +++ b/source/adios2/toolkit/remote/remote_common.cpp @@ -96,6 +96,23 @@ FMField CloseFileList[] = { FMStructDescRec CloseFileStructs[] = {{"Close", CloseFileList, sizeof(struct _CloseFileMsg), NULL}, {NULL, NULL, 0, NULL}}; +FMField KillServerList[] = {{"KillResponseCondition", "integer", sizeof(long), + FMOffset(KillServerMsg, KillResponseCondition)}, + {NULL, NULL, 0, 0}}; + +FMStructDescRec KillServerStructs[] = { + {"KillServer", KillServerList, sizeof(struct _KillServerMsg), NULL}, {NULL, NULL, 0, NULL}}; + +FMField KillResponseList[] = { + {"KillResponseCondition", "integer", sizeof(long), + FMOffset(KillResponseMsg, KillResponseCondition)}, + {"Status", "string", sizeof(char *), FMOffset(KillResponseMsg, Status)}, + {NULL, NULL, 0, 0}}; + +FMStructDescRec KillResponseStructs[] = { + {"KillResponse", KillResponseList, sizeof(struct _KillResponseMsg), NULL}, + {NULL, NULL, 0, NULL}}; + void RegisterFormats(RemoteCommon::Remote_evpath_state &ev_state) { ev_state.OpenFileFormat = CMregister_format(ev_state.cm, RemoteCommon::OpenFileStructs); @@ -108,6 +125,8 @@ void RegisterFormats(RemoteCommon::Remote_evpath_state &ev_state) ev_state.ReadRequestFormat = CMregister_format(ev_state.cm, RemoteCommon::ReadRequestStructs); ev_state.ReadResponseFormat = CMregister_format(ev_state.cm, RemoteCommon::ReadResponseStructs); ev_state.CloseFileFormat = CMregister_format(ev_state.cm, RemoteCommon::CloseFileStructs); + ev_state.KillServerFormat = CMregister_format(ev_state.cm, RemoteCommon::KillServerStructs); + ev_state.KillResponseFormat = CMregister_format(ev_state.cm, RemoteCommon::KillResponseStructs); } } } diff --git a/source/adios2/toolkit/remote/remote_common.h b/source/adios2/toolkit/remote/remote_common.h index 48102e7b2d..a8c5aee5db 100644 --- a/source/adios2/toolkit/remote/remote_common.h +++ b/source/adios2/toolkit/remote/remote_common.h @@ -87,6 +87,17 @@ typedef struct _CloseFileMsg void *FileHandle; } *CloseFileMsg; +typedef struct _KillServerMsg +{ + int KillResponseCondition; +} *KillServerMsg; + +typedef struct _KillResponseMsg +{ + int KillResponseCondition; + char *Status; +} *KillResponseMsg; + enum VerbosityLevel { NoVerbose = 0, // Generally no output (but not absolutely quiet?) @@ -111,6 +122,8 @@ struct Remote_evpath_state CMFormat ReadRequestFormat; CMFormat ReadResponseFormat; CMFormat CloseFileFormat; + CMFormat KillServerFormat; + CMFormat KillResponseFormat; }; void RegisterFormats(struct Remote_evpath_state &ev_state); diff --git a/source/adios2/toolkit/remote/remote_server.cpp b/source/adios2/toolkit/remote/remote_server.cpp index 523ab70c55..9ae911322d 100644 --- a/source/adios2/toolkit/remote/remote_server.cpp +++ b/source/adios2/toolkit/remote/remote_server.cpp @@ -30,6 +30,13 @@ using namespace adios2; int verbose = 1; ADIOS adios("C++"); +size_t TotalSimpleBytesSent = 0; +size_t TotalGetBytesSent = 0; +size_t TotalSimpleReads = 0; +size_t TotalGets = 0; +size_t SimpleFilesOpened = 0; +size_t ADIOSFilesOpened = 0; + std::string readable_size(uint64_t size) { constexpr const char FILE_SIZE_UNITS[8][3]{"B ", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"}; @@ -178,6 +185,7 @@ static void OpenHandler(CManager cm, CMConnection conn, void *vevent, void *clie CMconn_register_close_handler(conn, ConnCloseHandler, NULL); ADIOSFileMap[f->m_ID] = f; ConnToFileMap.emplace(conn, f->m_ID); + ADIOSFilesOpened++; } static void OpenSimpleHandler(CManager cm, CMConnection conn, void *vevent, void *client_data, @@ -198,6 +206,7 @@ static void OpenSimpleHandler(CManager cm, CMConnection conn, void *vevent, void CMconn_register_close_handler(conn, ConnCloseHandler, NULL); SimpleFileMap[f->m_ID] = f; ConnToFileMap.emplace(conn, f->m_ID); + SimpleFilesOpened++; } static void GetRequestHandler(CManager cm, CMConnection conn, void *vevent, void *client_data, @@ -263,6 +272,8 @@ static void GetRequestHandler(CManager cm, CMConnection conn, void *vevent, void << " for Get<" << TypeOfVar << ">(" << VarName << ")" << b << std::endl; \ f->m_BytesSent += Response.Size; \ f->m_OperationCount++; \ + TotalGetBytesSent += Response.Size; \ + TotalGets++; \ CMwrite(conn, ev_state->ReadResponseFormat, &Response); \ } ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(GET) @@ -300,16 +311,78 @@ static void ReadRequestHandler(CManager cm, CMConnection conn, void *vevent, voi std::cout << "Returning " << readable_size(Response.Size) << " for Read " << std::endl; f->m_BytesSent += Response.Size; f->m_OperationCount++; + TotalSimpleBytesSent += Response.Size; + TotalSimpleReads++; CMwrite(conn, ev_state->ReadResponseFormat, &Response); free(tmp); } -void REVPServerRegisterHandlers(struct Remote_evpath_state &ev_state) +static void KillServerHandler(CManager cm, CMConnection conn, void *vevent, void *client_data, + attr_list attrs) +{ + KillServerMsg kill_msg = static_cast(vevent); + struct Remote_evpath_state *ev_state = static_cast(client_data); + _KillResponseMsg kill_response_msg; + memset(&kill_response_msg, 0, sizeof(kill_response_msg)); + kill_response_msg.KillResponseCondition = kill_msg->KillResponseCondition; + std::stringstream Status; + Status << "ADIOS files Opened: " << ADIOSFilesOpened << " (" << TotalGets << " gets for " + << readable_size(TotalGetBytesSent) << ") Simple files opened: " << SimpleFilesOpened + << " (" << TotalSimpleReads << " reads for " << readable_size(TotalSimpleBytesSent) + << ")"; + kill_response_msg.Status = strdup(Status.str().c_str()); + CMwrite(conn, ev_state->KillResponseFormat, &kill_response_msg); + free(kill_response_msg.Status); + exit(0); +} + +static void KillResponseHandler(CManager cm, CMConnection conn, void *vevent, void *client_data, + attr_list attrs) +{ + KillResponseMsg kill_response_msg = static_cast(vevent); + std::cout << "Server final status: " << kill_response_msg->Status << std::endl; + exit(0); +} + +void ServerRegisterHandlers(struct Remote_evpath_state &ev_state) { CMregister_handler(ev_state.OpenFileFormat, OpenHandler, &ev_state); CMregister_handler(ev_state.OpenSimpleFileFormat, OpenSimpleHandler, &ev_state); CMregister_handler(ev_state.GetRequestFormat, GetRequestHandler, &ev_state); CMregister_handler(ev_state.ReadRequestFormat, ReadRequestHandler, &ev_state); + CMregister_handler(ev_state.KillServerFormat, KillServerHandler, &ev_state); + CMregister_handler(ev_state.KillResponseFormat, KillResponseHandler, &ev_state); +} + +static const char *hostname = "localhost"; + +void connect_and_kill(int ServerPort) +{ + CManager cm = CManager_create(); + _KillServerMsg kill_msg; + struct Remote_evpath_state ev_state; + attr_list contact_list = create_attr_list(); + atom_t CM_IP_PORT = -1; + atom_t CM_IP_HOSTNAME = -1; + CM_IP_HOSTNAME = attr_atom_from_string("IP_HOST"); + CM_IP_PORT = attr_atom_from_string("IP_PORT"); + add_attr(contact_list, CM_IP_HOSTNAME, Attr_String, (attr_value)hostname); + add_attr(contact_list, CM_IP_PORT, Attr_Int4, (attr_value)ServerPort); + CMConnection conn = CMinitiate_conn(cm, contact_list); + if (!conn) + return; + + ev_state.cm = cm; + + RegisterFormats(ev_state); + + ServerRegisterHandlers(ev_state); + + memset(&kill_msg, 0, sizeof(kill_msg)); + kill_msg.KillResponseCondition = CMCondition_get(ev_state.cm, conn); + CMwrite(conn, ev_state.KillServerFormat, &kill_msg); + CMCondition_wait(ev_state.cm, kill_msg.KillResponseCondition); + exit(0); } static atom_t CM_IP_PORT = -1; @@ -318,9 +391,67 @@ int main(int argc, char **argv) { CManager cm; struct Remote_evpath_state ev_state; + int background = 0; + int kill_server = 0; + + for (int i = 1; i < argc; i++) + { + if (strcmp(argv[i], "-background") == 0) + { + background++; + } + else if (strcmp(argv[i], "-kill_server") == 0) + { + kill_server++; + } + if (argv[i][0] == '-') + { + size_t j = 1; + while (argv[i][j] != 0) + { + if (argv[i][j] == 'v') + { + verbose++; + } + else if (argv[i][j] == 'q') + { + verbose--; + } + j++; + } + } + else + { + fprintf(stderr, "Unknown argument \"%s\"\n", argv[i]); + fprintf(stderr, "Usage: remote_server [-background] [-kill_server] [-v] [-q]\n"); + exit(1); + } + } + + if (kill_server) + { + connect_and_kill(ServerPort); + exit(0); + } + if (background) + { + if (verbose) + { + printf("Forking server to background\n"); + } + if (fork() != 0) + { + /* I'm the parent, wait a sec to let the child start, then exit */ + sleep(1); + exit(0); + } + /* I'm the child, close IO FDs so that ctest continues. No verbosity here */ + verbose = 0; + close(0); + close(1); + close(2); + } - (void)argc; - (void)argv; cm = CManager_create(); CM_IP_PORT = attr_atom_from_string("IP_PORT"); attr_list listen_list = NULL; @@ -339,28 +470,9 @@ int main(int argc, char **argv) } ev_state.cm = cm; - while (argv[1] && (argv[1][0] == '-')) - { - size_t i = 1; - while (argv[1][i] != 0) - { - if (argv[1][i] == 'v') - { - verbose++; - } - else if (argv[1][i] == 'q') - { - verbose--; - } - i++; - } - argv++; - argc--; - } - RegisterFormats(ev_state); - REVPServerRegisterHandlers(ev_state); + ServerRegisterHandlers(ev_state); std::cout << "doing Run Network" << std::endl; CMrun_network(cm); diff --git a/testing/adios2/engine/bp/CMakeLists.txt b/testing/adios2/engine/bp/CMakeLists.txt index a57f950a23..10f724cc1b 100644 --- a/testing/adios2/engine/bp/CMakeLists.txt +++ b/testing/adios2/engine/bp/CMakeLists.txt @@ -106,6 +106,25 @@ bp_gtest_add_tests_helper(LargeMetadata MPI_ALLOW) set(BP5LargeMeta "Engine.BP.BPLargeMetadata.BPWrite1D_LargeMetadata.BP5.Serial") +if ((NOT WIN32) AND ADIOS2_HAVE_SST) +# prototype for remote server testing +# (we don't really use SST here, just EVPath, but ADIOS2_HAVE_SST is the most relevant conditional) + macro(add_remote_tests_helper testname) + add_test(NAME "Remote.BP${testname}.GetRemote" COMMAND Test.Engine.BP.${testname}.Serial bp5) + set_tests_properties(Remote.BP${testname}.GetRemote PROPERTIES FIXTURES_REQUIRED Server ENVIRONMENT "DoRemote=1") + endmacro() + + add_test(NAME remoteServerSetup COMMAND remote_server -background) + set_tests_properties(remoteServerSetup PROPERTIES FIXTURES_SETUP Server) + + add_test(NAME remoteServerCleanup COMMAND remote_server -kill_server) + set_tests_properties(remoteServerCleanup PROPERTIES FIXTURES_CLEANUP Server) + + #add remote tests below this line + add_remote_tests_helper(WriteReadADIOS2stdio) + add_remote_tests_helper(WriteMemorySelectionRead) +endif() + if(ADIOS2_HAVE_MPI) list(APPEND BP5LargeMeta "Engine.BP.BPLargeMetadata.BPWrite1D_LargeMetadata.BP5.MPI" "Engine.BP.BPLargeMetadata.ManyLongStrings.BP5.MPI") endif() From 107164d6fba5db462e739247380d6154448ca295 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Fri, 13 Oct 2023 23:13:05 -0400 Subject: [PATCH 039/126] Tweak Remote class and test multi-threaded file remote access (#3834) * Tweak Remote class and test multi-threaded file remote access * rework * Bad clang-format * New formulation --- source/adios2/toolkit/remote/Remote.cpp | 22 +++++++++++-------- source/adios2/toolkit/remote/Remote.h | 28 ++++++++++--------------- testing/adios2/engine/bp/CMakeLists.txt | 19 +++++++++++------ 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/source/adios2/toolkit/remote/Remote.cpp b/source/adios2/toolkit/remote/Remote.cpp index 0fe3199420..3a397b05a9 100644 --- a/source/adios2/toolkit/remote/Remote.cpp +++ b/source/adios2/toolkit/remote/Remote.cpp @@ -50,16 +50,20 @@ void ReadResponseHandler(CManager cm, CMConnection conn, void *vevent, void *cli return; }; +CManagerSingleton &CManagerSingleton::Instance(RemoteCommon::Remote_evpath_state &ev_state) +{ + std::mutex mtx; + const std::lock_guard lock(mtx); + static CManagerSingleton instance; + ev_state = instance.internalEvState; + return instance; +} + void Remote::InitCMData() { - std::lock_guard lockGuard(m_CMInitMutex); - bool first = true; - auto CM = CManagerSingleton::Instance(first); - ev_state.cm = CM->m_cm; - RegisterFormats(ev_state); - if (first) - { - CMfork_comm_thread(ev_state.cm); + (void)CManagerSingleton::Instance(ev_state); + static std::once_flag flag; + std::call_once(flag, [&]() { CMregister_handler(ev_state.OpenResponseFormat, (CMHandlerFunc)OpenResponseHandler, &ev_state); CMregister_handler(ev_state.ReadResponseFormat, (CMHandlerFunc)ReadResponseHandler, @@ -68,7 +72,7 @@ void Remote::InitCMData() (CMHandlerFunc)OpenSimpleResponseHandler, &ev_state); CMregister_handler(ev_state.ReadResponseFormat, (CMHandlerFunc)ReadResponseHandler, &ev_state); - } + }); } void Remote::Open(const std::string hostname, const int32_t port, const std::string filename, diff --git a/source/adios2/toolkit/remote/Remote.h b/source/adios2/toolkit/remote/Remote.h index 75824cdc31..608d35f637 100644 --- a/source/adios2/toolkit/remote/Remote.h +++ b/source/adios2/toolkit/remote/Remote.h @@ -63,32 +63,26 @@ class Remote bool m_Active = false; }; +#ifdef ADIOS2_HAVE_SST class CManagerSingleton { public: -#ifdef ADIOS2_HAVE_SST + static CManagerSingleton &Instance(RemoteCommon::Remote_evpath_state &ev_state); + +private: CManager m_cm = NULL; -#endif - static CManagerSingleton *Instance(bool &first) + RemoteCommon::Remote_evpath_state internalEvState; + CManagerSingleton() { - static CManagerSingleton *ptr = new CManagerSingleton(); - static bool internal_first = true; - first = internal_first; - internal_first = false; - return ptr; + m_cm = CManager_create(); + internalEvState.cm = m_cm; + RegisterFormats(internalEvState); + CMfork_comm_thread(internalEvState.cm); } -protected: -#ifdef ADIOS2_HAVE_SST - CManagerSingleton() { m_cm = CManager_create(); } - ~CManagerSingleton() { CManager_close(m_cm); } -#else - CManagerSingleton() {} - - ~CManagerSingleton() {} -#endif }; +#endif } // end namespace adios2 diff --git a/testing/adios2/engine/bp/CMakeLists.txt b/testing/adios2/engine/bp/CMakeLists.txt index 10f724cc1b..03479c7edc 100644 --- a/testing/adios2/engine/bp/CMakeLists.txt +++ b/testing/adios2/engine/bp/CMakeLists.txt @@ -107,22 +107,29 @@ bp_gtest_add_tests_helper(LargeMetadata MPI_ALLOW) set(BP5LargeMeta "Engine.BP.BPLargeMetadata.BPWrite1D_LargeMetadata.BP5.Serial") if ((NOT WIN32) AND ADIOS2_HAVE_SST) -# prototype for remote server testing -# (we don't really use SST here, just EVPath, but ADIOS2_HAVE_SST is the most relevant conditional) - macro(add_remote_tests_helper testname) + # prototype for remote server testing + # (we don't really use SST here, just EVPath, but ADIOS2_HAVE_SST is the most relevant conditional) + + macro(add_get_remote_tests_helper testname) add_test(NAME "Remote.BP${testname}.GetRemote" COMMAND Test.Engine.BP.${testname}.Serial bp5) set_tests_properties(Remote.BP${testname}.GetRemote PROPERTIES FIXTURES_REQUIRED Server ENVIRONMENT "DoRemote=1") endmacro() + macro(add_file_remote_tests_helper testname) + add_test(NAME "Remote.BP${testname}.FileRemote" COMMAND Test.Engine.BP.${testname}.Serial bp5) + set_tests_properties(Remote.BP${testname}.FileRemote PROPERTIES FIXTURES_REQUIRED Server ENVIRONMENT "DoFileRemote=1") + endmacro() + add_test(NAME remoteServerSetup COMMAND remote_server -background) set_tests_properties(remoteServerSetup PROPERTIES FIXTURES_SETUP Server) add_test(NAME remoteServerCleanup COMMAND remote_server -kill_server) set_tests_properties(remoteServerCleanup PROPERTIES FIXTURES_CLEANUP Server) - #add remote tests below this line - add_remote_tests_helper(WriteReadADIOS2stdio) - add_remote_tests_helper(WriteMemorySelectionRead) + ##### add remote tests below this line + add_get_remote_tests_helper(WriteReadADIOS2stdio) + add_get_remote_tests_helper(WriteMemorySelectionRead) + add_file_remote_tests_helper(WriteMemorySelectionRead) endif() if(ADIOS2_HAVE_MPI) From ac071858422b1e848dab6c8dc5f3cd4e1fa1fab8 Mon Sep 17 00:00:00 2001 From: Vicente Bolea Date: Tue, 17 Oct 2023 13:56:40 -0400 Subject: [PATCH 040/126] MPI: add timeout for conf test for MPI_DP (#3848) --- cmake/DetectOptions.cmake | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cmake/DetectOptions.cmake b/cmake/DetectOptions.cmake index c8f277567c..409db1b552 100644 --- a/cmake/DetectOptions.cmake +++ b/cmake/DetectOptions.cmake @@ -445,9 +445,11 @@ if(ADIOS2_USE_SST AND NOT WIN32) endif() endif() if(ADIOS2_HAVE_MPI) - set(CMAKE_REQUIRED_LIBRARIES MPI::MPI_C) - include(CheckCSourceRuns) - check_c_source_runs([=[ + set(CMAKE_REQUIRED_LIBRARIES "MPI::MPI_C;Threads::Threads") + include(CheckCXXSourceRuns) + check_cxx_source_runs([=[ + #include + #include #include #include @@ -457,9 +459,18 @@ if(ADIOS2_USE_SST AND NOT WIN32) int main() { + // Timeout after 5 second + auto task = std::async(std::launch::async, []() { + std::this_thread::sleep_for(std::chrono::seconds(5)); + exit(EXIT_FAILURE); + }); + + char* port_name = new char[MPI_MAX_PORT_NAME]; MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, NULL); - MPI_Open_port(MPI_INFO_NULL, malloc(sizeof(char) * MPI_MAX_PORT_NAME)); + MPI_Open_port(MPI_INFO_NULL, port_name); + MPI_Close_port(port_name); MPI_Finalize(); + exit(EXIT_SUCCESS); }]=] ADIOS2_HAVE_MPI_CLIENT_SERVER) unset(CMAKE_REQUIRED_LIBRARIES) From d0fcf101823c9693dcfc3c5b665693b8acf1013e Mon Sep 17 00:00:00 2001 From: Vicente Bolea Date: Tue, 17 Oct 2023 15:38:56 -0400 Subject: [PATCH 041/126] cmake: update minimum cmake to 3.12 (#3849) --- cmake/adios2-config-install.cmake.in | 2 +- cmake/install/post/adios2-config-dummy/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/adios2-config-install.cmake.in b/cmake/adios2-config-install.cmake.in index 86d3ef64ef..a0d6cf1def 100644 --- a/cmake/adios2-config-install.cmake.in +++ b/cmake/adios2-config-install.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.12) set(_ADIOS2_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cmake/install/post/adios2-config-dummy/CMakeLists.txt b/cmake/install/post/adios2-config-dummy/CMakeLists.txt index 7b31c5c911..83db648edd 100644 --- a/cmake/install/post/adios2-config-dummy/CMakeLists.txt +++ b/cmake/install/post/adios2-config-dummy/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.12) project(adios2-config-dummy C CXX) From 975e8deba0f5b53f0dc6d8e37d0d1aa36bd1a858 Mon Sep 17 00:00:00 2001 From: Vicente Bolea Date: Tue, 17 Oct 2023 15:53:52 -0400 Subject: [PATCH 042/126] MPI_DP: do not call MPI_Init (#3847) --- source/adios2/toolkit/sst/dp/mpi_dp.c | 66 ++++++++------------------- 1 file changed, 20 insertions(+), 46 deletions(-) diff --git a/source/adios2/toolkit/sst/dp/mpi_dp.c b/source/adios2/toolkit/sst/dp/mpi_dp.c index 612985c146..d82fc189b4 100644 --- a/source/adios2/toolkit/sst/dp/mpi_dp.c +++ b/source/adios2/toolkit/sst/dp/mpi_dp.c @@ -42,8 +42,6 @@ #define QUOTE(name) #name #define MACRO_TO_STR(name) QUOTE(name) -static pthread_once_t OnceMpiInitializer = PTHREAD_ONCE_INIT; - /*****Stream Basic Structures ***********************************************/ typedef struct _MpiReaderContactInfo @@ -235,40 +233,6 @@ static void MpiReadReplyHandler(CManager cm, CMConnection conn, void *msg_v, voi static void MpiReadRequestHandler(CManager cm, CMConnection conn, void *msg_v, void *client_Data, attr_list attrs); -/** - * Initialize MPI in the mode that it is required for MPI_DP to work. - * - * It can be called multiple times. - */ -static void MpiInitialize() -{ - int IsInitialized = 0; - int provided; - - MPI_Initialized(&IsInitialized); - if (!IsInitialized) - { - MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &provided); - } - else - { - MPI_Query_thread(&provided); - } - - if (provided != MPI_THREAD_MULTIPLE) - { - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - if (!rank) - { - fprintf(stderr, - "MPI init without MPI_THREAD_MULTIPLE (Externally " - "initialized:%s)\n", - IsInitialized ? "true" : "false"); - } - } -} - /*****Public accessible functions********************************************/ /** @@ -286,8 +250,6 @@ static DP_RS_Stream MpiInitReader(CP_Services Svcs, void *CP_Stream, void **Read struct _SstParams *Params, attr_list WriterContact, SstStats Stats) { - pthread_once(&OnceMpiInitializer, MpiInitialize); - MpiStreamRD Stream = calloc(sizeof(struct _MpiStreamRD), 1); CManager cm = Svcs->getCManager(CP_Stream); SMPI_Comm comm = Svcs->getMPIComm(CP_Stream); @@ -327,8 +289,6 @@ static DP_RS_Stream MpiInitReader(CP_Services Svcs, void *CP_Stream, void **Read static DP_WS_Stream MpiInitWriter(CP_Services Svcs, void *CP_Stream, struct _SstParams *Params, attr_list DPAttrs, SstStats Stats) { - pthread_once(&OnceMpiInitializer, MpiInitialize); - MpiStreamWR Stream = calloc(sizeof(struct _MpiStreamWR), 1); CManager cm = Svcs->getCManager(CP_Stream); SMPI_Comm comm = Svcs->getMPIComm(CP_Stream); @@ -798,16 +758,30 @@ static void MpiReleaseTimeStep(CP_Services Svcs, DP_WS_Stream Stream_v, long Tim */ static int MpiGetPriority(CP_Services Svcs, void *CP_Stream, struct _SstParams *Params) { -#if defined(MPICH) - // Only enabled when MPI_THREAD_MULTIPLE and using MPICH + int IsInitialized = 0; int provided = 0; - pthread_once(&OnceMpiInitializer, MpiInitialize); - MPI_Query_thread(&provided); - if (provided == MPI_THREAD_MULTIPLE) + int IsMPICH = 0; +#if defined(MPICH) + IsMPICH = 1; + + MPI_Initialized(&IsInitialized); + if (IsInitialized) { - return 100; + MPI_Query_thread(&provided); + // Only enabled when MPI_THREAD_MULTIPLE and using MPICH + if (provided == MPI_THREAD_MULTIPLE) + { + return 100; + } } #endif + + Svcs->verbose(CP_Stream, DPTraceVerbose, + "MPI DP disabled since the following predicate is false: " + "(MPICH=%s AND MPI_initialized=%s AND MPI_THREAD_MULTIPLE=%s)", + IsMPICH ? "true" : "false", IsInitialized ? "true" : "false", + provided == MPI_THREAD_MULTIPLE ? "true" : "false"); + return -100; } From 897ca42ccbe0cd21718b5f9f046d21326d4d7ed5 Mon Sep 17 00:00:00 2001 From: Spiros Tsalikis Date: Thu, 14 Sep 2023 14:52:33 -0400 Subject: [PATCH 043/126] Improve existing examples 1) Make all examples individually compilable 2) Make examples' executable names be consistent 3) Move certain examples in the right folders 4) Rename certain examples for clarity 5) Make all examples installable 6) Fix Python formatting using black 7) Add licence documentation wherever it's missing --- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 22 +--- examples/basics/CMakeLists.txt | 5 +- examples/basics/globalArray/CMakeLists.txt | 12 --- examples/basics/globalArrayND/CMakeLists.txt | 31 ++++++ .../globalArrayNDWrite.cpp} | 0 examples/basics/joinedArray/CMakeLists.txt | 27 ++++- ...edArray_write.cpp => joinedArrayWrite.cpp} | 0 examples/basics/localArray/CMakeLists.txt | 32 ++++-- ...localArray_read.cpp => localArrayRead.cpp} | 0 ...calArray_write.cpp => localArrayWrite.cpp} | 0 examples/basics/queryWorker/CMakeLists.txt | 30 ++++++ .../READ.ME => basics/queryWorker/README.md} | 0 .../queryWorker}/configs/bp4io.xml | 2 +- .../queryWorker}/configs/bp4io_composite.xml | 4 +- .../queryWorker}/configs/q1.json | 0 .../queryWorker}/configs/q2.json | 0 .../queryWorker/queryWorker.cpp} | 38 ------- examples/basics/values/CMakeLists.txt | 28 ++++- .../{values_write.cpp => valuesWrite.cpp} | 0 examples/cuda/CMakeLists.txt | 8 -- examples/fides/01_onecell/CMakeLists.txt | 7 -- examples/fides/01_onecell/README.md | 28 ----- examples/fides/CMakeLists.txt | 6 -- examples/h5subfile/CMakeLists.txt | 10 -- examples/heatTransfer/inline/CMakeLists.txt | 14 --- examples/heatTransfer/read/CMakeLists.txt | 11 -- .../heatTransfer/read_fileonly/CMakeLists.txt | 12 --- .../read_fileonly/heatRead_adios1.cpp | 101 ------------------ examples/heatTransfer/write/CMakeLists.txt | 66 ------------ examples/hello/CMakeLists.txt | 34 +++--- .../hello/bpAttributeWriter/CMakeLists.txt | 28 ++++- ...ributeWriter.cpp => bpAttributeWriter.cpp} | 2 +- ..._nompi.cpp => bpAttributeWriter_nompi.cpp} | 2 +- examples/hello/bpFWriteCRead/CMakeLists.txt | 59 +++++++--- examples/hello/bpFlushWriter/CMakeLists.txt | 27 ++++- ...lloBPFlushWriter.cpp => bpFlushWriter.cpp} | 2 +- ...iter_nompi.cpp => bpFlushWriter_nompi.cpp} | 2 +- examples/hello/bpReader/CMakeLists.txt | 69 ++++++++---- .../{helloBPReader.cpp => bpReader.cpp} | 4 +- ...derHeatMap2D.cpp => bpReaderHeatMap2D.cpp} | 2 +- ...eaderHeatMap2D.py => bpReaderHeatMap2D.py} | 17 +-- ...derHeatMap3D.F90 => bpReaderHeatMap3D.F90} | 4 +- ...derHeatMap3D.cpp => bpReaderHeatMap3D.cpp} | 0 ...oBPReader_nompi.cpp => bpReader_nompi.cpp} | 2 +- examples/hello/bpTimeWriter/CMakeLists.txt | 27 ++++- ...helloBPTimeWriter.cpp => bpTimeWriter.cpp} | 2 +- .../{helloBPTimeWriter.py => bpTimeWriter.py} | 7 +- ...riter_nompi.cpp => bpTimeWriter_nompi.cpp} | 2 +- examples/hello/bpWriteReadCuda/CMakeLists.txt | 25 +++++ .../bpWriteReadCuda/bpWriteReadCuda.cu} | 3 + examples/hello/bpWriter/CMakeLists.txt | 91 +++++++++++----- ...lloBPPutDeferred.cpp => bpPutDeferred.cpp} | 12 +-- .../bpWriter/{helloBPSZ.cpp => bpSZ.cpp} | 2 +- ...helloBPSubStreams.cpp => bpSubStreams.cpp} | 2 +- .../{helloBPWriter.F90 => bpWriter.F90} | 4 +- .../bpWriter/{helloBPWriter.c => bpWriter.c} | 2 +- .../{helloBPWriter.cpp => bpWriter.cpp} | 2 +- .../{helloBPWriter.py => bpWriter.py} | 17 +-- ...lloBPWriter_nompi.py => bpWriter_nompi.py} | 7 +- examples/hello/datamanReader/CMakeLists.txt | 26 ++++- ...lloDataManReader.cpp => dataManReader.cpp} | 2 +- ...helloDataManReader.py => dataManReader.py} | 4 +- examples/hello/datamanWriter/CMakeLists.txt | 26 ++++- ...lloDataManWriter.cpp => dataManWriter.cpp} | 2 +- ...helloDataManWriter.py => dataManWriter.py} | 7 +- .../hello/dataspacesReader/CMakeLists.txt | 33 +++++- ...aSpacesReader.cpp => dataSpacesReader.cpp} | 2 +- .../hello/dataspacesWriter/CMakeLists.txt | 33 +++++- ...aSpacesWriter.cpp => dataSpacesWriter.cpp} | 2 +- examples/hello/hdf5Reader/CMakeLists.txt | 33 +++++- .../{helloHDF5Reader.cpp => hdf5Reader.cpp} | 2 +- ...5Reader_nompi.cpp => hdf5Reader_nompi.cpp} | 2 +- examples/hello/hdf5SubFile/CMakeLists.txt | 30 ++++++ .../hdf5SubFile/hdf5SubFile.cpp} | 2 +- examples/hello/hdf5Writer/CMakeLists.txt | 33 +++++- .../{helloHDF5Writer.cpp => hdf5Writer.cpp} | 2 +- ...5Writer_nompi.cpp => hdf5Writer_nompi.cpp} | 2 +- .../hello/inlineFWriteCppRead/CMakeLists.txt | 43 +++++--- examples/hello/inlineMWE/CMakeLists.txt | 17 +++ examples/{ => hello}/inlineMWE/inlineMWE.cpp | 5 + .../hello/inlineReaderWriter/CMakeLists.txt | 27 ++++- ...eaderWriter.cpp => inlineReaderWriter.cpp} | 2 +- examples/hello/skeleton/CMakeLists.txt | 37 +++++-- ...HelloSkeletonArgs.cpp => SkeletonArgs.cpp} | 9 +- .../{HelloSkeletonArgs.h => SkeletonArgs.h} | 4 +- .../{HelloSkeletonPrint.h => SkeletonPrint.h} | 0 .../skeleton/{hello_bpfile.xml => bpfile.xml} | 2 +- .../{hello_skeleton.xml => skeleton.xml} | 2 +- ...oSkeletonReader.cpp => skeletonReader.cpp} | 11 +- ...oSkeletonWriter.cpp => skeletonWriter.cpp} | 6 +- examples/hello/sstReader/CMakeLists.txt | 35 +++++- .../{helloSstReader.cpp => sstReader.cpp} | 4 +- examples/hello/sstWriter/CMakeLists.txt | 35 +++++- .../{helloSstWriter.cpp => sstWriter.cpp} | 13 +-- .../{helloSstWriter.py => sstWriter.py} | 10 +- examples/inlineMWE/CMakeLists.txt | 7 -- examples/plugins/CMakeLists.txt | 4 +- examples/plugins/engine/CMakeLists.txt | 46 ++++---- ...e_read.cpp => examplePluginEngineRead.cpp} | 2 +- ...write.cpp => examplePluginEngineWrite.cpp} | 2 +- examples/plugins/engine/example_engine.xml | 4 +- examples/plugins/operator/CMakeLists.txt | 30 ++++-- ...read.cpp => examplePluginOperatorRead.cpp} | 2 +- ...ite.cpp => examplePluginOperatorWrite.cpp} | 0 examples/query/CMakeLists.txt | 10 -- examples/simulations/CMakeLists.txt | 3 + .../heatTransfer/CMakeLists.txt | 9 +- .../{ => simulations}/heatTransfer/ReadMe.md | 14 +-- .../heatTransfer/heat_bp3.xml | 4 +- .../heatTransfer/heat_bp3_zfp.xml | 4 +- .../heatTransfer/heat_bp4.xml | 4 +- .../heatTransfer/heat_bp4_zfp.xml | 4 +- .../heatTransfer/heat_dataman.xml | 4 +- .../heatTransfer/heat_dataspaces.xml | 4 +- .../heatTransfer/heat_file.xml | 4 +- .../heatTransfer/heat_hdf5.xml | 4 +- .../heatTransfer/heat_inline.xml | 2 +- .../heatTransfer/heat_nullcore.xml | 4 +- .../heatTransfer/heat_ssc.xml | 4 +- .../heatTransfer/heat_sst_bp.xml | 4 +- .../heatTransfer/heat_sst_bp_rdma.xml | 4 +- .../heatTransfer/heat_sst_ffs.xml | 4 +- .../heatTransfer/heat_sst_ffs_rdma.xml | 4 +- .../heatTransfer/inline/CMakeLists.txt | 34 ++++++ .../heatTransfer/inline/InlineIO.cpp | 0 .../heatTransfer/inline/InlineIO.h | 0 .../heatTransfer/inline/main.cpp | 0 .../heatTransfer/read/CMakeLists.txt | 31 ++++++ .../heatTransfer/read/PrintDataStep.h | 0 .../heatTransfer/read/ReadSettings.cpp | 0 .../heatTransfer/read/ReadSettings.h | 0 .../heatTransfer/read/heatRead.cpp | 0 .../heatTransfer/readFileOnly/CMakeLists.txt | 27 +++++ .../heatTransfer/readFileOnly}/PrintData.h | 0 .../readFileOnly/heatReadFileOnly.cpp} | 9 +- .../heatTransfer/write/CMakeLists.txt | 81 ++++++++++++++ .../heatTransfer/write/HeatTransfer.cpp | 0 .../heatTransfer/write/HeatTransfer.h | 0 .../{ => simulations}/heatTransfer/write/IO.h | 0 .../heatTransfer/write/IO_adios2.cpp | 2 +- .../heatTransfer/write/IO_ascii.cpp | 0 .../heatTransfer/write/IO_h5mixer.cpp | 0 .../heatTransfer/write/IO_hdf5_a.cpp | 2 +- .../heatTransfer/write/IO_ph5.cpp | 0 .../heatTransfer/write/Settings.cpp | 0 .../heatTransfer/write/Settings.h | 0 .../heatTransfer/write/main.cpp | 0 examples/useCases/CMakeLists.txt | 2 +- examples/useCases/fidesOneCell/CMakeLists.txt | 17 +++ examples/useCases/fidesOneCell/ReadMe.md | 37 +++++++ .../fidesOneCell/fidesOneCell.cpp} | 2 +- .../fidesOneCell/fidesOneCell.json} | 0 .../fidesOneCell}/paraview-onecell-step0.png | Bin .../fidesOneCell}/paraview-onecell-step9.png | Bin .../insituGlobalArrays/CMakeLists.txt | 38 +++++-- .../examples/heatTransfer/TestBPFileMx1.cmake | 16 +-- .../heatTransfer/TestBPFileMx1_zfp.cmake | 16 +-- .../examples/heatTransfer/TestBPFileMxM.cmake | 16 +-- .../examples/heatTransfer/TestBPFileMxN.cmake | 16 +-- .../examples/heatTransfer/TestInlineMxM.cmake | 4 +- .../examples/heatTransfer/TestSSCMx1.cmake | 8 +- .../examples/heatTransfer/TestSSCMxM.cmake | 8 +- .../examples/heatTransfer/TestSSCMxN.cmake | 8 +- .../examples/heatTransfer/TestSSTBPMx1.cmake | 8 +- .../examples/heatTransfer/TestSSTBPMxM.cmake | 8 +- .../examples/heatTransfer/TestSSTBPMxN.cmake | 8 +- .../heatTransfer/TestSSTBPRDMAMxN.cmake | 8 +- .../examples/heatTransfer/TestSSTFFSMx1.cmake | 8 +- .../examples/heatTransfer/TestSSTFFSMxM.cmake | 8 +- .../examples/heatTransfer/TestSSTFFSMxN.cmake | 8 +- .../heatTransfer/TestSSTFFSRDMAMxN.cmake | 8 +- .../install/EncryptionOperator/CMakeLists.txt | 4 +- testing/install/EnginePlugin/CMakeLists.txt | 4 +- 174 files changed, 1314 insertions(+), 783 deletions(-) delete mode 100644 examples/basics/globalArray/CMakeLists.txt create mode 100644 examples/basics/globalArrayND/CMakeLists.txt rename examples/basics/{globalArray/globalArray_write.cpp => globalArrayND/globalArrayNDWrite.cpp} (100%) rename examples/basics/joinedArray/{joinedArray_write.cpp => joinedArrayWrite.cpp} (100%) rename examples/basics/localArray/{localArray_read.cpp => localArrayRead.cpp} (100%) rename examples/basics/localArray/{localArray_write.cpp => localArrayWrite.cpp} (100%) create mode 100644 examples/basics/queryWorker/CMakeLists.txt rename examples/{query/READ.ME => basics/queryWorker/README.md} (100%) rename examples/{query => basics/queryWorker}/configs/bp4io.xml (99%) rename examples/{query => basics/queryWorker}/configs/bp4io_composite.xml (98%) rename examples/{query => basics/queryWorker}/configs/q1.json (100%) rename examples/{query => basics/queryWorker}/configs/q2.json (100%) rename examples/{query/test.cpp => basics/queryWorker/queryWorker.cpp} (75%) rename examples/basics/values/{values_write.cpp => valuesWrite.cpp} (100%) delete mode 100644 examples/cuda/CMakeLists.txt delete mode 100644 examples/fides/01_onecell/CMakeLists.txt delete mode 100644 examples/fides/01_onecell/README.md delete mode 100644 examples/fides/CMakeLists.txt delete mode 100644 examples/h5subfile/CMakeLists.txt delete mode 100644 examples/heatTransfer/inline/CMakeLists.txt delete mode 100644 examples/heatTransfer/read/CMakeLists.txt delete mode 100644 examples/heatTransfer/read_fileonly/CMakeLists.txt delete mode 100644 examples/heatTransfer/read_fileonly/heatRead_adios1.cpp delete mode 100644 examples/heatTransfer/write/CMakeLists.txt rename examples/hello/bpAttributeWriter/{helloBPAttributeWriter.cpp => bpAttributeWriter.cpp} (97%) rename examples/hello/bpAttributeWriter/{helloBPAttributeWriter_nompi.cpp => bpAttributeWriter_nompi.cpp} (96%) rename examples/hello/bpFlushWriter/{helloBPFlushWriter.cpp => bpFlushWriter.cpp} (97%) rename examples/hello/bpFlushWriter/{helloBPFlushWriter_nompi.cpp => bpFlushWriter_nompi.cpp} (96%) rename examples/hello/bpReader/{helloBPReader.cpp => bpReader.cpp} (97%) rename examples/hello/bpReader/{helloBPReaderHeatMap2D.cpp => bpReaderHeatMap2D.cpp} (98%) rename examples/hello/bpReader/{helloBPReaderHeatMap2D.py => bpReaderHeatMap2D.py} (75%) rename examples/hello/bpReader/{helloBPReaderHeatMap3D.F90 => bpReaderHeatMap3D.F90} (98%) rename examples/hello/bpReader/{helloBPReaderHeatMap3D.cpp => bpReaderHeatMap3D.cpp} (100%) rename examples/hello/bpReader/{helloBPReader_nompi.cpp => bpReader_nompi.cpp} (97%) rename examples/hello/bpTimeWriter/{helloBPTimeWriter.cpp => bpTimeWriter.cpp} (98%) rename examples/hello/bpTimeWriter/{helloBPTimeWriter.py => bpTimeWriter.py} (87%) rename examples/hello/bpTimeWriter/{helloBPTimeWriter_nompi.cpp => bpTimeWriter_nompi.cpp} (96%) create mode 100644 examples/hello/bpWriteReadCuda/CMakeLists.txt rename examples/{cuda/cudaBPWriteRead.cu => hello/bpWriteReadCuda/bpWriteReadCuda.cu} (96%) rename examples/hello/bpWriter/{helloBPPutDeferred.cpp => bpPutDeferred.cpp} (91%) rename examples/hello/bpWriter/{helloBPSZ.cpp => bpSZ.cpp} (98%) rename examples/hello/bpWriter/{helloBPSubStreams.cpp => bpSubStreams.cpp} (99%) rename examples/hello/bpWriter/{helloBPWriter.F90 => bpWriter.F90} (97%) rename examples/hello/bpWriter/{helloBPWriter.c => bpWriter.c} (97%) rename examples/hello/bpWriter/{helloBPWriter.cpp => bpWriter.cpp} (97%) rename examples/hello/bpWriter/{helloBPWriter.py => bpWriter.py} (73%) rename examples/hello/bpWriter/{helloBPWriter_nompi.py => bpWriter_nompi.py} (72%) rename examples/hello/datamanReader/{helloDataManReader.cpp => dataManReader.cpp} (98%) rename examples/hello/datamanReader/{helloDataManReader.py => dataManReader.py} (92%) rename examples/hello/datamanWriter/{helloDataManWriter.cpp => dataManWriter.cpp} (98%) rename examples/hello/datamanWriter/{helloDataManWriter.py => dataManWriter.py} (92%) rename examples/hello/dataspacesReader/{helloDataSpacesReader.cpp => dataSpacesReader.cpp} (98%) rename examples/hello/dataspacesWriter/{helloDataSpacesWriter.cpp => dataSpacesWriter.cpp} (98%) rename examples/hello/hdf5Reader/{helloHDF5Reader.cpp => hdf5Reader.cpp} (99%) rename examples/hello/hdf5Reader/{helloHDF5Reader_nompi.cpp => hdf5Reader_nompi.cpp} (99%) create mode 100644 examples/hello/hdf5SubFile/CMakeLists.txt rename examples/{h5subfile/h5_subfile.cpp => hello/hdf5SubFile/hdf5SubFile.cpp} (99%) rename examples/hello/hdf5Writer/{helloHDF5Writer.cpp => hdf5Writer.cpp} (98%) rename examples/hello/hdf5Writer/{helloHDF5Writer_nompi.cpp => hdf5Writer_nompi.cpp} (96%) create mode 100644 examples/hello/inlineMWE/CMakeLists.txt rename examples/{ => hello}/inlineMWE/inlineMWE.cpp (88%) rename examples/hello/inlineReaderWriter/{helloInlineReaderWriter.cpp => inlineReaderWriter.cpp} (98%) rename examples/hello/skeleton/{HelloSkeletonArgs.cpp => SkeletonArgs.cpp} (92%) rename examples/hello/skeleton/{HelloSkeletonArgs.h => SkeletonArgs.h} (93%) rename examples/hello/skeleton/{HelloSkeletonPrint.h => SkeletonPrint.h} (100%) rename examples/hello/skeleton/{hello_bpfile.xml => bpfile.xml} (97%) rename examples/hello/skeleton/{hello_skeleton.xml => skeleton.xml} (96%) rename examples/hello/skeleton/{helloSkeletonReader.cpp => skeletonReader.cpp} (93%) rename examples/hello/skeleton/{helloSkeletonWriter.cpp => skeletonWriter.cpp} (93%) rename examples/hello/sstReader/{helloSstReader.cpp => sstReader.cpp} (97%) rename examples/hello/sstWriter/{helloSstWriter.cpp => sstWriter.cpp} (81%) rename examples/hello/sstWriter/{helloSstWriter.py => sstWriter.py} (72%) delete mode 100644 examples/inlineMWE/CMakeLists.txt rename examples/plugins/engine/{examplePluginEngine_read.cpp => examplePluginEngineRead.cpp} (97%) rename examples/plugins/engine/{examplePluginEngine_write.cpp => examplePluginEngineWrite.cpp} (97%) rename examples/plugins/operator/{examplePluginOperator_read.cpp => examplePluginOperatorRead.cpp} (97%) rename examples/plugins/operator/{examplePluginOperator_write.cpp => examplePluginOperatorWrite.cpp} (100%) delete mode 100644 examples/query/CMakeLists.txt create mode 100644 examples/simulations/CMakeLists.txt rename examples/{ => simulations}/heatTransfer/CMakeLists.txt (75%) rename examples/{ => simulations}/heatTransfer/ReadMe.md (75%) rename examples/{ => simulations}/heatTransfer/heat_bp3.xml (97%) rename examples/{ => simulations}/heatTransfer/heat_bp3_zfp.xml (98%) rename examples/{ => simulations}/heatTransfer/heat_bp4.xml (97%) rename examples/{ => simulations}/heatTransfer/heat_bp4_zfp.xml (98%) rename examples/{ => simulations}/heatTransfer/heat_dataman.xml (97%) rename examples/{ => simulations}/heatTransfer/heat_dataspaces.xml (91%) rename examples/{ => simulations}/heatTransfer/heat_file.xml (97%) rename examples/{ => simulations}/heatTransfer/heat_hdf5.xml (97%) rename examples/{ => simulations}/heatTransfer/heat_inline.xml (96%) rename examples/{ => simulations}/heatTransfer/heat_nullcore.xml (78%) rename examples/{ => simulations}/heatTransfer/heat_ssc.xml (94%) rename examples/{ => simulations}/heatTransfer/heat_sst_bp.xml (91%) rename examples/{ => simulations}/heatTransfer/heat_sst_bp_rdma.xml (92%) rename examples/{ => simulations}/heatTransfer/heat_sst_ffs.xml (91%) rename examples/{ => simulations}/heatTransfer/heat_sst_ffs_rdma.xml (92%) create mode 100644 examples/simulations/heatTransfer/inline/CMakeLists.txt rename examples/{ => simulations}/heatTransfer/inline/InlineIO.cpp (100%) rename examples/{ => simulations}/heatTransfer/inline/InlineIO.h (100%) rename examples/{ => simulations}/heatTransfer/inline/main.cpp (100%) create mode 100644 examples/simulations/heatTransfer/read/CMakeLists.txt rename examples/{ => simulations}/heatTransfer/read/PrintDataStep.h (100%) rename examples/{ => simulations}/heatTransfer/read/ReadSettings.cpp (100%) rename examples/{ => simulations}/heatTransfer/read/ReadSettings.h (100%) rename examples/{ => simulations}/heatTransfer/read/heatRead.cpp (100%) create mode 100644 examples/simulations/heatTransfer/readFileOnly/CMakeLists.txt rename examples/{heatTransfer/read_fileonly => simulations/heatTransfer/readFileOnly}/PrintData.h (100%) rename examples/{heatTransfer/read_fileonly/heatRead_adios2.cpp => simulations/heatTransfer/readFileOnly/heatReadFileOnly.cpp} (96%) create mode 100644 examples/simulations/heatTransfer/write/CMakeLists.txt rename examples/{ => simulations}/heatTransfer/write/HeatTransfer.cpp (100%) rename examples/{ => simulations}/heatTransfer/write/HeatTransfer.h (100%) rename examples/{ => simulations}/heatTransfer/write/IO.h (100%) rename examples/{ => simulations}/heatTransfer/write/IO_adios2.cpp (99%) rename examples/{ => simulations}/heatTransfer/write/IO_ascii.cpp (100%) rename examples/{ => simulations}/heatTransfer/write/IO_h5mixer.cpp (100%) rename examples/{ => simulations}/heatTransfer/write/IO_hdf5_a.cpp (96%) rename examples/{ => simulations}/heatTransfer/write/IO_ph5.cpp (100%) rename examples/{ => simulations}/heatTransfer/write/Settings.cpp (100%) rename examples/{ => simulations}/heatTransfer/write/Settings.h (100%) rename examples/{ => simulations}/heatTransfer/write/main.cpp (100%) create mode 100644 examples/useCases/fidesOneCell/CMakeLists.txt create mode 100644 examples/useCases/fidesOneCell/ReadMe.md rename examples/{fides/01_onecell/fides_onecell.cpp => useCases/fidesOneCell/fidesOneCell.cpp} (97%) rename examples/{fides/01_onecell/fides_onecell.json => useCases/fidesOneCell/fidesOneCell.json} (100%) rename examples/{fides/01_onecell => useCases/fidesOneCell}/paraview-onecell-step0.png (100%) rename examples/{fides/01_onecell => useCases/fidesOneCell}/paraview-onecell-step9.png (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3f223ed14..90122c6507 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,7 +176,7 @@ if(ADIOS2_HAVE_CUDA OR ADIOS2_HAVE_Kokkos_CUDA) if(DEFINED Kokkos_CUDA_ARCHITECTURES) set(CMAKE_CUDA_ARCHITECTURES ${Kokkos_CUDA_ARCHITECTURES}) else() - # Mininum common non-deprecated architecture + # Minimum common non-deprecated architecture set(CMAKE_CUDA_ARCHITECTURES 52) endif() endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3187dc3f49..316e77723e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,24 +5,6 @@ add_subdirectory(basics) add_subdirectory(hello) -add_subdirectory(query) -add_subdirectory(useCases) -add_subdirectory(inlineMWE) add_subdirectory(plugins) -add_subdirectory(fides) - -if(ADIOS2_HAVE_MPI) - add_subdirectory(heatTransfer) -endif() - - -if(ADIOS2_HAVE_CUDA OR ADIOS2_HAVE_Kokkos_CUDA) - add_subdirectory(cuda) -endif() - - -if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_HDF5) - if(HDF5_VERSION VERSION_GREATER_EQUAL 1.14) - add_subdirectory(h5subfile) - endif() -endif() +add_subdirectory(simulations) +add_subdirectory(useCases) diff --git a/examples/basics/CMakeLists.txt b/examples/basics/CMakeLists.txt index 94fa54cd4c..7e470c02d1 100644 --- a/examples/basics/CMakeLists.txt +++ b/examples/basics/CMakeLists.txt @@ -3,7 +3,10 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_subdirectory(globalArray) +add_subdirectory(globalArrayND) add_subdirectory(joinedArray) add_subdirectory(localArray) +if(ADIOS2_HAVE_DATAMAN) + add_subdirectory(queryWorker) +endif() add_subdirectory(values) diff --git a/examples/basics/globalArray/CMakeLists.txt b/examples/basics/globalArray/CMakeLists.txt deleted file mode 100644 index a145a8939b..0000000000 --- a/examples/basics/globalArray/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(globalArray_write globalArray_write.cpp) -target_link_libraries(globalArray_write adios2::cxx11) - -if(ADIOS2_HAVE_MPI) - add_executable(globalArray_write_mpi globalArray_write.cpp) - target_link_libraries(globalArray_write_mpi adios2::cxx11_mpi MPI::MPI_C) -endif() diff --git a/examples/basics/globalArrayND/CMakeLists.txt b/examples/basics/globalArrayND/CMakeLists.txt new file mode 100644 index 0000000000..f1d131c5fa --- /dev/null +++ b/examples/basics/globalArrayND/CMakeLists.txt @@ -0,0 +1,31 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2BasicsGlobalArrayNDExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_basics_globalArrayNDWrite globalArrayNDWrite.cpp) +target_link_libraries(adios2_basics_globalArrayNDWrite adios2::cxx11) +install(TARGETS adios2_basics_globalArrayNDWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +if(ADIOS2_HAVE_MPI) + add_executable(adios2_basics_globalArrayNDWrite_mpi globalArrayNDWrite.cpp) + target_link_libraries(adios2_basics_globalArrayNDWrite_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_basics_globalArrayNDWrite_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/basics/globalArray/globalArray_write.cpp b/examples/basics/globalArrayND/globalArrayNDWrite.cpp similarity index 100% rename from examples/basics/globalArray/globalArray_write.cpp rename to examples/basics/globalArrayND/globalArrayNDWrite.cpp diff --git a/examples/basics/joinedArray/CMakeLists.txt b/examples/basics/joinedArray/CMakeLists.txt index 0ac015c3a1..a342d75293 100644 --- a/examples/basics/joinedArray/CMakeLists.txt +++ b/examples/basics/joinedArray/CMakeLists.txt @@ -3,10 +3,29 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(joinedArray_write joinedArray_write.cpp) -target_link_libraries(joinedArray_write adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2BasicsJoinedArrayExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_basics_joinedArrayWrite joinedArrayWrite.cpp) +target_link_libraries(adios2_basics_joinedArrayWrite adios2::cxx11) +install(TARGETS adios2_basics_joinedArrayWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(joinedArray_write_mpi joinedArray_write.cpp) - target_link_libraries(joinedArray_write_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_basics_joinedArrayWrite_mpi joinedArrayWrite.cpp) + target_link_libraries(adios2_basics_joinedArrayWrite_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_basics_joinedArrayWrite_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/basics/joinedArray/joinedArray_write.cpp b/examples/basics/joinedArray/joinedArrayWrite.cpp similarity index 100% rename from examples/basics/joinedArray/joinedArray_write.cpp rename to examples/basics/joinedArray/joinedArrayWrite.cpp diff --git a/examples/basics/localArray/CMakeLists.txt b/examples/basics/localArray/CMakeLists.txt index 1d304a647e..a43a61550f 100644 --- a/examples/basics/localArray/CMakeLists.txt +++ b/examples/basics/localArray/CMakeLists.txt @@ -3,13 +3,33 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(localArray_write localArray_write.cpp) -target_link_libraries(localArray_write adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2BasicsLocalArrayExample) -add_executable(localArray_read localArray_read.cpp) -target_link_libraries(localArray_read adios2::cxx11) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_basics_localArrayWrite localArrayWrite.cpp) +target_link_libraries(adios2_basics_localArrayWrite adios2::cxx11) +install(TARGETS adios2_basics_localArrayWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_basics_localArrayRead localArrayRead.cpp) +target_link_libraries(adios2_basics_localArrayRead adios2::cxx11) +install(TARGETS adios2_basics_localArrayRead RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(localArray_write_mpi localArray_write.cpp) - target_link_libraries(localArray_write_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_basics_localArrayWrite_mpi localArrayWrite.cpp) + target_link_libraries(adios2_basics_localArrayWrite_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_basics_localArrayWrite_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/basics/localArray/localArray_read.cpp b/examples/basics/localArray/localArrayRead.cpp similarity index 100% rename from examples/basics/localArray/localArray_read.cpp rename to examples/basics/localArray/localArrayRead.cpp diff --git a/examples/basics/localArray/localArray_write.cpp b/examples/basics/localArray/localArrayWrite.cpp similarity index 100% rename from examples/basics/localArray/localArray_write.cpp rename to examples/basics/localArray/localArrayWrite.cpp diff --git a/examples/basics/queryWorker/CMakeLists.txt b/examples/basics/queryWorker/CMakeLists.txt new file mode 100644 index 0000000000..839dd19bf2 --- /dev/null +++ b/examples/basics/queryWorker/CMakeLists.txt @@ -0,0 +1,30 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2BasicsQueryWorkerExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ZeroMQ 4.1 QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_DataMan) + add_executable(adios2_basics_queryWorker queryWorker.cpp) + target_link_libraries(adios2_basics_queryWorker adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_basics_queryWorker RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() + diff --git a/examples/query/READ.ME b/examples/basics/queryWorker/README.md similarity index 100% rename from examples/query/READ.ME rename to examples/basics/queryWorker/README.md diff --git a/examples/query/configs/bp4io.xml b/examples/basics/queryWorker/configs/bp4io.xml similarity index 99% rename from examples/query/configs/bp4io.xml rename to examples/basics/queryWorker/configs/bp4io.xml index 65245c97e6..d921181b65 100644 --- a/examples/query/configs/bp4io.xml +++ b/examples/basics/queryWorker/configs/bp4io.xml @@ -1,6 +1,6 @@ diff --git a/examples/query/configs/bp4io_composite.xml b/examples/basics/queryWorker/configs/bp4io_composite.xml similarity index 98% rename from examples/query/configs/bp4io_composite.xml rename to examples/basics/queryWorker/configs/bp4io_composite.xml index 4e6136b4e4..412f883bcd 100644 --- a/examples/query/configs/bp4io_composite.xml +++ b/examples/basics/queryWorker/configs/bp4io_composite.xml @@ -1,7 +1,7 @@ diff --git a/examples/query/configs/q1.json b/examples/basics/queryWorker/configs/q1.json similarity index 100% rename from examples/query/configs/q1.json rename to examples/basics/queryWorker/configs/q1.json diff --git a/examples/query/configs/q2.json b/examples/basics/queryWorker/configs/q2.json similarity index 100% rename from examples/query/configs/q2.json rename to examples/basics/queryWorker/configs/q2.json diff --git a/examples/query/test.cpp b/examples/basics/queryWorker/queryWorker.cpp similarity index 75% rename from examples/query/test.cpp rename to examples/basics/queryWorker/queryWorker.cpp index b97a2d7714..2f172a18f0 100644 --- a/examples/query/test.cpp +++ b/examples/basics/queryWorker/queryWorker.cpp @@ -99,41 +99,3 @@ int main(int argc, char *argv[]) return 0; } - -bool testMe(std::string &queryConfigFile, std::string const &doubleVarName, MPI_Comm comm) -{ - adios2::ADIOS ad(queryConfigFile, comm); - std::string dataFileName = "test.file"; - - // adios2::query::Worker w(queryConfigFile, comm); - - // w.SetSource(inIO, reader); - - { - // the config file should have info on idx method to use - - /* - // if wanting to build customized minmax idx - // instead of using the existing block stats or bp4 minmax arrays - bool overwrite = false; - size_t recommendedSize = 20000; - - if (!w.PrepareIdx(overwrite, recommendedSize, doubleVarName)) - return false; - */ - } - - adios2::IO inIO = ad.DeclareIO("query"); - adios2::Engine reader = inIO.Open(dataFileName, adios2::Mode::Read, comm); - - // to be continued - if (!reader) - return false; - // std::vector dataOutput; - // std::vector coordinateOutput; - - return true; -} - -/* - */ diff --git a/examples/basics/values/CMakeLists.txt b/examples/basics/values/CMakeLists.txt index f36b4c745a..799c72cc54 100644 --- a/examples/basics/values/CMakeLists.txt +++ b/examples/basics/values/CMakeLists.txt @@ -3,10 +3,30 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(values_write values_write.cpp) -target_link_libraries(values_write adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2BasicsValuesExample) + +if(NOT TARGET adios2_core) + set(_components C) + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + list(APPEND _components CXX) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_basics_valuesWrite valuesWrite.cpp) +target_link_libraries(adios2_basics_valuesWrite adios2::cxx11) +install(TARGETS adios2_basics_valuesWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(values_write_mpi values_write.cpp) - target_link_libraries(values_write_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_basics_valuesWrite_mpi valuesWrite.cpp) + target_link_libraries(adios2_basics_valuesWrite_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_basics_valuesWrite_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/basics/values/values_write.cpp b/examples/basics/values/valuesWrite.cpp similarity index 100% rename from examples/basics/values/values_write.cpp rename to examples/basics/values/valuesWrite.cpp diff --git a/examples/cuda/CMakeLists.txt b/examples/cuda/CMakeLists.txt deleted file mode 100644 index 6a613392f4..0000000000 --- a/examples/cuda/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(CudaBPWriteRead_cuda cudaBPWriteRead.cu) -target_link_libraries(CudaBPWriteRead_cuda PUBLIC adios2::cxx11 CUDA::cudart) -set_target_properties(CudaBPWriteRead_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/examples/fides/01_onecell/CMakeLists.txt b/examples/fides/01_onecell/CMakeLists.txt deleted file mode 100644 index e553b37ccc..0000000000 --- a/examples/fides/01_onecell/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(fides_onecell fides_onecell.cpp) -target_link_libraries(fides_onecell adios2::cxx11) diff --git a/examples/fides/01_onecell/README.md b/examples/fides/01_onecell/README.md deleted file mode 100644 index d55174b571..0000000000 --- a/examples/fides/01_onecell/README.md +++ /dev/null @@ -1,28 +0,0 @@ -Single cell example for visualization with Fides schema in ParaView -------------------------------------------------------------------- - -This example writes 8 points in 3D space, the corners of a box, and then defines a single hexagon cell of those eight points. -The coordinates of the points are stored in three 1D arrays, separating the X-Y-Z coordinates. - -The cell is the enumeration of the points connected in the order of a hexagon prescribed by VTK, see -Figure 19-20 in the VTK User Guide, type VTK_HEXAHEDRON in page 480 (page 494 in the PDF). -https://vtk.org/wp-content/uploads/2021/08/VTKUsersGuide.pdf - -The visualization schema is described in the fides-onecell.json file, according to https://fides.readthedocs.io/en/latest/schema/schema.html - -We compose the coordinate system as a composite of the three 1D arrays for X, Y and Z coordinates. This is just an enumeration of the N points in space (N = size of X = size of Y = size of Z) , in contrast to other examples where X, Y, Z is combined to specify a structured grid (number of points = size of X * size of Y * size of Z). - -In ParaView, one opens the fides-onecell.json file and adds an property "source" with the value of the full path of the onecell.bp. See left-middle Properties box in the ParaView window in the image paraview-onecell-step0.png. Then hit Apply button and a gray box should appear (the single cell visualized). which can be rotated on screen. Then one must color the box with the data ("pointdata") to get the pictures shown in the included images. - -Note that the dataset over the points is called "DataOnPoints" in the onecell.bp file, but it is called "pointdata" in the Fides schema to demonstrate which name is which (ParaView presents pointdata to the user while reading the DataOnPoints array from the file). - -First step of onecell.bp in ParaView: - -paraview-onecell-step0.png - -Last step of onecell.bp in ParaView: - -paraview-onecell-step9.png - diff --git a/examples/fides/CMakeLists.txt b/examples/fides/CMakeLists.txt deleted file mode 100644 index 98d3e0e647..0000000000 --- a/examples/fides/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_subdirectory(01_onecell) diff --git a/examples/h5subfile/CMakeLists.txt b/examples/h5subfile/CMakeLists.txt deleted file mode 100644 index 0d94ae241b..0000000000 --- a/examples/h5subfile/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -if(ADIOS2_HAVE_MPI) - add_executable(H5EngineSubfileTest h5_subfile.cpp) - target_link_libraries(H5EngineSubfileTest adios2::cxx11_mpi MPI::MPI_C) -endif() - diff --git a/examples/heatTransfer/inline/CMakeLists.txt b/examples/heatTransfer/inline/CMakeLists.txt deleted file mode 100644 index 54fd8de038..0000000000 --- a/examples/heatTransfer/inline/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(heatTransfer_inline_adios2 - main.cpp - InlineIO.cpp - ../write/HeatTransfer.cpp - ../write/Settings.cpp -) -target_link_libraries(heatTransfer_inline_adios2 - adios2::cxx11_mpi MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT} -) diff --git a/examples/heatTransfer/read/CMakeLists.txt b/examples/heatTransfer/read/CMakeLists.txt deleted file mode 100644 index dd1adbe0cb..0000000000 --- a/examples/heatTransfer/read/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(heatTransfer_read - heatRead.cpp - PrintDataStep.h - ReadSettings.cpp -) -target_link_libraries(heatTransfer_read adios2::cxx11_mpi MPI::MPI_C) diff --git a/examples/heatTransfer/read_fileonly/CMakeLists.txt b/examples/heatTransfer/read_fileonly/CMakeLists.txt deleted file mode 100644 index d0ab4b830b..0000000000 --- a/examples/heatTransfer/read_fileonly/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(heatTransfer_read_fileonly_adios2 heatRead_adios2.cpp PrintData.h) -target_link_libraries(heatTransfer_read_fileonly_adios2 adios2::cxx11_mpi MPI::MPI_C) - -#if(ADIOS2_HAVE_HDF5) - #add_executable(heatTransfer_read_fileonly_h5_mpi heatRead_h5.cpp PrintData.h) - #target_link_libraries(heatTransfer_read_fileonly_h5_mpi adios2::cxx11_mpi MPI::MPI_C) -#endif() diff --git a/examples/heatTransfer/read_fileonly/heatRead_adios1.cpp b/examples/heatTransfer/read_fileonly/heatRead_adios1.cpp deleted file mode 100644 index c727a9e825..0000000000 --- a/examples/heatTransfer/read_fileonly/heatRead_adios1.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "PrintData.h" - -int main(int argc, char *argv[]) -{ - MPI_Init(&argc, &argv); - - if (argc < 2) - { - std::cout << "Not enough arguments: need an input file\n"; - return 1; - } - const char *inputfile = argv[1]; - - /* World comm spans all applications started with the same aprun command - on a Cray XK6. So we have to split and create the local - 'world' communicator for the reader only. - In normal start-up, the communicator will just equal the MPI_COMM_WORLD. - */ - - int wrank, wnproc; - MPI_Comm_rank(MPI_COMM_WORLD, &wrank); - MPI_Comm_size(MPI_COMM_WORLD, &wnproc); - - const unsigned int color = 2; - MPI_Comm mpiReaderComm; - MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &mpiReaderComm); - - int rank, nproc; - MPI_Comm_rank(mpiReaderComm, &rank); - MPI_Comm_size(mpiReaderComm, &nproc); - - adios_read_init_method(ADIOS_READ_METHOD_BP, mpiReaderComm, "verbose=3"); - - ADIOS_FILE *f; - f = adios_read_open_file(inputfile, ADIOS_READ_METHOD_BP, mpiReaderComm); - if (f == NULL) - { - std::cout << adios_errmsg() << std::endl; - return -1; - } - - ADIOS_VARINFO *vgndx = adios_inq_var(f, "gndx"); - ADIOS_VARINFO *vgndy = adios_inq_var(f, "gndy"); - - unsigned int gndx = *(unsigned int *)vgndx->value; - unsigned int gndy = *(unsigned int *)vgndy->value; - - if (rank == 0) - { - std::cout << "gndx = " << gndx << std::endl; - std::cout << "gndy = " << gndy << std::endl; - } - adios_free_varinfo(vgndx); - adios_free_varinfo(vgndy); - - // 1D decomposition of the columns, which is inefficient for reading! - uint64_t readsize[2] = {gndx, gndy / nproc}; - uint64_t offset[2] = {0LL, rank * readsize[1]}; - if (rank == nproc - 1) - { - // last process should read all the rest of columns - readsize[1] = gndy - readsize[1] * (nproc - 1); - } - - std::cout << "rank " << rank << " reads " << readsize[1] << " columns from offset " << offset[1] - << std::endl; - - ADIOS_VARINFO *vT = adios_inq_var(f, "T"); - - double *T = new double[vT->nsteps * readsize[0] * readsize[1]]; - - // Create a 2D selection for the subset - ADIOS_SELECTION *sel = adios_selection_boundingbox(2, offset, readsize); - - // Arrays are read by scheduling one or more of them - // and performing the reads at once - adios_schedule_read(f, sel, "T", 0, vT->nsteps, T); - adios_perform_reads(f, 1); - - printData(T, readsize, offset, rank, vT->nsteps); - adios_read_close(f); - adios_free_varinfo(vT); - delete[] T; - // Terminate - adios_selection_delete(sel); - adios_read_finalize_method(ADIOS_READ_METHOD_BP); - MPI_Finalize(); - return 0; -} diff --git a/examples/heatTransfer/write/CMakeLists.txt b/examples/heatTransfer/write/CMakeLists.txt deleted file mode 100644 index 268b05fe28..0000000000 --- a/examples/heatTransfer/write/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(heatTransfer_write_adios2 - main.cpp - HeatTransfer.cpp - Settings.cpp - IO_adios2.cpp -) -target_link_libraries(heatTransfer_write_adios2 - adios2::cxx11_mpi MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT} -) - -add_executable(heatTransfer_write_ascii - main.cpp - HeatTransfer.cpp - Settings.cpp - IO_ascii.cpp -) -target_link_libraries(heatTransfer_write_ascii - MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT} -) - -if(ADIOS2_HAVE_HDF5) - add_executable(heatTransfer_write_hdf5 - main.cpp - HeatTransfer.cpp - Settings.cpp - IO_hdf5_a.cpp - ) - target_include_directories(heatTransfer_write_hdf5 - PRIVATE ${HDF5_C_INCLUDE_DIRS} - ) - target_link_libraries(heatTransfer_write_hdf5 - ${HDF5_C_LIBRARIES} MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT} - ) - - if(HDF5_IS_PARALLEL) - add_executable(heatTransfer_write_ph5 - main.cpp - HeatTransfer.cpp - Settings.cpp - IO_ph5.cpp - ) - target_include_directories(heatTransfer_write_ph5 - PRIVATE ${HDF5_C_INCLUDE_DIRS} - ) - target_link_libraries(heatTransfer_write_ph5 - ${HDF5_C_LIBRARIES} MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT} - ) - endif() - - if(NOT (HDF5_VERSION VERSION_LESS 1.11)) - add_executable(heatTransfer_write_h5mixer - main.cpp - HeatTransfer.cpp - Settings.cpp - IO_h5mixer.cpp - ) - target_link_libraries(heatTransfer_write_h5mixer - adios2::cxx11_mpi MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT} - ) - endif() -endif() diff --git a/examples/hello/CMakeLists.txt b/examples/hello/CMakeLists.txt index 1de325635a..dd90609718 100644 --- a/examples/hello/CMakeLists.txt +++ b/examples/hello/CMakeLists.txt @@ -3,13 +3,16 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_subdirectory(bpWriter) +add_subdirectory(bpAttributeWriter) +add_subdirectory(bpFlushWriter) + +if(ADIOS2_HAVE_MPI) + add_subdirectory(bpFWriteCRead) +endif() + add_subdirectory(bpReader) add_subdirectory(bpTimeWriter) -add_subdirectory(bpFlushWriter) -add_subdirectory(bpAttributeWriter) -add_subdirectory(inlineReaderWriter) -add_subdirectory(skeleton) +add_subdirectory(bpWriter) if(ADIOS2_HAVE_DataMan) add_subdirectory(datamanReader) @@ -21,20 +24,23 @@ if(ADIOS2_HAVE_DataSpaces) add_subdirectory(dataspacesWriter) endif() -if(ADIOS2_HAVE_SST) - add_subdirectory(sstReader) - add_subdirectory(sstWriter) -endif() - if(ADIOS2_HAVE_HDF5) add_subdirectory(hdf5Writer) add_subdirectory(hdf5Reader) + if(HDF5_VERSION VERSION_GREATER_EQUAL 1.14) + add_subdirectory(hdf5SubFile) + endif() endif() -if(ADIOS2_HAVE_MPI) - add_subdirectory(bpFWriteCRead) +if(ADIOS2_HAVE_Fortran) + add_subdirectory(inlineFWriteCppRead) endif() -if(ADIOS2_HAVE_Fortran) - add_subdirectory(inlineFWriteCppRead) +add_subdirectory(inlineMWE) +add_subdirectory(inlineReaderWriter) +add_subdirectory(skeleton) + +if(ADIOS2_HAVE_SST) + add_subdirectory(sstReader) + add_subdirectory(sstWriter) endif() diff --git a/examples/hello/bpAttributeWriter/CMakeLists.txt b/examples/hello/bpAttributeWriter/CMakeLists.txt index 6222de2122..c5eaf598e3 100644 --- a/examples/hello/bpAttributeWriter/CMakeLists.txt +++ b/examples/hello/bpAttributeWriter/CMakeLists.txt @@ -3,12 +3,30 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_bpAttributeWriter helloBPAttributeWriter_nompi.cpp) -target_link_libraries(hello_bpAttributeWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPAttributeWriterExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_bpAttributeWriter bpAttributeWriter_nompi.cpp) +target_link_libraries(adios2_hello_bpAttributeWriter adios2::cxx11) +install(TARGETS adios2_hello_bpAttributeWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - find_package(MPI COMPONENTS C REQUIRED) - add_executable(hello_bpAttributeWriter_mpi helloBPAttributeWriter.cpp) - target_link_libraries(hello_bpAttributeWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_bpAttributeWriter_mpi bpAttributeWriter.cpp) + target_link_libraries(adios2_hello_bpAttributeWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpAttributeWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/hello/bpAttributeWriter/helloBPAttributeWriter.cpp b/examples/hello/bpAttributeWriter/bpAttributeWriter.cpp similarity index 97% rename from examples/hello/bpAttributeWriter/helloBPAttributeWriter.cpp rename to examples/hello/bpAttributeWriter/bpAttributeWriter.cpp index dce3946fa1..beb376d434 100644 --- a/examples/hello/bpAttributeWriter/helloBPAttributeWriter.cpp +++ b/examples/hello/bpAttributeWriter/bpAttributeWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPWriter.cpp: Simple self-descriptive example of how to write a variable + * bpAttributeWriter.cpp: Simple self-descriptive example of how to write a variable * to a BP File that lives in several MPI processes. * * Created on: Feb 16, 2017 diff --git a/examples/hello/bpAttributeWriter/helloBPAttributeWriter_nompi.cpp b/examples/hello/bpAttributeWriter/bpAttributeWriter_nompi.cpp similarity index 96% rename from examples/hello/bpAttributeWriter/helloBPAttributeWriter_nompi.cpp rename to examples/hello/bpAttributeWriter/bpAttributeWriter_nompi.cpp index 9b9fedd9ab..0a01f808fc 100644 --- a/examples/hello/bpAttributeWriter/helloBPAttributeWriter_nompi.cpp +++ b/examples/hello/bpAttributeWriter/bpAttributeWriter_nompi.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPWriter_nompi.cpp sequential non-mpi version of helloBPWriter + * bpAttributeWriter_nompi.cpp sequential non-mpi version of bpAttributeWriter * * Created on: Jan 9, 2017 * Author: William F Godoy godoywf@ornl.gov diff --git a/examples/hello/bpFWriteCRead/CMakeLists.txt b/examples/hello/bpFWriteCRead/CMakeLists.txt index ff5dcc1b2b..759d6919c6 100644 --- a/examples/hello/bpFWriteCRead/CMakeLists.txt +++ b/examples/hello/bpFWriteCRead/CMakeLists.txt @@ -3,18 +3,49 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(CppWriter CppWriter.cpp) -target_link_libraries(CppWriter adios2::cxx11_mpi MPI::MPI_C) - -add_executable(CppReader CppReader.cpp) -target_link_libraries(CppReader adios2::cxx11_mpi MPI::MPI_C) - -if(ADIOS2_HAVE_Fortran) - add_executable(FWriter FWriter.f90) - add_executable(FReader FReader.f90) - target_link_libraries(FWriter adios2::fortran_mpi MPI::MPI_Fortran) - target_link_libraries(FReader adios2::fortran_mpi MPI::MPI_Fortran) - set_target_properties(FWriter FReader PROPERTIES - LINKER_LANGUAGE Fortran - ) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPFWriteCReadExample) + +if(NOT TARGET adios2_core) + set(_components C) + + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + endif() + if(CMAKE_Fortran_COMPILER_LOADED) + list(APPEND _components Fortran) + endif() + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + list(APPEND _components CXX) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if (ADIOS2_HAVE_MPI) + add_executable(adios2_hello_CppWriter CppWriter.cpp) + target_link_libraries(adios2_hello_CppWriter adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_CppWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_hello_CppReader CppReader.cpp) + target_link_libraries(adios2_hello_CppReader adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_CppReader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_Fortran) + add_executable(adios2_hello_FWriter FWriter.f90) + target_link_libraries(adios2_hello_FWriter adios2::fortran_mpi MPI::MPI_Fortran) + install(TARGETS adios2_hello_FWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_hello_FReader FReader.f90) + target_link_libraries(adios2_hello_FReader adios2::fortran_mpi MPI::MPI_Fortran) + install(TARGETS adios2_hello_FReader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/hello/bpFlushWriter/CMakeLists.txt b/examples/hello/bpFlushWriter/CMakeLists.txt index 351282fa3c..61c78ebc7b 100644 --- a/examples/hello/bpFlushWriter/CMakeLists.txt +++ b/examples/hello/bpFlushWriter/CMakeLists.txt @@ -3,10 +3,29 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_bpFlushWriter helloBPFlushWriter_nompi.cpp) -target_link_libraries(hello_bpFlushWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPFlushWriterExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_bpFlushWriter bpFlushWriter_nompi.cpp) +target_link_libraries(adios2_hello_bpFlushWriter adios2::cxx11) +install(TARGETS adios2_hello_bpFlushWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(hello_bpFlushWriter_mpi helloBPFlushWriter.cpp) - target_link_libraries(hello_bpFlushWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_bpFlushWriter_mpi bpFlushWriter.cpp) + target_link_libraries(adios2_hello_bpFlushWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpFlushWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/hello/bpFlushWriter/helloBPFlushWriter.cpp b/examples/hello/bpFlushWriter/bpFlushWriter.cpp similarity index 97% rename from examples/hello/bpFlushWriter/helloBPFlushWriter.cpp rename to examples/hello/bpFlushWriter/bpFlushWriter.cpp index bcdfc441f9..785ec43369 100644 --- a/examples/hello/bpFlushWriter/helloBPFlushWriter.cpp +++ b/examples/hello/bpFlushWriter/bpFlushWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPFlushWriter.cpp: Example that tests buffer overflow forcing a flush to + * bpFlushWriter.cpp: Example that tests buffer overflow forcing a flush to * transports when writing a large variable in independent N-to-N mode. This * will have performance penalties, but it's safer. * diff --git a/examples/hello/bpFlushWriter/helloBPFlushWriter_nompi.cpp b/examples/hello/bpFlushWriter/bpFlushWriter_nompi.cpp similarity index 96% rename from examples/hello/bpFlushWriter/helloBPFlushWriter_nompi.cpp rename to examples/hello/bpFlushWriter/bpFlushWriter_nompi.cpp index edd92663ac..f8480c4464 100644 --- a/examples/hello/bpFlushWriter/helloBPFlushWriter_nompi.cpp +++ b/examples/hello/bpFlushWriter/bpFlushWriter_nompi.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPWriter_nompi.cpp sequential non-mpi version of helloBPWriter + * bpFlushWriter_nompi.cpp sequential non-mpi version of bpFlushWriter * * Created on: Jan 9, 2017 * Author: William F Godoy godoywf@ornl.gov diff --git a/examples/hello/bpReader/CMakeLists.txt b/examples/hello/bpReader/CMakeLists.txt index 462227301f..95be573537 100644 --- a/examples/hello/bpReader/CMakeLists.txt +++ b/examples/hello/bpReader/CMakeLists.txt @@ -3,28 +3,59 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_bpReader helloBPReader_nompi.cpp) -target_link_libraries(hello_bpReader adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPReaderExample) -if(ADIOS2_HAVE_Fortran) - add_executable(hello_bpReaderHeatMap3D_f helloBPReaderHeatMap3D.F90) - set_property(TARGET hello_bpReaderHeatMap3D_f PROPERTY LINKER_LANGUAGE Fortran) - target_link_libraries(hello_bpReaderHeatMap3D_f adios2::fortran) +if(NOT TARGET adios2::cxx11) + set(_components C) + + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + endif() + if(CMAKE_Fortran_COMPILER_LOADED) + list(APPEND _components Fortran) + endif() + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + list(APPEND _components CXX) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) endif() +add_executable(adios2_hello_bpReader bpReader_nompi.cpp) +target_link_libraries(adios2_hello_bpReader adios2::cxx11) +install(TARGETS adios2_hello_bpReader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + if(ADIOS2_HAVE_MPI) - add_executable(hello_bpReader_mpi helloBPReader.cpp) - target_link_libraries(hello_bpReader_mpi adios2::cxx11_mpi MPI::MPI_C) - - add_executable(hello_bpReaderHeatMap2D helloBPReaderHeatMap2D.cpp) - target_link_libraries(hello_bpReaderHeatMap2D adios2::cxx11_mpi MPI::MPI_C) - - add_executable(hello_bpReaderHeatMap3D helloBPReaderHeatMap3D.cpp) - target_link_libraries(hello_bpReaderHeatMap3D adios2::cxx11_mpi MPI::MPI_C) - - if(ADIOS2_HAVE_Fortran) - add_executable(hello_bpReaderHeatMap3D_f_mpi helloBPReaderHeatMap3D.F90) - target_link_libraries(hello_bpReaderHeatMap3D_f_mpi adios2::fortran_mpi MPI::MPI_Fortran) - set_property(TARGET hello_bpReaderHeatMap3D_f_mpi PROPERTY LINKER_LANGUAGE Fortran) + add_executable(adios2_hello_bpReader_mpi bpReader.cpp) + target_link_libraries(adios2_hello_bpReader_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpReader_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_hello_bpReaderHeatMap2D bpReaderHeatMap2D.cpp) + target_link_libraries(adios2_hello_bpReaderHeatMap2D adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpReaderHeatMap2D RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_hello_bpReaderHeatMap3D bpReaderHeatMap3D.cpp) + target_link_libraries(adios2_hello_bpReaderHeatMap3D adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpReaderHeatMap3D RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() + +if(ADIOS2_HAVE_Fortran) + add_executable(adios2_hello_bpReaderHeatMap3D_f bpReaderHeatMap3D.F90) + target_link_libraries(adios2_hello_bpReaderHeatMap3D_f adios2::fortran) + install(TARGETS adios2_hello_bpReaderHeatMap3D_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_bpReaderHeatMap3D_f_mpi bpReaderHeatMap3D.F90) + target_link_libraries(adios2_hello_bpReaderHeatMap3D_f_mpi adios2::fortran_mpi MPI::MPI_Fortran) + install(TARGETS adios2_hello_bpReaderHeatMap3D_f_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() endif() diff --git a/examples/hello/bpReader/helloBPReader.cpp b/examples/hello/bpReader/bpReader.cpp similarity index 97% rename from examples/hello/bpReader/helloBPReader.cpp rename to examples/hello/bpReader/bpReader.cpp index 9da7f3c83e..d873b76c3a 100644 --- a/examples/hello/bpReader/helloBPReader.cpp +++ b/examples/hello/bpReader/bpReader.cpp @@ -2,8 +2,8 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPReader.cpp: Simple self-descriptive example of how to read a variable - * to a BP File. + * bpReader.cpp: Simple self-descriptive example of how to read a variable + * from a BP File. * * Try running like this from the build directory: * mpirun -np 3 ./bin/hello_bpReader diff --git a/examples/hello/bpReader/helloBPReaderHeatMap2D.cpp b/examples/hello/bpReader/bpReaderHeatMap2D.cpp similarity index 98% rename from examples/hello/bpReader/helloBPReaderHeatMap2D.cpp rename to examples/hello/bpReader/bpReaderHeatMap2D.cpp index 184d5730c2..46df44ce90 100644 --- a/examples/hello/bpReader/helloBPReaderHeatMap2D.cpp +++ b/examples/hello/bpReader/bpReaderHeatMap2D.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPReaderHeatMap.cpp : Writes a heat map in a regular 2D mesh, + * bpReaderHeatMap2D.cpp : Writes a heat map in a regular 2D mesh, * values grow from 0 in increments of 1 * * temperature[gNx, Ny] diff --git a/examples/hello/bpReader/helloBPReaderHeatMap2D.py b/examples/hello/bpReader/bpReaderHeatMap2D.py similarity index 75% rename from examples/hello/bpReader/helloBPReaderHeatMap2D.py rename to examples/hello/bpReader/bpReaderHeatMap2D.py index 9aa8925a39..ea63fee022 100644 --- a/examples/hello/bpReader/helloBPReaderHeatMap2D.py +++ b/examples/hello/bpReader/bpReaderHeatMap2D.py @@ -2,7 +2,7 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. # -# helloBPReaderHeatMap2D.py +# bpReaderHeatMap2D.py # # # Created on: Dec 5th, 2017 @@ -41,10 +41,11 @@ adios = adios2.ADIOS(comm) ioWrite = adios.DeclareIO("ioWriter") -varTemperature = ioWrite.DefineVariable("temperature2D", temperatures, shape, - start, count, adios2.ConstantDims) +varTemperature = ioWrite.DefineVariable( + "temperature2D", temperatures, shape, start, count, adios2.ConstantDims +) -obpStream = ioWrite.Open('HeatMap2D_py.bp', adios2.Mode.Write) +obpStream = ioWrite.Open("HeatMap2D_py.bp", adios2.Mode.Write) obpStream.Put(varTemperature, temperatures) obpStream.Close() @@ -52,7 +53,7 @@ if rank == 0: ioRead = adios.DeclareIO("ioReader") - ibpStream = ioRead.Open('HeatMap2D_py.bp', adios2.Mode.Read, MPI.COMM_SELF) + ibpStream = ioRead.Open("HeatMap2D_py.bp", adios2.Mode.Read, MPI.COMM_SELF) var_inTemperature = ioRead.InquireVariable("temperature2D") @@ -60,15 +61,15 @@ var_inTemperature.SetSelection([[2, 2], [4, 4]]) inSize = var_inTemperature.SelectionSize() - print('Incoming size ' + str(inSize)) + print("Incoming size " + str(inSize)) inTemperatures = numpy.zeros(inSize, dtype=numpy.int) ibpStream.Get(var_inTemperature, inTemperatures, adios2.Mode.Sync) - print('Incoming temperature map') + print("Incoming temperature map") for i in range(0, inTemperatures.size): - print(str(inTemperatures[i]) + ' ') + print(str(inTemperatures[i]) + " ") if (i + 1) % 4 == 0: print() diff --git a/examples/hello/bpReader/helloBPReaderHeatMap3D.F90 b/examples/hello/bpReader/bpReaderHeatMap3D.F90 similarity index 98% rename from examples/hello/bpReader/helloBPReaderHeatMap3D.F90 rename to examples/hello/bpReader/bpReaderHeatMap3D.F90 index e44d9c53bf..3bd7251e89 100644 --- a/examples/hello/bpReader/helloBPReaderHeatMap3D.F90 +++ b/examples/hello/bpReader/bpReaderHeatMap3D.F90 @@ -1,4 +1,4 @@ -program helloBPReaderHeatMap3D +program bpReaderHeatMap3D #if ADIOS2_USE_MPI use mpi #endif @@ -130,4 +130,4 @@ program helloBPReaderHeatMap3D call MPI_Finalize(ierr) #endif -end program helloBPReaderHeatMap3D +end program bpReaderHeatMap3D diff --git a/examples/hello/bpReader/helloBPReaderHeatMap3D.cpp b/examples/hello/bpReader/bpReaderHeatMap3D.cpp similarity index 100% rename from examples/hello/bpReader/helloBPReaderHeatMap3D.cpp rename to examples/hello/bpReader/bpReaderHeatMap3D.cpp diff --git a/examples/hello/bpReader/helloBPReader_nompi.cpp b/examples/hello/bpReader/bpReader_nompi.cpp similarity index 97% rename from examples/hello/bpReader/helloBPReader_nompi.cpp rename to examples/hello/bpReader/bpReader_nompi.cpp index 629fa2e1f9..b2651d17fa 100644 --- a/examples/hello/bpReader/helloBPReader_nompi.cpp +++ b/examples/hello/bpReader/bpReader_nompi.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPReader.cpp: Simple self-descriptive example of how to read a variable + * bpReader_nompi.cpp: Simple self-descriptive example of how to read a variable * from a BP File. * * Created on: Feb 16, 2017 diff --git a/examples/hello/bpTimeWriter/CMakeLists.txt b/examples/hello/bpTimeWriter/CMakeLists.txt index 5306bbd375..30a9f1d361 100644 --- a/examples/hello/bpTimeWriter/CMakeLists.txt +++ b/examples/hello/bpTimeWriter/CMakeLists.txt @@ -3,10 +3,29 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_bpTimeWriter helloBPTimeWriter_nompi.cpp) -target_link_libraries(hello_bpTimeWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPTimeWriterExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_bpTimeWriter bpTimeWriter_nompi.cpp) +target_link_libraries(adios2_hello_bpTimeWriter adios2::cxx11) +install(TARGETS adios2_hello_bpTimeWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(hello_bpTimeWriter_mpi helloBPTimeWriter.cpp) - target_link_libraries(hello_bpTimeWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_bpTimeWriter_mpi bpTimeWriter.cpp) + target_link_libraries(adios2_hello_bpTimeWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpTimeWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/hello/bpTimeWriter/helloBPTimeWriter.cpp b/examples/hello/bpTimeWriter/bpTimeWriter.cpp similarity index 98% rename from examples/hello/bpTimeWriter/helloBPTimeWriter.cpp rename to examples/hello/bpTimeWriter/bpTimeWriter.cpp index eab24b40e9..77e37389cc 100644 --- a/examples/hello/bpTimeWriter/helloBPTimeWriter.cpp +++ b/examples/hello/bpTimeWriter/bpTimeWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPTimeWriter.cpp example for writing a variable using the Advance + * bpTimeWriter.cpp example for writing a variable using the Advance * function for time aggregation. Time step is saved as an additional (global) * single value variable, just for tracking purposes. * diff --git a/examples/hello/bpTimeWriter/helloBPTimeWriter.py b/examples/hello/bpTimeWriter/bpTimeWriter.py similarity index 87% rename from examples/hello/bpTimeWriter/helloBPTimeWriter.py rename to examples/hello/bpTimeWriter/bpTimeWriter.py index 4ddff5a1aa..87afc7f1c1 100644 --- a/examples/hello/bpTimeWriter/helloBPTimeWriter.py +++ b/examples/hello/bpTimeWriter/bpTimeWriter.py @@ -2,7 +2,7 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. # -# test_hello.py +# bpTimeWriter.py # Created on: Feb 2, 2017 # Author: William F Godoy godoywf@ornl.gov @@ -28,8 +28,9 @@ bpIO = adios.DeclareIO("BPN2N") # Variables -bpArray = bpIO.DefineVariable("bpArray", myArray, [size * nx], [rank * nx], - [nx], adios2.ConstantDims) +bpArray = bpIO.DefineVariable( + "bpArray", myArray, [size * nx], [rank * nx], [nx], adios2.ConstantDims +) bpTimeStep = bpIO.DefineVariable("bpTimeStep", time) # Engine diff --git a/examples/hello/bpTimeWriter/helloBPTimeWriter_nompi.cpp b/examples/hello/bpTimeWriter/bpTimeWriter_nompi.cpp similarity index 96% rename from examples/hello/bpTimeWriter/helloBPTimeWriter_nompi.cpp rename to examples/hello/bpTimeWriter/bpTimeWriter_nompi.cpp index 9165189504..ddfd113fa4 100644 --- a/examples/hello/bpTimeWriter/helloBPTimeWriter_nompi.cpp +++ b/examples/hello/bpTimeWriter/bpTimeWriter_nompi.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPTimeWriter_nompi.cpp no mpi version of helloBPTimeWriter.cpp + * bpTimeWriter_nompi.cpp no mpi version of bpTimeWriter.cpp * * Created on: Feb 16, 2017 * Author: William F Godoy godoywf@ornl.gov diff --git a/examples/hello/bpWriteReadCuda/CMakeLists.txt b/examples/hello/bpWriteReadCuda/CMakeLists.txt new file mode 100644 index 0000000000..453867f0b4 --- /dev/null +++ b/examples/hello/bpWriteReadCuda/CMakeLists.txt @@ -0,0 +1,25 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPWriteReadCudaExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(CUDAToolkit REQUIRED) + if(CUDAToolkit_FOUND) + enable_language(CUDA) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_CUDA OR ADIOS2_HAVE_Kokkos_CUDA) + add_executable(adios2_hello_bpWriteReadCuda bpWriteReadCuda.cu) + target_link_libraries(adios2_hello_bpWriteReadCuda PUBLIC adios2::cxx11 CUDA::cudart) + set_target_properties(adios2_hello_bpWriteReadCuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + install(TARGETS adios2_hello_bpWriteReadCuda RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/cuda/cudaBPWriteRead.cu b/examples/hello/bpWriteReadCuda/bpWriteReadCuda.cu similarity index 96% rename from examples/cuda/cudaBPWriteRead.cu rename to examples/hello/bpWriteReadCuda/bpWriteReadCuda.cu index 1d2dcd4eda..953ae92924 100644 --- a/examples/cuda/cudaBPWriteRead.cu +++ b/examples/hello/bpWriteReadCuda/bpWriteReadCuda.cu @@ -1,4 +1,7 @@ /* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * * Simple example of writing and reading data * through ADIOS2 BP engine with multiple simulations steps * for every IO step. diff --git a/examples/hello/bpWriter/CMakeLists.txt b/examples/hello/bpWriter/CMakeLists.txt index aad594f556..0e48312f8c 100644 --- a/examples/hello/bpWriter/CMakeLists.txt +++ b/examples/hello/bpWriter/CMakeLists.txt @@ -3,50 +3,89 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_bpWriter helloBPWriter.cpp) -target_link_libraries(hello_bpWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPWriterExample) -add_executable(hello_bpWriter_c helloBPWriter.c) -target_link_libraries(hello_bpWriter_c adios2::c) +if(NOT TARGET adios2_core) + set(_components C) -add_executable(hello_bpPutDeferred helloBPPutDeferred.cpp) -target_link_libraries(hello_bpPutDeferred adios2::cxx11) + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + endif() + if(CMAKE_Fortran_COMPILER_LOADED) + list(APPEND _components Fortran) + endif() + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + list(APPEND _components CXX) + + find_package(SZ QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_bpWriter bpWriter.cpp) +target_link_libraries(adios2_hello_bpWriter adios2::cxx11) +install(TARGETS adios2_hello_bpWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_hello_bpWriter_c bpWriter.c) +target_link_libraries(adios2_hello_bpWriter_c adios2::c) +install(TARGETS adios2_hello_bpWriter_c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_hello_bpPutDeferred bpPutDeferred.cpp) +target_link_libraries(adios2_hello_bpPutDeferred adios2::cxx11) +install(TARGETS adios2_hello_bpPutDeferred RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -add_executable(hello_bpSubStreams helloBPSubStreams.cpp) -target_link_libraries(hello_bpSubStreams adios2::cxx11) +add_executable(adios2_hello_bpSubStreams bpSubStreams.cpp) +target_link_libraries(adios2_hello_bpSubStreams adios2::cxx11) +install(TARGETS adios2_hello_bpSubStreams RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_SZ) - add_executable(hello_bpSZ helloBPSZ.cpp) - target_link_libraries(hello_bpSZ adios2::cxx11) + add_executable(adios2_hello_bpSZ bpSZ.cpp) + target_link_libraries(adios2_hello_bpSZ adios2::cxx11) + install(TARGETS adios2_hello_bpSZ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() if(ADIOS2_HAVE_Fortran) - add_executable(hello_bpWriter_f helloBPWriter.F90) - set_property(TARGET hello_bpWriter_f PROPERTY LINKER_LANGUAGE Fortran) - target_link_libraries(hello_bpWriter_f adios2::fortran) + add_executable(adios2_hello_bpWriter_f bpWriter.F90) + target_link_libraries(adios2_hello_bpWriter_f adios2::fortran) + install(TARGETS adios2_hello_bpWriter_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() if(ADIOS2_HAVE_MPI) - add_executable(hello_bpWriter_mpi helloBPWriter.cpp) - target_link_libraries(hello_bpWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_bpWriter_mpi bpWriter.cpp) + target_link_libraries(adios2_hello_bpWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - add_executable(hello_bpWriter_c_mpi helloBPWriter.c) - target_link_libraries(hello_bpWriter_c_mpi adios2::c_mpi MPI::MPI_C) + add_executable(adios2_hello_bpWriter_c_mpi bpWriter.c) + target_link_libraries(adios2_hello_bpWriter_c_mpi adios2::c_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpWriter_c_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - add_executable(hello_bpPutDeferred_mpi helloBPPutDeferred.cpp) - target_link_libraries(hello_bpPutDeferred_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_bpPutDeferred_mpi bpPutDeferred.cpp) + target_link_libraries(adios2_hello_bpPutDeferred_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpPutDeferred_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - add_executable(hello_bpSubStreams_mpi helloBPSubStreams.cpp) - target_link_libraries(hello_bpSubStreams_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_bpSubStreams_mpi bpSubStreams.cpp) + target_link_libraries(adios2_hello_bpSubStreams_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpSubStreams_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_SZ) - add_executable(hello_bpSZ_mpi helloBPSZ.cpp) - target_link_libraries(hello_bpSZ_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_bpSZ_mpi bpSZ.cpp) + target_link_libraries(adios2_hello_bpSZ_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_bpSZ_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() if(ADIOS2_HAVE_Fortran) - add_executable(hello_bpWriter_f_mpi helloBPWriter.F90) - set_property(TARGET hello_bpWriter_f_mpi PROPERTY LINKER_LANGUAGE Fortran) - target_link_libraries(hello_bpWriter_f_mpi adios2::fortran_mpi MPI::MPI_Fortran) + add_executable(adios2_hello_bpWriter_f_mpi bpWriter.F90) + target_link_libraries(adios2_hello_bpWriter_f_mpi adios2::fortran_mpi MPI::MPI_Fortran) + install(TARGETS adios2_hello_bpWriter_f_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() endif() diff --git a/examples/hello/bpWriter/helloBPPutDeferred.cpp b/examples/hello/bpWriter/bpPutDeferred.cpp similarity index 91% rename from examples/hello/bpWriter/helloBPPutDeferred.cpp rename to examples/hello/bpWriter/bpPutDeferred.cpp index 209486496d..bec6d3e289 100644 --- a/examples/hello/bpWriter/helloBPPutDeferred.cpp +++ b/examples/hello/bpWriter/bpPutDeferred.cpp @@ -2,17 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPPutDeferred.cpp - * - * Created on: Oct 23, 2017 - * Author: William F Godoy godoywf@ornl.gov - */ - -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloBPPutDeferred.cpp: Simple self-descriptive example of how to write a + * bpPutDeferred.cpp: Simple self-descriptive example of how to write a * variable * to a BP File that lives in several MPI processes. * diff --git a/examples/hello/bpWriter/helloBPSZ.cpp b/examples/hello/bpWriter/bpSZ.cpp similarity index 98% rename from examples/hello/bpWriter/helloBPSZ.cpp rename to examples/hello/bpWriter/bpSZ.cpp index 5678ecb12c..357f42f829 100644 --- a/examples/hello/bpWriter/helloBPSZ.cpp +++ b/examples/hello/bpWriter/bpSZ.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPSZ.cpp : example passing runtime compression arguments + * bpSZ.cpp : example passing runtime compression arguments * * Created on: Aug 3, 2018 * Author: William F Godoy godoywf@ornl.gov diff --git a/examples/hello/bpWriter/helloBPSubStreams.cpp b/examples/hello/bpWriter/bpSubStreams.cpp similarity index 99% rename from examples/hello/bpWriter/helloBPSubStreams.cpp rename to examples/hello/bpWriter/bpSubStreams.cpp index 54db43007d..dad04e82b7 100644 --- a/examples/hello/bpWriter/helloBPSubStreams.cpp +++ b/examples/hello/bpWriter/bpSubStreams.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPSubStreams.cpp + * bpSubStreams.cpp * * Created on: Feb 21, 2018 * Author: William F Godoy godoywf@ornl.gov diff --git a/examples/hello/bpWriter/helloBPWriter.F90 b/examples/hello/bpWriter/bpWriter.F90 similarity index 97% rename from examples/hello/bpWriter/helloBPWriter.F90 rename to examples/hello/bpWriter/bpWriter.F90 index d1cea302ae..296cb290a1 100644 --- a/examples/hello/bpWriter/helloBPWriter.F90 +++ b/examples/hello/bpWriter/bpWriter.F90 @@ -1,4 +1,4 @@ -program helloBPWriter +program bpWriter #if ADIOS2_USE_MPI use mpi #endif @@ -72,4 +72,4 @@ program helloBPWriter call MPI_Finalize(ierr) #endif -end program helloBPWriter +end program bpWriter diff --git a/examples/hello/bpWriter/helloBPWriter.c b/examples/hello/bpWriter/bpWriter.c similarity index 97% rename from examples/hello/bpWriter/helloBPWriter.c rename to examples/hello/bpWriter/bpWriter.c index b88271347b..a4e17ce3ae 100644 --- a/examples/hello/bpWriter/helloBPWriter.c +++ b/examples/hello/bpWriter/bpWriter.c @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPWriter.c : C bindings version of helloBPWriter.cpp + * bpWriter.c : C bindings version of bpWriter.cpp * * Created on: Aug 8, 2017 * Author: William F Godoy godoywf@ornl.gov diff --git a/examples/hello/bpWriter/helloBPWriter.cpp b/examples/hello/bpWriter/bpWriter.cpp similarity index 97% rename from examples/hello/bpWriter/helloBPWriter.cpp rename to examples/hello/bpWriter/bpWriter.cpp index 5a80cdbeb4..878a02a60a 100644 --- a/examples/hello/bpWriter/helloBPWriter.cpp +++ b/examples/hello/bpWriter/bpWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloBPWriter.cpp: Simple self-descriptive example of how to write a variable + * bpWriter.cpp: Simple self-descriptive example of how to write a variable * to a BP File that lives in several MPI processes. * * Created on: Feb 16, 2017 diff --git a/examples/hello/bpWriter/helloBPWriter.py b/examples/hello/bpWriter/bpWriter.py similarity index 73% rename from examples/hello/bpWriter/helloBPWriter.py rename to examples/hello/bpWriter/bpWriter.py index ce29de2f0e..5218e79933 100644 --- a/examples/hello/bpWriter/helloBPWriter.py +++ b/examples/hello/bpWriter/bpWriter.py @@ -2,7 +2,7 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. # -# helloBPWriter_nompi.py : only works with non MPI version +# bpWriter.py : only works with MPI version # Created on: Feb 2, 2017 # Author: William F Godoy godoywf@ornl.gov from mpi4py import MPI @@ -15,7 +15,7 @@ size = comm.Get_size() # User data -myArray = numpy.array([0, 1., 2., 3., 4., 5., 6., 7., 8., 9.]) +myArray = numpy.array([0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) Nx = myArray.size # ADIOS MPI Communicator @@ -23,20 +23,21 @@ # ADIOS IO bpIO = adios.DeclareIO("BPFile_N2N") -bpIO.SetEngine('bp3') +bpIO.SetEngine("bp3") # bpIO.SetParameters( {"Threads" : "2", "ProfileUnits" : "Microseconds", # "InitialBufferSize" : "17Kb"} ) bpIOParams = {} -bpIOParams['Threads'] = '2' -bpIOParams['ProfileUnits'] = 'Microseconds' -bpIOParams['InitialBufferSize'] = '17Kb' +bpIOParams["Threads"] = "2" +bpIOParams["ProfileUnits"] = "Microseconds" +bpIOParams["InitialBufferSize"] = "17Kb" bpIO.SetParameters(bpIOParams) -fileID = bpIO.AddTransport('File', {'Library': 'fstream'}) +fileID = bpIO.AddTransport("File", {"Library": "fstream"}) # ADIOS Variable name, shape, start, offset, constant dims ioArray = bpIO.DefineVariable( - "bpArray", myArray, [size * Nx], [rank * Nx], [Nx], adios2.ConstantDims) + "bpArray", myArray, [size * Nx], [rank * Nx], [Nx], adios2.ConstantDims +) # ADIOS Engine bpFileWriter = bpIO.Open("npArray.bp", adios2.Mode.Write) diff --git a/examples/hello/bpWriter/helloBPWriter_nompi.py b/examples/hello/bpWriter/bpWriter_nompi.py similarity index 72% rename from examples/hello/bpWriter/helloBPWriter_nompi.py rename to examples/hello/bpWriter/bpWriter_nompi.py index 9428808fa0..5155104df1 100644 --- a/examples/hello/bpWriter/helloBPWriter_nompi.py +++ b/examples/hello/bpWriter/bpWriter_nompi.py @@ -2,7 +2,7 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. # -# helloBPWriter.py : only works with MPI version +# bpWriter_nonmpi.py : only works with non MPI version # Created on: Feb 2, 2017 # Author: William F Godoy godoywf@ornl.gov @@ -10,7 +10,7 @@ import adios2 # User data -myArray = numpy.array([0, 1., 2., 3., 4., 5., 6., 7., 8., 9.]) +myArray = numpy.array([0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) Nx = myArray.size # adios @@ -20,8 +20,7 @@ bpIO = adios.DeclareIO("BPFile_N2N") # ADIOS Variable name, shape, start, offset, constant dims -ioArray = bpIO.DefineVariable( - "bpArray", myArray, [], [], [Nx], adios2.ConstantDims) +ioArray = bpIO.DefineVariable("bpArray", myArray, [], [], [Nx], adios2.ConstantDims) # ADIOS Engine bpFileWriter = bpIO.Open("npArray.bp", adios2.Mode.Write) diff --git a/examples/hello/datamanReader/CMakeLists.txt b/examples/hello/datamanReader/CMakeLists.txt index 56a6139009..656bacefac 100644 --- a/examples/hello/datamanReader/CMakeLists.txt +++ b/examples/hello/datamanReader/CMakeLists.txt @@ -3,8 +3,28 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -if(ADIOS2_HAVE_MPI) - add_executable(hello_datamanReader helloDataManReader.cpp) - target_link_libraries(hello_datamanReader adios2::cxx11_mpi MPI::MPI_C) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloDataManReaderExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ZeroMQ 4.1 QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_DataMan) + add_executable(adios2_hello_datamanReader dataManReader.cpp) + target_link_libraries(adios2_hello_datamanReader adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_datamanReader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/hello/datamanReader/helloDataManReader.cpp b/examples/hello/datamanReader/dataManReader.cpp similarity index 98% rename from examples/hello/datamanReader/helloDataManReader.cpp rename to examples/hello/datamanReader/dataManReader.cpp index 8313a9a56d..2bc58495b2 100644 --- a/examples/hello/datamanReader/helloDataManReader.cpp +++ b/examples/hello/datamanReader/dataManReader.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloDataManReader.cpp + * dataManReader.cpp * * Created on: Jan 9, 2017 * Author: Jason Wang diff --git a/examples/hello/datamanReader/helloDataManReader.py b/examples/hello/datamanReader/dataManReader.py similarity index 92% rename from examples/hello/datamanReader/helloDataManReader.py rename to examples/hello/datamanReader/dataManReader.py index 87248b6a64..c773e84fb8 100644 --- a/examples/hello/datamanReader/helloDataManReader.py +++ b/examples/hello/datamanReader/dataManReader.py @@ -2,7 +2,7 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. # -# helloDataManReader.py +# dataManReader.py # # Created on: Sept 5, 2019 # Author: Jason Wang @@ -21,7 +21,7 @@ io.SetEngine("DataMan") io.SetParameters({"IPAddress": "127.0.0.1", "Port": "12306", "Timeout": "5"}) -engine = io.Open('HelloDataMan', adios2.Mode.Read, comm) +engine = io.Open("HelloDataMan", adios2.Mode.Read, comm) while True: stepStatus = engine.BeginStep() diff --git a/examples/hello/datamanWriter/CMakeLists.txt b/examples/hello/datamanWriter/CMakeLists.txt index 7c500d6e12..0bc0789ac6 100644 --- a/examples/hello/datamanWriter/CMakeLists.txt +++ b/examples/hello/datamanWriter/CMakeLists.txt @@ -3,7 +3,27 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -if(ADIOS2_HAVE_MPI) - add_executable(hello_datamanWriter helloDataManWriter.cpp) - target_link_libraries(hello_datamanWriter adios2::cxx11_mpi MPI::MPI_C) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloDataManWriterExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ZeroMQ 4.1 QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_DataMan) + add_executable(adios2_hello_datamanWriter dataManWriter.cpp) + target_link_libraries(adios2_hello_datamanWriter adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_datamanWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/hello/datamanWriter/helloDataManWriter.cpp b/examples/hello/datamanWriter/dataManWriter.cpp similarity index 98% rename from examples/hello/datamanWriter/helloDataManWriter.cpp rename to examples/hello/datamanWriter/dataManWriter.cpp index bd29cb9c2b..fc106c2bb3 100644 --- a/examples/hello/datamanWriter/helloDataManWriter.cpp +++ b/examples/hello/datamanWriter/dataManWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloDataManWriter.cpp + * dataManWriter.cpp * * Created on: Feb 16, 2017 * Author: Jason Wang diff --git a/examples/hello/datamanWriter/helloDataManWriter.py b/examples/hello/datamanWriter/dataManWriter.py similarity index 92% rename from examples/hello/datamanWriter/helloDataManWriter.py rename to examples/hello/datamanWriter/dataManWriter.py index e23774cb38..9035d0f42a 100644 --- a/examples/hello/datamanWriter/helloDataManWriter.py +++ b/examples/hello/datamanWriter/dataManWriter.py @@ -2,7 +2,7 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. # -# helloDataManWriter.py +# dataManWriter.py # # Created on: Sept 5, 2019 # Author: Jason Wang @@ -36,9 +36,10 @@ io.SetParameters({"IPAddress": "127.0.0.1", "Port": "12306", "Timeout": "5"}) var = io.DefineVariable( - "FloatArray", floatArray, shape, start, count, adios2.ConstantDims) + "FloatArray", floatArray, shape, start, count, adios2.ConstantDims +) -engine = io.Open('HelloDataMan', adios2.Mode.Write) +engine = io.Open("HelloDataMan", adios2.Mode.Write) for i in range(steps): floatArray = floatArray + 1 diff --git a/examples/hello/dataspacesReader/CMakeLists.txt b/examples/hello/dataspacesReader/CMakeLists.txt index 7136868362..11e8e3ff13 100644 --- a/examples/hello/dataspacesReader/CMakeLists.txt +++ b/examples/hello/dataspacesReader/CMakeLists.txt @@ -3,10 +3,33 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_dataSpacesReader helloDataSpacesReader.cpp) -target_link_libraries(hello_dataSpacesReader adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloDataSpacesReaderExample) -if(ADIOS2_HAVE_MPI) - add_executable(hello_dataSpacesReader_mpi helloDataSpacesReader.cpp) - target_link_libraries(hello_dataSpacesReader_mpi adios2::cxx11_mpi MPI::MPI_C) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(DataSpaces 2.1.1 QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_DataSpaces) + add_executable(adios2_hello_dataSpacesReader dataSpacesReader.cpp) + target_link_libraries(adios2_hello_dataSpacesReader adios2::cxx11) + install(TARGETS adios2_hello_dataSpacesReader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_dataSpacesReader_mpi dataSpacesReader.cpp) + target_link_libraries(adios2_hello_dataSpacesReader_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_dataSpacesReader_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/hello/dataspacesReader/helloDataSpacesReader.cpp b/examples/hello/dataspacesReader/dataSpacesReader.cpp similarity index 98% rename from examples/hello/dataspacesReader/helloDataSpacesReader.cpp rename to examples/hello/dataspacesReader/dataSpacesReader.cpp index c2efd7ee1b..c6f6731432 100644 --- a/examples/hello/dataspacesReader/helloDataSpacesReader.cpp +++ b/examples/hello/dataspacesReader/dataSpacesReader.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloDataSpacesReader.cpp + * dataSpacesReader.cpp * * Created on: Feb 06, 2019 * Author: Pradeep Subedi diff --git a/examples/hello/dataspacesWriter/CMakeLists.txt b/examples/hello/dataspacesWriter/CMakeLists.txt index 6518c8c24b..32a1bb4673 100644 --- a/examples/hello/dataspacesWriter/CMakeLists.txt +++ b/examples/hello/dataspacesWriter/CMakeLists.txt @@ -3,10 +3,33 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_dataSpacesWriter helloDataSpacesWriter.cpp) -target_link_libraries(hello_dataSpacesWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloDataSpacesWriterExample) -if(ADIOS2_HAVE_MPI) - add_executable(hello_dataSpacesWriter_mpi helloDataSpacesWriter.cpp) - target_link_libraries(hello_dataSpacesWriter_mpi adios2::cxx11_mpi MPI::MPI_C) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(DataSpaces 2.1.1 QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_DataSpaces) + add_executable(adios2_hello_dataSpacesWriter dataSpacesWriter.cpp) + target_link_libraries(adios2_hello_dataSpacesWriter adios2::cxx11) + install(TARGETS adios2_hello_dataSpacesWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_dataSpacesWriter_mpi dataSpacesWriter.cpp) + target_link_libraries(adios2_hello_dataSpacesWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_dataSpacesWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/hello/dataspacesWriter/helloDataSpacesWriter.cpp b/examples/hello/dataspacesWriter/dataSpacesWriter.cpp similarity index 98% rename from examples/hello/dataspacesWriter/helloDataSpacesWriter.cpp rename to examples/hello/dataspacesWriter/dataSpacesWriter.cpp index 103578c716..9c9e23b466 100644 --- a/examples/hello/dataspacesWriter/helloDataSpacesWriter.cpp +++ b/examples/hello/dataspacesWriter/dataSpacesWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloDataSpacesWriter.cpp + * dataSpacesWriter.cpp * * Created on: Feb 06, 2019 * Author: Pradeep Subedi diff --git a/examples/hello/hdf5Reader/CMakeLists.txt b/examples/hello/hdf5Reader/CMakeLists.txt index 2dd4227cf9..ebfcb9ad7b 100644 --- a/examples/hello/hdf5Reader/CMakeLists.txt +++ b/examples/hello/hdf5Reader/CMakeLists.txt @@ -3,10 +3,33 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_hdf5Reader helloHDF5Reader_nompi.cpp) -target_link_libraries(hello_hdf5Reader adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloHDF5ReaderExample) -if(ADIOS2_HAVE_MPI) - add_executable(hello_hdf5Reader_mpi helloHDF5Reader.cpp) - target_link_libraries(hello_hdf5Reader_mpi adios2::cxx11_mpi MPI::MPI_C) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(HDF5 QUIET COMPONENTS C) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_HDF5) + add_executable(adios2_hello_hdf5Reader hdf5Reader_nompi.cpp) + target_link_libraries(adios2_hello_hdf5Reader adios2::cxx11) + install(TARGETS adios2_hello_hdf5Reader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_hdf5Reader_mpi hdf5Reader.cpp) + target_link_libraries(adios2_hello_hdf5Reader_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_hdf5Reader_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/hello/hdf5Reader/helloHDF5Reader.cpp b/examples/hello/hdf5Reader/hdf5Reader.cpp similarity index 99% rename from examples/hello/hdf5Reader/helloHDF5Reader.cpp rename to examples/hello/hdf5Reader/hdf5Reader.cpp index 33a2b7fb01..c1db98dde9 100644 --- a/examples/hello/hdf5Reader/helloHDF5Reader.cpp +++ b/examples/hello/hdf5Reader/hdf5Reader.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloHDF5Reader.cpp + * hdf5Reader.cpp * * Created on: Jan 24, 2018 * Author: Junmin Gu diff --git a/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp b/examples/hello/hdf5Reader/hdf5Reader_nompi.cpp similarity index 99% rename from examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp rename to examples/hello/hdf5Reader/hdf5Reader_nompi.cpp index c52d7515e0..45826a8979 100644 --- a/examples/hello/hdf5Reader/helloHDF5Reader_nompi.cpp +++ b/examples/hello/hdf5Reader/hdf5Reader_nompi.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloHDF5Reader.cpp + * hdf5Reader.cpp * * Created on: Jan 24, 2018 * Author: Junmin Gu diff --git a/examples/hello/hdf5SubFile/CMakeLists.txt b/examples/hello/hdf5SubFile/CMakeLists.txt new file mode 100644 index 0000000000..81e494fa1b --- /dev/null +++ b/examples/hello/hdf5SubFile/CMakeLists.txt @@ -0,0 +1,30 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(HelloHDF5SubFileExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(HDF5 QUIET COMPONENTS C) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_HDF5 AND HDF5_VERSION VERSION_GREATER_EQUAL 1.14) + add_executable(adios2_hello_hdf5Subfile hdf5SubFile.cpp) + target_link_libraries(adios2_hello_hdf5Subfile adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_hdf5Subfile RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() + diff --git a/examples/h5subfile/h5_subfile.cpp b/examples/hello/hdf5SubFile/hdf5SubFile.cpp similarity index 99% rename from examples/h5subfile/h5_subfile.cpp rename to examples/hello/hdf5SubFile/hdf5SubFile.cpp index 09e3111ecf..a018267b1a 100644 --- a/examples/h5subfile/h5_subfile.cpp +++ b/examples/hello/hdf5SubFile/hdf5SubFile.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloHDF5Writer.cpp: Simple self-descriptive example of how to write a + * hdf5SubFile.cpp: Simple self-descriptive example of how to write a * variable to a parallel HDF5 File using MPI processes. * * Created on: March 6, 2023 diff --git a/examples/hello/hdf5Writer/CMakeLists.txt b/examples/hello/hdf5Writer/CMakeLists.txt index 934fbb4cfb..b1fd2bcdcf 100644 --- a/examples/hello/hdf5Writer/CMakeLists.txt +++ b/examples/hello/hdf5Writer/CMakeLists.txt @@ -3,10 +3,33 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_hdf5Writer helloHDF5Writer_nompi.cpp) -target_link_libraries(hello_hdf5Writer adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloHDF5WriterExample) -if(ADIOS2_HAVE_MPI) - add_executable(hello_hdf5Writer_mpi helloHDF5Writer.cpp) - target_link_libraries(hello_hdf5Writer_mpi adios2::cxx11_mpi MPI::MPI_C) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(HDF5 QUIET COMPONENTS C) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_HDF5) + add_executable(adios2_hello_hdf5Writer hdf5Writer_nompi.cpp) + target_link_libraries(adios2_hello_hdf5Writer adios2::cxx11) + install(TARGETS adios2_hello_hdf5Writer RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_hdf5Writer_mpi hdf5Writer.cpp) + target_link_libraries(adios2_hello_hdf5Writer_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_hdf5Writer_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/hello/hdf5Writer/helloHDF5Writer.cpp b/examples/hello/hdf5Writer/hdf5Writer.cpp similarity index 98% rename from examples/hello/hdf5Writer/helloHDF5Writer.cpp rename to examples/hello/hdf5Writer/hdf5Writer.cpp index 7b5e001533..3e09334593 100644 --- a/examples/hello/hdf5Writer/helloHDF5Writer.cpp +++ b/examples/hello/hdf5Writer/hdf5Writer.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloHDF5Writer.cpp: Simple self-descriptive example of how to write a + * hdf5Writer.cpp: Simple self-descriptive example of how to write a * variable to a parallel HDF5 File using MPI processes. * * Created on: March 20, 2017 diff --git a/examples/hello/hdf5Writer/helloHDF5Writer_nompi.cpp b/examples/hello/hdf5Writer/hdf5Writer_nompi.cpp similarity index 96% rename from examples/hello/hdf5Writer/helloHDF5Writer_nompi.cpp rename to examples/hello/hdf5Writer/hdf5Writer_nompi.cpp index 436cde2194..c781519f82 100644 --- a/examples/hello/hdf5Writer/helloHDF5Writer_nompi.cpp +++ b/examples/hello/hdf5Writer/hdf5Writer_nompi.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloHDF5Writer_nompi.cpp no mpi version of helloHDF5Writer.cpp + * hdf5Writer_nompi.cpp no mpi version of helloHDF5Writer.cpp * * Created on: March 20, 2017 * Author: Junmin diff --git a/examples/hello/inlineFWriteCppRead/CMakeLists.txt b/examples/hello/inlineFWriteCppRead/CMakeLists.txt index 64b99b539d..ad5cfbd537 100644 --- a/examples/hello/inlineFWriteCppRead/CMakeLists.txt +++ b/examples/hello/inlineFWriteCppRead/CMakeLists.txt @@ -3,17 +3,36 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -include(FortranCInterface) -FortranCInterface_HEADER(InlineExampleFC.h MACRO_NAMESPACE "FC_") -FortranCInterface_VERIFY(CXX QUIET) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloFWriteCppReadExample) -add_library(InlineMixedLangCPP inlineMixedLang.cpp) -target_link_libraries(InlineMixedLangCPP adios2::cxx11) -target_include_directories(InlineMixedLangCPP - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR} - ) +if(NOT TARGET adios2_core) + set(_components CXX) -add_executable(InlineMixedLangF inlineMixedLang.f90) -target_link_libraries(InlineMixedLangF adios2::fortran InlineMixedLangCPP) -set_target_properties(InlineMixedLangF PROPERTIES LINKER_LANGUAGE Fortran) + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + endif() + if(CMAKE_Fortran_COMPILER_LOADED) + list(APPEND _components Fortran) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_Fortran) + include(FortranCInterface) + FortranCInterface_HEADER(InlineExampleFC.h MACRO_NAMESPACE "FC_") + FortranCInterface_VERIFY(CXX QUIET) + + add_library(adios2_hello_inlineMixedLang inlineMixedLang.cpp) + target_link_libraries(adios2_hello_inlineMixedLang adios2::cxx11) + target_include_directories(adios2_hello_inlineMixedLang PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + install(TARGETS adios2_hello_inlineMixedLang RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_hello_inlineMixedLang_f inlineMixedLang.f90) + target_link_libraries(adios2_hello_inlineMixedLang_f adios2_hello_inlineMixedLang adios2::fortran) + set_target_properties(adios2_hello_inlineMixedLang_f PROPERTIES LINKER_LANGUAGE Fortran) + install(TARGETS adios2_hello_inlineMixedLang_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/hello/inlineMWE/CMakeLists.txt b/examples/hello/inlineMWE/CMakeLists.txt new file mode 100644 index 0000000000..98ac7fcc70 --- /dev/null +++ b/examples/hello/inlineMWE/CMakeLists.txt @@ -0,0 +1,17 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloInlineMWEExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_inlineMWE inlineMWE.cpp) +target_link_libraries(adios2_hello_inlineMWE adios2::cxx11) +install(TARGETS adios2_hello_inlineMWE RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/inlineMWE/inlineMWE.cpp b/examples/hello/inlineMWE/inlineMWE.cpp similarity index 88% rename from examples/inlineMWE/inlineMWE.cpp rename to examples/hello/inlineMWE/inlineMWE.cpp index 41d4ba37a6..5dc5ed6f04 100644 --- a/examples/inlineMWE/inlineMWE.cpp +++ b/examples/hello/inlineMWE/inlineMWE.cpp @@ -1,3 +1,8 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + #include #include diff --git a/examples/hello/inlineReaderWriter/CMakeLists.txt b/examples/hello/inlineReaderWriter/CMakeLists.txt index 25a8334140..cf76d4d0e6 100644 --- a/examples/hello/inlineReaderWriter/CMakeLists.txt +++ b/examples/hello/inlineReaderWriter/CMakeLists.txt @@ -3,10 +3,29 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_inlineReaderWriter helloInlineReaderWriter.cpp) -target_link_libraries(hello_inlineReaderWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloInlineReaderWriterExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_inlineReaderWriter inlineReaderWriter.cpp) +target_link_libraries(adios2_hello_inlineReaderWriter adios2::cxx11) +install(TARGETS adios2_hello_inlineReaderWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(hello_inlineReaderWriter_mpi helloInlineReaderWriter.cpp) - target_link_libraries(hello_inlineReaderWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_inlineReaderWriter_mpi inlineReaderWriter.cpp) + target_link_libraries(adios2_hello_inlineReaderWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_inlineReaderWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/hello/inlineReaderWriter/helloInlineReaderWriter.cpp b/examples/hello/inlineReaderWriter/inlineReaderWriter.cpp similarity index 98% rename from examples/hello/inlineReaderWriter/helloInlineReaderWriter.cpp rename to examples/hello/inlineReaderWriter/inlineReaderWriter.cpp index 3fe9674924..f7ca536bfc 100644 --- a/examples/hello/inlineReaderWriter/helloInlineReaderWriter.cpp +++ b/examples/hello/inlineReaderWriter/inlineReaderWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloInlineReaderWriter.cpp example borrowed from helloBPTimeWriter, using + * inlineReaderWriter.cpp example borrowed from bpTimeWriter, using * the inline engine. Writes a variable using the Advance function for time * aggregation. Time step is saved as an additional (global) single value * variable, just for tracking purposes. diff --git a/examples/hello/skeleton/CMakeLists.txt b/examples/hello/skeleton/CMakeLists.txt index 5e5a35007c..4c6ead50ab 100644 --- a/examples/hello/skeleton/CMakeLists.txt +++ b/examples/hello/skeleton/CMakeLists.txt @@ -3,16 +3,37 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_skeletonWriter helloSkeletonWriter.cpp HelloSkeletonArgs.cpp) -target_link_libraries(hello_skeletonWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloSkeletonExample) -add_executable(hello_skeletonReader helloSkeletonReader.cpp HelloSkeletonArgs.cpp) -target_link_libraries(hello_skeletonReader adios2::cxx11) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_skeletonWriter skeletonWriter.cpp SkeletonArgs.cpp) +target_link_libraries(adios2_hello_skeletonWriter adios2::cxx11) +install(TARGETS adios2_hello_skeletonWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_hello_skeletonReader skeletonReader.cpp SkeletonArgs.cpp) +target_link_libraries(adios2_hello_skeletonReader adios2::cxx11) +install(TARGETS adios2_hello_skeletonReader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(hello_skeletonWriter_mpi helloSkeletonWriter.cpp HelloSkeletonArgs.cpp) - target_link_libraries(hello_skeletonWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_skeletonWriter_mpi skeletonWriter.cpp SkeletonArgs.cpp) + target_link_libraries(adios2_hello_skeletonWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_skeletonWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - add_executable(hello_skeletonReader_mpi helloSkeletonReader.cpp HelloSkeletonArgs.cpp) - target_link_libraries(hello_skeletonReader_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_hello_skeletonReader_mpi skeletonReader.cpp SkeletonArgs.cpp) + target_link_libraries(adios2_hello_skeletonReader_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_skeletonReader_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/hello/skeleton/HelloSkeletonArgs.cpp b/examples/hello/skeleton/SkeletonArgs.cpp similarity index 92% rename from examples/hello/skeleton/HelloSkeletonArgs.cpp rename to examples/hello/skeleton/SkeletonArgs.cpp index 2ee3b8ff64..109ca5388d 100644 --- a/examples/hello/skeleton/HelloSkeletonArgs.cpp +++ b/examples/hello/skeleton/SkeletonArgs.cpp @@ -6,7 +6,7 @@ * Author: Norbert Podhorszki */ -#include "HelloSkeletonArgs.h" +#include "SkeletonArgs.h" #include @@ -42,7 +42,7 @@ static void printUsage(bool isWriter) static unsigned int convertToUint(std::string varName, char *arg) { char *end; - unsigned int retval = std::strtoul(arg, &end, 10); + const auto retval = static_cast(std::strtoul(arg, &end, 10)); if (end[0] || errno == ERANGE) { throw std::invalid_argument("Invalid value given for " + varName + ": " + std::string(arg)); @@ -50,8 +50,7 @@ static unsigned int convertToUint(std::string varName, char *arg) return retval; } -HelloSkeletonArgs::HelloSkeletonArgs(bool isWriter, int argc, char *argv[], int rank, int nproc) -: rank{rank} +SkeletonArgs::SkeletonArgs(bool isWriter, int argc, char *argv[], int rank, int nproc) : rank{rank} { npx = npy = ndx = ndy = steps = sleeptime = 0; gndx = gndy = posx = posy = offsx = offsy = 0; @@ -98,7 +97,7 @@ HelloSkeletonArgs::HelloSkeletonArgs(bool isWriter, int argc, char *argv[], int } } -void HelloSkeletonArgs::DecomposeArray(size_t NX, size_t NY) +void SkeletonArgs::DecomposeArray(size_t NX, size_t NY) { gndx = static_cast(NX); gndy = static_cast(NY); diff --git a/examples/hello/skeleton/HelloSkeletonArgs.h b/examples/hello/skeleton/SkeletonArgs.h similarity index 93% rename from examples/hello/skeleton/HelloSkeletonArgs.h rename to examples/hello/skeleton/SkeletonArgs.h index 7ae34366f0..0433e83950 100644 --- a/examples/hello/skeleton/HelloSkeletonArgs.h +++ b/examples/hello/skeleton/SkeletonArgs.h @@ -11,7 +11,7 @@ #include -class HelloSkeletonArgs +class SkeletonArgs { public: @@ -41,7 +41,7 @@ class HelloSkeletonArgs int rank; // MPI rank unsigned int nproc; // number of processors - HelloSkeletonArgs(bool isWriter, int argc, char *argv[], int rank, int nproc); + SkeletonArgs(bool isWriter, int argc, char *argv[], int rank, int nproc); void DecomposeArray(size_t NX, size_t NY); }; diff --git a/examples/hello/skeleton/HelloSkeletonPrint.h b/examples/hello/skeleton/SkeletonPrint.h similarity index 100% rename from examples/hello/skeleton/HelloSkeletonPrint.h rename to examples/hello/skeleton/SkeletonPrint.h diff --git a/examples/hello/skeleton/hello_bpfile.xml b/examples/hello/skeleton/bpfile.xml similarity index 97% rename from examples/hello/skeleton/hello_bpfile.xml rename to examples/hello/skeleton/bpfile.xml index aeb255fd93..f46b17d38b 100644 --- a/examples/hello/skeleton/hello_bpfile.xml +++ b/examples/hello/skeleton/bpfile.xml @@ -1,6 +1,6 @@ diff --git a/examples/hello/skeleton/hello_skeleton.xml b/examples/hello/skeleton/skeleton.xml similarity index 96% rename from examples/hello/skeleton/hello_skeleton.xml rename to examples/hello/skeleton/skeleton.xml index bbca561454..ed9ad58b9c 100644 --- a/examples/hello/skeleton/hello_skeleton.xml +++ b/examples/hello/skeleton/skeleton.xml @@ -1,6 +1,6 @@ diff --git a/examples/hello/skeleton/helloSkeletonReader.cpp b/examples/hello/skeleton/skeletonReader.cpp similarity index 93% rename from examples/hello/skeleton/helloSkeletonReader.cpp rename to examples/hello/skeleton/skeletonReader.cpp index 5744647b2a..87a070f004 100644 --- a/examples/hello/skeleton/helloSkeletonReader.cpp +++ b/examples/hello/skeleton/skeletonReader.cpp @@ -1,3 +1,8 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + #include #include //std::ios_base::failure #include //std::cout @@ -6,8 +11,8 @@ #include -#include "HelloSkeletonArgs.h" -#include "HelloSkeletonPrint.h" +#include "SkeletonArgs.h" +#include "SkeletonPrint.h" int main(int argc, char *argv[]) { @@ -32,7 +37,7 @@ int main(int argc, char *argv[]) try { - HelloSkeletonArgs settings(false, argc, argv, rank, nproc); + SkeletonArgs settings(false, argc, argv, rank, nproc); /** ADIOS class factory of IO class objects, Debug is ON by default */ #if ADIOS2_USE_MPI diff --git a/examples/hello/skeleton/helloSkeletonWriter.cpp b/examples/hello/skeleton/skeletonWriter.cpp similarity index 93% rename from examples/hello/skeleton/helloSkeletonWriter.cpp rename to examples/hello/skeleton/skeletonWriter.cpp index 407fe967dc..0eb1d43638 100644 --- a/examples/hello/skeleton/helloSkeletonWriter.cpp +++ b/examples/hello/skeleton/skeletonWriter.cpp @@ -13,7 +13,7 @@ #include #include -#include "HelloSkeletonArgs.h" +#include "SkeletonArgs.h" #include @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) try { - HelloSkeletonArgs settings(true, argc, argv, rank, nproc); + SkeletonArgs settings(true, argc, argv, rank, nproc); std::vector myArray(settings.ndx * settings.ndy); @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) { for (size_t i = 0; i < settings.ndx; ++i) { - myArray[idx] = rank + (step / 100.0f); + myArray[idx] = static_cast(rank) + (static_cast(step) / 100.0f); ++idx; } } diff --git a/examples/hello/sstReader/CMakeLists.txt b/examples/hello/sstReader/CMakeLists.txt index eff30267d5..39a0b615c0 100644 --- a/examples/hello/sstReader/CMakeLists.txt +++ b/examples/hello/sstReader/CMakeLists.txt @@ -3,10 +3,35 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_sstReader helloSstReader.cpp) -target_link_libraries(hello_sstReader adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloSstReaderExample) -if(ADIOS2_HAVE_MPI) - add_executable(hello_sstReader_mpi helloSstReader.cpp) - target_link_libraries(hello_sstReader_mpi adios2::cxx11_mpi MPI::MPI_C) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + if(NOT WIN32) + find_package(LIBFABRIC 1.6 QUIET) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_SST) + add_executable(adios2_hello_sstReader sstReader.cpp) + target_link_libraries(adios2_hello_sstReader adios2::cxx11) + install(TARGETS adios2_hello_sstReader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_sstReader_mpi sstReader.cpp) + target_link_libraries(adios2_hello_sstReader_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_sstReader_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/hello/sstReader/helloSstReader.cpp b/examples/hello/sstReader/sstReader.cpp similarity index 97% rename from examples/hello/sstReader/helloSstReader.cpp rename to examples/hello/sstReader/sstReader.cpp index 8dfcb1ba0c..56630b3eea 100644 --- a/examples/hello/sstReader/helloSstReader.cpp +++ b/examples/hello/sstReader/sstReader.cpp @@ -2,10 +2,10 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloSstReader.cpp + * sstReader.cpp * * Created on: Aug 17, 2017 -v * Author: Greg Eisenhauer + * Author: Greg Eisenhauer */ #include diff --git a/examples/hello/sstWriter/CMakeLists.txt b/examples/hello/sstWriter/CMakeLists.txt index 637e00bfd4..f5adca3e58 100644 --- a/examples/hello/sstWriter/CMakeLists.txt +++ b/examples/hello/sstWriter/CMakeLists.txt @@ -3,10 +3,35 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_sstWriter helloSstWriter.cpp) -target_link_libraries(hello_sstWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloSstWriterExample) -if(ADIOS2_HAVE_MPI) - add_executable(hello_sstWriter_mpi helloSstWriter.cpp) - target_link_libraries(hello_sstWriter_mpi adios2::cxx11_mpi MPI::MPI_C) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + if (NOT WIN32) + find_package(LIBFABRIC 1.6 QUIET) + endif () + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_SST) + add_executable(adios2_hello_sstWriter sstWriter.cpp) + target_link_libraries(adios2_hello_sstWriter adios2::cxx11) + install(TARGETS adios2_hello_sstWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_sstWriter_mpi sstWriter.cpp) + target_link_libraries(adios2_hello_sstWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_sstWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/hello/sstWriter/helloSstWriter.cpp b/examples/hello/sstWriter/sstWriter.cpp similarity index 81% rename from examples/hello/sstWriter/helloSstWriter.cpp rename to examples/hello/sstWriter/sstWriter.cpp index e4c58b1b17..02d4981171 100644 --- a/examples/hello/sstWriter/helloSstWriter.cpp +++ b/examples/hello/sstWriter/sstWriter.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * helloSstWriter.cpp + * sstWriter.cpp * * Created on: Aug 17, 2017 * Author: Greg Eisenhauer @@ -35,11 +35,12 @@ int main(int argc, char *argv[]) size = 1; #endif - std::vector myFloats = {(float)10.0 * rank + 0, (float)10.0 * rank + 1, - (float)10.0 * rank + 2, (float)10.0 * rank + 3, - (float)10.0 * rank + 4, (float)10.0 * rank + 5, - (float)10.0 * rank + 6, (float)10.0 * rank + 7, - (float)10.0 * rank + 8, (float)10.0 * rank + 9}; + std::vector myFloats = { + static_cast(10.0 * rank + 0), static_cast(10.0 * rank + 1), + static_cast(10.0 * rank + 2), static_cast(10.0 * rank + 3), + static_cast(10.0 * rank + 4), static_cast(10.0 * rank + 5), + static_cast(10.0 * rank + 6), static_cast(10.0 * rank + 7), + static_cast(10.0 * rank + 8), static_cast(10.0 * rank + 9)}; const std::size_t Nx = myFloats.size(); try diff --git a/examples/hello/sstWriter/helloSstWriter.py b/examples/hello/sstWriter/sstWriter.py similarity index 72% rename from examples/hello/sstWriter/helloSstWriter.py rename to examples/hello/sstWriter/sstWriter.py index 99508627ad..08a7a8270a 100644 --- a/examples/hello/sstWriter/helloSstWriter.py +++ b/examples/hello/sstWriter/sstWriter.py @@ -12,13 +12,13 @@ # ADIOS IO sstIO = adios.DeclareIO("myIO") -sstIO.SetEngine('Sst') -myArray = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0], - dtype='f') +sstIO.SetEngine("Sst") +myArray = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0], dtype="f") myArray = 10.0 * rank + myArray nx = len(myArray) -ioArray = sstIO.DefineVariable("bpFloats", myArray, [size * nx], - [rank * nx], [nx], adios2.ConstantDims) +ioArray = sstIO.DefineVariable( + "bpFloats", myArray, [size * nx], [rank * nx], [nx], adios2.ConstantDims +) sstFileWriter = sstIO.Open("helloSst", adios2.Mode.Write) sstFileWriter.BeginStep() sstFileWriter.Put(ioArray, myArray, adios2.Mode.Sync) diff --git a/examples/inlineMWE/CMakeLists.txt b/examples/inlineMWE/CMakeLists.txt deleted file mode 100644 index 3773d2d3f7..0000000000 --- a/examples/inlineMWE/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(inlineMWE inlineMWE.cpp) -target_link_libraries(inlineMWE adios2::cxx11) diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt index 5fed9662d6..013d696b17 100644 --- a/examples/plugins/CMakeLists.txt +++ b/examples/plugins/CMakeLists.txt @@ -4,4 +4,6 @@ #------------------------------------------------------------------------------# add_subdirectory(engine) -add_subdirectory(operator) +if(ADIOS2_HAVE_Sodium) + add_subdirectory(operator) +endif() diff --git a/examples/plugins/engine/CMakeLists.txt b/examples/plugins/engine/CMakeLists.txt index a611c0b8b7..d902043a83 100644 --- a/examples/plugins/engine/CMakeLists.txt +++ b/examples/plugins/engine/CMakeLists.txt @@ -3,33 +3,39 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# +cmake_minimum_required(VERSION 3.12) +project(ADIOS2PluginsEngineExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + include(GenerateExportHeader) -add_library(PluginEngineWrite - ExampleWritePlugin.cpp -) -target_link_libraries(PluginEngineWrite adios2::cxx11 adios2_core) -generate_export_header(PluginEngineWrite BASE_NAME plugin_engine_write) -target_include_directories(PluginEngineWrite PUBLIC + +add_library(adios2_plugins_exampleWritePlugin ExampleWritePlugin.cpp) +target_link_libraries(adios2_plugins_exampleWritePlugin adios2::cxx11 adios2_core) +generate_export_header(adios2_plugins_exampleWritePlugin BASE_NAME plugin_engine_write) +target_include_directories(adios2_plugins_exampleWritePlugin PUBLIC $ $ ) +install(TARGETS adios2_plugins_exampleWritePlugin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -add_library(PluginEngineRead - ExampleReadPlugin.cpp -) -target_link_libraries(PluginEngineRead adios2::cxx11 adios2_core) -generate_export_header(PluginEngineRead BASE_NAME plugin_engine_read) -target_include_directories(PluginEngineRead PUBLIC +add_library(adios2_plugins_exampleReadPlugin ExampleReadPlugin.cpp) +target_link_libraries(adios2_plugins_exampleReadPlugin adios2::cxx11 adios2_core) +generate_export_header(adios2_plugins_exampleReadPlugin BASE_NAME plugin_engine_read) +target_include_directories(adios2_plugins_exampleReadPlugin PUBLIC $ $ ) +install(TARGETS adios2_plugins_exampleReadPlugin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -add_executable(examplePluginEngine_write - examplePluginEngine_write.cpp -) -target_link_libraries(examplePluginEngine_write adios2::cxx11) +add_executable(adios2_plugins_examplePluginEngineWrite examplePluginEngineWrite.cpp) +target_link_libraries(adios2_plugins_examplePluginEngineWrite adios2::cxx11) +install(TARGETS adios2_plugins_examplePluginEngineWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -add_executable(examplePluginEngine_read - examplePluginEngine_read.cpp -) -target_link_libraries(examplePluginEngine_read adios2::cxx11) +add_executable(adios2_plugins_examplePluginEngineRead examplePluginEngineRead.cpp) +target_link_libraries(adios2_plugins_examplePluginEngineRead adios2::cxx11) +install(TARGETS adios2_plugins_examplePluginEngineRead RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/plugins/engine/examplePluginEngine_read.cpp b/examples/plugins/engine/examplePluginEngineRead.cpp similarity index 97% rename from examples/plugins/engine/examplePluginEngine_read.cpp rename to examples/plugins/engine/examplePluginEngineRead.cpp index 17042868dc..684ea561c1 100644 --- a/examples/plugins/engine/examplePluginEngine_read.cpp +++ b/examples/plugins/engine/examplePluginEngineRead.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * examplePluginEngine_read.cpp example showing how to use ExampleReadPlugin + * examplePluginEngineRead.cpp example showing how to use ExampleReadPlugin * engine * * Created on: July 5, 2021 diff --git a/examples/plugins/engine/examplePluginEngine_write.cpp b/examples/plugins/engine/examplePluginEngineWrite.cpp similarity index 97% rename from examples/plugins/engine/examplePluginEngine_write.cpp rename to examples/plugins/engine/examplePluginEngineWrite.cpp index bb6f6f51b9..3d142d36c6 100644 --- a/examples/plugins/engine/examplePluginEngine_write.cpp +++ b/examples/plugins/engine/examplePluginEngineWrite.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * examplePluginEngine_write.cpp example showing how to use ExampleWritePlugin + * examplePluginEngineWrite.cpp example showing how to use ExampleWritePlugin * engine * * Created on: July 5, 2021 diff --git a/examples/plugins/engine/example_engine.xml b/examples/plugins/engine/example_engine.xml index 412c1a9684..46393a70d7 100644 --- a/examples/plugins/engine/example_engine.xml +++ b/examples/plugins/engine/example_engine.xml @@ -10,7 +10,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/plugins/operator/CMakeLists.txt b/examples/plugins/operator/CMakeLists.txt index 8881bb8f16..f71e6dca20 100644 --- a/examples/plugins/operator/CMakeLists.txt +++ b/examples/plugins/operator/CMakeLists.txt @@ -2,12 +2,24 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(exampleOperatorPlugin_write - examplePluginOperator_write.cpp -) -target_link_libraries(exampleOperatorPlugin_write adios2::cxx11) - -add_executable(exampleOperatorPlugin_read - examplePluginOperator_read.cpp -) -target_link_libraries(exampleOperatorPlugin_read adios2::cxx11) + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2PluginsOperatorExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(Sodium QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_Sodium) + add_executable(adios2_plugins_exampleOperatorPluginWrite examplePluginOperatorWrite.cpp) + target_link_libraries(adios2_plugins_exampleOperatorPluginWrite adios2::cxx11) + install(TARGETS adios2_plugins_exampleOperatorPluginWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_plugins_exampleOperatorPluginRead examplePluginOperatorRead.cpp) + target_link_libraries(adios2_plugins_exampleOperatorPluginRead adios2::cxx11) + install(TARGETS adios2_plugins_exampleOperatorPluginRead RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() \ No newline at end of file diff --git a/examples/plugins/operator/examplePluginOperator_read.cpp b/examples/plugins/operator/examplePluginOperatorRead.cpp similarity index 97% rename from examples/plugins/operator/examplePluginOperator_read.cpp rename to examples/plugins/operator/examplePluginOperatorRead.cpp index 01e47e92a5..e48fff3b74 100644 --- a/examples/plugins/operator/examplePluginOperator_read.cpp +++ b/examples/plugins/operator/examplePluginOperatorRead.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * examplePluginOperator_read.cpp example showing how to use EncryptionOperator + * examplePluginOperatorRead.cpp example showing how to use EncryptionOperator * plugin * * Created on: July 5, 2021 diff --git a/examples/plugins/operator/examplePluginOperator_write.cpp b/examples/plugins/operator/examplePluginOperatorWrite.cpp similarity index 100% rename from examples/plugins/operator/examplePluginOperator_write.cpp rename to examples/plugins/operator/examplePluginOperatorWrite.cpp diff --git a/examples/query/CMakeLists.txt b/examples/query/CMakeLists.txt deleted file mode 100644 index 444dda6fef..0000000000 --- a/examples/query/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -if(ADIOS2_HAVE_MPI) - add_executable(queryTest test.cpp) - target_link_libraries(queryTest adios2::cxx11_mpi MPI::MPI_C) -endif() - diff --git a/examples/simulations/CMakeLists.txt b/examples/simulations/CMakeLists.txt new file mode 100644 index 0000000000..93f7e8c70c --- /dev/null +++ b/examples/simulations/CMakeLists.txt @@ -0,0 +1,3 @@ +if(ADIOS2_HAVE_MPI) + add_subdirectory(heatTransfer) +endif() diff --git a/examples/heatTransfer/CMakeLists.txt b/examples/simulations/heatTransfer/CMakeLists.txt similarity index 75% rename from examples/heatTransfer/CMakeLists.txt rename to examples/simulations/heatTransfer/CMakeLists.txt index 48a07f6fd2..7b00974587 100644 --- a/examples/heatTransfer/CMakeLists.txt +++ b/examples/simulations/heatTransfer/CMakeLists.txt @@ -3,7 +3,10 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_subdirectory(write) -add_subdirectory(read) -add_subdirectory(read_fileonly) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2SimulationsHeatTransferExample) + add_subdirectory(inline) +add_subdirectory(read) +add_subdirectory(readFileOnly) +add_subdirectory(write) diff --git a/examples/heatTransfer/ReadMe.md b/examples/simulations/heatTransfer/ReadMe.md similarity index 75% rename from examples/heatTransfer/ReadMe.md rename to examples/simulations/heatTransfer/ReadMe.md index 9ad00c1681..a378c72f96 100644 --- a/examples/heatTransfer/ReadMe.md +++ b/examples/simulations/heatTransfer/ReadMe.md @@ -1,4 +1,4 @@ -examples/heatTransfer +### heatTransfer example This example solves a 2D Poisson equation for temperature in homogeneous media using finite differences. This examples shows a straight-forward way to hook @@ -7,7 +7,7 @@ an application to the ADIOS2 library for its IO. 1. write: illustrates the Write API as well as has implementations of other IO libraries - * adios 1.x + * adios 2 * hdf5 sequential, separate file per process per step * phdf5 parallel, steps appended to the same one file @@ -17,7 +17,7 @@ an application to the ADIOS2 library for its IO. * in situ to read step by step as the writer outputs them (need to run with a suitable engine) -3. read_fileonly: illustrates reading all output steps at once (a single read +3. readFileOnly: illustrates reading all output steps at once (a single read statement) into a single contiguous memory block. This approach only works for post-mortem processing. @@ -38,12 +38,12 @@ Writer usage: heatTransfer config output N M nx ny steps iterations steps: the total number of steps to output iterations: one step consist of this many iterations -The ADIOS2 executable needs an XML config file to select the Engine used for the output. The engines are: File, BP4 and HDF5, the corresponding XML config files are in the examples/heatTransfer/ directory. The "File" engine will be BP4 or HDF5 depending on the extension of the file name. +The ADIOS2 executable needs an XML config file to select the Engine used for the output. The engines are: File, BP4 and HDF5, the corresponding XML config files are in the examples/simulations/heatTransfer/ directory. The "File" engine will be BP4 or HDF5 depending on the extension of the file name. The adios1, ph5 and hdf5 versions of the example do not use XML config files, so just type "none" for the config argument. -$ mpirun -np 12 ./bin/heatTransfer_write_adios2 ../examples/heatTransfer/heat_file.xml heat.bp 4 3 5 10 10 10 -$ mpirun -np 12 ./bin/heatTransfer_write_adios2 ../examples/heatTransfer/heat_file.xml heat.h5 4 3 5 10 10 10 +$ mpirun -np 12 ./bin/adios2_simulations_heatTransferWrite ../examples/simulations/heatTransfer/heat_file.xml heat.bp 4 3 5 10 10 10 +$ mpirun -np 12 ./bin/adios2_simulations_heatTransferWrite ../examples/simulations/heatTransfer/heat_file.xml heat.h5 4 3 5 10 10 10 2. Read the output step-by-step and print data into text files (data. per reader process) @@ -55,7 +55,7 @@ Reader Usage: heatRead config input N M M: number of processes in Y dimension -$ mpirun -np 2 ./bin/heatTransfer_read ../examples/heatTransfer/heat_file.xml heat 2 1 +$ mpirun -np 2 ./bin/heatTransfer_read ../examples/simulations/heatTransfer/heat_file.xml heat 2 1 Notes: diff --git a/examples/heatTransfer/heat_bp3.xml b/examples/simulations/heatTransfer/heat_bp3.xml similarity index 97% rename from examples/heatTransfer/heat_bp3.xml rename to examples/simulations/heatTransfer/heat_bp3.xml index 6b004a3c6d..bc5e91fc53 100644 --- a/examples/heatTransfer/heat_bp3.xml +++ b/examples/simulations/heatTransfer/heat_bp3.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_bp3_zfp.xml b/examples/simulations/heatTransfer/heat_bp3_zfp.xml similarity index 98% rename from examples/heatTransfer/heat_bp3_zfp.xml rename to examples/simulations/heatTransfer/heat_bp3_zfp.xml index b2220e480a..ab7fc71756 100644 --- a/examples/heatTransfer/heat_bp3_zfp.xml +++ b/examples/simulations/heatTransfer/heat_bp3_zfp.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_bp4.xml b/examples/simulations/heatTransfer/heat_bp4.xml similarity index 97% rename from examples/heatTransfer/heat_bp4.xml rename to examples/simulations/heatTransfer/heat_bp4.xml index 5373aa9fca..dd7ba50541 100644 --- a/examples/heatTransfer/heat_bp4.xml +++ b/examples/simulations/heatTransfer/heat_bp4.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_bp4_zfp.xml b/examples/simulations/heatTransfer/heat_bp4_zfp.xml similarity index 98% rename from examples/heatTransfer/heat_bp4_zfp.xml rename to examples/simulations/heatTransfer/heat_bp4_zfp.xml index f7401bc5de..b6af72c1ce 100644 --- a/examples/heatTransfer/heat_bp4_zfp.xml +++ b/examples/simulations/heatTransfer/heat_bp4_zfp.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_dataman.xml b/examples/simulations/heatTransfer/heat_dataman.xml similarity index 97% rename from examples/heatTransfer/heat_dataman.xml rename to examples/simulations/heatTransfer/heat_dataman.xml index e7cbddb66a..dc5164e8d5 100644 --- a/examples/heatTransfer/heat_dataman.xml +++ b/examples/simulations/heatTransfer/heat_dataman.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_dataspaces.xml b/examples/simulations/heatTransfer/heat_dataspaces.xml similarity index 91% rename from examples/heatTransfer/heat_dataspaces.xml rename to examples/simulations/heatTransfer/heat_dataspaces.xml index 3d8fabe929..690436b548 100644 --- a/examples/heatTransfer/heat_dataspaces.xml +++ b/examples/simulations/heatTransfer/heat_dataspaces.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_file.xml b/examples/simulations/heatTransfer/heat_file.xml similarity index 97% rename from examples/heatTransfer/heat_file.xml rename to examples/simulations/heatTransfer/heat_file.xml index b5bd9a970e..1a2392301e 100644 --- a/examples/heatTransfer/heat_file.xml +++ b/examples/simulations/heatTransfer/heat_file.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_hdf5.xml b/examples/simulations/heatTransfer/heat_hdf5.xml similarity index 97% rename from examples/heatTransfer/heat_hdf5.xml rename to examples/simulations/heatTransfer/heat_hdf5.xml index a4abcf1290..334b9841f4 100644 --- a/examples/heatTransfer/heat_hdf5.xml +++ b/examples/simulations/heatTransfer/heat_hdf5.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_inline.xml b/examples/simulations/heatTransfer/heat_inline.xml similarity index 96% rename from examples/heatTransfer/heat_inline.xml rename to examples/simulations/heatTransfer/heat_inline.xml index 7de2cb351b..e01923f265 100644 --- a/examples/heatTransfer/heat_inline.xml +++ b/examples/simulations/heatTransfer/heat_inline.xml @@ -1,6 +1,6 @@ diff --git a/examples/heatTransfer/heat_ssc.xml b/examples/simulations/heatTransfer/heat_ssc.xml similarity index 94% rename from examples/heatTransfer/heat_ssc.xml rename to examples/simulations/heatTransfer/heat_ssc.xml index 5f37add34b..435b12df9f 100644 --- a/examples/heatTransfer/heat_ssc.xml +++ b/examples/simulations/heatTransfer/heat_ssc.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_sst_bp_rdma.xml b/examples/simulations/heatTransfer/heat_sst_bp_rdma.xml similarity index 92% rename from examples/heatTransfer/heat_sst_bp_rdma.xml rename to examples/simulations/heatTransfer/heat_sst_bp_rdma.xml index a324215006..9c321e76b5 100644 --- a/examples/heatTransfer/heat_sst_bp_rdma.xml +++ b/examples/simulations/heatTransfer/heat_sst_bp_rdma.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_sst_ffs.xml b/examples/simulations/heatTransfer/heat_sst_ffs.xml similarity index 91% rename from examples/heatTransfer/heat_sst_ffs.xml rename to examples/simulations/heatTransfer/heat_sst_ffs.xml index 1e8712cf93..6332d8e46e 100644 --- a/examples/heatTransfer/heat_sst_ffs.xml +++ b/examples/simulations/heatTransfer/heat_sst_ffs.xml @@ -1,7 +1,7 @@ diff --git a/examples/heatTransfer/heat_sst_ffs_rdma.xml b/examples/simulations/heatTransfer/heat_sst_ffs_rdma.xml similarity index 92% rename from examples/heatTransfer/heat_sst_ffs_rdma.xml rename to examples/simulations/heatTransfer/heat_sst_ffs_rdma.xml index ed2b0be094..08a0844b54 100644 --- a/examples/heatTransfer/heat_sst_ffs_rdma.xml +++ b/examples/simulations/heatTransfer/heat_sst_ffs_rdma.xml @@ -1,7 +1,7 @@ diff --git a/examples/simulations/heatTransfer/inline/CMakeLists.txt b/examples/simulations/heatTransfer/inline/CMakeLists.txt new file mode 100644 index 0000000000..4e41311ce9 --- /dev/null +++ b/examples/simulations/heatTransfer/inline/CMakeLists.txt @@ -0,0 +1,34 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2SimulationsHeatTransferInlineExample) + +if(NOT TARGET adios2_core) + set(_components C CXX) + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(Threads QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI AND Threads_FOUND) + add_executable(adios2_simulations_heatTransferInline + main.cpp + InlineIO.cpp + ../write/HeatTransfer.cpp + ../write/Settings.cpp + ) + target_link_libraries(adios2_simulations_heatTransferInline adios2::cxx11_mpi MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS adios2_simulations_heatTransferInline RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/heatTransfer/inline/InlineIO.cpp b/examples/simulations/heatTransfer/inline/InlineIO.cpp similarity index 100% rename from examples/heatTransfer/inline/InlineIO.cpp rename to examples/simulations/heatTransfer/inline/InlineIO.cpp diff --git a/examples/heatTransfer/inline/InlineIO.h b/examples/simulations/heatTransfer/inline/InlineIO.h similarity index 100% rename from examples/heatTransfer/inline/InlineIO.h rename to examples/simulations/heatTransfer/inline/InlineIO.h diff --git a/examples/heatTransfer/inline/main.cpp b/examples/simulations/heatTransfer/inline/main.cpp similarity index 100% rename from examples/heatTransfer/inline/main.cpp rename to examples/simulations/heatTransfer/inline/main.cpp diff --git a/examples/simulations/heatTransfer/read/CMakeLists.txt b/examples/simulations/heatTransfer/read/CMakeLists.txt new file mode 100644 index 0000000000..fcc241a2fe --- /dev/null +++ b/examples/simulations/heatTransfer/read/CMakeLists.txt @@ -0,0 +1,31 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2SimulationsHeatTransferReadExample) + +if(NOT TARGET adios2_core) + set(_components C CXX) + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI) + add_executable(adios2_simulations_heatTransferRead + heatRead.cpp + PrintDataStep.h + ReadSettings.cpp + ) + target_link_libraries(adios2_simulations_heatTransferRead adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_simulations_heatTransferRead RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/heatTransfer/read/PrintDataStep.h b/examples/simulations/heatTransfer/read/PrintDataStep.h similarity index 100% rename from examples/heatTransfer/read/PrintDataStep.h rename to examples/simulations/heatTransfer/read/PrintDataStep.h diff --git a/examples/heatTransfer/read/ReadSettings.cpp b/examples/simulations/heatTransfer/read/ReadSettings.cpp similarity index 100% rename from examples/heatTransfer/read/ReadSettings.cpp rename to examples/simulations/heatTransfer/read/ReadSettings.cpp diff --git a/examples/heatTransfer/read/ReadSettings.h b/examples/simulations/heatTransfer/read/ReadSettings.h similarity index 100% rename from examples/heatTransfer/read/ReadSettings.h rename to examples/simulations/heatTransfer/read/ReadSettings.h diff --git a/examples/heatTransfer/read/heatRead.cpp b/examples/simulations/heatTransfer/read/heatRead.cpp similarity index 100% rename from examples/heatTransfer/read/heatRead.cpp rename to examples/simulations/heatTransfer/read/heatRead.cpp diff --git a/examples/simulations/heatTransfer/readFileOnly/CMakeLists.txt b/examples/simulations/heatTransfer/readFileOnly/CMakeLists.txt new file mode 100644 index 0000000000..5cb5dd3c4d --- /dev/null +++ b/examples/simulations/heatTransfer/readFileOnly/CMakeLists.txt @@ -0,0 +1,27 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2SimulationsHeatTransferReadFileOnlyExample) + +if(NOT TARGET adios2_core) + set(_components C CXX) + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI) + add_executable(adios2_simulations_heatTransferReadFileOnly heatReadFileOnly.cpp PrintData.h) + target_link_libraries(adios2_simulations_heatTransferReadFileOnly adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_simulations_heatTransferReadFileOnly RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif () diff --git a/examples/heatTransfer/read_fileonly/PrintData.h b/examples/simulations/heatTransfer/readFileOnly/PrintData.h similarity index 100% rename from examples/heatTransfer/read_fileonly/PrintData.h rename to examples/simulations/heatTransfer/readFileOnly/PrintData.h diff --git a/examples/heatTransfer/read_fileonly/heatRead_adios2.cpp b/examples/simulations/heatTransfer/readFileOnly/heatReadFileOnly.cpp similarity index 96% rename from examples/heatTransfer/read_fileonly/heatRead_adios2.cpp rename to examples/simulations/heatTransfer/readFileOnly/heatReadFileOnly.cpp index af7d6dfb5e..28ba45d18e 100644 --- a/examples/heatTransfer/read_fileonly/heatRead_adios2.cpp +++ b/examples/simulations/heatTransfer/readFileOnly/heatReadFileOnly.cpp @@ -1,15 +1,14 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ #include #include "adios2.h" #include -#include #include -#include -#include -#include -#include #include #include "PrintData.h" diff --git a/examples/simulations/heatTransfer/write/CMakeLists.txt b/examples/simulations/heatTransfer/write/CMakeLists.txt new file mode 100644 index 0000000000..7f1378c982 --- /dev/null +++ b/examples/simulations/heatTransfer/write/CMakeLists.txt @@ -0,0 +1,81 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2SimulationsHeatTransferWriteExample) + +if(NOT TARGET adios2_core) + set(_components C CXX) + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(Threads QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if (ADIOS2_HAVE_MPI AND Threads_FOUND) + add_executable(adios2_simulations_heatTransferWrite + main.cpp + HeatTransfer.cpp + Settings.cpp + IO_adios2.cpp + ) + target_link_libraries(adios2_simulations_heatTransferWrite adios2::cxx11_mpi MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS adios2_simulations_heatTransferWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_simulations_heatTransferWrite_ascii + main.cpp + HeatTransfer.cpp + Settings.cpp + IO_ascii.cpp + ) + target_link_libraries(adios2_simulations_heatTransferWrite_ascii MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS adios2_simulations_heatTransferWrite_ascii RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_HDF5) + add_executable(adios2_simulations_heatTransferWrite_hdf5 + main.cpp + HeatTransfer.cpp + Settings.cpp + IO_hdf5_a.cpp + ) + target_include_directories(adios2_simulations_heatTransferWrite_hdf5 PRIVATE ${HDF5_C_INCLUDE_DIRS}) + target_link_libraries(adios2_simulations_heatTransferWrite_hdf5 + ${HDF5_C_LIBRARIES} MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS adios2_simulations_heatTransferWrite_hdf5 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(HDF5_IS_PARALLEL) + add_executable(adios2_simulations_heatTransferWrite_ph5 + main.cpp + HeatTransfer.cpp + Settings.cpp + IO_ph5.cpp + ) + target_include_directories(adios2_simulations_heatTransferWrite_ph5 PRIVATE ${HDF5_C_INCLUDE_DIRS}) + target_link_libraries(adios2_simulations_heatTransferWrite_ph5 + ${HDF5_C_LIBRARIES} MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS adios2_simulations_heatTransferWrite_ph5 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() + + if(NOT (HDF5_VERSION VERSION_LESS 1.11)) + add_executable(adios2_simulations_heatTransferWrite_h5mixer + main.cpp + HeatTransfer.cpp + Settings.cpp + IO_h5mixer.cpp + ) + target_link_libraries(adios2_simulations_heatTransferWrite_h5mixer + adios2::cxx11_mpi MPI::MPI_C ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS adios2_simulations_heatTransferWrite_h5mixer RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() + endif() +endif() diff --git a/examples/heatTransfer/write/HeatTransfer.cpp b/examples/simulations/heatTransfer/write/HeatTransfer.cpp similarity index 100% rename from examples/heatTransfer/write/HeatTransfer.cpp rename to examples/simulations/heatTransfer/write/HeatTransfer.cpp diff --git a/examples/heatTransfer/write/HeatTransfer.h b/examples/simulations/heatTransfer/write/HeatTransfer.h similarity index 100% rename from examples/heatTransfer/write/HeatTransfer.h rename to examples/simulations/heatTransfer/write/HeatTransfer.h diff --git a/examples/heatTransfer/write/IO.h b/examples/simulations/heatTransfer/write/IO.h similarity index 100% rename from examples/heatTransfer/write/IO.h rename to examples/simulations/heatTransfer/write/IO.h diff --git a/examples/heatTransfer/write/IO_adios2.cpp b/examples/simulations/heatTransfer/write/IO_adios2.cpp similarity index 99% rename from examples/heatTransfer/write/IO_adios2.cpp rename to examples/simulations/heatTransfer/write/IO_adios2.cpp index b983f3a0bc..b33c2b55ff 100644 --- a/examples/heatTransfer/write/IO_adios2.cpp +++ b/examples/simulations/heatTransfer/write/IO_adios2.cpp @@ -12,7 +12,7 @@ #include -#include +#include "adios2.h" adios2::ADIOS ad; adios2::Engine bpWriter; diff --git a/examples/heatTransfer/write/IO_ascii.cpp b/examples/simulations/heatTransfer/write/IO_ascii.cpp similarity index 100% rename from examples/heatTransfer/write/IO_ascii.cpp rename to examples/simulations/heatTransfer/write/IO_ascii.cpp diff --git a/examples/heatTransfer/write/IO_h5mixer.cpp b/examples/simulations/heatTransfer/write/IO_h5mixer.cpp similarity index 100% rename from examples/heatTransfer/write/IO_h5mixer.cpp rename to examples/simulations/heatTransfer/write/IO_h5mixer.cpp diff --git a/examples/heatTransfer/write/IO_hdf5_a.cpp b/examples/simulations/heatTransfer/write/IO_hdf5_a.cpp similarity index 96% rename from examples/heatTransfer/write/IO_hdf5_a.cpp rename to examples/simulations/heatTransfer/write/IO_hdf5_a.cpp index 2546e03e23..4f2e54c693 100644 --- a/examples/heatTransfer/write/IO_hdf5_a.cpp +++ b/examples/simulations/heatTransfer/write/IO_hdf5_a.cpp @@ -49,7 +49,7 @@ void IO::write(int step, const HeatTransfer &ht, const Settings &s, MPI_Comm com double total_time = MPI_Wtime() - time_start; uint64_t adios_totalsize = 2 * sizeof(int) + 2 * s.ndx * s.ndy * sizeof(double); uint64_t sizeMB = adios_totalsize * s.nproc / 1024 / 1024 / 1024; // size in MB - double mbs = sizeMB / total_time; + double mbs = static_cast(sizeMB) / total_time; if (s.rank == 0) std::cout << "Step " << step << ": " << m_outputfilename << " " << sizeMB << " " << total_time << "" << mbs << std::endl; diff --git a/examples/heatTransfer/write/IO_ph5.cpp b/examples/simulations/heatTransfer/write/IO_ph5.cpp similarity index 100% rename from examples/heatTransfer/write/IO_ph5.cpp rename to examples/simulations/heatTransfer/write/IO_ph5.cpp diff --git a/examples/heatTransfer/write/Settings.cpp b/examples/simulations/heatTransfer/write/Settings.cpp similarity index 100% rename from examples/heatTransfer/write/Settings.cpp rename to examples/simulations/heatTransfer/write/Settings.cpp diff --git a/examples/heatTransfer/write/Settings.h b/examples/simulations/heatTransfer/write/Settings.h similarity index 100% rename from examples/heatTransfer/write/Settings.h rename to examples/simulations/heatTransfer/write/Settings.h diff --git a/examples/heatTransfer/write/main.cpp b/examples/simulations/heatTransfer/write/main.cpp similarity index 100% rename from examples/heatTransfer/write/main.cpp rename to examples/simulations/heatTransfer/write/main.cpp diff --git a/examples/useCases/CMakeLists.txt b/examples/useCases/CMakeLists.txt index f5de8aeacf..e53d930f80 100644 --- a/examples/useCases/CMakeLists.txt +++ b/examples/useCases/CMakeLists.txt @@ -3,5 +3,5 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# +add_subdirectory(fidesOneCell) add_subdirectory(insituGlobalArrays) - diff --git a/examples/useCases/fidesOneCell/CMakeLists.txt b/examples/useCases/fidesOneCell/CMakeLists.txt new file mode 100644 index 0000000000..d64277fc57 --- /dev/null +++ b/examples/useCases/fidesOneCell/CMakeLists.txt @@ -0,0 +1,17 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2UseCasesFidesOneCellExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_useCases_fidesOneCell fidesOneCell.cpp) +target_link_libraries(adios2_useCases_fidesOneCell adios2::cxx11) +install(TARGETS adios2_useCases_fidesOneCell RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/useCases/fidesOneCell/ReadMe.md b/examples/useCases/fidesOneCell/ReadMe.md new file mode 100644 index 0000000000..ef39aa28e0 --- /dev/null +++ b/examples/useCases/fidesOneCell/ReadMe.md @@ -0,0 +1,37 @@ +Single cell example for visualization with Fides schema in ParaView +------------------------------------------------------------------- + +This example writes 8 points in 3D space, the corners of a box, and then defines a single hexagon cell of those eight +points. +The coordinates of the points are stored in three 1D arrays, separating the X-Y-Z coordinates. + +The cell is the enumeration of the points connected in the order of a hexagon prescribed by VTK, see +Figure 19-20 in the VTK User Guide, type VTK_HEXAHEDRON in page 480 (page 494 in the PDF). +https://vtk.org/wp-content/uploads/2021/08/VTKUsersGuide.pdf + +The visualization schema is described in the fidesOneCell.json file, according +to https://fides.readthedocs.io/en/latest/schema/schema.html + +We compose the coordinate system as a composite of the three 1D arrays for X, Y and Z coordinates. This is just an +enumeration of the N points in space (N = size of X = size of Y = size of Z) , in contrast to other examples where X, Y, +Z is combined to specify a structured grid (number of points = size of X * size of Y * size of Z). + +In ParaView, one opens the fidesOneCell.json file and adds an property "source" with the value of the full path of the +onecell.bp. See left-middle Properties box in the ParaView window in the image paraview-onecell-step0.png. Then hit +Apply button and a gray box should appear (the single cell visualized). which can be rotated on screen. Then one must +color the box with the data ("pointdata") to get the pictures shown in the included images. + +Note that the dataset over the points is called "DataOnPoints" in the onecell.bp file, but it is called "pointdata" in +the Fides schema to demonstrate which name is which (ParaView presents pointdata to the user while reading the +DataOnPoints array from the file). + +First step of onecell.bp in ParaView: + +paraview-onecell-step0.png + +Last step of onecell.bp in ParaView: + +paraview-onecell-step9.png + diff --git a/examples/fides/01_onecell/fides_onecell.cpp b/examples/useCases/fidesOneCell/fidesOneCell.cpp similarity index 97% rename from examples/fides/01_onecell/fides_onecell.cpp rename to examples/useCases/fidesOneCell/fidesOneCell.cpp index d02c82750d..e012965fcc 100644 --- a/examples/fides/01_onecell/fides_onecell.cpp +++ b/examples/useCases/fidesOneCell/fidesOneCell.cpp @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) writer.Put(varPointData, pointdata); writer.Put(varCellData, celldata); writer.Put(varStep, step); - writer.Put(varTime, step * 1.0); + writer.Put(varTime, static_cast(step)); writer.EndStep(); } diff --git a/examples/fides/01_onecell/fides_onecell.json b/examples/useCases/fidesOneCell/fidesOneCell.json similarity index 100% rename from examples/fides/01_onecell/fides_onecell.json rename to examples/useCases/fidesOneCell/fidesOneCell.json diff --git a/examples/fides/01_onecell/paraview-onecell-step0.png b/examples/useCases/fidesOneCell/paraview-onecell-step0.png similarity index 100% rename from examples/fides/01_onecell/paraview-onecell-step0.png rename to examples/useCases/fidesOneCell/paraview-onecell-step0.png diff --git a/examples/fides/01_onecell/paraview-onecell-step9.png b/examples/useCases/fidesOneCell/paraview-onecell-step9.png similarity index 100% rename from examples/fides/01_onecell/paraview-onecell-step9.png rename to examples/useCases/fidesOneCell/paraview-onecell-step9.png diff --git a/examples/useCases/insituGlobalArrays/CMakeLists.txt b/examples/useCases/insituGlobalArrays/CMakeLists.txt index 8ef3a1c205..281c687b7e 100644 --- a/examples/useCases/insituGlobalArrays/CMakeLists.txt +++ b/examples/useCases/insituGlobalArrays/CMakeLists.txt @@ -3,16 +3,38 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(insituGlobalArraysWriter insituGlobalArraysWriter.cpp) -target_link_libraries(insituGlobalArraysWriter adios2::cxx11) +cmake_minimum_required(VERSION 3.12) +project(ADIOS2UseCasesInSituGlobalArraysExample) -add_executable(insituGlobalArraysReaderNxN insituGlobalArraysReaderNxN.cpp) -target_link_libraries(insituGlobalArraysReaderNxN adios2::cxx11) +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + + +add_executable(adios2_useCases_insituGlobalArraysWriter insituGlobalArraysWriter.cpp) +target_link_libraries(adios2_useCases_insituGlobalArraysWriter adios2::cxx11) +install(TARGETS adios2_useCases_insituGlobalArraysWriter RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_useCases_insituGlobalArraysReaderNxN insituGlobalArraysReaderNxN.cpp) +target_link_libraries(adios2_useCases_insituGlobalArraysReaderNxN adios2::cxx11) +install(TARGETS adios2_useCases_insituGlobalArraysReaderNxN RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ADIOS2_HAVE_MPI) - add_executable(insituGlobalArraysWriter_mpi insituGlobalArraysWriter.cpp) - target_link_libraries(insituGlobalArraysWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_useCases_insituGlobalArraysWriter_mpi insituGlobalArraysWriter.cpp) + target_link_libraries(adios2_useCases_insituGlobalArraysWriter_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_useCases_insituGlobalArraysWriter_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - add_executable(insituGlobalArraysReaderNxN_mpi insituGlobalArraysReaderNxN.cpp) - target_link_libraries(insituGlobalArraysReaderNxN_mpi adios2::cxx11_mpi MPI::MPI_C) + add_executable(adios2_useCases_insituGlobalArraysReaderNxN_mpi insituGlobalArraysReaderNxN.cpp) + target_link_libraries(adios2_useCases_insituGlobalArraysReaderNxN_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_useCases_insituGlobalArraysReaderNxN_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/testing/examples/heatTransfer/TestBPFileMx1.cmake b/testing/examples/heatTransfer/TestBPFileMx1.cmake index 354856868f..f2855476bb 100644 --- a/testing/examples/heatTransfer/TestBPFileMx1.cmake +++ b/testing/examples/heatTransfer/TestBPFileMx1.cmake @@ -8,8 +8,8 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.BP3.Mx1.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP3.Mx1.Write PROPERTIES PROCESSORS 4) @@ -17,8 +17,8 @@ set_tests_properties(HeatTransfer.BP3.Mx1.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP3.Mx1.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 1 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3.xml Write.bp Read.bp 1 1 ) @@ -43,8 +43,8 @@ SetupTestPipeline(HeatTransfer.BP3.Mx1 "Write;Read;Dump;Validate" TRUE) add_test(NAME HeatTransfer.BP4.Mx1.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP4.Mx1.Write PROPERTIES PROCESSORS 4) @@ -52,8 +52,8 @@ set_tests_properties(HeatTransfer.BP4.Mx1.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP4.Mx1.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 1 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4.xml Write.bp Read.bp 1 1 ) diff --git a/testing/examples/heatTransfer/TestBPFileMx1_zfp.cmake b/testing/examples/heatTransfer/TestBPFileMx1_zfp.cmake index 4f5651a06a..ed75a60b9f 100644 --- a/testing/examples/heatTransfer/TestBPFileMx1_zfp.cmake +++ b/testing/examples/heatTransfer/TestBPFileMx1_zfp.cmake @@ -8,8 +8,8 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.BP3.zfp.Mx1.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3_zfp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3_zfp.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP3.zfp.Mx1.Write PROPERTIES PROCESSORS 4) @@ -17,8 +17,8 @@ set_tests_properties(HeatTransfer.BP3.zfp.Mx1.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP3.zfp.Mx1.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 1 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3.xml Write.bp Read.bp 1 1 ) @@ -36,8 +36,8 @@ SetupTestPipeline(HeatTransfer.BP3.zfp.Mx1 "Write;Read;Dump" TRUE) add_test(NAME HeatTransfer.BP4.zfp.Mx1.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4_zfp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4_zfp.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP3.zfp.Mx1.Write PROPERTIES PROCESSORS 4) @@ -45,8 +45,8 @@ set_tests_properties(HeatTransfer.BP3.zfp.Mx1.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP4.zfp.Mx1.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 1 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4.xml Write.bp Read.bp 1 1 ) diff --git a/testing/examples/heatTransfer/TestBPFileMxM.cmake b/testing/examples/heatTransfer/TestBPFileMxM.cmake index ac3e02bd85..64d5cbe1e2 100644 --- a/testing/examples/heatTransfer/TestBPFileMxM.cmake +++ b/testing/examples/heatTransfer/TestBPFileMxM.cmake @@ -9,8 +9,8 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.BP3.MxM.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP3.MxM.Write PROPERTIES PROCESSORS 4) @@ -18,8 +18,8 @@ set_tests_properties(HeatTransfer.BP3.MxM.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP3.MxM.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3.xml Write.bp Read.bp 2 2 ) set_tests_properties(HeatTransfer.BP3.MxM.Read PROPERTIES PROCESSORS 4) @@ -44,8 +44,8 @@ SetupTestPipeline(HeatTransfer.BP3.MxM "Write;Read;Dump;Validate" True) add_test(NAME HeatTransfer.BP4.MxM.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP4.MxM.Write PROPERTIES PROCESSORS 4) @@ -53,8 +53,8 @@ set_tests_properties(HeatTransfer.BP4.MxM.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP4.MxM.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4.xml Write.bp Read.bp 2 2 ) set_tests_properties(HeatTransfer.BP4.MxM.Read PROPERTIES PROCESSORS 4) diff --git a/testing/examples/heatTransfer/TestBPFileMxN.cmake b/testing/examples/heatTransfer/TestBPFileMxN.cmake index 9c89a4977e..b94bd843a3 100644 --- a/testing/examples/heatTransfer/TestBPFileMxN.cmake +++ b/testing/examples/heatTransfer/TestBPFileMxN.cmake @@ -9,8 +9,8 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.BP3.MxN.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP3.MxN.Write PROPERTIES PROCESSORS 4) @@ -18,8 +18,8 @@ set_tests_properties(HeatTransfer.BP3.MxN.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP3.MxN.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 3 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp3.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp3.xml Write.bp Read.bp 1 3 ) set_tests_properties(HeatTransfer.BP3.MxN.Read PROPERTIES PROCESSORS 3) @@ -44,8 +44,8 @@ SetupTestPipeline(HeatTransfer.BP3.MxN "Write;Read;Dump;Validate" True) add_test(NAME HeatTransfer.BP4.MxN.Write COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4.xml Write.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.BP4.MxN.Write PROPERTIES PROCESSORS 4) @@ -53,8 +53,8 @@ set_tests_properties(HeatTransfer.BP4.MxN.Write PROPERTIES PROCESSORS 4) add_test(NAME HeatTransfer.BP4.MxN.Read COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 3 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_bp4.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_bp4.xml Write.bp Read.bp 1 3 ) set_tests_properties(HeatTransfer.BP4.MxN.Read PROPERTIES PROCESSORS 3) diff --git a/testing/examples/heatTransfer/TestInlineMxM.cmake b/testing/examples/heatTransfer/TestInlineMxM.cmake index b14102f196..ecdf64abaf 100644 --- a/testing/examples/heatTransfer/TestInlineMxM.cmake +++ b/testing/examples/heatTransfer/TestInlineMxM.cmake @@ -8,8 +8,8 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.Inline.MxM COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_inline.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_inline.xml Read.bp 2 2 10 10 10 10 ) set_tests_properties(HeatTransfer.Inline.MxM PROPERTIES PROCESSORS 8) diff --git a/testing/examples/heatTransfer/TestSSCMx1.cmake b/testing/examples/heatTransfer/TestSSCMx1.cmake index 7183b35657..eb599d00e4 100644 --- a/testing/examples/heatTransfer/TestSSCMx1.cmake +++ b/testing/examples/heatTransfer/TestSSCMx1.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.InsituMPI.Mx1 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_ssc.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_ssc.xml Write.bp 2 2 10 10 10 10 : ${MPIEXEC_NUMPROC_FLAG} 1 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_ssc.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_ssc.xml Write.bp Read.bp 1 1 ) set_tests_properties(HeatTransfer.InsituMPI.Mx1 PROPERTIES PROCESSORS 5) diff --git a/testing/examples/heatTransfer/TestSSCMxM.cmake b/testing/examples/heatTransfer/TestSSCMxM.cmake index 9af79873de..94c326786a 100644 --- a/testing/examples/heatTransfer/TestSSCMxM.cmake +++ b/testing/examples/heatTransfer/TestSSCMxM.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SSC.MxM COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_ssc.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_ssc.xml Write.bp 2 2 10 10 10 10 : ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_ssc.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_ssc.xml Write.bp Read.bp 2 2 ) set_tests_properties(HeatTransfer.SSC.MxM PROPERTIES PROCESSORS 8) diff --git a/testing/examples/heatTransfer/TestSSCMxN.cmake b/testing/examples/heatTransfer/TestSSCMxN.cmake index 46818db55d..ebbbc7e8bf 100644 --- a/testing/examples/heatTransfer/TestSSCMxN.cmake +++ b/testing/examples/heatTransfer/TestSSCMxN.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.InsituMPI.MxN COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_ssc.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_ssc.xml Write.bp 2 2 10 10 10 10 : ${MPIEXEC_NUMPROC_FLAG} 3 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_ssc.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_ssc.xml Write.bp Read.bp 1 3 ) set_tests_properties(HeatTransfer.InsituMPI.MxN PROPERTIES PROCESSORS 7) diff --git a/testing/examples/heatTransfer/TestSSTBPMx1.cmake b/testing/examples/heatTransfer/TestSSTBPMx1.cmake index 7da75f9cb4..6566541d62 100644 --- a/testing/examples/heatTransfer/TestSSTBPMx1.cmake +++ b/testing/examples/heatTransfer/TestSSTBPMx1.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.BP.Mx1 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 1 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp.xml Write.bp Read.bp 1 1 SST ) set_tests_properties(HeatTransfer.SST.BP.Mx1 PROPERTIES PROCESSORS 5) diff --git a/testing/examples/heatTransfer/TestSSTBPMxM.cmake b/testing/examples/heatTransfer/TestSSTBPMxM.cmake index 286b707eb7..d4fe9f52ae 100644 --- a/testing/examples/heatTransfer/TestSSTBPMxM.cmake +++ b/testing/examples/heatTransfer/TestSSTBPMxM.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.BP.MxM COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp.xml Write.bp Read.bp 2 2 SST ) set_tests_properties(HeatTransfer.SST.BP.MxM PROPERTIES PROCESSORS 8) diff --git a/testing/examples/heatTransfer/TestSSTBPMxN.cmake b/testing/examples/heatTransfer/TestSSTBPMxN.cmake index 1860244786..c7c26b2f51 100644 --- a/testing/examples/heatTransfer/TestSSTBPMxN.cmake +++ b/testing/examples/heatTransfer/TestSSTBPMxN.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.BP.MxN COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 3 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp.xml Write.bp Read.bp 1 3 SST ) set_tests_properties(HeatTransfer.SST.BP.MxN PROPERTIES PROCESSORS 7) diff --git a/testing/examples/heatTransfer/TestSSTBPRDMAMxN.cmake b/testing/examples/heatTransfer/TestSSTBPRDMAMxN.cmake index 70dbb99a7e..487194089d 100644 --- a/testing/examples/heatTransfer/TestSSTBPRDMAMxN.cmake +++ b/testing/examples/heatTransfer/TestSSTBPRDMAMxN.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.BP.RDMA.MxN COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp_rdma.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp_rdma.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 3 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_bp_rdma.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_bp_rdma.xml Write.bp Read.bp 1 3 SST ) set_tests_properties(HeatTransfer.SST.BP.RDMA.MxN PROPERTIES PROCESSORS 7) diff --git a/testing/examples/heatTransfer/TestSSTFFSMx1.cmake b/testing/examples/heatTransfer/TestSSTFFSMx1.cmake index 1c261b0f0f..b0dfb92210 100644 --- a/testing/examples/heatTransfer/TestSSTFFSMx1.cmake +++ b/testing/examples/heatTransfer/TestSSTFFSMx1.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.FFS.Mx1 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 1 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs.xml Write.bp Read.bp 1 1 SST ) set_tests_properties(HeatTransfer.SST.FFS.Mx1 PROPERTIES PROCESSORS 5) diff --git a/testing/examples/heatTransfer/TestSSTFFSMxM.cmake b/testing/examples/heatTransfer/TestSSTFFSMxM.cmake index 500869e30c..fd9ff096c9 100644 --- a/testing/examples/heatTransfer/TestSSTFFSMxM.cmake +++ b/testing/examples/heatTransfer/TestSSTFFSMxM.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.FFS.MxM COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs.xml Write.bp Read.bp 2 2 SST ) set_tests_properties(HeatTransfer.SST.FFS.MxM PROPERTIES PROCESSORS 8) diff --git a/testing/examples/heatTransfer/TestSSTFFSMxN.cmake b/testing/examples/heatTransfer/TestSSTFFSMxN.cmake index 774a1ce7ff..0e973c1f5c 100644 --- a/testing/examples/heatTransfer/TestSSTFFSMxN.cmake +++ b/testing/examples/heatTransfer/TestSSTFFSMxN.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.FFS.MxN COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 3 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs.xml Write.bp Read.bp 1 3 SST ) set_tests_properties(HeatTransfer.SST.FFS.MxN PROPERTIES PROCESSORS 7) diff --git a/testing/examples/heatTransfer/TestSSTFFSRDMAMxN.cmake b/testing/examples/heatTransfer/TestSSTFFSRDMAMxN.cmake index 70c933e375..08f1cad1a7 100644 --- a/testing/examples/heatTransfer/TestSSTFFSRDMAMxN.cmake +++ b/testing/examples/heatTransfer/TestSSTFFSRDMAMxN.cmake @@ -8,13 +8,13 @@ include(ADIOSFunctions) add_test(NAME HeatTransfer.SST.FFS.MxN COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs_rdma.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs_rdma.xml Write.bp 2 2 10 10 10 10 SST : ${MPIEXEC_NUMPROC_FLAG} 3 - $ - ${PROJECT_SOURCE_DIR}/examples/heatTransfer/heat_sst_ffs_rdma.xml + $ + ${PROJECT_SOURCE_DIR}/examples/simulations/heatTransfer/heat_sst_ffs_rdma.xml Write.bp Read.bp 1 3 SST ) set_tests_properties(HeatTransfer.SST.FFS.MxN PROPERTIES PROCESSORS 7) diff --git a/testing/install/EncryptionOperator/CMakeLists.txt b/testing/install/EncryptionOperator/CMakeLists.txt index ed4fae524b..aca5c62e68 100644 --- a/testing/install/EncryptionOperator/CMakeLists.txt +++ b/testing/install/EncryptionOperator/CMakeLists.txt @@ -17,14 +17,14 @@ set(ENV{ADIOS2_PLUGIN_PATH} "${adios2_DIR}/../../") # add write test add_executable(adios_plugin_operator_write_test - ../../../examples/plugins/operator/examplePluginOperator_write.cpp + ../../../examples/plugins/operator/examplePluginOperatorWrite.cpp ) target_link_libraries(adios_plugin_operator_write_test adios2::cxx11) add_test(NAME adios_plugin_operator_write_test COMMAND adios_plugin_operator_write_test) # add read test add_executable(adios_plugin_operator_read_test - ../../../examples/plugins/operator/examplePluginOperator_read.cpp + ../../../examples/plugins/operator/examplePluginOperatorRead.cpp ) target_link_libraries(adios_plugin_operator_read_test adios2::cxx11) add_test(NAME adios_plugin_operator_read_test COMMAND adios_plugin_operator_read_test) diff --git a/testing/install/EnginePlugin/CMakeLists.txt b/testing/install/EnginePlugin/CMakeLists.txt index 7a7425f8d6..2949290c2b 100644 --- a/testing/install/EnginePlugin/CMakeLists.txt +++ b/testing/install/EnginePlugin/CMakeLists.txt @@ -43,7 +43,7 @@ endif() # add write test add_executable(adios_plugin_engine_write_test - ../../../examples/plugins/engine/examplePluginEngine_write.cpp + ../../../examples/plugins/engine/examplePluginEngineWrite.cpp ) target_link_libraries(adios_plugin_engine_write_test adios2::cxx11) add_test(NAME adios_plugin_engine_write_test COMMAND adios_plugin_engine_write_test) @@ -53,7 +53,7 @@ set_tests_properties(adios_plugin_engine_write_test PROPERTIES # add read test add_executable(adios_plugin_engine_read_test - ../../../examples/plugins/engine/examplePluginEngine_read.cpp + ../../../examples/plugins/engine/examplePluginEngineRead.cpp ) target_link_libraries(adios_plugin_engine_read_test adios2::cxx11) add_test(NAME adios_plugin_engine_read_test COMMAND adios_plugin_engine_read_test) From 3bdc1aa2b33c53c2f4764e8162e1f8088d788cdb Mon Sep 17 00:00:00 2001 From: Spiros Tsalikis Date: Mon, 18 Sep 2023 14:16:55 -0400 Subject: [PATCH 044/126] Add examples from ADIOS2-Examples 1) Make all examples individually compilable 2) Make examples' executable names be consistent 3) Rename certain examples for clarity 4) Make all examples installable 5) Fix Python formatting using black 6) Add licence documentation wherever it's missing --- examples/basics/CMakeLists.txt | 8 +- examples/basics/globalArray1D/CMakeLists.txt | 80 + examples/basics/globalArray1D/decomp.F90 | 53 + examples/basics/globalArray1D/decomp.c | 67 + examples/basics/globalArray1D/decomp.h | 14 + .../globalArray1D/globalArray1DRead.F90 | 104 + .../basics/globalArray1D/globalArray1DRead.c | 86 + .../globalArray1D/globalArray1DWrite.F90 | 93 + .../basics/globalArray1D/globalArray1DWrite.c | 99 + examples/basics/globalArray1D/mpivars.F90 | 30 + examples/basics/globalArray1D/mpivars.c | 29 + examples/basics/globalArray1D/mpivars.h | 14 + .../globalArrayND/globalArrayNDWrite.cpp | 3 +- examples/basics/queryWorker/CMakeLists.txt | 4 +- examples/basics/queryWorker/README.md | 8 - examples/basics/queryWorker/queryWorker.cpp | 11 +- examples/basics/values/CMakeLists.txt | 21 + examples/basics/values/mpivars.F90 | 30 + examples/basics/values/values.F90 | 169 + .../basics/variablesShapes/CMakeLists.txt | 39 + .../variablesShapes/variablesShapes.cpp | 269 + .../variablesShapes/variablesShapes_hl.cpp | 194 + examples/hello/CMakeLists.txt | 16 + examples/hello/bpThreadWrite/CMakeLists.txt | 21 + .../hello/bpThreadWrite/bpThreadWrite.cpp | 122 + examples/hello/bpWriteReadHip/CMakeLists.txt | 25 + .../hello/bpWriteReadHip/bpWriteReadHip.cpp | 135 + .../hello/bpWriteReadKokkos/CMakeLists.txt | 33 + .../bpWriteReadKokkos/bpWriteReadKokkos.cpp | 117 + examples/hello/helloWorld/CMakeLists.txt | 47 + examples/hello/helloWorld/hello-world-hl.cpp | 75 + examples/hello/helloWorld/hello-world-hl.py | 47 + examples/hello/helloWorld/hello-world.c | 71 + examples/hello/helloWorld/hello-world.cpp | 76 + examples/hello/helloWorld/hello-world.py | 54 + examples/simulations/CMakeLists.txt | 10 + .../GrayScott.jl/.JuliaFormatter.toml | 4 + .../simulations/GrayScott.jl/Project.toml | 19 + examples/simulations/GrayScott.jl/ReadMe.md | 139 + .../GrayScott.jl/examples/settings-files.json | 23 + .../simulations/GrayScott.jl/gray-scott.jl | 15 + .../GrayScott.jl/scripts/config_crusher.sh | 43 + .../GrayScott.jl/scripts/config_summit.sh | 43 + .../GrayScott.jl/scripts/job_crusher.sh | 17 + .../GrayScott.jl/scripts/job_summit.sh | 18 + .../simulations/GrayScott.jl/src/GrayScott.jl | 91 + .../GrayScott.jl/src/analysis/pdfcalc.jl | 160 + .../GrayScott.jl/src/helper/Helper.jl | 7 + .../GrayScott.jl/src/helper/helperMPI.jl | 15 + .../GrayScott.jl/src/helper/helperString.jl | 14 + .../GrayScott.jl/src/simulation/IO.jl | 106 + .../GrayScott.jl/src/simulation/Inputs.jl | 78 + .../GrayScott.jl/src/simulation/Simulation.jl | 281 + .../src/simulation/Simulation_AMDGPU.jl | 168 + .../src/simulation/Simulation_CUDA.jl | 160 + .../GrayScott.jl/src/simulation/Structs.jl | 102 + .../GrayScott.jl/test/Project.toml | 3 + .../test/functional/functional-GrayScott.jl | 12 + .../simulations/GrayScott.jl/test/runtests.jl | 26 + .../test/unit/analysis/unit-pdfcalc.jl | 19 + .../test/unit/helper/unit-helperMPI.jl | 12 + .../test/unit/simulation/unit-IO.jl | 36 + .../test/unit/simulation/unit-Inputs.jl | 15 + .../test/unit/simulation/unit-Simulation.jl | 34 + .../unit/simulation/unit-Simulation_CUDA.jl | 28 + .../gray-scott-kokkos/CMakeLists.txt | 47 + .../simulations/gray-scott-kokkos/README.md | 2 + .../gray-scott-kokkos/gray-scott.cpp | 330 + .../gray-scott-kokkos/gray-scott.h | 102 + .../simulations/gray-scott-kokkos/json.hpp | 20274 ++++++++++++++++ .../simulations/gray-scott-kokkos/main.cpp | 183 + .../simulations/gray-scott-kokkos/restart.cpp | 96 + .../simulations/gray-scott-kokkos/restart.h | 18 + .../gray-scott-kokkos/settings.cpp | 89 + .../simulations/gray-scott-kokkos/settings.h | 37 + .../simulations/gray-scott-kokkos/timer.hpp | 55 + .../simulations/gray-scott-kokkos/writer.cpp | 140 + .../simulations/gray-scott-kokkos/writer.h | 32 + .../gray-scott-struct/CMakeLists.txt | 70 + .../simulations/gray-scott-struct/README.md | 197 + .../adios2-inline-plugin.xml | 135 + .../simulations/gray-scott-struct/adios2.xml | 142 + .../gray-scott-struct/analysis/curvature.cpp | 202 + .../gray-scott-struct/analysis/find_blobs.cpp | 245 + .../gray-scott-struct/analysis/isosurface.cpp | 346 + .../gray-scott-struct/analysis/pdf-calc.cpp | 354 + .../gray-scott-struct/catalyst/gs-fides.json | 60 + .../gray-scott-struct/catalyst/gs-pipeline.py | 65 + .../gray-scott-struct/catalyst/setup.sh | 6 + .../simulations/gray-scott-struct/cleanup.sh | 28 + .../gray-scott-struct/common/timer.hpp | 59 + .../gray-scott-struct/img/example1.jpg | Bin 0 -> 23365 bytes .../gray-scott-struct/img/example2.jpg | Bin 0 -> 24700 bytes .../gray-scott-struct/img/example3.jpg | Bin 0 -> 22000 bytes .../gray-scott-struct/img/example4.jpg | Bin 0 -> 19246 bytes .../gray-scott-struct/img/example5.jpg | Bin 0 -> 17746 bytes .../gray-scott-struct/plot/decomp.py | 121 + .../gray-scott-struct/plot/gsplot.py | 187 + .../gray-scott-struct/plot/pdfplot.py | 135 + .../plot/render_isosurface.cpp | 204 + .../gray-scott-struct/simulation/LICENSE | 20 + .../simulation/gray-scott.cpp | 290 + .../gray-scott-struct/simulation/gray-scott.h | 131 + .../gray-scott-struct/simulation/json.hpp | 20274 ++++++++++++++++ .../gray-scott-struct/simulation/main.cpp | 176 + .../gray-scott-struct/simulation/restart.cpp | 92 + .../gray-scott-struct/simulation/restart.h | 19 + .../simulation/settings-files.json | 21 + .../simulation/settings-inline.json | 21 + .../simulation/settings-staging.json | 21 + .../gray-scott-struct/simulation/settings.cpp | 89 + .../gray-scott-struct/simulation/settings.h | 37 + .../gray-scott-struct/simulation/writer.cpp | 146 + .../gray-scott-struct/simulation/writer.h | 33 + .../gray-scott-struct/test-firstrun.json | 21 + .../gray-scott-struct/test-restart.json | 21 + .../gray-scott-struct/visit-bp4.session | 5456 +++++ .../gray-scott-struct/visit-bp4.session.gui | 54 + .../gray-scott-struct/visit-sst.session | 5600 +++++ .../gray-scott-struct/visit-sst.session.gui | 54 + .../simulations/gray-scott/CMakeLists.txt | 69 + examples/simulations/gray-scott/README.md | 211 + .../gray-scott/adios2-fides-staging.xml | 142 + .../gray-scott/adios2-inline-plugin.xml | 135 + examples/simulations/gray-scott/adios2.xml | 142 + .../gray-scott/analysis/curvature.cpp | 202 + .../gray-scott/analysis/find_blobs.cpp | 245 + .../gray-scott/analysis/isosurface.cpp | 346 + .../gray-scott/analysis/pdf-calc.cpp | 354 + .../gray-scott/catalyst/gs-fides.json | 60 + .../gray-scott/catalyst/gs-pipeline.py | 193 + .../simulations/gray-scott/catalyst/setup.sh | 6 + examples/simulations/gray-scott/cleanup.sh | 28 + .../simulations/gray-scott/common/timer.hpp | 55 + .../simulations/gray-scott/img/example1.jpg | Bin 0 -> 23365 bytes .../simulations/gray-scott/img/example2.jpg | Bin 0 -> 24700 bytes .../simulations/gray-scott/img/example3.jpg | Bin 0 -> 22000 bytes .../simulations/gray-scott/img/example4.jpg | Bin 0 -> 19246 bytes .../simulations/gray-scott/img/example5.jpg | Bin 0 -> 17746 bytes .../simulations/gray-scott/plot/decomp.py | 121 + .../simulations/gray-scott/plot/gsplot.py | 187 + .../simulations/gray-scott/plot/pdfplot.py | 135 + .../gray-scott/plot/render_isosurface.cpp | 204 + .../simulations/gray-scott/simulation/LICENSE | 20 + .../gray-scott/simulation/gray-scott.cpp | 277 + .../gray-scott/simulation/gray-scott.h | 130 + .../gray-scott/simulation/json.hpp | 20274 ++++++++++++++++ .../gray-scott/simulation/main.cpp | 177 + .../gray-scott/simulation/restart.cpp | 96 + .../gray-scott/simulation/restart.h | 19 + .../gray-scott/simulation/settings-files.json | 21 + .../simulation/settings-inline.json | 21 + .../simulation/settings-staging.json | 21 + .../gray-scott/simulation/settings.cpp | 89 + .../gray-scott/simulation/settings.h | 37 + .../gray-scott/simulation/writer.cpp | 152 + .../gray-scott/simulation/writer.h | 33 + .../simulations/gray-scott/visit-bp4.session | 5456 +++++ .../gray-scott/visit-bp4.session.gui | 54 + .../simulations/gray-scott/visit-sst.session | 5600 +++++ .../gray-scott/visit-sst.session.gui | 54 + .../korteweg-de-vries/CMakeLists.txt | 17 + .../simulations/korteweg-de-vries/KdV.cpp | 198 + .../simulations/korteweg-de-vries/README.md | 15 + .../korteweg-de-vries/graph_solution.py | 34 + .../simulations/lorenz_ode/CMakeLists.txt | 23 + examples/simulations/lorenz_ode/README.md | 38 + examples/simulations/lorenz_ode/lorenz.hpp | 221 + .../simulations/lorenz_ode/lorenzReader.cpp | 123 + .../simulations/lorenz_ode/lorenzWriter.cpp | 88 + .../simulations/lorenz_ode/lorenz_ode.svg | 2 + .../lorenz_ode/ode_phase_space.svg | 2 + .../simulations/lorenz_ode/ode_tuples.svg | 2 + .../lorenz_ode/second_derivative.svg | 2 + .../simulations/lorenz_ode/taylor_series.svg | 2 + 175 files changed, 96611 insertions(+), 21 deletions(-) create mode 100644 examples/basics/globalArray1D/CMakeLists.txt create mode 100644 examples/basics/globalArray1D/decomp.F90 create mode 100644 examples/basics/globalArray1D/decomp.c create mode 100644 examples/basics/globalArray1D/decomp.h create mode 100644 examples/basics/globalArray1D/globalArray1DRead.F90 create mode 100644 examples/basics/globalArray1D/globalArray1DRead.c create mode 100644 examples/basics/globalArray1D/globalArray1DWrite.F90 create mode 100644 examples/basics/globalArray1D/globalArray1DWrite.c create mode 100644 examples/basics/globalArray1D/mpivars.F90 create mode 100644 examples/basics/globalArray1D/mpivars.c create mode 100644 examples/basics/globalArray1D/mpivars.h delete mode 100644 examples/basics/queryWorker/README.md create mode 100644 examples/basics/values/mpivars.F90 create mode 100644 examples/basics/values/values.F90 create mode 100644 examples/basics/variablesShapes/CMakeLists.txt create mode 100644 examples/basics/variablesShapes/variablesShapes.cpp create mode 100644 examples/basics/variablesShapes/variablesShapes_hl.cpp create mode 100644 examples/hello/bpThreadWrite/CMakeLists.txt create mode 100644 examples/hello/bpThreadWrite/bpThreadWrite.cpp create mode 100644 examples/hello/bpWriteReadHip/CMakeLists.txt create mode 100644 examples/hello/bpWriteReadHip/bpWriteReadHip.cpp create mode 100644 examples/hello/bpWriteReadKokkos/CMakeLists.txt create mode 100644 examples/hello/bpWriteReadKokkos/bpWriteReadKokkos.cpp create mode 100644 examples/hello/helloWorld/CMakeLists.txt create mode 100644 examples/hello/helloWorld/hello-world-hl.cpp create mode 100644 examples/hello/helloWorld/hello-world-hl.py create mode 100644 examples/hello/helloWorld/hello-world.c create mode 100644 examples/hello/helloWorld/hello-world.cpp create mode 100644 examples/hello/helloWorld/hello-world.py create mode 100644 examples/simulations/GrayScott.jl/.JuliaFormatter.toml create mode 100644 examples/simulations/GrayScott.jl/Project.toml create mode 100644 examples/simulations/GrayScott.jl/ReadMe.md create mode 100644 examples/simulations/GrayScott.jl/examples/settings-files.json create mode 100644 examples/simulations/GrayScott.jl/gray-scott.jl create mode 100644 examples/simulations/GrayScott.jl/scripts/config_crusher.sh create mode 100644 examples/simulations/GrayScott.jl/scripts/config_summit.sh create mode 100644 examples/simulations/GrayScott.jl/scripts/job_crusher.sh create mode 100644 examples/simulations/GrayScott.jl/scripts/job_summit.sh create mode 100644 examples/simulations/GrayScott.jl/src/GrayScott.jl create mode 100644 examples/simulations/GrayScott.jl/src/analysis/pdfcalc.jl create mode 100644 examples/simulations/GrayScott.jl/src/helper/Helper.jl create mode 100644 examples/simulations/GrayScott.jl/src/helper/helperMPI.jl create mode 100644 examples/simulations/GrayScott.jl/src/helper/helperString.jl create mode 100644 examples/simulations/GrayScott.jl/src/simulation/IO.jl create mode 100644 examples/simulations/GrayScott.jl/src/simulation/Inputs.jl create mode 100644 examples/simulations/GrayScott.jl/src/simulation/Simulation.jl create mode 100644 examples/simulations/GrayScott.jl/src/simulation/Simulation_AMDGPU.jl create mode 100644 examples/simulations/GrayScott.jl/src/simulation/Simulation_CUDA.jl create mode 100644 examples/simulations/GrayScott.jl/src/simulation/Structs.jl create mode 100644 examples/simulations/GrayScott.jl/test/Project.toml create mode 100644 examples/simulations/GrayScott.jl/test/functional/functional-GrayScott.jl create mode 100644 examples/simulations/GrayScott.jl/test/runtests.jl create mode 100644 examples/simulations/GrayScott.jl/test/unit/analysis/unit-pdfcalc.jl create mode 100644 examples/simulations/GrayScott.jl/test/unit/helper/unit-helperMPI.jl create mode 100644 examples/simulations/GrayScott.jl/test/unit/simulation/unit-IO.jl create mode 100644 examples/simulations/GrayScott.jl/test/unit/simulation/unit-Inputs.jl create mode 100644 examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation.jl create mode 100644 examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation_CUDA.jl create mode 100644 examples/simulations/gray-scott-kokkos/CMakeLists.txt create mode 100644 examples/simulations/gray-scott-kokkos/README.md create mode 100644 examples/simulations/gray-scott-kokkos/gray-scott.cpp create mode 100644 examples/simulations/gray-scott-kokkos/gray-scott.h create mode 100644 examples/simulations/gray-scott-kokkos/json.hpp create mode 100644 examples/simulations/gray-scott-kokkos/main.cpp create mode 100644 examples/simulations/gray-scott-kokkos/restart.cpp create mode 100644 examples/simulations/gray-scott-kokkos/restart.h create mode 100644 examples/simulations/gray-scott-kokkos/settings.cpp create mode 100644 examples/simulations/gray-scott-kokkos/settings.h create mode 100644 examples/simulations/gray-scott-kokkos/timer.hpp create mode 100644 examples/simulations/gray-scott-kokkos/writer.cpp create mode 100644 examples/simulations/gray-scott-kokkos/writer.h create mode 100644 examples/simulations/gray-scott-struct/CMakeLists.txt create mode 100644 examples/simulations/gray-scott-struct/README.md create mode 100644 examples/simulations/gray-scott-struct/adios2-inline-plugin.xml create mode 100644 examples/simulations/gray-scott-struct/adios2.xml create mode 100644 examples/simulations/gray-scott-struct/analysis/curvature.cpp create mode 100644 examples/simulations/gray-scott-struct/analysis/find_blobs.cpp create mode 100644 examples/simulations/gray-scott-struct/analysis/isosurface.cpp create mode 100644 examples/simulations/gray-scott-struct/analysis/pdf-calc.cpp create mode 100644 examples/simulations/gray-scott-struct/catalyst/gs-fides.json create mode 100644 examples/simulations/gray-scott-struct/catalyst/gs-pipeline.py create mode 100644 examples/simulations/gray-scott-struct/catalyst/setup.sh create mode 100755 examples/simulations/gray-scott-struct/cleanup.sh create mode 100644 examples/simulations/gray-scott-struct/common/timer.hpp create mode 100644 examples/simulations/gray-scott-struct/img/example1.jpg create mode 100644 examples/simulations/gray-scott-struct/img/example2.jpg create mode 100644 examples/simulations/gray-scott-struct/img/example3.jpg create mode 100644 examples/simulations/gray-scott-struct/img/example4.jpg create mode 100644 examples/simulations/gray-scott-struct/img/example5.jpg create mode 100644 examples/simulations/gray-scott-struct/plot/decomp.py create mode 100644 examples/simulations/gray-scott-struct/plot/gsplot.py create mode 100644 examples/simulations/gray-scott-struct/plot/pdfplot.py create mode 100644 examples/simulations/gray-scott-struct/plot/render_isosurface.cpp create mode 100644 examples/simulations/gray-scott-struct/simulation/LICENSE create mode 100644 examples/simulations/gray-scott-struct/simulation/gray-scott.cpp create mode 100644 examples/simulations/gray-scott-struct/simulation/gray-scott.h create mode 100644 examples/simulations/gray-scott-struct/simulation/json.hpp create mode 100644 examples/simulations/gray-scott-struct/simulation/main.cpp create mode 100644 examples/simulations/gray-scott-struct/simulation/restart.cpp create mode 100644 examples/simulations/gray-scott-struct/simulation/restart.h create mode 100644 examples/simulations/gray-scott-struct/simulation/settings-files.json create mode 100644 examples/simulations/gray-scott-struct/simulation/settings-inline.json create mode 100644 examples/simulations/gray-scott-struct/simulation/settings-staging.json create mode 100644 examples/simulations/gray-scott-struct/simulation/settings.cpp create mode 100644 examples/simulations/gray-scott-struct/simulation/settings.h create mode 100644 examples/simulations/gray-scott-struct/simulation/writer.cpp create mode 100644 examples/simulations/gray-scott-struct/simulation/writer.h create mode 100644 examples/simulations/gray-scott-struct/test-firstrun.json create mode 100644 examples/simulations/gray-scott-struct/test-restart.json create mode 100644 examples/simulations/gray-scott-struct/visit-bp4.session create mode 100644 examples/simulations/gray-scott-struct/visit-bp4.session.gui create mode 100644 examples/simulations/gray-scott-struct/visit-sst.session create mode 100644 examples/simulations/gray-scott-struct/visit-sst.session.gui create mode 100644 examples/simulations/gray-scott/CMakeLists.txt create mode 100644 examples/simulations/gray-scott/README.md create mode 100644 examples/simulations/gray-scott/adios2-fides-staging.xml create mode 100644 examples/simulations/gray-scott/adios2-inline-plugin.xml create mode 100644 examples/simulations/gray-scott/adios2.xml create mode 100644 examples/simulations/gray-scott/analysis/curvature.cpp create mode 100644 examples/simulations/gray-scott/analysis/find_blobs.cpp create mode 100644 examples/simulations/gray-scott/analysis/isosurface.cpp create mode 100644 examples/simulations/gray-scott/analysis/pdf-calc.cpp create mode 100644 examples/simulations/gray-scott/catalyst/gs-fides.json create mode 100644 examples/simulations/gray-scott/catalyst/gs-pipeline.py create mode 100644 examples/simulations/gray-scott/catalyst/setup.sh create mode 100755 examples/simulations/gray-scott/cleanup.sh create mode 100644 examples/simulations/gray-scott/common/timer.hpp create mode 100644 examples/simulations/gray-scott/img/example1.jpg create mode 100644 examples/simulations/gray-scott/img/example2.jpg create mode 100644 examples/simulations/gray-scott/img/example3.jpg create mode 100644 examples/simulations/gray-scott/img/example4.jpg create mode 100644 examples/simulations/gray-scott/img/example5.jpg create mode 100644 examples/simulations/gray-scott/plot/decomp.py create mode 100644 examples/simulations/gray-scott/plot/gsplot.py create mode 100644 examples/simulations/gray-scott/plot/pdfplot.py create mode 100644 examples/simulations/gray-scott/plot/render_isosurface.cpp create mode 100644 examples/simulations/gray-scott/simulation/LICENSE create mode 100644 examples/simulations/gray-scott/simulation/gray-scott.cpp create mode 100644 examples/simulations/gray-scott/simulation/gray-scott.h create mode 100644 examples/simulations/gray-scott/simulation/json.hpp create mode 100644 examples/simulations/gray-scott/simulation/main.cpp create mode 100644 examples/simulations/gray-scott/simulation/restart.cpp create mode 100644 examples/simulations/gray-scott/simulation/restart.h create mode 100644 examples/simulations/gray-scott/simulation/settings-files.json create mode 100644 examples/simulations/gray-scott/simulation/settings-inline.json create mode 100644 examples/simulations/gray-scott/simulation/settings-staging.json create mode 100644 examples/simulations/gray-scott/simulation/settings.cpp create mode 100644 examples/simulations/gray-scott/simulation/settings.h create mode 100644 examples/simulations/gray-scott/simulation/writer.cpp create mode 100644 examples/simulations/gray-scott/simulation/writer.h create mode 100644 examples/simulations/gray-scott/visit-bp4.session create mode 100644 examples/simulations/gray-scott/visit-bp4.session.gui create mode 100644 examples/simulations/gray-scott/visit-sst.session create mode 100644 examples/simulations/gray-scott/visit-sst.session.gui create mode 100644 examples/simulations/korteweg-de-vries/CMakeLists.txt create mode 100644 examples/simulations/korteweg-de-vries/KdV.cpp create mode 100644 examples/simulations/korteweg-de-vries/README.md create mode 100644 examples/simulations/korteweg-de-vries/graph_solution.py create mode 100644 examples/simulations/lorenz_ode/CMakeLists.txt create mode 100644 examples/simulations/lorenz_ode/README.md create mode 100644 examples/simulations/lorenz_ode/lorenz.hpp create mode 100644 examples/simulations/lorenz_ode/lorenzReader.cpp create mode 100644 examples/simulations/lorenz_ode/lorenzWriter.cpp create mode 100644 examples/simulations/lorenz_ode/lorenz_ode.svg create mode 100644 examples/simulations/lorenz_ode/ode_phase_space.svg create mode 100644 examples/simulations/lorenz_ode/ode_tuples.svg create mode 100644 examples/simulations/lorenz_ode/second_derivative.svg create mode 100644 examples/simulations/lorenz_ode/taylor_series.svg diff --git a/examples/basics/CMakeLists.txt b/examples/basics/CMakeLists.txt index 7e470c02d1..972125c4df 100644 --- a/examples/basics/CMakeLists.txt +++ b/examples/basics/CMakeLists.txt @@ -3,10 +3,12 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# +if(ADIOS2_HAVE_MPI) + add_subdirectory(globalArray1D) +endif() add_subdirectory(globalArrayND) add_subdirectory(joinedArray) add_subdirectory(localArray) -if(ADIOS2_HAVE_DATAMAN) - add_subdirectory(queryWorker) -endif() +add_subdirectory(queryWorker) add_subdirectory(values) +add_subdirectory(variablesShapes) diff --git a/examples/basics/globalArray1D/CMakeLists.txt b/examples/basics/globalArray1D/CMakeLists.txt new file mode 100644 index 0000000000..1173b5fab5 --- /dev/null +++ b/examples/basics/globalArray1D/CMakeLists.txt @@ -0,0 +1,80 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2BasicsGlobalArray1DExample) + +if(NOT TARGET adios2_core) + set(_components C) + + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + endif() + if(CMAKE_Fortran_COMPILER_LOADED) + list(APPEND _components Fortran) + endif() + + find_package(MPI COMPONENTS ${_components}) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_MPI) + add_library(adios2_basics_globalArray1D_mpivars_c OBJECT mpivars.c) + target_link_libraries(adios2_basics_globalArray1D_mpivars_c MPI::MPI_C) + install(TARGETS adios2_basics_globalArray1D_mpivars_c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_library(adios2_basics_globalArray1D_decomp_c OBJECT decomp.c) + target_link_libraries(adios2_basics_globalArray1D_decomp_c + adios2_basics_globalArray1D_mpivars_c MPI::MPI_C) + install(TARGETS adios2_basics_globalArray1D_decomp_c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_basics_globalArray1DWrite_c globalArray1DWrite.c) + target_link_libraries(adios2_basics_globalArray1DWrite_c + adios2_basics_globalArray1D_mpivars_c + adios2_basics_globalArray1D_decomp_c + adios2::c_mpi MPI::MPI_C) + install(TARGETS adios2_basics_globalArray1DWrite_c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_basics_globalArray1DRead_c globalArray1DRead.c) + target_link_libraries(adios2_basics_globalArray1DRead_c + adios2_basics_globalArray1D_mpivars_c + adios2_basics_globalArray1D_decomp_c + adios2::c_mpi MPI::MPI_C) + install(TARGETS adios2_basics_globalArray1DRead_c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_Fortran) + add_library(adios2_basics_globalArray1D_mpivars_f OBJECT mpivars.F90) + target_link_libraries(adios2_basics_globalArray1D_mpivars_f MPI::MPI_Fortran) + install(TARGETS adios2_basics_globalArray1D_mpivars_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_library(adios2_basics_globalArray1D_decomp_f OBJECT decomp.F90) + target_link_libraries(adios2_basics_globalArray1D_decomp_f + adios2_basics_globalArray1D_mpivars_f MPI::MPI_Fortran) + install(TARGETS adios2_basics_globalArray1D_decomp_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_basics_globalArray1DWrite_f globalArray1DWrite.F90) + target_link_libraries(adios2_basics_globalArray1DWrite_f + adios2_basics_globalArray1D_mpivars_f + adios2_basics_globalArray1D_decomp_f + adios2::fortran_mpi MPI::MPI_Fortran) + install(TARGETS adios2_basics_globalArray1DWrite_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_basics_globalArray1DRead_f globalArray1DRead.F90) + target_link_libraries(adios2_basics_globalArray1DRead_f + adios2_basics_globalArray1D_mpivars_f + adios2_basics_globalArray1D_decomp_f + adios2::fortran_mpi MPI::MPI_Fortran) + install(TARGETS adios2_basics_globalArray1DRead_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() +endif() diff --git a/examples/basics/globalArray1D/decomp.F90 b/examples/basics/globalArray1D/decomp.F90 new file mode 100644 index 0000000000..b39d93d92c --- /dev/null +++ b/examples/basics/globalArray1D/decomp.F90 @@ -0,0 +1,53 @@ +! Helper functions for all examples +module decomp +contains + +! random integer from {minv, minv+1, ..., maxv} +! including minv and maxv +function get_random(minv, maxv) result(n) + implicit none + integer, intent(in) :: minv, maxv + real :: r + integer :: n + call random_number(r) + n = minv + FLOOR((maxv+1-minv)*r) +end function get_random + +! gather the local sizes of arrays and sum them up +! so that each process knows the global shape +! and its own offset in the global space +subroutine gather_decomp_1d(mysize, myshape, myoffset) + use mpivars + implicit none + integer*8, intent(in) :: mysize + integer*8, intent(out) :: myshape, myoffset + integer*8, dimension(:), allocatable :: sizes + + allocate(sizes(nproc)) + call MPI_Allgather( mysize, 1, MPI_LONG_LONG, & + sizes, 1, MPI_LONG_LONG, & + app_comm, ierr) + myshape = sum(sizes) + myoffset = sum(sizes(1:rank)) + deallocate(sizes) +end subroutine gather_decomp_1d + +subroutine decompose_1d(globalsize, myoffset, mysize) + use mpivars + implicit none + integer*8, intent(in) :: globalsize + integer*8, intent(out) :: myoffset, mysize + integer*8 :: rem + + mysize = globalsize/nproc + rem = globalsize-(nproc*mysize) + if (rank < rem) then + mysize = mysize + 1 + myoffset = rank*mysize + else + myoffset = rank*mysize + rem + endif +end subroutine decompose_1d + +end module decomp + diff --git a/examples/basics/globalArray1D/decomp.c b/examples/basics/globalArray1D/decomp.c new file mode 100644 index 0000000000..bb7d3300a5 --- /dev/null +++ b/examples/basics/globalArray1D/decomp.c @@ -0,0 +1,67 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Created by Dmitry Ganyushin ganyushindi@ornl.gov + * + * Helper functions for all examples + */ +#include "decomp.h" +#include "mpivars.h" +#include +#include +#include +#include + +/* random integer from {minv, minv+1, ..., maxv} + including minv and maxv */ +long long int get_random(int minv, int maxv) +{ + long long int n; + time_t t; + /* Intializes random number generator */ + srand((unsigned)time(&t)); + n = (rand() % (maxv - minv + 1)) + minv; + return n; +} +/* gather the local sizes of arrays and sum them up + so that each process knows the global shape + and its own offset in the global space */ +void gather_decomp_1d(long long int *mysize, long long int *myshape, long long int *myoffset) +{ + long long int *sizes; + int i; + sizes = malloc(sizeof(long long int) * (size_t)nproc); + MPI_Allgather(mysize, 1, MPI_LONG_LONG, sizes, 1, MPI_LONG_LONG, app_comm); + + *myshape = 0; + for (i = 0; i < nproc; i++) + { + *myshape += sizes[i]; + } + *myoffset = 0; + for (i = 0; i < rank; i++) + { + *myoffset += sizes[i]; + } + + free(sizes); + return; +} + +void decomp_1d(long long int globalsize, long long int *myoffset, long long int *mysize) +{ + long long int rem; + *mysize = globalsize / nproc; + rem = globalsize - (nproc * *mysize); + if (rank < rem) + { + mysize = mysize + 1; + *myoffset = rank * *mysize; + } + else + { + *myoffset = rank * *mysize + rem; + } + return; +} diff --git a/examples/basics/globalArray1D/decomp.h b/examples/basics/globalArray1D/decomp.h new file mode 100644 index 0000000000..e972714844 --- /dev/null +++ b/examples/basics/globalArray1D/decomp.h @@ -0,0 +1,14 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Created by Dmitry Ganyushin ganyushindi@ornl.gov + */ + +#ifndef ADIOS2EXAMPLES_DECOMP_H +#define ADIOS2EXAMPLES_DECOMP_H + +extern long long int get_random(int, int); +extern void gather_decomp_1d(long long int *, long long int *, long long int *); +extern void decomp_1d(long long int, long long int *, long long int *); +#endif // ADIOS2EXAMPLES_DECOMP_H diff --git a/examples/basics/globalArray1D/globalArray1DRead.F90 b/examples/basics/globalArray1D/globalArray1DRead.F90 new file mode 100644 index 0000000000..725f1992cd --- /dev/null +++ b/examples/basics/globalArray1D/globalArray1DRead.F90 @@ -0,0 +1,104 @@ +program adios2_global_array_1d_read + use mpivars + use adios2 + implicit none + + ! ADIOS2 variables + type(adios2_adios) :: adios + + ! MPI then ADIOS2 initialization + call init_mpi(234) + call adios2_init(adios, app_comm, ierr) + + call reader() + + ! ADIOS2 then MPI finalization + call adios2_finalize(adios, ierr) + call finalize_mpi() + +contains + +subroutine reader + use mpivars + use decomp + use adios2 + implicit none + + character(len=256), parameter :: streamname = "adios2-global-array-1d-f.bp" + + type(adios2_io) :: io + type(adios2_engine) :: engine + type(adios2_variable) :: var_g + integer :: step, istatus + + ! Application variables + ! g = 1D distributed array, global shape and per-process size is fixed + + real*4, dimension(:), allocatable :: g + integer :: ndims + integer*8, dimension(:), allocatable :: fixed_shape + integer*8, dimension(1) :: fixed_start, fixed_count + + call adios2_declare_io (io, adios, 'input', ierr) + call adios2_open(engine, io, streamname, adios2_mode_read, ierr) + if (ierr .ne. 0) then + print '(" Failed to open stream: ",a)', streamname + print '(" open stream ierr=: ",i0)', ierr + return + endif + + ! Reading steps + step = 0 + do + call adios2_begin_step(engine, adios2_step_mode_read, 0.0, istatus, ierr) + if (ierr /= 0) then + print '(" Failure when trying to get next step: ",a)', streamname + exit + endif + if (istatus == adios2_step_status_end_of_stream) then + ! Stream has terminated, no more steps are available + !print '(" Input stream has terminated: ",a)', streamname + exit + endif + + ! Variable pointer MUST be retrieved every step, the reference + ! will go invalid after adios2_end_step + call adios2_inquire_variable(var_g, io, "GlobalArray", ierr ) + + ! Get variable dimensions and do decomposition in the first step + ! These don't change for the stream in this example + if (step == 0) then + ! fixed_shape is allocated in the next call + call adios2_variable_shape(fixed_shape, ndims, var_g, ierr) + + call decompose_1d(fixed_shape(1), fixed_start(1), fixed_count(1)) + allocate(g(fixed_count(1))) + + write (*,100) "Read plan rank=", rank, & + " global shape = ", fixed_shape(1), & + " local count = ", fixed_count(1), & + " offset = ", fixed_start(1) +100 format (a,i2,a,i4,a,i1,a,i4) + endif + + call adios2_set_selection(var_g, 1, fixed_start, fixed_count, ierr) + call adios2_get(engine, var_g, g, ierr) + call adios2_end_step(engine, ierr) + + ! g[] is now filled with data AFTER adios2_end_step/adios2_perform_gets + ! or should call adios2_get(engine, var_g, g, adios2_mode_sync, ierr) + ! to get it immediately in the get() call + + step = step + 1 + enddo + + ! Close the output + call adios2_close(engine, ierr) + + deallocate(g) + deallocate(fixed_shape) + +end subroutine reader + + +end program adios2_global_array_1d_read diff --git a/examples/basics/globalArray1D/globalArray1DRead.c b/examples/basics/globalArray1D/globalArray1DRead.c new file mode 100644 index 0000000000..288ce9f11b --- /dev/null +++ b/examples/basics/globalArray1D/globalArray1DRead.c @@ -0,0 +1,86 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Created by Dmitry Ganyushin ganyushindi@ornl.gov + */ +#include "decomp.h" +#include "mpivars.h" +#include +#include +#include + +void reader(adios2_adios *adios) +{ + int step; + float *g; + const char *streamname = "adios2-global-array-1d-c.bp"; + adios2_step_status err; + + long long int fixed_shape = 0, fixed_start = 0, fixed_count = 0; + + adios2_io *io = adios2_declare_io(adios, "input"); + size_t shape[1]; + shape[0] = (size_t)fixed_shape; + + adios2_engine *engine = adios2_open(io, streamname, adios2_mode_read); + step = 0; + do + { + adios2_begin_step(engine, adios2_step_mode_read, 10.0, &err); + adios2_variable *var_g = adios2_inquire_variable(io, "GlobalArray"); + if (step == 0) + { + /* fixed_shape is allocated in the next call*/ + adios2_variable_shape(shape, var_g); + fixed_shape = (long long int)shape[0]; + decomp_1d(fixed_shape, &fixed_start, &fixed_count); + g = malloc((size_t)fixed_count * sizeof(float)); + + printf("Read plan rank = %d global shape = %lld local count = %lld " + "offset = %lld\n", + rank, fixed_shape, fixed_count, fixed_start); + } + adios2_end_step(engine); + step++; + } while (err != adios2_step_status_end_of_stream); + // Close the output + adios2_close(engine); + free(g); + + if (rank == 0) + { + printf("Try the following: \n"); + printf(" bpls -la adios2-global-array-1d-c.bp GlobalArray -d -n " + "%lld \n", + fixed_shape); + printf(" bpls -la adios2-global-array-1d-c.bp GlobalArray -d -t -n " + "%lld \n ", + fixed_shape); + printf(" mpirun -n 2 ./adios2-global-array-1d-read-c \n"); + } +} + +int main(int argc, char *argv[]) +{ +#if ADIOS2_USE_MPI + init_mpi(123, argc, argv); +#endif + + { +#if ADIOS2_USE_MPI + + adios2_adios *adios = adios2_init_mpi(MPI_COMM_WORLD); +#else + adios2_adios *adios = adios2_init(); +#endif + reader(adios); + adios2_finalize(adios); + } + +#if ADIOS2_USE_MPI + finalize_mpi(); +#endif + + return 0; +} diff --git a/examples/basics/globalArray1D/globalArray1DWrite.F90 b/examples/basics/globalArray1D/globalArray1DWrite.F90 new file mode 100644 index 0000000000..90d0778909 --- /dev/null +++ b/examples/basics/globalArray1D/globalArray1DWrite.F90 @@ -0,0 +1,93 @@ +program adios2_global_array_1d_write + use mpivars + use adios2 + implicit none + integer, parameter :: numsteps = 5 + + ! ADIOS2 variables + type(adios2_adios) :: adios + + ! MPI then ADIOS2 initialization + call init_mpi(123) + call adios2_init(adios, app_comm, ierr) + + call writer() + + ! ADIOS2 then MPI finalization + call adios2_finalize(adios, ierr) + call finalize_mpi() + +contains + +subroutine writer + use mpivars + use decomp + use adios2 + implicit none + + type(adios2_io) :: io + type(adios2_engine) :: engine + type(adios2_variable) :: var_g + type(adios2_attribute) :: attr + integer :: step + + ! Application variables + ! g = 1D distributed array, + ! global shape and per-process size is fixed + + real*4, dimension(:), allocatable :: g + character(80), parameter :: ga = "Global Array with fixed shape and decomposition" + + integer, parameter :: mincount = 2, maxcount = 5 + integer*8, dimension(1) :: fixed_shape, fixed_start, fixed_count + + fixed_count(1) = get_random(mincount, maxcount) + allocate(g(fixed_count(1))) + call gather_decomp_1d(fixed_count(1), fixed_shape(1), fixed_start(1)) + + call adios2_declare_io (io, adios, 'output', ierr) + + call adios2_define_variable(var_g, io, "GlobalArray", & + adios2_type_real4, 1, & + fixed_shape, fixed_start, fixed_count, & + adios2_constant_dims, ierr) + + call adios2_define_attribute(attr, io, "GlobalArray/info", ga, ierr) + + call adios2_open(engine, io, "adios2-global-array-1d-f.bp", adios2_mode_write, ierr) + + write (*,100) "Decomp rank=", rank, & + " global shape = ", fixed_shape(1), & + " local count = ", fixed_count(1), & + " offset = ", fixed_start(1) +100 format (a,i2,a,i4,a,i1,a,i4) + + ! Computation/output loop + do step=0,numsteps-1 + g = rank + (step+1)/100.0 + ! Output all data + call adios2_begin_step(engine, adios2_step_mode_append, ierr) + call adios2_put(engine, var_g, g, ierr); + call adios2_end_step(engine, ierr) + enddo + + ! Close the output + call adios2_close(engine, ierr) + + deallocate(g) + + if (rank == 0) then + write (*,*) "Try the following: " + write (*,'(a,a,i4)') & + " bpls -la adios2-global-array-1d-f.bp ", & + "GlobalArray -d -n ", fixed_shape(1) + write (*,'(a,a,i4)') & + " bpls -la adios2-global-array-1d-f.bp ", & + "GlobalArray -d -t -n ", fixed_shape(1) + write (*,'(a)') & + " mpirun -n 2 ./adios2-global-array-1d-read-f " + endif +end subroutine writer + + +end program adios2_global_array_1d_write diff --git a/examples/basics/globalArray1D/globalArray1DWrite.c b/examples/basics/globalArray1D/globalArray1DWrite.c new file mode 100644 index 0000000000..4ae38ed3da --- /dev/null +++ b/examples/basics/globalArray1D/globalArray1DWrite.c @@ -0,0 +1,99 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Created by Dmitry Ganyushin ganyushindi@ornl.gov + */ +#include "decomp.h" +#include "mpivars.h" +#include +#include +#include + +void writer(adios2_adios *adios) +{ + int step, i; + float *g; + const int mincount = 2; + const int maxcount = 5; + const int numsteps = 5; + adios2_step_status err; + + long long int fixed_shape = 0, fixed_start = 0, fixed_count = 0; + + /* Application variables + g = 1D distributed array, + global shape and per-process size is fixed */ + fixed_count = get_random(mincount, maxcount); + g = malloc((size_t)fixed_count * sizeof(float)); + gather_decomp_1d(&fixed_count, &fixed_shape, &fixed_start); + + adios2_io *io = adios2_declare_io(adios, "output"); + size_t shape[1]; + shape[0] = (size_t)fixed_shape; + + size_t start[1]; + start[0] = (size_t)fixed_start; + + size_t count[1]; + count[0] = (size_t)fixed_count; + + adios2_variable *var_g = adios2_define_variable(io, "GlobalArray", adios2_type_float, 1, shape, + start, count, adios2_constant_dims_true); + + adios2_engine *engine = adios2_open(io, "adios2-global-array-1d-c.bp", adios2_mode_write); + printf("Decmp rank = %d global shape = %lld local count = %lld offset = " + "%lld\n", + rank, fixed_shape, fixed_count, fixed_start); + for (step = 0; step < numsteps; step++) + { + for (i = 0; i < fixed_count; i++) + { + g[i] = (float)(rank + (step + 1) / 100.0); + } + + adios2_begin_step(engine, adios2_step_mode_append, 10.0f, &err); + adios2_put(engine, var_g, g, adios2_mode_deferred); + adios2_end_step(engine); + } + // Close the output + adios2_close(engine); + free(g); + + if (rank == 0) + { + printf("Try the following: \n"); + printf(" bpls -la adios2-global-array-1d-c.bp GlobalArray -d -n " + "%lld \n", + fixed_shape); + printf(" bpls -la adios2-global-array-1d-c.bp GlobalArray -d -t -n " + "%lld \n ", + fixed_shape); + printf(" mpirun -n 2 ./adios2-global-array-1d-read-c \n"); + } +} + +int main(int argc, char *argv[]) +{ +#if ADIOS2_USE_MPI + init_mpi(123, argc, argv); +#endif + + { +#if ADIOS2_USE_MPI + + adios2_adios *adios = adios2_init_mpi(MPI_COMM_WORLD); +#else + adios2_adios *adios = adios2_init(); +#endif + + writer(adios); + adios2_finalize(adios); + } + +#if ADIOS2_USE_MPI + finalize_mpi(); +#endif + + return 0; +} diff --git a/examples/basics/globalArray1D/mpivars.F90 b/examples/basics/globalArray1D/mpivars.F90 new file mode 100644 index 0000000000..323e4b0c15 --- /dev/null +++ b/examples/basics/globalArray1D/mpivars.F90 @@ -0,0 +1,30 @@ +module mpivars + implicit none + include 'mpif.h' + + integer:: app_comm, rank, nproc + integer:: wrank, wnproc + integer:: ierr + +contains + +subroutine init_mpi(color) + integer, intent(in):: color + call MPI_Init(ierr) + ! World comm spans all applications started with the same mpirun command + call MPI_Comm_rank(MPI_COMM_WORLD, wrank, ierr) + call MPI_Comm_size(MPI_COMM_WORLD, wnproc, ierr) + + ! Have to split and create a 'world' communicator for this app only + ! color must be unique for each application + call MPI_Comm_split (MPI_COMM_WORLD, color, wrank, app_comm, ierr) + call MPI_Comm_rank (app_comm, rank, ierr) + call MPI_Comm_size (app_comm, nproc , ierr) +end subroutine init_mpi + +subroutine finalize_mpi() + call MPI_Finalize(ierr) +end subroutine finalize_mpi + +end module mpivars + diff --git a/examples/basics/globalArray1D/mpivars.c b/examples/basics/globalArray1D/mpivars.c new file mode 100644 index 0000000000..5c4aa5634b --- /dev/null +++ b/examples/basics/globalArray1D/mpivars.c @@ -0,0 +1,29 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Created by Dmitry Ganyushin ganyushindi@ornl.gov + */ +#include "mpivars.h" +#include + +int rank, nproc; +int wrank, wnproc; +MPI_Comm app_comm; + +void init_mpi(int color, int argc, char *argv[]) +{ + MPI_Init(&argc, &argv); + /* World comm spans all applications started with the same mpirun command */ + MPI_Comm_rank(MPI_COMM_WORLD, &wrank); + MPI_Comm_size(MPI_COMM_WORLD, &wnproc); + + /* Have to split and create a 'world' communicator for this app only + color must be unique for each application*/ + MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &app_comm); + MPI_Comm_rank(app_comm, &rank); + MPI_Comm_size(app_comm, &nproc); + return; +} + +void finalize_mpi() { MPI_Finalize(); } diff --git a/examples/basics/globalArray1D/mpivars.h b/examples/basics/globalArray1D/mpivars.h new file mode 100644 index 0000000000..98c00586d3 --- /dev/null +++ b/examples/basics/globalArray1D/mpivars.h @@ -0,0 +1,14 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Created by Dmitry Ganyushin ganyushindi@ornl.gov + */ +#ifndef ADIOS2EXAMPLES_MPIVARS_H +#define ADIOS2EXAMPLES_MPIVARS_H +#include +extern int rank, nproc; +extern MPI_Comm app_comm; +void init_mpi(int, int, char *argv[]); +void finalize_mpi(); +#endif // ADIOS2EXAMPLES_MPIVARS_H diff --git a/examples/basics/globalArrayND/globalArrayNDWrite.cpp b/examples/basics/globalArrayND/globalArrayNDWrite.cpp index 45c63c5c25..9832cc47ab 100644 --- a/examples/basics/globalArrayND/globalArrayNDWrite.cpp +++ b/examples/basics/globalArrayND/globalArrayNDWrite.cpp @@ -94,7 +94,8 @@ int main(int argc, char *argv[]) for (size_t i = 0; i < Nx; i++) { - row[i] = step * Nx * nproc * 1.0 + rank * Nx * 1.0 + (double)i; + row[i] = static_cast(step) * Nx * nproc * 1.0 + rank * Nx * 1.0 + + static_cast(i); } // Make a 2D selection to describe the local dimensions of the diff --git a/examples/basics/queryWorker/CMakeLists.txt b/examples/basics/queryWorker/CMakeLists.txt index 839dd19bf2..7cce9e5c4c 100644 --- a/examples/basics/queryWorker/CMakeLists.txt +++ b/examples/basics/queryWorker/CMakeLists.txt @@ -17,12 +17,10 @@ if(NOT TARGET adios2_core) list(APPEND _components MPI) endif() - find_package(ZeroMQ 4.1 QUIET) - find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) endif() -if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_DataMan) +if(ADIOS2_HAVE_MPI) add_executable(adios2_basics_queryWorker queryWorker.cpp) target_link_libraries(adios2_basics_queryWorker adios2::cxx11_mpi MPI::MPI_C) install(TARGETS adios2_basics_queryWorker RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/basics/queryWorker/README.md b/examples/basics/queryWorker/README.md deleted file mode 100644 index 65b8042d3e..0000000000 --- a/examples/basics/queryWorker/README.md +++ /dev/null @@ -1,8 +0,0 @@ -q1.json is a json query file for one var - -q2.json is a composite query - -The bp*xml are the from heat transfer example with bp4 engine. -and tag is added at the end for xml query spec - -JSON query file option should be used with ADIOS2_HAVE_DATAMAN \ No newline at end of file diff --git a/examples/basics/queryWorker/queryWorker.cpp b/examples/basics/queryWorker/queryWorker.cpp index 2f172a18f0..9d878714b7 100644 --- a/examples/basics/queryWorker/queryWorker.cpp +++ b/examples/basics/queryWorker/queryWorker.cpp @@ -1,17 +1,16 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + #include "adios2.h" #include #include -#include #include -#include -#include -#include #include #include -// #include "adios2/toolkit/query/Worker.h" - void queryWithStreaming(adios2::IO &queryIO, std::string &dataFileName, std::string &queryFile) { adios2::Engine reader = queryIO.Open(dataFileName, adios2::Mode::Read, MPI_COMM_WORLD); diff --git a/examples/basics/values/CMakeLists.txt b/examples/basics/values/CMakeLists.txt index 799c72cc54..f37b7da6ab 100644 --- a/examples/basics/values/CMakeLists.txt +++ b/examples/basics/values/CMakeLists.txt @@ -9,6 +9,15 @@ project(ADIOS2BasicsValuesExample) if(NOT TARGET adios2_core) set(_components C) + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + endif() + if(CMAKE_Fortran_COMPILER_LOADED) + list(APPEND _components Fortran) + endif() + find_package(MPI COMPONENTS ${_components}) if(MPI_FOUND) # Workaround for various MPI implementations forcing the link of C++ bindings @@ -29,4 +38,16 @@ if(ADIOS2_HAVE_MPI) add_executable(adios2_basics_valuesWrite_mpi valuesWrite.cpp) target_link_libraries(adios2_basics_valuesWrite_mpi adios2::cxx11_mpi MPI::MPI_C) install(TARGETS adios2_basics_valuesWrite_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ADIOS2_HAVE_Fortran) + add_library(adios2_basics_values_mpivars_f OBJECT mpivars.F90) + target_link_libraries(adios2_basics_values_mpivars_f MPI::MPI_Fortran) + install(TARGETS adios2_basics_values_mpivars_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_basics_values_f values.F90) + target_link_libraries(adios2_basics_values_f + adios2_basics_values_mpivars_f + adios2::fortran_mpi MPI::MPI_Fortran) + install(TARGETS adios2_basics_values_f RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() diff --git a/examples/basics/values/mpivars.F90 b/examples/basics/values/mpivars.F90 new file mode 100644 index 0000000000..323e4b0c15 --- /dev/null +++ b/examples/basics/values/mpivars.F90 @@ -0,0 +1,30 @@ +module mpivars + implicit none + include 'mpif.h' + + integer:: app_comm, rank, nproc + integer:: wrank, wnproc + integer:: ierr + +contains + +subroutine init_mpi(color) + integer, intent(in):: color + call MPI_Init(ierr) + ! World comm spans all applications started with the same mpirun command + call MPI_Comm_rank(MPI_COMM_WORLD, wrank, ierr) + call MPI_Comm_size(MPI_COMM_WORLD, wnproc, ierr) + + ! Have to split and create a 'world' communicator for this app only + ! color must be unique for each application + call MPI_Comm_split (MPI_COMM_WORLD, color, wrank, app_comm, ierr) + call MPI_Comm_rank (app_comm, rank, ierr) + call MPI_Comm_size (app_comm, nproc , ierr) +end subroutine init_mpi + +subroutine finalize_mpi() + call MPI_Finalize(ierr) +end subroutine finalize_mpi + +end module mpivars + diff --git a/examples/basics/values/values.F90 b/examples/basics/values/values.F90 new file mode 100644 index 0000000000..608ecf37b6 --- /dev/null +++ b/examples/basics/values/values.F90 @@ -0,0 +1,169 @@ +program adios2_values + use mpivars + use adios2 + implicit none + integer, parameter :: numsteps = 5 + ! ADIOS2 variables + type(adios2_adios) :: adios + + ! MPI then ADIOS2 initialization + call init_mpi(12345) + call adios2_init(adios, app_comm, ierr) + + call writer() + call reader() + + ! ADIOS2 then MPI finalization + call adios2_finalize(adios, ierr) + call finalize_mpi() + +contains + +subroutine writer + use mpivars + use adios2 + implicit none + + type(adios2_variable) :: var_gc, var_gv, var_lc, var_lv, var_gs + type(adios2_io) :: io + type(adios2_engine) :: engine + integer :: step + + ! Application variables + ! gc = Global Constant (a single value from the entire application, once per run (e.g. NPROC)) + ! gv = Global Value (a single value from the entire application, changes over time) + ! lc = Local Constant (one value per process, once per run (e.g. RANK)) + ! lv = Local Value (one value per process, changes over time) + ! gs = a string, same as a global value + integer :: gc, gv, lc, lv + character(len=80) :: gs + + call adios2_declare_io (io, adios, 'Values', ierr) + + call adios2_define_variable(var_gc, io, "GlobalConstant", adios2_type_integer4, ierr) + call adios2_define_variable(var_gv, io, "GlobalValue", adios2_type_integer4, ierr) + ! Local values will show up in reading as a 1D array of nproc elements + ! the write side definition is quite cumbersome in Fortran :-( + ! We have to define it almost like a distributed global array with a special + ! dimension value to indicate its type + call adios2_define_variable(var_lc, io, "LocalConstant", adios2_type_integer4, & + 1, (/ adios2_local_value_dim /), & + adios2_null_dims, & + adios2_null_dims, & + adios2_constant_dims, ierr) + + call adios2_define_variable(var_lv, io, "LocalValue", adios2_type_integer4, & + 1, (/ adios2_local_value_dim /), & + adios2_null_dims, & + adios2_null_dims, & + adios2_constant_dims, ierr) + + call adios2_define_variable(var_gs, io, "GlobalString", adios2_type_string, ierr) + + call adios2_open(engine, io, "adios2-values-f.bp", adios2_mode_write, ierr) + + ! Computation/output loop + gc = nproc + lc = rank + do step=0,numsteps-1 + gv = step + lv = nproc*(step)+rank + write (gs,'(a,i3)') "This is step ", step + + call adios2_begin_step(engine, adios2_step_mode_append, ierr) + if (step == 0) then + call adios2_put(engine, var_lc, lc, ierr); + if (rank == 0) then + ! could be written from every process but it is useless + call adios2_put(engine, var_gc, gc, ierr); + endif + endif + if (rank == 0) then + ! could be written from every process but it is useless + call adios2_put(engine, var_gv, gv, ierr); + call adios2_put(engine, var_gs, gs, ierr); + endif + call adios2_put(engine, var_lv, lv, ierr); + call adios2_end_step(engine, ierr) + enddo + + ! Close the output + call adios2_close(engine, ierr) + +end subroutine writer + + +subroutine reader + use mpivars + implicit none + + type(adios2_variable) :: var_gc, var_gv, var_lc, var_lv + type(adios2_io) :: io + type(adios2_engine) :: engine + integer*8 :: numsteps, i + integer*4 :: gc + integer*4, dimension(:), allocatable :: gvs, lcs + integer*4, dimension(:,:), allocatable :: lvs + character(len=80)::fmt + integer*8, dimension(:), allocatable :: shape_lv, shape_lc + integer :: ndims_lv, ndims_lc + + ! Note, every process reads everything in this example + + call adios2_declare_io(io, adios, "ValuesInput", ierr) + call adios2_open(engine, io, "adios2-values-f.bp", adios2_mode_read, MPI_COMM_SELF, ierr) + + call adios2_inquire_variable(var_gc, io, "GlobalConstant", ierr) + call adios2_get(engine, var_gc, gc , ierr) + + call adios2_inquire_variable(var_gv, io, "GlobalValue", ierr) + call adios2_variable_steps(numsteps, var_gv, ierr) + call adios2_set_step_selection(var_gv, 0_8, numsteps, ierr) + allocate(gvs(numsteps)) + call adios2_get(engine, var_gv, gvs , ierr) + + ! Read Local Values and Local Constants as a 1D array + ! shape array is allocated inside adios2_variable_shape() + + call adios2_inquire_variable(var_lc, io, "LocalConstant", ierr) + call adios2_variable_shape(shape_lc, ndims_lc, var_lc, ierr) + allocate(lcs(shape_lc(1))) + call adios2_get(engine, var_lc, lcs , ierr) + + call adios2_inquire_variable(var_lv, io, "LocalValue", ierr) + call adios2_variable_shape(shape_lv, ndims_lv, var_lv, ierr) + call adios2_set_step_selection(var_lv, 0_8, numsteps, ierr) + allocate(lvs(shape_lv(1),numsteps)) + call adios2_get(engine, var_lv, lvs , ierr) + + call adios2_close(engine, ierr) + + ! By default, get()s are deferred and content is available AFTER + ! adios2_close() or adios2_perform_gets() + ! Use adios2_mode_sync option in adios2_get() to get the content immediately + + if (rank == 0) then + write(*,'("Number of steps in file = ",i5)') numsteps + write(*,'("GlobalConstant = ", i5)') gc + + write(fmt,'(a,i5,a)') '(a18,',numsteps,'i4,a2)' + !write(*,'(a)') fmt + write(*,fmt) "GlobalValue(s) = [", gvs, " ]" + + write(fmt,'(a,i5,a)') '(a20,',shape_lc(1),'i4,a2)' + !write(*,'(a)') fmt + write(*,fmt) "LocalConstant(s) = [", lcs, " ]" + + write(fmt,'(a,i5,a)') '(a6,i3,a4,',shape_lv(1),'i4)' + !write(*,'(a)') fmt + write(*,'(a)') "LocalValues = [" + do i = 1, numsteps + write(*,fmt) " step", i-1, ":", lvs(:,i) + enddo + write(*,*) " ]" + endif + + deallocate(gvs, lcs, lvs) +end subroutine reader + +end program adios2_values diff --git a/examples/basics/variablesShapes/CMakeLists.txt b/examples/basics/variablesShapes/CMakeLists.txt new file mode 100644 index 0000000000..2dbd92f4fd --- /dev/null +++ b/examples/basics/variablesShapes/CMakeLists.txt @@ -0,0 +1,39 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2BasicsVariablesShapesExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_basics_variablesShapes variablesShapes.cpp) +target_link_libraries(adios2_basics_variablesShapes adios2::cxx11) +install(TARGETS adios2_basics_variablesShapes RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_basics_variablesShapes_hl variablesShapes_hl.cpp) +target_link_libraries(adios2_basics_variablesShapes_hl adios2::cxx11) +install(TARGETS adios2_basics_variablesShapes_hl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +if(ADIOS2_HAVE_MPI) + add_executable(adios2_basics_variablesShapes_mpi variablesShapes.cpp) + target_link_libraries(adios2_basics_variablesShapes_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_basics_variablesShapes_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_basics_variablesShapes_hl_mpi variablesShapes_hl.cpp) + target_link_libraries(adios2_basics_variablesShapes_hl_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_basics_variablesShapes_hl_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/basics/variablesShapes/variablesShapes.cpp b/examples/basics/variablesShapes/variablesShapes.cpp new file mode 100644 index 0000000000..6dce0f8fae --- /dev/null +++ b/examples/basics/variablesShapes/variablesShapes.cpp @@ -0,0 +1,269 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * * variablesShapes.cpp : adios2 low-level API example to write and read + * supported Variables shapes using stepping + * (streaming) mode + * + * Created on: Nov 14, 2019 + * Author: William F Godoy godoywf@ornl.gov + */ + +#include //std::size_t +#include // std::cout +#include // std::numeric_limits +#include //std::iota +#include //std::exception + +#include +#if ADIOS2_USE_MPI +#include +#endif + +void writer(adios2::ADIOS &adios, const std::size_t nx, const std::size_t nsteps, const int rank, + const int size) +{ + auto lf_compute = [](const std::size_t step, const std::size_t nx, + const int rank) -> std::vector { + const float value = static_cast(step + rank * nx); + std::vector array(nx); + std::iota(array.begin(), array.end(), value); + return array; + }; + + adios2::IO io = adios.DeclareIO("variables-shapes_writer"); + + // You can define variables according to: + // type : string, uint8_t, int8_t8, ... , float, double + // shape: global : value or array + // local : value (return a global array), array + + /********** GLOBAL VALUE *************/ + // string variables are always of value type, can't pass dimensions + adios2::Variable varGlobalValueString = + io.DefineVariable("GlobalValueString"); + + // global value can change on each step. Example: Step + adios2::Variable varStep = io.DefineVariable("Step"); + + /********** GLOBAL ARRAYS *************/ + // For a regular 1D decomposition: + + // 0*nx 1*nx 2*nx 3*nx shape (4*nx) + //--------//-------//--------//---------// + // nx nx nx nx + + // global shape -> this is the physical dimension across MPI processes + const adios2::Dims shape = {static_cast(size * nx)}; + + // local start for rank offset -> this is the local origin for the rank + // domain + const adios2::Dims start = {static_cast(rank * nx)}; + + // local count -> this is the local size from the local start for the rank + // domain + const adios2::Dims count = {nx}; + + // adios2::Dims is an alias to std::vector + // helps remember the inputs to adios2 functions DefineVariable (write) and + // SetSelection (read) make sure you always pass std::size_t types + + // global array with dimensions (shape, start, count) + // last argument indicates to adios2 that dimensions won't change + adios2::Variable varGlobalArray = + io.DefineVariable("GlobalArray", shape, start, count, adios2::ConstantDims); + + /********** LOCAL VALUE **************/ + // Independent values per rank at write, but presented as a global array at + // read Example: store current rank, but presented as an array of ranks + adios2::Variable varLocalValueInt32 = + io.DefineVariable("Rank", {adios2::LocalValueDim}); + + /********** LOCAL ARRAY **************/ + // Independent values and dimensions per rank, there is no notion of + // "continuity", each start from 0-origin to count. Example: mesh + // nodes-per-rank + adios2::Variable varLocalArray = + io.DefineVariable("LocalArray", {}, {}, count, adios2::ConstantDims); + + adios2::Engine writer = io.Open("variables-shapes.bp", adios2::Mode::Write); + + for (size_t step = 0; step < nsteps; ++step) + { + // this part mimics the compute portion in an application + const std::vector array = lf_compute(step, nx, rank); + + // ADIOS2 I/O portion + + // BeginStep/EndStep is the streaming API -> supported by all engines + writer.BeginStep(); + + // minimize global and local values footprint, by only one rank putting + // the variables + if (rank == 0) + { + // Global value changing over steps + writer.Put(varStep, static_cast(step)); + + if (step == 0) + { + // Global absolute value + writer.Put(varGlobalValueString, std::string("ADIOS2 Basics Variable Example")); + // Local absolute value + writer.Put(varLocalValueInt32, static_cast(rank)); + } + } + + // for this example all ranks put a global and a local array + writer.Put(varGlobalArray, array.data()); + writer.Put(varLocalArray, array.data()); + writer.EndStep(); + } + writer.Close(); +} + +void reader(adios2::ADIOS &adios, const int rank, const int size) +{ + adios2::IO io = adios.DeclareIO("variables-shapes_reader"); + // all ranks opening the bp file have access to the entire metadata + adios2::Engine reader = io.Open("variables-shapes.bp", adios2::Mode::Read); + + // reading in streaming mode + while (reader.BeginStep() != adios2::StepStatus::EndOfStream) + { + // scope between BeginStep and EndStep is only for the current step + const size_t currentStep = reader.CurrentStep(); + + // Typical flow: InquireVariable + adios2::Variable varStep = io.InquireVariable("Step"); + uint64_t step = std::numeric_limits::max(); + // check Variable existence + if (varStep) + { + if (rank == 0) + { + // variable objects are "printable" reporting Name and Type + std::cout << "Found Global Value " << varStep << " in step " << currentStep << "\n"; + // output: Found Global Value Variable(Name: "Step") + // in step 0 + } + reader.Get(varStep, step); + } + + // GlobalValueString + adios2::Variable varGlobalValueString = + io.InquireVariable("GlobalValueString"); + std::string globalValueString; + // check Variable existence and Get + if (varGlobalValueString) + { + if (rank == 0) + { + std::cout << "Found Global Value " << varGlobalValueString << " in step " + << currentStep << "\n"; + } + reader.Get(varGlobalValueString, globalValueString); + } + + // Global Arrays at read from local values at write + adios2::Variable varRanks = io.InquireVariable("Ranks"); + std::vector ranks; + if (varRanks) + { + if (rank == 0) + { + std::cout << "Found Global Array " << varRanks << " in step " << currentStep + << "\n"; + } + // passing a vector convenience: adios2 would resize it + // automatically + reader.Get(varRanks, ranks); + } + + // Global Array + adios2::Variable varGlobalArray = io.InquireVariable("GlobalArray"); + std::vector globalArray; + if (varGlobalArray) + { + if (rank == 0) + { + std::cout << "Found GlobalArray " << varGlobalArray << " in step " << currentStep + << "\n"; + } + reader.Get(varGlobalArray, globalArray); + } + + // Local Array + adios2::Variable varLocalArray = io.InquireVariable("LocalArray"); + std::vector localArray; + if (varLocalArray) + { + // local arrays require an extra step to select the block of + // interest (0 is default) we only select block 0 in this example + varLocalArray.SetBlockSelection(0); + if (rank == 0) + { + std::cout << "Found LocalArray " << varLocalArray << " in step " << currentStep + << "\n"; + } + reader.Get(varLocalArray, localArray); + } + + // since all Get calls are "deferred" all the data would be populated at + // EndStep + reader.EndStep(); + + // data is available + + if (rank == 0) + { + std::cout << "\n"; + } + } + + reader.Close(); +} + +int main(int argc, char *argv[]) +{ +#if ADIOS2_USE_MPI + MPI_Init(&argc, &argv); +#endif + + int rank = 0; + int size = 1; + +#if ADIOS2_USE_MPI + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + try + { +#if ADIOS2_USE_MPI + adios2::ADIOS adios(MPI_COMM_WORLD); +#else + adios2::ADIOS adios; +#endif + + constexpr std::size_t nx = 10; + constexpr std::size_t nsteps = 3; + + writer(adios, nx, nsteps, rank, size); + reader(adios, rank, size); + } + catch (const std::exception &e) + { + std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n"; +#if ADIOS2_USE_MPI + MPI_Abort(MPI_COMM_WORLD, -1); +#endif + } + +#if ADIOS2_USE_MPI + MPI_Finalize(); +#endif + + return 0; +} diff --git a/examples/basics/variablesShapes/variablesShapes_hl.cpp b/examples/basics/variablesShapes/variablesShapes_hl.cpp new file mode 100644 index 0000000000..5977b2c311 --- /dev/null +++ b/examples/basics/variablesShapes/variablesShapes_hl.cpp @@ -0,0 +1,194 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * variablesShapes_hl.cpp : adios2 high-level API example to write and read + * supported Variables shapes using stepping (streaming) mode + * + * Created on: Nov 14, 2019 + * Author: William F Godoy godoywf@ornl.gov + */ + +#include //std::size_t +#include // std::cout +#include // std::numeric_limits +#include //std::iota +#include //std::exception + +#include +#if ADIOS2_USE_MPI +#include +#endif + +void writer(const std::size_t nx, const std::size_t nsteps, const int rank, const int size) +{ + auto lf_compute = [](const std::size_t step, const std::size_t nx, + const int rank) -> std::vector { + const float value = static_cast(step + rank * nx); + std::vector array(nx); + std::iota(array.begin(), array.end(), value); + return array; + }; + + // You can define variables according to: + // type : string, uint8_t, int8_t8, ... , float, double + // shape: global : value or array + // local : value (return a global array), array + + // global shape -> this is the physical dimension across MPI processes + const adios2::Dims shape = {static_cast(size * nx)}; + + // local start for rank offset -> this is the local origin for the rank + // domain + const adios2::Dims start = {static_cast(rank * nx)}; + + // local count -> this is the local size from the local start for the rank + // domain + const adios2::Dims count = {nx}; + + // adios2::Dims is an alias to std::vector + // helps remember the inputs to adios2 functions DefineVariable (write) and + // SetSelection (read) make sure you always pass std::size_t types + +#if ADIOS2_USE_MPI + adios2::fstream out("variables-shapes_hl.bp", adios2::fstream::out, MPI_COMM_WORLD); +#else + adios2::fstream out("variables-shapes_hl.bp", adios2::fstream::out); +#endif + + for (size_t step = 0; step < nsteps; ++step) + { + // this part mimics the compute portion in an application + const std::vector array = lf_compute(step, nx, rank); + + // ADIOS2 I/O portion + + // minimize global and local values footprint, by only one rank writing + // the variables + if (rank == 0) + { + // Global value changing over steps + out.write("Step", static_cast(step)); + + if (step == 0) + { + // Constant Global value + out.write("GlobalValueString", std::string("ADIOS2 Basics Variable Example")); + + // Constant Local value + out.write("LocalValueInt32", static_cast(rank), adios2::LocalValue); + } + } + + // for this example all ranks write a global and a local array + out.write("GlobalArray", array.data(), shape, start, count); + out.write("LocalArray", array.data(), {}, {}, count); + + out.end_step(); + } + out.close(); +} + +void reader(const int rank, const int size) +{ + auto lf_ArrayToString = [](const std::vector &array) -> std::string { + std::string contents = "{ "; + for (const float value : array) + { + contents += std::to_string(static_cast(value)) + " "; + } + contents += "}"; + return contents; + }; + +// all ranks opening the bp file have access to the entire metadata +#if ADIOS2_USE_MPI + adios2::fstream in("variables-shapes_hl.bp", adios2::fstream::in, MPI_COMM_WORLD); +#else + adios2::fstream in("variables-shapes_hl.bp", adios2::fstream::in); +#endif + + // reading in streaming mode, supported by all engines + // similar to std::getline in std::fstream + adios2::fstep inStep; + while (adios2::getstep(in, inStep)) + { + const std::size_t currentStep = inStep.current_step(); + + const std::vector steps = inStep.read("Step"); + if (!steps.empty() && rank == 0) + { + std::cout << "Found Step " << steps.front() << " in currentStep " << currentStep + << "\n"; + } + + const std::vector globalValueString = + inStep.read("GlobalValueString"); + if (!globalValueString.empty() && rank == 0) + { + std::cout << "Found GlobalValueString " << globalValueString.front() + << " in currentStep " << currentStep << "\n"; + } + + const std::vector ranks = inStep.read("Ranks"); + if (!ranks.empty() && rank == 0) + { + std::cout << "Found rank " << ranks.front() << " in currentStep " << currentStep + << "\n"; + } + + const std::vector globalArray = inStep.read("GlobalArray"); + if (!globalArray.empty() && rank == 0) + { + std::cout << "Found globalArray " << lf_ArrayToString(globalArray) + " in currentStep " + << currentStep << "\n"; + } + + // default reads block 0 + const std::vector localArray = inStep.read("LocalArray"); + if (!localArray.empty() && rank == 0) + { + std::cout << "Found localArray " << lf_ArrayToString(localArray) + " in currentStep " + << currentStep << "\n"; + } + // indicate end of adios2 operations for this step + in.end_step(); + } + in.close(); +} + +int main(int argc, char *argv[]) +{ +#if ADIOS2_USE_MPI + MPI_Init(&argc, &argv); +#endif + int rank = 0; + int size = 1; + +#if ADIOS2_USE_MPI + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + try + { + constexpr std::size_t nx = 10; + constexpr std::size_t nsteps = 3; + + writer(nx, nsteps, rank, size); + reader(rank, size); + } + catch (std::exception &e) + { + std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n"; +#if ADIOS2_USE_MPI + MPI_Abort(MPI_COMM_WORLD, -1); +#endif + } + +#if ADIOS2_USE_MPI + MPI_Finalize(); +#endif + + return 0; +} diff --git a/examples/hello/CMakeLists.txt b/examples/hello/CMakeLists.txt index dd90609718..297ed51882 100644 --- a/examples/hello/CMakeLists.txt +++ b/examples/hello/CMakeLists.txt @@ -11,9 +11,23 @@ if(ADIOS2_HAVE_MPI) endif() add_subdirectory(bpReader) +add_subdirectory(bpThreadWrite) add_subdirectory(bpTimeWriter) add_subdirectory(bpWriter) +if(ADIOS2_HAVE_CUDA OR ADIOS2_HAVE_Kokkos_CUDA) + add_subdirectory(bpWriteReadCuda) +endif() + +find_package(hip QUIET) +if(ADIOS2_HAVE_Kokkos_HIP OR hip_FOUND) + add_subdirectory(bpWriteReadHip) +endif() + +if(ADIOS2_HAVE_Kokkos) + add_subdirectory(bpWriteReadKokkos) +endif() + if(ADIOS2_HAVE_DataMan) add_subdirectory(datamanReader) add_subdirectory(datamanWriter) @@ -32,6 +46,8 @@ if(ADIOS2_HAVE_HDF5) endif() endif() +add_subdirectory(helloWorld) + if(ADIOS2_HAVE_Fortran) add_subdirectory(inlineFWriteCppRead) endif() diff --git a/examples/hello/bpThreadWrite/CMakeLists.txt b/examples/hello/bpThreadWrite/CMakeLists.txt new file mode 100644 index 0000000000..bc7fd8fb1b --- /dev/null +++ b/examples/hello/bpThreadWrite/CMakeLists.txt @@ -0,0 +1,21 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloThreadWriteExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(Threads QUIET) + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(Threads_FOUND) + add_executable(adios2_hello_bpThreadWrite bpThreadWrite.cpp) + target_link_libraries(adios2_hello_bpThreadWrite adios2::cxx11 ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS adios2_hello_bpThreadWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/hello/bpThreadWrite/bpThreadWrite.cpp b/examples/hello/bpThreadWrite/bpThreadWrite.cpp new file mode 100644 index 0000000000..f29c288879 --- /dev/null +++ b/examples/hello/bpThreadWrite/bpThreadWrite.cpp @@ -0,0 +1,122 @@ + +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * bpThreadWrite.cpp : adios2 low-level API example to write in a threaded + * application using C++11 thread and having adios2 calls + * inside mutex regions adios2 API are not thread-safe: + * 1. launching MPI from a thread is not possible on many + * supercomputers + * 2. I/O is highly serialized (buffering and low-level I/O + * calls), therefore users must be aware that adios2 might introduce + * bottlenecks. To run: Do not use MPI, just run the executable + * ./adios2_hello_bpThreadWrite + * + * Created on: Nov 14, 2019 + * Author: William F Godoy godoywf@ornl.gov + */ + +#include + +#include //std::size_t +#include +#include +#include +#include +#include + +namespace +{ + +std::mutex mutex; + +// tasks that runs on thread, each section of the vector is covered +template +void ThreadTask(const std::size_t threadID, std::vector &data, const std::size_t startIndex, + const std::size_t localSize, const std::string &variableName, adios2::IO io, + adios2::Engine engine) +{ + (void)threadID; // unused variable + // populate vector data, but simply adding step to index + for (std::size_t i = 0; i < localSize; ++i) + { + const std::size_t index = startIndex + i; + data[index] = static_cast(index); + } + + // I/O write region in a locked mutex + { + mutex.lock(); + + adios2::Variable variable = io.InquireVariable(variableName); + variable.SetSelection({{startIndex}, {localSize}}); + + engine.Put(variable, &data[startIndex]); + // PerformPuts must be called to collect memory per buffer + engine.PerformPuts(); + + mutex.unlock(); + } +} + +} // end namespace + +int main(int argc, char *argv[]) +{ + try + { + constexpr std::size_t nx = 100; + // data to be populated and written per thread + std::vector data(nx); + + // initialize adios2 objects serially + adios2::ADIOS adios; + adios2::IO io = adios.DeclareIO("thread-write"); + // populate shape, leave start and count empty as + // they will come from each thread SetSelection + const std::string variableName = "data"; + io.DefineVariable(variableName, adios2::Dims{nx}, adios2::Dims(), adios2::Dims()); + + adios2::Engine engine = io.Open("thread-writes.bp", adios2::Mode::Write); + + // set up thread tasks + // just grab maximum number of threads to simplify things + const auto nthreads = static_cast(std::thread::hardware_concurrency()); + std::vector threadTasks; + threadTasks.reserve(nthreads); + + // launch threaded tasks (this is what OpenMP would simplify) + // elements per thread + const std::size_t stride = nx / nthreads; + // elements for last thread, add remainder + const std::size_t last = stride + nx % nthreads; + + // launch threads + for (std::size_t t = 0; t < nthreads; ++t) + { + const std::size_t startIndex = stride * t; + // non-inclusive endIndex + const std::size_t localSize = (t == nthreads - 1) ? last : stride; + + // use std::ref to pass things by reference + // adios2 objects can be passed by value + + threadTasks.emplace_back(ThreadTask, t, std::ref(data), startIndex, localSize, + std::ref(variableName), io, engine); + } + + for (auto &threadTask : threadTasks) + { + threadTask.join(); + } + + engine.Close(); + } + catch (std::exception &e) + { + std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/examples/hello/bpWriteReadHip/CMakeLists.txt b/examples/hello/bpWriteReadHip/CMakeLists.txt new file mode 100644 index 0000000000..431f1586e1 --- /dev/null +++ b/examples/hello/bpWriteReadHip/CMakeLists.txt @@ -0,0 +1,25 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPWriteReadHipExample) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(hip QUIET) + if(hip_FOUND) + enable_language(HIP) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +if(ADIOS2_HAVE_Kokkos_HIP OR hip_FOUND) + add_executable(adios2_hello_bpWriteReadHip bpWriteReadHip.cpp) + target_link_libraries(adios2_hello_bpWriteReadHip adios2::cxx11 hip::runtime) + set_target_properties(adios2_hello_bpWriteReadHip PROPERTIES LANGUAGE "HIP") + install(TARGETS adios2_hello_bpWriteReadHip RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/hello/bpWriteReadHip/bpWriteReadHip.cpp b/examples/hello/bpWriteReadHip/bpWriteReadHip.cpp new file mode 100644 index 0000000000..99e3e94bf3 --- /dev/null +++ b/examples/hello/bpWriteReadHip/bpWriteReadHip.cpp @@ -0,0 +1,135 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ +#include +#include +#include +#include + +#include + +#include + +__global__ void hip_initialize(float *vec) { vec[hipBlockIdx_x] = hipBlockIdx_x; } + +__global__ void hip_increment(float *vec, float val) { vec[hipBlockIdx_x] += val; } + +int BPWrite(const std::string fname, const size_t N, int nSteps, const std::string engine) +{ + hipError_t hipExit; + float *gpuSimData; + hipExit = hipMalloc((void **)&gpuSimData, N * sizeof(float)); + if (hipExit != hipSuccess) + { + std::cout << "[BPWrite] error: " << hipGetErrorString(hipExit) << std::endl; + return 1; + } + hipLaunchKernelGGL(hip_initialize, dim3(N), dim3(1), 0, 0, gpuSimData); + hipExit = hipDeviceSynchronize(); + if (hipExit != hipSuccess) + { + std::cout << "[BPWrite] error: " << hipGetErrorString(hipExit) << std::endl; + return 1; + } + + adios2::ADIOS adios; + adios2::IO io = adios.DeclareIO("WriteIO"); + io.SetEngine(engine); + + const adios2::Dims shape{static_cast(N)}; + const adios2::Dims start{static_cast(0)}; + const adios2::Dims count{N}; + auto data = io.DefineVariable("data", shape, start, count); + + adios2::Engine bpWriter = io.Open(fname, adios2::Mode::Write); + + for (size_t step = 0; step < nSteps; ++step) + { + adios2::Box sel({0}, {N}); + data.SetSelection(sel); + + bpWriter.BeginStep(); + bpWriter.Put(data, gpuSimData); + bpWriter.EndStep(); + + hipLaunchKernelGGL(hip_increment, dim3(N), dim3(1), 0, 0, gpuSimData, 10); + hipExit = hipDeviceSynchronize(); + if (hipExit != hipSuccess) + { + std::cout << "[BPWrite] error: " << hipGetErrorString(hipExit) << std::endl; + return 1; + } + } + + bpWriter.Close(); + return 0; +} + +int BPRead(const std::string fname, const size_t N, int nSteps, const std::string engine) +{ + hipError_t hipExit; + adios2::ADIOS adios; + adios2::IO io = adios.DeclareIO("ReadIO"); + io.SetEngine(engine); + + adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); + + unsigned int step = 0; + float *gpuSimData; + hipExit = hipMalloc((void **)&gpuSimData, N * sizeof(float)); + if (hipExit != hipSuccess) + { + std::cout << "[BPWrite] error: " << hipGetErrorString(hipExit) << std::endl; + return 1; + } + for (; bpReader.BeginStep() == adios2::StepStatus::OK; ++step) + { + auto data = io.InquireVariable("data"); + const adios2::Dims start{0}; + const adios2::Dims count{N}; + const adios2::Box sel(start, count); + data.SetSelection(sel); + + bpReader.Get(data, gpuSimData); + bpReader.EndStep(); + + std::vector cpuData(N); + hipExit = hipMemcpy(cpuData.data(), gpuSimData, N * sizeof(float), hipMemcpyDeviceToHost); + if (hipExit != hipSuccess) + { + std::cout << "[BPWrite] error: " << hipGetErrorString(hipExit) << std::endl; + return 1; + } + std::cout << "Simualation step " << step << " : "; + std::cout << cpuData.size() << " elements: " << cpuData[0]; + std::cout << " " << cpuData[1] << " ... "; + std::cout << cpuData[cpuData.size() - 1] << std::endl; + } + bpReader.Close(); + return 0; +} + +int main(int argc, char **argv) +{ + hipError_t hipExit; + const int device_id = 0; + hipExit = hipSetDevice(device_id); + if (hipExit != hipSuccess) + { + std::cout << "[BPWrite] error: " << hipGetErrorString(hipExit) << std::endl; + return 1; + } + const std::vector list_of_engines = {"BP4", "BP5"}; + const size_t N = 6000; + int nSteps = 2, ret = 0; + + for (auto engine : list_of_engines) + { + std::cout << "Using engine " << engine << std::endl; + const std::string fname(engine + "_HIP_WR.bp"); + ret += BPWrite(fname, N, nSteps, engine); + ret += BPRead(fname, N, nSteps, engine); + } + return ret; +} diff --git a/examples/hello/bpWriteReadKokkos/CMakeLists.txt b/examples/hello/bpWriteReadKokkos/CMakeLists.txt new file mode 100644 index 0000000000..a8e810b734 --- /dev/null +++ b/examples/hello/bpWriteReadKokkos/CMakeLists.txt @@ -0,0 +1,33 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloBPWriteReadKokkosExample) + +# CXX Compiler settings only in for this example +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(Kokkos 3.7 QUIET) + if(Kokkos_FOUND AND DEFINED Kokkos_CXX_COMPILER) + set(CMAKE_CXX_COMPILER "${Kokkos_CXX_COMPILER}") + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +else() + if(DEFINED Kokkos_CXX_COMPILER) + set(CMAKE_CXX_COMPILER "${Kokkos_CXX_COMPILER}") + endif() +endif() + +if(ADIOS2_HAVE_Kokkos) + add_executable(adios2_hello_bpWriteReadKokkos bpWriteReadKokkos.cpp) + kokkos_compilation(SOURCE bpWriteReadKokkos.cpp) + target_link_libraries(adios2_hello_bpWriteReadKokkos adios2::cxx11 Kokkos::kokkos) + install(TARGETS adios2_hello_bpWriteReadKokkos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/hello/bpWriteReadKokkos/bpWriteReadKokkos.cpp b/examples/hello/bpWriteReadKokkos/bpWriteReadKokkos.cpp new file mode 100644 index 0000000000..7f837d6538 --- /dev/null +++ b/examples/hello/bpWriteReadKokkos/bpWriteReadKokkos.cpp @@ -0,0 +1,117 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ +#include +#include +#include + +#include + +#include + +int BPWrite(const std::string fname, const size_t N, int nSteps, const std::string engine) +{ + // Initialize the simulation data with the default memory space + using mem_space = Kokkos::DefaultExecutionSpace::memory_space; + Kokkos::View gpuSimData("simBuffer", N); + Kokkos::parallel_for( + "initBuffer", Kokkos::RangePolicy(0, N), + KOKKOS_LAMBDA(int i) { gpuSimData(i) = static_cast(i); }); + Kokkos::fence(); + + // Set up the ADIOS structures + adios2::ADIOS adios; + adios2::IO io = adios.DeclareIO("WriteIO"); + io.SetEngine(engine); + + const adios2::Dims shape{static_cast(N)}; + const adios2::Dims start{static_cast(0)}; + const adios2::Dims count{N}; + auto data = io.DefineVariable("data", shape, start, count); + + adios2::Engine bpWriter = io.Open(fname, adios2::Mode::Write); + + // Simulation steps + for (int step = 0; step < nSteps; ++step) + { + // Make a 1D selection to describe the local dimensions of the + // variable we write and its offsets in the global spaces + adios2::Box sel({0}, {N}); + data.SetSelection(sel); + + // Start IO step every write step + bpWriter.BeginStep(); + bpWriter.Put(data, gpuSimData.data()); + bpWriter.EndStep(); + + // Update values in the simulation data using the default + // execution space + Kokkos::parallel_for( + "updateBuffer", Kokkos::RangePolicy(0, N), + KOKKOS_LAMBDA(int i) { gpuSimData(i) += 10; }); + Kokkos::fence(); + } + + bpWriter.Close(); + Kokkos::DefaultExecutionSpace exe_space; + std::cout << "Done writing on memory space: " << exe_space.name() << std::endl; + return 0; +} + +int BPRead(const std::string fname, const size_t N, int nSteps, const std::string engine) +{ + // Create ADIOS structures + adios2::ADIOS adios; + adios2::IO io = adios.DeclareIO("ReadIO"); + io.SetEngine(engine); + + Kokkos::DefaultExecutionSpace exe_space; + std::cout << "Read on memory space: " << exe_space.name() << std::endl; + + adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); + + unsigned int step = 0; + using mem_space = Kokkos::DefaultExecutionSpace::memory_space; + Kokkos::View gpuSimData("simBuffer", N); + for (; bpReader.BeginStep() == adios2::StepStatus::OK; ++step) + { + auto data = io.InquireVariable("data"); + const adios2::Dims start{0}; + const adios2::Dims count{N}; + const adios2::Box sel(start, count); + data.SetSelection(sel); + + bpReader.Get(data, gpuSimData.data()); + bpReader.EndStep(); + + auto cpuData = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, gpuSimData); + std::cout << "Simualation step " << step << " : "; + std::cout << cpuData.size() << " elements: " << cpuData[0]; + std::cout << " " << cpuData[1] << " ... "; + std::cout << cpuData[cpuData.size() - 1] << std::endl; + } + + bpReader.Close(); + return 0; +} + +int main(int argc, char **argv) +{ + const std::vector list_of_engines = {"BP4", "BP5"}; + const size_t N = 6000; + int nSteps = 2, ret = 0; + + Kokkos::initialize(argc, argv); + { + for (auto engine : list_of_engines) + { + std::cout << "Using engine " << engine << std::endl; + const std::string fname(engine + "_Kokkos_WR.bp"); + ret += BPWrite(fname, N, nSteps, engine); + ret += BPRead(fname, N, nSteps, engine); + } + } + Kokkos::finalize(); + return ret; +} diff --git a/examples/hello/helloWorld/CMakeLists.txt b/examples/hello/helloWorld/CMakeLists.txt new file mode 100644 index 0000000000..416d0d5b26 --- /dev/null +++ b/examples/hello/helloWorld/CMakeLists.txt @@ -0,0 +1,47 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2HelloHelloWorldExample) + +if(NOT TARGET adios2_core) + set(_components C CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +endif() + +add_executable(adios2_hello_helloWorld_c hello-world.c) +target_link_libraries(adios2_hello_helloWorld_c adios2::c) +install(TARGETS adios2_hello_helloWorld_c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_hello_helloWorld hello-world.cpp) +target_link_libraries(adios2_hello_helloWorld adios2::cxx11) +install(TARGETS adios2_hello_helloWorld RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(adios2_hello_helloWorld_hl hello-world-hl.cpp) +target_link_libraries(adios2_hello_helloWorld_hl adios2::cxx11) +install(TARGETS adios2_hello_helloWorld_hl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +if(ADIOS2_HAVE_MPI) + add_executable(adios2_hello_helloWorld_c_mpi hello-world.c) + target_link_libraries(adios2_hello_helloWorld_c_mpi adios2::c_mpi MPI::MPI_C) + install(TARGETS adios2_hello_helloWorld_c_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_hello_helloWorld_mpi hello-world.cpp) + target_link_libraries(adios2_hello_helloWorld_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_helloWorld_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + add_executable(adios2_hello_helloWorld_hl_mpi hello-world-hl.cpp) + target_link_libraries(adios2_hello_helloWorld_hl_mpi adios2::cxx11_mpi MPI::MPI_C) + install(TARGETS adios2_hello_helloWorld_hl_mpi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/hello/helloWorld/hello-world-hl.cpp b/examples/hello/helloWorld/hello-world-hl.cpp new file mode 100644 index 0000000000..d1a4f2c05f --- /dev/null +++ b/examples/hello/helloWorld/hello-world-hl.cpp @@ -0,0 +1,75 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * hello-world-hl.cpp : adios2 high-level API example to write and read a + * std::string Variable with a greeting + * + * Created on: Nov 14, 2019 + * Author: William F Godoy godoywf@ornl.gov + */ + +#include +#include + +#include +#if ADIOS2_USE_MPI +#include +#endif + +void writer(const std::string &greeting) +{ +#if ADIOS2_USE_MPI + adios2::fstream out("hello-world-hl-cpp.bp", adios2::fstream::out, MPI_COMM_WORLD); +#else + adios2::fstream out("hello-world-hl-cpp.bp", adios2::fstream::out); +#endif + + out.write("Greeting", greeting); + out.close(); +} + +std::string reader() +{ +#if ADIOS2_USE_MPI + adios2::fstream in("hello-world-hl-cpp.bp", adios2::fstream::in, MPI_COMM_WORLD); +#else + adios2::fstream in("hello-world-hl-cpp.bp", adios2::fstream::in); +#endif + + for (adios2::fstep iStep; adios2::getstep(in, iStep);) + { + const std::vector greetings = in.read("Greeting"); + return greetings.front(); + } + return ""; +} + +int main(int argc, char *argv[]) +{ +#if ADIOS2_USE_MPI + MPI_Init(&argc, &argv); +#endif + + try + { + const std::string greeting = "Hello World from ADIOS2"; + writer(greeting); + + const std::string message = reader(); + std::cout << message << "\n"; + } + catch (std::exception &e) + { + std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n"; +#if ADIOS2_USE_MPI + MPI_Abort(MPI_COMM_WORLD, -1); +#endif + } + +#if ADIOS2_USE_MPI + MPI_Finalize(); +#endif + + return 0; +} diff --git a/examples/hello/helloWorld/hello-world-hl.py b/examples/hello/helloWorld/hello-world-hl.py new file mode 100644 index 0000000000..825fb5282e --- /dev/null +++ b/examples/hello/helloWorld/hello-world-hl.py @@ -0,0 +1,47 @@ +# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +# +# hello-world.py : adios2 high-level API example to write and read a +# string Variable with a greeting +# +# Created on: 2/2/2021 +# Author: Dmitry Ganyushin ganyushindi@ornl.gov +# +import sys +from mpi4py import MPI +import adios2 + +DATA_FILENAME = "hello-world-hl-py.bp" +# MPI +comm = MPI.COMM_WORLD +rank = comm.Get_rank() +size = comm.Get_size() + + +def writer(greeting): + """write a string to a bp file""" + with adios2.open(DATA_FILENAME, "w", comm) as fh: + fh.write("Greeting", greeting, end_step=True) + return 0 + + +def reader(): + """read a string from to a bp file""" + with adios2.open(DATA_FILENAME, "r", comm) as fh: + for fstep in fh: + message = fstep.read_string("Greeting") + return message + + +def main(): + """driver function""" + greeting = "Hello World from ADIOS2" + writer(greeting) + message = reader() + print("{}".format(message)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/examples/hello/helloWorld/hello-world.c b/examples/hello/helloWorld/hello-world.c new file mode 100644 index 0000000000..6c14ea65ad --- /dev/null +++ b/examples/hello/helloWorld/hello-world.c @@ -0,0 +1,71 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * hello-world.c : adios2 C API example to write and read a + * char* Variable with a greeting + * + * Created on: Nov 14, 2019 + * Author: William F Godoy godoywf@ornl.gov + */ + +#include //printf +#include //malloc, free + +#include +#if ADIOS2_USE_MPI +#include +#endif + +void writer(adios2_adios *adios, const char *greeting) +{ + adios2_io *io = adios2_declare_io(adios, "hello-world-writer"); + adios2_variable *var_greeting = adios2_define_variable( + io, "Greeting", adios2_type_string, 0, NULL, NULL, NULL, adios2_constant_dims_true); + + adios2_engine *engine = adios2_open(io, "hello-world-c.bp", adios2_mode_write); + adios2_put(engine, var_greeting, greeting, adios2_mode_deferred); + adios2_close(engine); +} + +void reader(adios2_adios *adios, char *greeting) +{ + adios2_step_status status; + adios2_io *io = adios2_declare_io(adios, "hello-world-reader"); + adios2_engine *engine = adios2_open(io, "hello-world-c.bp", adios2_mode_read); + adios2_variable *var_greeting = adios2_inquire_variable(io, "Greeting"); + adios2_begin_step(engine, adios2_step_mode_read, -1., &status); + adios2_get(engine, var_greeting, greeting, adios2_mode_deferred); + adios2_end_step(engine); + adios2_close(engine); +} + +int main(int argc, char *argv[]) +{ +#if ADIOS2_USE_MPI + MPI_Init(&argc, &argv); +#endif + + { +#if ADIOS2_USE_MPI + adios2_adios *adios = adios2_init_mpi(MPI_COMM_WORLD); +#else + adios2_adios *adios = adios2_init(); +#endif + + const char greeting[] = "Hello World from ADIOS2"; + writer(adios, greeting); + + char *message = (char *)malloc(24); + reader(adios, message); + printf("%s\n", message); + + free(message); + } + +#if ADIOS2_USE_MPI + MPI_Finalize(); +#endif + + return 0; +} diff --git a/examples/hello/helloWorld/hello-world.cpp b/examples/hello/helloWorld/hello-world.cpp new file mode 100644 index 0000000000..9f30c14fa3 --- /dev/null +++ b/examples/hello/helloWorld/hello-world.cpp @@ -0,0 +1,76 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * hello-world.cpp : adios2 low-level API example to write and read a + * std::string Variable with a greeting + * + * Created on: Nov 14, 2019 + * Author: William F Godoy godoywf@ornl.gov + */ + +#include +#include + +#include +#if ADIOS2_USE_MPI +#include +#endif + +void writer(adios2::ADIOS &adios, const std::string &greeting) +{ + adios2::IO io = adios.DeclareIO("hello-world-writer"); + adios2::Variable varGreeting = io.DefineVariable("Greeting"); + + adios2::Engine writer = io.Open("hello-world-cpp.bp", adios2::Mode::Write); + writer.Put(varGreeting, greeting); + writer.Close(); +} + +std::string reader(adios2::ADIOS &adios) +{ + adios2::IO io = adios.DeclareIO("hello-world-reader"); + adios2::Engine reader = io.Open("hello-world-cpp.bp", adios2::Mode::Read); + reader.BeginStep(); + adios2::Variable varGreeting = io.InquireVariable("Greeting"); + std::string greeting; + reader.Get(varGreeting, greeting); + reader.EndStep(); + reader.Close(); + return greeting; +} + +int main(int argc, char *argv[]) +{ +#if ADIOS2_USE_MPI + MPI_Init(&argc, &argv); +#endif + + try + { +#if ADIOS2_USE_MPI + adios2::ADIOS adios(MPI_COMM_WORLD); +#else + adios2::ADIOS adios; +#endif + + const std::string greeting = "Hello World from ADIOS2"; + writer(adios, greeting); + + const std::string message = reader(adios); + std::cout << message << "\n"; + } + catch (std::exception &e) + { + std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n"; +#if ADIOS2_USE_MPI + MPI_Abort(MPI_COMM_WORLD, -1); +#endif + } + +#if ADIOS2_USE_MPI + MPI_Finalize(); +#endif + + return 0; +} diff --git a/examples/hello/helloWorld/hello-world.py b/examples/hello/helloWorld/hello-world.py new file mode 100644 index 0000000000..f73e5c4d31 --- /dev/null +++ b/examples/hello/helloWorld/hello-world.py @@ -0,0 +1,54 @@ +# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +# +# hello-world.py : adios2 low-level API example to write and read a +# string Variable with a greeting +# +# Created on: 2/2/2021 +# Author: Dmitry Ganyushin ganyushindi@ornl.gov +# +import sys +from mpi4py import MPI +import adios2 + +DATA_FILENAME = "hello-world-py.bp" +# MPI +comm = MPI.COMM_WORLD +rank = comm.Get_rank() +size = comm.Get_size() + + +def writer(ad, greeting): + """write a string to a bp file""" + io = ad.DeclareIO("hello-world-writer") + var_greeting = io.DefineVariable("Greeting") + w = io.Open(DATA_FILENAME, adios2.Mode.Write) + w.Put(var_greeting, greeting) + w.Close() + return 0 + + +def reader(ad): + """read a string from to a bp file""" + io = ad.DeclareIO("hello-world-reader") + r = io.Open(DATA_FILENAME, adios2.Mode.Read) + r.BeginStep() + var_greeting = io.InquireVariable("Greeting") + message = r.Get(var_greeting) + r.EndStep() + return message + + +def main(): + """driver function""" + ad = adios2.ADIOS(comm) + greeting = "Hello World from ADIOS2" + writer(ad, greeting) + message = reader(ad) + print("{}".format(message)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/examples/simulations/CMakeLists.txt b/examples/simulations/CMakeLists.txt index 93f7e8c70c..d6b6434beb 100644 --- a/examples/simulations/CMakeLists.txt +++ b/examples/simulations/CMakeLists.txt @@ -1,3 +1,13 @@ if(ADIOS2_HAVE_MPI) + add_subdirectory(gray-scott) + add_subdirectory(gray-scott-struct) + + if(ADIOS2_HAVE_Kokkos) + add_subdirectory(gray-scott-kokkos) + endif() + add_subdirectory(heatTransfer) endif() + +add_subdirectory(korteweg-de-vries) +add_subdirectory(lorenz_ode) diff --git a/examples/simulations/GrayScott.jl/.JuliaFormatter.toml b/examples/simulations/GrayScott.jl/.JuliaFormatter.toml new file mode 100644 index 0000000000..00db94693b --- /dev/null +++ b/examples/simulations/GrayScott.jl/.JuliaFormatter.toml @@ -0,0 +1,4 @@ +margin = 80 +join_lines_based_on_source = true +style = "sciml" +format_doctrings = true diff --git a/examples/simulations/GrayScott.jl/Project.toml b/examples/simulations/GrayScott.jl/Project.toml new file mode 100644 index 0000000000..a295ba3546 --- /dev/null +++ b/examples/simulations/GrayScott.jl/Project.toml @@ -0,0 +1,19 @@ +name = "GrayScott" +uuid = "089a57ea-382b-4fd7-9f05-24902db6ec52" +authors = ["William F Godoy "] +version = "0.1.0" + +[deps] +ADIOS2 = "e0ce9d3b-0dbd-416f-8264-ccca772f60ec" +AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" +ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" +JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" +MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267" +PProf = "e4faabce-9ead-11e9-39d9-4379958e3056" +Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" + +[compat] +julia = "1.8" diff --git a/examples/simulations/GrayScott.jl/ReadMe.md b/examples/simulations/GrayScott.jl/ReadMe.md new file mode 100644 index 0000000000..fe4f08631d --- /dev/null +++ b/examples/simulations/GrayScott.jl/ReadMe.md @@ -0,0 +1,139 @@ +# ADIOS2 GrayScott.jl example + +Julia version of [the gray-scott C++ and Python](https://github.com/ornladios/ADIOS2/blob/master/examples/simulations/gray-scott/) +example. + +This is a 3D 7-point stencil code to simulate the following [Gray-Scott +reaction diffusion model](https://doi.org/10.1126/science.261.5118.189): + +``` +u_t = Du * (u_xx + u_yy + u_zz) - u * v^2 + F * (1 - u) + noise * randn(-1,1) +v_t = Dv * (v_xx + v_yy + v_zz) + u * v^2 - (F + k) * v +``` + +This version contains: + +- CPU threaded solver using Julia's [multithreading]](https://docs.julialang.org/en/v1/manual/multi-threading/) +- GPU solvers using [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl), [AMDGPU.jl](https://github.com/JuliaGPU/AMDGPU.jl) +- Parallel I/O using the [ADIOS2.jl](https://github.com/eschnett/ADIOS2.jl) Julia bindings to [ADIOS2](https://github.com/ornladios/ADIOS2) +- Message passing interface (MPI) using [MPI.jl](https://github.com/JuliaParallel/MPI.jl) Julia bindings to MPI +- Easily switch between float- (Float32) and double- (Float64) precision in the configuration file + +## How to run + +Currently only the simulation part is ported from C++, the data analysis is work-in-progress. + +Pre-requisites: + +- A recent Julia version: v1.8.5 or v1.9.0-beta3 as of January 2023 from [julialang.org/downloads](https://julialang.org/downloads/) + +### Run locally + +1. **Set up dependencies** + +From the `GrayScott.jl` directory instantiate and use MPI artifact jll (preferred method). +To use a system provided MPI, see [here](https://juliaparallel.org/MPI.jl/latest/configuration/#using_system_mpi) + +```julia + +$ julia --project + +Julia REPL + +julia> ] + +(GrayScott.jl)> instantiate +... +(GrayScott.jl)> <- +julia> using MPIPreferences +julia> MPIPreferences.use_jll_binary() +julia> exit() +``` + +Julia manages its own packages using [Pkg.jl](https://pkgdocs.julialang.org/v1/), the above would create platform-specific `LocalPreferences.toml` and `Manifest.toml` files. + +2. **Set up the examples/settings-files.json configuration file** + +``` +{ + "L": 64, + "Du": 0.2, + "Dv": 0.1, + "F": 0.02, + "k": 0.048, + "dt": 1.0, + "plotgap": 10, + "steps": 10000, + "noise": 0.1, + "output": "gs-julia-1MPI-64L-F32.bp", + "checkpoint": false, + "checkpoint_freq": 700, + "checkpoint_output": "ckpt.bp", + "restart": false, + "restart_input": "ckpt.bp", + "adios_config": "adios2.xml", + "adios_span": false, + "adios_memory_selection": false, + "mesh_type": "image", + "precision": "Float32", + "backend": "CPU" +} + +``` + +The file is nearly identical to the C++ original example. +Not all options are currently supported, but two Julia-only options are added: + + - "precision": either Float32 or Float64 in the array simulation (including GPUs) + - "backend": "CPU", "CUDA" or "AMDGPU" + +3. **Running the simulation** + +- `CPU threads`: launch julia assigning a number of threads (e.g. -t 8): + + ``` + $ julia --project -t 8 gray-scott.jl examples/settings-files.json + ``` + +- `CUDA/AMDGPU`: set the "backend" option in examples/settings-files.json to either "CUDA" or "AMDGPU" + + ``` + $ julia --project gray-scott.jl examples/settings-files.json + ``` + +This would generate an adios2 file from the output entry in the configuration file (e.g. `gs-julia-1MPI-64L-F32.bp`) +that can be visualized with ParaView with either the VTX or the FIDES readers. +**Important**: the AMDGPU.jl implementation of `randn` is currently work in progress. +See related issue [here](https://github.com/JuliaGPU/AMDGPU.jl/issues/378) + + +4. **Running on OLCF Summit and Crusher systems** +The code was tested on the Oak Ridge National Laboratory Leadership Computing Facilities (OLCF): [Summit](https://docs.olcf.ornl.gov/systems/summit_user_guide.html) and [Crusher](https://docs.olcf.ornl.gov/systems/crusher_quick_start_guide.html). Both are used testing a recent version of Julia [v1.9.0-beta3](https://julialang.org/downloads/#upcoming_release) and a `JULIA_DEPOT_PATH` is required to install packages and artifacts. **DO NOT USE your home directory**. We are providing configuration scripts in `scripts/config_XXX.sh` showing the plumming required for these systems. They need to be executed only once per session from the login nodes. + +To reuse these file the first 3 entries must be modified and run on login-nodes and the PATH poiting at a downloaded Julia binary for the corresponding PowerPC (Summit) and x86-64 (Crusher) architectures. Only "CPU" and "CUDA" backends are supported on Summit, while "CPU" and "AMDGPU" backends are supported on Crusher. + + ``` + # Replace these 3 entries + PROJ_DIR=/gpfs/alpine/proj-shared/csc383 + export JULIA_DEPOT_PATH=$PROJ_DIR/etc/summit/julia_depot + GS_DIR=$PROJ_DIR/wgodoy/ADIOS2/examples/simulations/GrayScott.jl + ... + # and the path + export PATH=$PROJ_DIR/opt/summit/julia-1.9.0-beta3/bin:$PATH + ``` + +## To-do list + + 1. Add support including random number on device kernel code on `AMDGPU.jl` + 2. Set the domain size `L` in the configuration file as a multiple of 6 for Summit, and a multiple of 4 on Crusher + 3. Add data analysis: PDF for u and v and Julia 2D plotting capabilities: Plots.jl, Makie.jl + 4. Add interactive computing with Pluto.jl notebooks + + +## Acknowledgements +This research was supported by the Exascale Computing Project (17-SC-20-SC), a joint project of the U.S. Department of Energy’s Office of Science and National Nuclear Security Administration, responsible for delivering a capable exascale ecosystem, including software, applications, and hardware technology, to support the nation’s exascale computing imperative. + +This research used resources of the Oak Ridge Leadership Computing Facility at the Oak Ridge National Laboratory, which is supported by the Office of Science of the U.S. Department of Energy under Contract No. DE-AC05-00OR22725. + +Thanks to the Exascale Computing Project PROTEAS-TUNE and ADIOS subprojects, and the ASCR Bluestone. +Thanks to all the Julia community members, packages developers and maintainers for their great work. \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/examples/settings-files.json b/examples/simulations/GrayScott.jl/examples/settings-files.json new file mode 100644 index 0000000000..ab6b9cc9d4 --- /dev/null +++ b/examples/simulations/GrayScott.jl/examples/settings-files.json @@ -0,0 +1,23 @@ +{ + "L": 64, + "Du": 0.2, + "Dv": 0.1, + "F": 0.02, + "k": 0.048, + "dt": 1.0, + "plotgap": 10, + "steps": 10000, + "noise": 0.1, + "output": "gs-julia-1MPI-64L-F32.bp", + "checkpoint": false, + "checkpoint_freq": 700, + "checkpoint_output": "ckpt.bp", + "restart": false, + "restart_input": "ckpt.bp", + "adios_config": "adios2.xml", + "adios_span": false, + "adios_memory_selection": false, + "mesh_type": "image", + "precision": "Float32", + "backend": "CPU" +} \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/gray-scott.jl b/examples/simulations/GrayScott.jl/gray-scott.jl new file mode 100644 index 0000000000..2c1196beb9 --- /dev/null +++ b/examples/simulations/GrayScott.jl/gray-scott.jl @@ -0,0 +1,15 @@ +import GrayScott + +# using Profile +# using PProf + +function julia_main()::Cint + GrayScott.main(ARGS) + return 0 +end + +if !isdefined(Base, :active_repl) + @time julia_main() + # @profile julia_main() + # pprof() +end \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/scripts/config_crusher.sh b/examples/simulations/GrayScott.jl/scripts/config_crusher.sh new file mode 100644 index 0000000000..3820dd297b --- /dev/null +++ b/examples/simulations/GrayScott.jl/scripts/config_crusher.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +PROJ_DIR=/gpfs/alpine/proj-shared/csc383 +export JULIA_DEPOT_PATH=$PROJ_DIR/etc/crusher/julia_depot +GS_DIR=$PROJ_DIR/wgodoy/ADIOS2/examples/simulations/GrayScott.jl + +# remove existing generated Manifest.toml +rm -f $GS_DIR/Manifest.toml +rm -f $GS_DIR/LocalPreferences.toml + +# good practice to avoid conflicts with existing default modules +module purge + +# load required modules +module load PrgEnv-cray/8.3.3 # has required gcc +module load cray-mpich +module load rocm/5.4.0 +module load adios2 # only works with PrgEnv-cray + +# existing julia 1.6 module is outdated +export PATH=$PROJ_DIR/opt/crusher/julia-1.9.0-beta3/bin:$PATH + +# Required to point at underlying modules above +export JULIA_AMDGPU_DISABLE_ARTIFACTS=1 +# Required to enable underlying ADIOS2 library from loaded module +export JULIA_ADIOS2_PATH=$OLCF_ADIOS2_ROOT + +# MPIPreferences to use spectrum-mpi +julia --project=$GS_DIR -e 'using Pkg; Pkg.add("MPIPreferences")' +julia --project=$GS_DIR -e 'using MPIPreferences; MPIPreferences.use_system_binary(; library_names=["libmpi_cray"], mpiexec="srun")' + +# Regression being fixed with CUDA v4.0.0. CUDA.jl does lazy loading for portability to systems without NVIDIA GPUs +julia --project=$GS_DIR -e 'using Pkg; Pkg.add(name="CUDA", version="v3.13.1")' + +# Instantiate the project by installing packages in Project.toml +julia --project=$GS_DIR -e 'using Pkg; Pkg.instantiate()' + +# Adds a custom branch in case the development version is needed (for devs to test new features) +julia --project=$GS_DIR -e 'using Pkg; Pkg.add(url="https://github.com/eschnett/ADIOS2.jl.git", rev="main")' + +# Build the new ADIOS2 +julia --project=$GS_DIR -e 'using Pkg; Pkg.build()' +julia --project=$GS_DIR -e 'using Pkg; Pkg.precompile()' diff --git a/examples/simulations/GrayScott.jl/scripts/config_summit.sh b/examples/simulations/GrayScott.jl/scripts/config_summit.sh new file mode 100644 index 0000000000..d5f616ee31 --- /dev/null +++ b/examples/simulations/GrayScott.jl/scripts/config_summit.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Replace these 3 entries +PROJ_DIR=/gpfs/alpine/proj-shared/csc383 +export JULIA_DEPOT_PATH=$PROJ_DIR/etc/summit/julia_depot +GS_DIR=$PROJ_DIR/wgodoy/ADIOS2/examples/simulations/GrayScott.jl + +# remove existing generated Manifest.toml +rm -f $GS_DIR/Manifest.toml +rm -f $GS_DIR/LocalPreferences.toml + +# good practice to avoid conflicts with existing default modules +# needed to avoid seg fault with MPI +module purge + +# load required modules +module load spectrum-mpi +module load gcc/12.1.0 # needed by julia libraries +module load cuda/11.0.3 # failure with 11.5.2 +module load adios2/2.8.1 +# module load julia/1.8.2 not working with CUDA.jl as it's missing libLLVM-13jl.so +export PATH=$PROJ_DIR/opt/summit/julia-1.9.0-beta3/bin:$PATH + +# Required to enable underlying ADIOS2 library from loaded module +export JULIA_ADIOS2_PATH=$OLCF_ADIOS2_ROOT + +# MPIPreferences to use spectrum-mpi +julia --project=$GS_DIR -e 'using Pkg; Pkg.add("MPIPreferences")' +julia --project=$GS_DIR -e 'using MPIPreferences; MPIPreferences.use_system_binary(; library_names=["libmpi_ibm"], mpiexec="jsrun")' + +# Instantiate the project by installing packages in Project.toml +julia --project=$GS_DIR -e 'using Pkg; Pkg.instantiate()' + +# Adds to LocalPreferences.toml to use underlying system CUDA since CUDA.jl v4.0.0 +# https://cuda.juliagpu.org/stable/installation/overview/#Using-a-local-CUDA +julia --project=$GS_DIR -e 'using CUDA; CUDA.set_runtime_version!("local")' + +# Adds a custom branch in case the development version is needed (for devs to test new features) +julia --project=$GS_DIR -e 'using Pkg; Pkg.add(url="https://github.com/eschnett/ADIOS2.jl.git", rev="main")' + +# Build the new ADIOS2 +julia --project=$GS_DIR -e 'using Pkg; Pkg.build()' +julia --project=$GS_DIR -e 'using Pkg; Pkg.precompile()' diff --git a/examples/simulations/GrayScott.jl/scripts/job_crusher.sh b/examples/simulations/GrayScott.jl/scripts/job_crusher.sh new file mode 100644 index 0000000000..ee4953f6d1 --- /dev/null +++ b/examples/simulations/GrayScott.jl/scripts/job_crusher.sh @@ -0,0 +1,17 @@ +#!/bin/bash +#SBATCH -A CSC383_crusher +#SBATCH -J gs-julia-1MPI-1GPU +#SBATCH -o %x-%j.out +#SBATCH -e %x-%j.err +#SBATCH -t 0:02:00 +#SBATCH -p batch +#SBATCH -N 1 + +date + +GS_DIR=/gpfs/alpine/proj-shared/csc383/wgodoy/ADIOS2/examples/simulations/GrayScott.jl +GS_EXE=$GS_DIR/gray-scott.jl + +srun -n 1 --gpus=1 julia --project=$GS_DIR $GS_EXE settings-files.json + +# launch this file with sbatch `$ sbatch job_crusher.sh` diff --git a/examples/simulations/GrayScott.jl/scripts/job_summit.sh b/examples/simulations/GrayScott.jl/scripts/job_summit.sh new file mode 100644 index 0000000000..9beffc157f --- /dev/null +++ b/examples/simulations/GrayScott.jl/scripts/job_summit.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Begin LSF directives +#BSUB -P csc383 +#BSUB -W 00:02 +#BSUB -nnodes 1 +#BSUB -J gs-julia +#BSUB -o output.%J +#BSUB -e output.%J +#BSUB -N godoywf@ornl.gov +# End BSUB directives and begin shell commands + +date +GS_DIR=/gpfs/alpine/proj-shared/csc383/wgodoy/ADIOS2/examples/simulations/GrayScott.jl +GS_EXE=$GS_DIR/gray-scott.jl + +jsrun -n 1 -g 1 julia --project=$GS_DIR $GS_EXE settings-files.json + +# launch this file with bsub `$ bsub job_summit.sh` diff --git a/examples/simulations/GrayScott.jl/src/GrayScott.jl b/examples/simulations/GrayScott.jl/src/GrayScott.jl new file mode 100644 index 0000000000..d50c1abb09 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/GrayScott.jl @@ -0,0 +1,91 @@ +""" +GrayScott.jl is a Simulation and Analysis parallel framework for solving the +Gray-Scott 3D diffusion reaction system of equations of two variables U and V on +a regular Cartesian mesh. + +The bp output files can be visualized with ParaView. +""" +module GrayScott + +import MPI, ADIOS2 + +# contains relevant data containers "structs" for Input, Domain and Fields +include(joinpath("simulation", "Structs.jl")) + +# contains helper functions for general use +include(joinpath("helper", "Helper.jl")) +import .Helper + +# initializes inputs from configuration file +include(joinpath("simulation", "Inputs.jl")) +import .Inputs + +# manages the simulation computation +include(joinpath("simulation", "Simulation.jl")) +import .Simulation + +# manages the I/O +include(joinpath("simulation", "IO.jl")) +import .IO + +function julia_main()::Cint + try + main(ARGS) + catch + Base.invokelatest(Base.display_error, Base.catch_stack()) + return 1 + end + return 0 +end + +function main(args::Vector{String})::Int32 + MPI.Init() + comm = MPI.COMM_WORLD + rank = MPI.Comm_rank(comm) + size = MPI.Comm_size(comm) + + # a data struct that holds settings data from config_file in args + # example config file: ../examples/settings-files.json + settings = Inputs.get_settings(args, comm) + + # initialize MPI Cartesian Domain and Communicator + mpi_cart_domain = Simulation.init_domain(settings, comm) + + # initialize fields + fields = Simulation.init_fields(settings, + mpi_cart_domain, + Helper.get_type(settings.precision)) + + # initialize IOStream struct holding ADIOS-2 components for parallel I/O + stream = IO.init(settings, mpi_cart_domain, fields) + + restart_step::Int32 = 0 + # @TODO: checkpoint-restart + step::Int32 = restart_step + + while step < settings.steps + Simulation.iterate!(fields, settings, mpi_cart_domain) + step += 1 + + if step % settings.plotgap == 0 + if rank == 0 + println("Simulation at step ", step, " writing output step ", + step / settings.plotgap) + end + + IO.write_step!(stream, step, fields) + end + end + + IO.close!(stream) + + # Debugging session or Julia REPL session, not needed overall as it would be + # called when the program ends + if !isinteractive() + MPI.Finalize() + end + + return 0 +end + +end # module GrayScott diff --git a/examples/simulations/GrayScott.jl/src/analysis/pdfcalc.jl b/examples/simulations/GrayScott.jl/src/analysis/pdfcalc.jl new file mode 100644 index 0000000000..f7fb0bb33f --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/analysis/pdfcalc.jl @@ -0,0 +1,160 @@ + +import MPI +import ArgParse +import ADIOS2 + +function _epsilon(d::T)::Bool where {T <: Number} + return (d < 1.0e-20) +end + +""" +Return 2 arrays pdf and bins of a 2D slice +""" +function _compute_pdf(data::Array{T, 3}, shape, count, nbins, min::T, + max::T) where {T} + pdf = Array{T, 2}(undef, nbins, count) + bins = Array{T, 1}(undef, nbins) + bin_width = (max - min) / nbins + + for i in 1:nbins + bins[i] = min + (i - 1) * bin_width + end + + slice_size = shape[2] * shape[3] + # special case: only one bin or small window + if nbins == 1 || _epsilon(max - min) || _epsilon(bin_width) + fill!(pdf, slice_size) + return pdf, bins + end + + # Calculate a PDF for 'nbins' bins for values between 'min' and 'max' + + for c in 1:count + for j in 1:shape[2] + for k in 1:shape[3] + value = data[k, j, c] + + if value > max || value < min + @show value, " is outside [", min, max "]" + end + bin = floor((value - min) / bin_width) + + if bin == nbins + bin = nbins - 1 + end + pdf[bin, c] += 1 + end + end + end +end + +function _parse_arguments(args) + s = ArgParse.ArgParseSettings(description = "gray-scott workflow pdf generator, Julia version") + + # @add_arg_table! s begin + # "--opt1" # an option (will take an argument) + # "--opt2", "-o" # another option, with short form + # "arg1" # a positional argument + # end + + ArgParse.@add_arg_table! s begin + "input" + help = "Name of the input file handle for reading data" + arg_type = String + required = true + "output" + help = "Name of the output file to which data must be written" + arg_type = String + required = true + "N" + help = "Number of bins for the PDF calculation, default = 1000" + arg_type = Int64 + required = false + default = 1000 + "output_inputdata" + help = "YES will write the original variables besides the analysis results" + arg_type = Bool + required = false + default = false + end + + # parse_args return a dictionary with key/value for arguments + parsed_arguments = ArgParse.parse_args(args, s) + return parsed_arguments +end + +function _read_data_write_pdf(inputs, comm) + in_filename = inputs["input"] + out_filename = inputs["output"] + nbins = inputs["N"] + write_inputvars = inputs["output_inputdata"] + + adios = ADIOS2.adios_init_mpi("adios2.xml", comm) + + reader_io = ADIOS2.declare_io(adios, "SimulationOutput") + writer_io = ADIOS2.declare_io(adios, "PDFAnalysisOutput") + + rank = MPI.Comm_rank(comm) + size = MPI.Comm_size(comm) + + if rank == 0 + println("PDF analysis reads from Simulation using engine type: ", + ADIOS2.engine_type(reader_io)) + println("PDF analysis writes using engine type: ", + ADIOS2.engine_type(writer_io)) + end + + # Engines for reading and writing + reader = ADIOS2.open(reader_io, inputs["input"], ADIOS2.mode_read) + writer = ADIOS2.open(writer_io, inputs["output"], ADIOS2.mode_write) + + # break inside if needed + while true + + # timeout is 10 seconds + read_status = ADIOS2.begin_step(reader, ADIOS2.step_mode_read, 10) + + if read_status == ADIOS2.step_status_not_ready + # sleep in seconds, minimum is one milisecond = 0.001 + sleep(1) + continue + else if read_status != ADIOS2.step_status_ok + break + end + + step_sim_out = ADIOS2.current_step(reader) + var_U = ADIOS2.inquire_variable(reader_io, "U") + var_V = ADIOS2.inquire_variable(reader_io, "V") + var_step = ADIOS2.inquire_variable(reader_io, "step") + + shape = ADIOS2.shape(var_U) + + # Split in the slowest dimension + count_z = shape[3] / size + start_z = count_z * rank + + # Last process needs to read all the rest + if rank == size-1 + count_z = shape[3] - count_z * (size-1) + end + + # missing set_selection + start = ( 0,0,start_z) + count = (shape[1], shape[2], count_z) + ADIOS2.set_selection(var_U, start, count) + ADIOS2.set_selection(var_V, start, count) + + # Calculate + + end +end + +function main(args) + MPI.Init() + + inputs = _parse_arguments(args) + comm = MPI.COMM_WORLD + _read_data_write_pdf(inputs, comm) + + MPI.Finalize() +end diff --git a/examples/simulations/GrayScott.jl/src/helper/Helper.jl b/examples/simulations/GrayScott.jl/src/helper/Helper.jl new file mode 100644 index 0000000000..757c571714 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/helper/Helper.jl @@ -0,0 +1,7 @@ + +module Helper + +include("helperMPI.jl") +include("helperString.jl") + +end \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/src/helper/helperMPI.jl b/examples/simulations/GrayScott.jl/src/helper/helperMPI.jl new file mode 100644 index 0000000000..529d7e0420 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/helper/helperMPI.jl @@ -0,0 +1,15 @@ + +import MPI + +export bcase_file + +function bcast_file_contents(file_name::String, comm, root = 0)::String + size::UInt32 = 0 + data::Vector{UInt8} = [] + if MPI.Comm_rank(comm) == root + data = read(open(file_name, "r")) + end + + data = MPI.bcast(data, comm) + return String(data) +end diff --git a/examples/simulations/GrayScott.jl/src/helper/helperString.jl b/examples/simulations/GrayScott.jl/src/helper/helperString.jl new file mode 100644 index 0000000000..596a2f0b94 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/helper/helperString.jl @@ -0,0 +1,14 @@ + +export get_type + +function get_type(input::String) + if input == "Float64" + return Float64 + elseif input == "Float32" + return Float32 + elseif input == "Float16" + return Float16 + end + + return nothing +end \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/src/simulation/IO.jl b/examples/simulations/GrayScott.jl/src/simulation/IO.jl new file mode 100644 index 0000000000..deb3a24ae8 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/simulation/IO.jl @@ -0,0 +1,106 @@ +module IO + +export init, write_step! + +# import external module +import ADIOS2 + +# internal submodule +import ..Simulation +# types from parent module types in Structs.jl +import ..Settings, ..MPICartDomain, ..Fields, ..IOStream + +function init(settings::Settings, mcd::MPICartDomain, + fields::Fields{T}) where {T} + + # initialize adios MPI using the cartesian communicator + adios = ADIOS2.adios_init_mpi(mcd.cart_comm) + io = ADIOS2.declare_io(adios, "SimulationOutput") + # @TODO: implement ADIOS2.set_engine in ADIOS2.jl + engine = ADIOS2.open(io, settings.output, ADIOS2.mode_write) + + # store simulation run provenance as attributes + ADIOS2.define_attribute(io, "F", settings.F) + ADIOS2.define_attribute(io, "k", settings.k) + ADIOS2.define_attribute(io, "dt", settings.dt) + ADIOS2.define_attribute(io, "Du", settings.Du) + ADIOS2.define_attribute(io, "Dv", settings.Dv) + ADIOS2.define_attribute(io, "noise", settings.noise) + + _add_visualization_schemas(io, settings.L) + + # ADIOS2 requires tuples for the dimensions + # define global variables u and v + shape = (settings.L, settings.L, settings.L) + start = Tuple(mcd.proc_offsets) + count = Tuple(mcd.proc_sizes) + + var_step = ADIOS2.define_variable(io, "step", Int32) + var_U = ADIOS2.define_variable(io, "U", T, shape, start, count) + var_V = ADIOS2.define_variable(io, "V", T, shape, start, count) + + return IOStream(adios, io, engine, var_step, var_U, var_V) +end + +function write_step!(stream::IOStream, step::Int32, fields::Fields{T}) where {T} + + # this creates temporaries similar to Fortran + u_no_ghost, v_no_ghost = Simulation.get_fields(fields) + + # writer engine + w = stream.engine + + ADIOS2.begin_step(w) + ADIOS2.put!(w, stream.var_step, step) + ADIOS2.put!(w, stream.var_U, u_no_ghost) + ADIOS2.put!(w, stream.var_V, v_no_ghost) + ADIOS2.end_step(w) +end + +function close!(stream::IOStream) + ADIOS2.close(stream.engine) + ADIOS2.adios_finalize(stream.adios) +end + +function _add_visualization_schemas(io, length) + + # Fides schema + ADIOS2.define_attribute(io, "Fides_Data_Model", "uniform") + ADIOS2.define_attribute_array(io, "Fides_Origin", [0.0, 0.0, 0.0]) + ADIOS2.define_attribute_array(io, "Fides_Spacing", [0.1, 0.1, 0.1]) + ADIOS2.define_attribute(io, "Fides_Dimension_Variable", "U") + ADIOS2.define_attribute_array(io, "Fides_Variable_List", ["U", "V"]) + ADIOS2.define_attribute_array(io, "Fides_Variable_Associations", + ["points", "points"]) + + # VTX schema + # string concatenation uses *, ^ is for repetition + # if length = 64 + # extent = "0 64 0 64 0 64 " + extent = ("0 " * string(length) * " ")^3 + extent = rstrip(extent) + + # deactive code formatting using JuliaFormatter.jl + # raw strings: " must be escaped with \" + #! format: off + vtx_schema = raw" + + + + + + + + + step + + + + + " + #! format: on + # reactive code formatting using JuliaFormatter.jl + ADIOS2.define_attribute(io, "vtk.xml", vtx_schema) +end + +end diff --git a/examples/simulations/GrayScott.jl/src/simulation/Inputs.jl b/examples/simulations/GrayScott.jl/src/simulation/Inputs.jl new file mode 100644 index 0000000000..a4160ce1d8 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/simulation/Inputs.jl @@ -0,0 +1,78 @@ + +""" +Submodule used by GrayScott to handle inputs +""" +module Inputs + +export get_settings + +import ArgParse +import JSON + +import ..Helper +# import directly from parent module (GrayScott) +import ..Settings, ..SettingsKeys + +# public facing function +function get_settings(args::Vector{String}, comm)::Settings + config_file = _parse_args(args) + + # check format extension + if !endswith(config_file, ".json") && + !(endswith(config_file, ".yaml") || endswith(config_file, ".yml")) + throw(ArgumentError("config file must be json, yaml format. Extension not recognized.\n")) + end + + config_file_contents::String = Helper.bcast_file_contents(config_file, comm) + + if endswith(config_file, ".json") + return _parse_settings_json(config_file_contents) + end + + return nothing +end + +# local scope functions +function _parse_args(args::Vector{String}; + error_handler = ArgParse.default_handler)::String + s = ArgParse.ArgParseSettings(description = "gray-scott workflow simulation example configuration file, Julia version, GrayScott.jl", + exc_handler = error_handler) + + # @add_arg_table! s begin + # "--opt1" # an option (will take an argument) + # "--opt2", "-o" # another option, with short form + # "arg1" # a positional argument + # end + + ArgParse.@add_arg_table! s begin + "config_file" + help = "configuration file" + arg_type = String + required = true + end + + # parse_args return a dictionary with key/value for arguments + parsed_arguments = ArgParse.parse_args(args, s) + + # key is mandatory, so it's safe to retrieve + config_file::String = parsed_arguments["config_file"] + + return config_file +end + +function _parse_settings_json(json_contents::String)::Settings + json = JSON.parse(json_contents) + settings = Settings() + + # Iterate through dictionary pairs + for (key, value) in json + # Iterate through predefined keys, else ignore (no error if unrecognized) + if key in SettingsKeys + setproperty!(settings, Symbol(key), value) + end + end + + return settings +end + +end # module \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/src/simulation/Simulation.jl b/examples/simulations/GrayScott.jl/src/simulation/Simulation.jl new file mode 100644 index 0000000000..f3cbf3325c --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/simulation/Simulation.jl @@ -0,0 +1,281 @@ +""" +The present file contains runtime backend for using CPU Threads, and optionally +CUDA.jl and AMDGPU.jl +""" +module Simulation + +export init_domain, init_fields + +import MPI +import Distributions + +# from parent module +import ..Settings, ..MPICartDomain, ..Fields + +# include functions for NVIDIA GPUs using CUDA.jl +include("Simulation_CUDA.jl") +# include functions for AMD GPUs using AMDGPU.jl +include("Simulation_AMDGPU.jl") + +function init_domain(settings::Settings, comm::MPI.Comm)::MPICartDomain + mcd = MPICartDomain() + + # set dims and Cartesian communicator + mcd.dims = MPI.Dims_create(MPI.Comm_size(comm), mcd.dims) + mcd.cart_comm = MPI.Cart_create(comm, mcd.dims) + + # set proc local coordinates in Cartesian communicator + rank = MPI.Comm_rank(comm) + mcd.coords = MPI.Cart_coords(mcd.cart_comm, rank) + + # set proc local mesh sizes + mcd.proc_sizes = settings.L ./ mcd.dims + + for (i, coord) in enumerate(mcd.coords) + if coord < settings.L % mcd.dims[i] + mcd.proc_sizes[i] += 1 + end + end + + # set proc local offsets + for i in 1:3 + mcd.proc_offsets[i] = settings.L / mcd.dims[i] * + mcd.coords[i] + +min(settings.L % mcd.dims[i], mcd.coords[i]) + end + + # get neighbors ranks + mcd.proc_neighbors["west"], + mcd.proc_neighbors["east"] = MPI.Cart_shift(mcd.cart_comm, 0, 1) + mcd.proc_neighbors["down"], + mcd.proc_neighbors["up"] = MPI.Cart_shift(mcd.cart_comm, 1, 1) + mcd.proc_neighbors["south"], + mcd.proc_neighbors["north"] = MPI.Cart_shift(mcd.cart_comm, 2, 1) + + return mcd +end + +""" +Create and Initialize fields for either CPU, CUDA.jl, AMDGPU.jl backends +Multiple dispatch would direct to the appropriate overleaded function +""" +function init_fields(settings::Settings, + mcd::MPICartDomain, T)::Fields{T} + lowercase_backend = lowercase(settings.backend) + if lowercase_backend == "cuda" + return _init_fields_cuda(settings, mcd, T) + elseif lowercase_backend == "amdgpu" + return _init_fields_amdgpu(settings, mcd, T) + end + # everything else would trigger the CPU threads backend + return _init_fields_cpu(settings, mcd, T) +end + +function _init_fields_cpu(settings::Settings, + mcd::MPICartDomain, T)::Fields{T} + size_x = mcd.proc_sizes[1] + size_y = mcd.proc_sizes[2] + size_z = mcd.proc_sizes[3] + + # should be ones + u = ones(T, size_x + 2, size_y + 2, size_z + 2) + v = zeros(T, size_x + 2, size_y + 2, size_z + 2) + + u_temp = zeros(T, size_x + 2, size_y + 2, size_z + 2) + v_temp = zeros(T, size_x + 2, size_y + 2, size_z + 2) + + function is_inside(x, y, z, offsets, sizes)::Bool + if x < offsets[1] || x >= offsets[1] + sizes[1] + return false + end + if y < offsets[2] || y >= offsets[2] + sizes[2] + return false + end + if z < offsets[3] || z >= offsets[3] + sizes[3] + return false + end + + return true + end + + d::Int64 = 6 + + # global locations + minL = Int64(settings.L / 2 - d) + maxL = Int64(settings.L / 2 + d) + + xoff = mcd.proc_offsets[1] + yoff = mcd.proc_offsets[2] + zoff = mcd.proc_offsets[3] + + Threads.@threads for z in minL:maxL + for y in minL:maxL + for x in minL:maxL + if !is_inside(x, y, z, mcd.proc_offsets, mcd.proc_sizes) + continue + end + + # Julia is 1-index, like Fortran :) + u[x - xoff + 2, y - yoff + 2, z - zoff + 2] = 0.25 + v[x - xoff + 2, y - yoff + 2, z - zoff + 2] = 0.33 + end + end + end + + xy_face_t, xz_face_t, yz_face_t = _get_mpi_faces(size_x, size_y, size_z, T) + + fields = Fields(u, v, u_temp, v_temp, xy_face_t, xz_face_t, yz_face_t) + return fields +end + +function iterate!(fields::Fields{T, N, Array{T, N}}, settings::Settings, + mcd::MPICartDomain) where {T, N} + _exchange!(fields, mcd) + # this function is the bottleneck + _calculate!(fields, settings, mcd) + + # swap the names + fields.u, fields.u_temp = fields.u_temp, fields.u + fields.v, fields.v_temp = fields.v_temp, fields.v +end + +function _get_mpi_faces(size_x, size_y, size_z, T) + + ## create a new type taking: count, block length, stride + ## to interoperate with MPI for ghost cell exchange + xy_face_t = MPI.Types.create_vector(size_y + 2, size_x, size_x + 2, + MPI.Datatype(T)) + xz_face_t = MPI.Types.create_vector(size_z, size_x, + (size_x + 2) * (size_y + 2), + MPI.Datatype(T)) + yz_face_t = MPI.Types.create_vector((size_y + 2) * (size_z + 2), 1, + size_x + 2, MPI.Datatype(T)) + MPI.Types.commit!(xy_face_t) + MPI.Types.commit!(xz_face_t) + MPI.Types.commit!(yz_face_t) + + return xy_face_t, xz_face_t, yz_face_t +end + +function _exchange!(fields, mcd) + """ + Send XY face z=size_z+1 to north and receive z=1 from south + """ + function _exchange_xy!(var, size_z, data_type, rank1, rank2, comm) + # to north + send_buf = MPI.Buffer(@view(var[2, 1, size_z + 1]), 1, data_type) + recv_buf = MPI.Buffer(@view(var[2, 1, 1]), 1, data_type) + MPI.Sendrecv!(send_buf, recv_buf, comm, dest = rank1, source = rank2) + + # to south + send_buf = MPI.Buffer(@view(var[2, 1, 2]), 1, data_type) + recv_buf = MPI.Buffer(@view(var[2, 1, size_z + 2]), 1, data_type) + MPI.Sendrecv!(send_buf, recv_buf, comm, dest = rank2, source = rank1) + end + + """ + Send XZ face y=size_y+1 to up and receive y=1 from down + """ + function _exchange_xz!(var, size_y, data_type, rank1, rank2, comm) + # to up + send_buf = MPI.Buffer(@view(var[2, size_y + 1, 2]), 1, data_type) + recv_buf = MPI.Buffer(@view(var[2, 1, 2]), 1, data_type) + MPI.Sendrecv!(send_buf, recv_buf, comm, dest = rank1, source = rank2) + + # to down + send_buf = MPI.Buffer(@view(var[2, 2, 2]), 1, data_type) + recv_buf = MPI.Buffer(@view(var[2, size_y + 2, 2]), 1, data_type) + MPI.Sendrecv!(send_buf, recv_buf, comm, dest = rank2, source = rank1) + end + + """ + Send YZ face x=size_x+2 to east and receive x=2 from west + """ + function _exchange_yz!(var, size_x, data_type, rank1, rank2, comm) + # to east + send_buf = MPI.Buffer(@view(var[size_x + 1, 1, 1]), 1, data_type) + recv_buf = MPI.Buffer(@view(var[1, 1, 1]), 1, data_type) + MPI.Sendrecv!(send_buf, recv_buf, comm, dest = rank1, source = rank2) + + # to west + send_buf = MPI.Buffer(@view(var[2, 1, 1]), 1, data_type) + recv_buf = MPI.Buffer(@view(var[size_x + 2, 1, 1]), 1, data_type) + MPI.Sendrecv!(send_buf, recv_buf, comm, dest = rank2, source = rank1) + end + + # if already a CPU array, no need to copy, + # otherwise (device) copy to host. + u = typeof(fields.u) <: Array ? fields.u : Array(fields.u) + v = typeof(fields.v) <: Array ? fields.v : Array(fields.v) + + for var in [u, v] + _exchange_xy!(var, mcd.proc_sizes[3], fields.xy_face_t, + mcd.proc_neighbors["north"], mcd.proc_neighbors["south"], + mcd.cart_comm) + + _exchange_xz!(var, mcd.proc_sizes[2], fields.xz_face_t, + mcd.proc_neighbors["up"], mcd.proc_neighbors["down"], + mcd.cart_comm) + + _exchange_yz!(var, mcd.proc_sizes[1], fields.yz_face_t, + mcd.proc_neighbors["east"], mcd.proc_neighbors["west"], + mcd.cart_comm) + end +end + +function _calculate!(fields::Fields{T, N, Array{T, N}}, settings::Settings, + mcd::MPICartDomain) where {T, N} + Du = convert(T, settings.Du) + Dv = convert(T, settings.Dv) + F = convert(T, settings.F) + K = convert(T, settings.k) + noise = convert(T, settings.noise) + dt = convert(T, settings.dt) + + # loop through non-ghost cells, bounds are inclusive + # @TODO: load balancing? option: a big linear loop + # use @inbounds at the right for-loop level, avoid putting it at the top level + Threads.@threads for k in 2:(mcd.proc_sizes[3] + 1) + for j in 2:(mcd.proc_sizes[2] + 1) + @inbounds for i in 2:(mcd.proc_sizes[1] + 1) + u = fields.u[i, j, k] + v = fields.v[i, j, k] + + # introduce a random disturbance on du + du = Du * _laplacian(i, j, k, fields.u) - u * v^2 + + F * (1.0 - u) + + noise * rand(Distributions.Uniform(-1, 1)) + + dv = Dv * _laplacian(i, j, k, fields.v) + u * v^2 - + (F + K) * v + + # advance the next step + fields.u_temp[i, j, k] = u + du * dt + fields.v_temp[i, j, k] = v + dv * dt + end + end + end +end + +""" + 7-point stencil around the cell, + this is equally a host and a device function! +""" +function _laplacian(i, j, k, var) + @inbounds l = var[i - 1, j, k] + var[i + 1, j, k] + var[i, j - 1, k] + + var[i, j + 1, k] + var[i, j, k - 1] + var[i, j, k + 1] - + 6.0 * var[i, j, k] + return l / 6.0 +end + +function get_fields(fields::Fields{T, N, Array{T, N}}) where {T, N} + @inbounds begin + u_no_ghost = fields.u[(begin + 1):(end - 1), (begin + 1):(end - 1), + (begin + 1):(end - 1)] + v_no_ghost = fields.v[(begin + 1):(end - 1), (begin + 1):(end - 1), + (begin + 1):(end - 1)] + end + return u_no_ghost, v_no_ghost +end + +end # module diff --git a/examples/simulations/GrayScott.jl/src/simulation/Simulation_AMDGPU.jl b/examples/simulations/GrayScott.jl/src/simulation/Simulation_AMDGPU.jl new file mode 100644 index 0000000000..8920167779 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/simulation/Simulation_AMDGPU.jl @@ -0,0 +1,168 @@ + +import AMDGPU + +function _init_fields_amdgpu(settings::Settings, mcd::MPICartDomain, + T)::Fields{T, 3, <:AMDGPU.ROCArray{T, 3}} + size_x = mcd.proc_sizes[1] + size_y = mcd.proc_sizes[2] + size_z = mcd.proc_sizes[3] + + # should be ones + u = AMDGPU.ones(T, size_x + 2, size_y + 2, size_z + 2) + v = AMDGPU.zeros(T, size_x + 2, size_y + 2, size_z + 2) + + u_temp = AMDGPU.zeros(T, size_x + 2, size_y + 2, size_z + 2) + v_temp = AMDGPU.zeros(T, size_x + 2, size_y + 2, size_z + 2) + + roc_offsets = AMDGPU.ROCArray(mcd.proc_offsets) + roc_sizes = AMDGPU.ROCArray(mcd.proc_sizes) + + d::Int64 = 6 + minL = Int64(settings.L / 2 - d) + maxL = Int64(settings.L / 2 + d) + + # @TODO: get ideal grid size and threads + threads = (16, 16) + # grid size must be the total number of threads of each direction + grid = (settings.L, settings.L) + + AMDGPU.wait(AMDGPU.@roc groupsize=threads gridsize=grid _populate_amdgpu!(u, + v, + roc_offsets, + roc_sizes, + minL, + maxL)) + + xy_face_t, xz_face_t, yz_face_t = _get_mpi_faces(size_x, size_y, size_z, T) + + fields = Fields(u, v, u_temp, v_temp, xy_face_t, xz_face_t, yz_face_t) + return fields +end + +function iterate!(fields::Fields{T, N, <:AMDGPU.ROCArray{T, N}}, + settings::Settings, + mcd::MPICartDomain) where {T, N} + _exchange!(fields, mcd) + # this function is the bottleneck + _calculate!(fields, settings, mcd) + + # swap the names + fields.u, fields.u_temp = fields.u_temp, fields.u + fields.v, fields.v_temp = fields.v_temp, fields.v +end + +function _populate_amdgpu!(u, v, offsets, sizes, minL, maxL) + function is_inside(x, y, z, offsets, sizes)::Bool + if x < offsets[1] || x >= offsets[1] + sizes[1] + return false + end + if y < offsets[2] || y >= offsets[2] + sizes[2] + return false + end + if z < offsets[3] || z >= offsets[3] + sizes[3] + return false + end + + return true + end + + # local coordinates (this are 1-index already) + lz = (AMDGPU.workgroupIdx().x - Int32(1)) * AMDGPU.workgroupDim().x + + AMDGPU.workitemIdx().x + ly = (AMDGPU.workgroupIdx().y - Int32(1)) * AMDGPU.workgroupDim().y + + AMDGPU.workitemIdx().y + + # This check might not be needed + if lz <= size(u, 3) && ly <= size(u, 2) + + # get global coordinates + z = lz + offsets[3] - 1 + y = ly + offsets[2] - 1 + + if z >= minL && z <= maxL && y >= minL && y <= maxL + xoff = offsets[1] + + for x in minL:maxL + # check if global coordinates for initialization are inside the region + if !is_inside(x, y, z, offsets, sizes) + continue + end + + # Julia is 1-index, like Fortran :) + u[x - xoff + 2, ly + 1, lz + 1] = 0.25 + v[x - xoff + 2, ly + 1, lz + 1] = 0.33 + end + end + end +end + +function _calculate!(fields::Fields{T, N, <:AMDGPU.ROCArray{T, N}}, + settings::Settings, + mcd::MPICartDomain) where {T, N} + Du = convert(T, settings.Du) + Dv = convert(T, settings.Dv) + F = convert(T, settings.F) + K = convert(T, settings.k) + noise = convert(T, settings.noise) + dt = convert(T, settings.dt) + + roc_sizes = AMDGPU.ROCArray(mcd.proc_sizes) + + threads = (16, 16) + blocks = (settings.L, settings.L) + + AMDGPU.wait(AMDGPU.@roc groupsize=threads gridsize=grid _calculate_kernel_amdgpu!(fields.u, + fields.v, + fields.u_temp, + fields.v_temp, + roc_sizes, + Du, + Dv, + F, + K, + noise, + dt)) +end + +function _calculate_kernel_amdgpu!(u, v, u_temp, v_temp, sizes, Du, Dv, F, K, + noise, dt) + + # local coordinates (this are 1-index already) + k = (AMDGPU.workgroupIdx().x - Int32(1)) * AMDGPU.workgroupDim().x + + AMDGPU.workitemIdx().x + j = (AMDGPU.workgroupIdx().y - Int32(1)) * AMDGPU.workgroupDim().y + + AMDGPU.workitemIdx().y + + # loop through non-ghost cells + if k >= 2 && k <= sizes[3] + 1 && j >= 2 && j <= sizes[2] + 1 + # bounds are inclusive + for i in 2:(sizes[1] + 1) + u_ijk = u[i, j, k] + v_ijk = v[i, j, k] + + du = Du * _laplacian(i, j, k, u) - u_ijk * v_ijk^2 + + F * (1.0 - u_ijk) + # + noise * AMDGPU.rand(eltype(u)) + # WIP in AMDGPU.jl, works with CUDA.jl + # + rand(Distributions.Uniform(-1, 1)) + + dv = Dv * _laplacian(i, j, k, v) + u_ijk * v_ijk^2 - + (F + K) * v_ijk + + # advance the next step + u_temp[i, j, k] = u_ijk + du * dt + v_temp[i, j, k] = v_ijk + dv * dt + end + end +end + +function get_fields(fields::Fields{T, N, <:AMDGPU.ROCArray{T, N}}) where {T, N} + u = Array(fields.u) + u_no_ghost = u[(begin + 1):(end - 1), (begin + 1):(end - 1), + (begin + 1):(end - 1)] + + v = Array(fields.v) + v_no_ghost = v[(begin + 1):(end - 1), (begin + 1):(end - 1), + (begin + 1):(end - 1)] + return u_no_ghost, v_no_ghost +end diff --git a/examples/simulations/GrayScott.jl/src/simulation/Simulation_CUDA.jl b/examples/simulations/GrayScott.jl/src/simulation/Simulation_CUDA.jl new file mode 100644 index 0000000000..ee470f00ec --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/simulation/Simulation_CUDA.jl @@ -0,0 +1,160 @@ + +import CUDA + +function _init_fields_cuda(settings::Settings, mcd::MPICartDomain, + T)::Fields{T, 3, <:CUDA.CuArray{T, 3}} + size_x = mcd.proc_sizes[1] + size_y = mcd.proc_sizes[2] + size_z = mcd.proc_sizes[3] + + # should be ones + u = CUDA.ones(T, size_x + 2, size_y + 2, size_z + 2) + v = CUDA.zeros(T, size_x + 2, size_y + 2, size_z + 2) + + u_temp = CUDA.zeros(T, size_x + 2, size_y + 2, size_z + 2) + v_temp = CUDA.zeros(T, size_x + 2, size_y + 2, size_z + 2) + + cu_offsets = CUDA.CuArray(mcd.proc_offsets) + cu_sizes = CUDA.CuArray(mcd.proc_sizes) + + d::Int64 = 6 + minL = Int64(settings.L / 2 - d) + maxL = Int64(settings.L / 2 + d) + + # @TODO: get ideal blocks and threads + threads = (16, 16) + blocks = (settings.L, settings.L) + + CUDA.@cuda threads=threads blocks=blocks _populate_cuda!(u, v, + cu_offsets, + cu_sizes, + minL, maxL) + CUDA.synchronize() + + xy_face_t, xz_face_t, yz_face_t = _get_mpi_faces(size_x, size_y, size_z, T) + + fields = Fields(u, v, u_temp, v_temp, xy_face_t, xz_face_t, yz_face_t) + return fields +end + +function iterate!(fields::Fields{T, N, <:CUDA.CuArray{T, N}}, + settings::Settings, + mcd::MPICartDomain) where {T, N} + _exchange!(fields, mcd) + # this function is the bottleneck + _calculate!(fields, settings, mcd) + + # swap the names + fields.u, fields.u_temp = fields.u_temp, fields.u + fields.v, fields.v_temp = fields.v_temp, fields.v +end + +function _populate_cuda!(u, v, offsets, sizes, minL, maxL) + function is_inside(x, y, z, offsets, sizes)::Bool + if x < offsets[1] || x >= offsets[1] + sizes[1] + return false + end + if y < offsets[2] || y >= offsets[2] + sizes[2] + return false + end + if z < offsets[3] || z >= offsets[3] + sizes[3] + return false + end + + return true + end + + # local coordinates (this are 1-index already) + lz = (CUDA.blockIdx().x - Int32(1)) * CUDA.blockDim().x + + CUDA.threadIdx().x + ly = (CUDA.blockIdx().y - Int32(1)) * CUDA.blockDim().y + + CUDA.threadIdx().y + + if lz <= size(u, 3) && ly <= size(u, 2) + + # get global coordinates + z = lz + offsets[3] - 1 + y = ly + offsets[2] - 1 + + if z >= minL && z <= maxL && y >= minL && y <= maxL + xoff = offsets[1] + + for x in minL:maxL + # check if global coordinates for initialization are inside the region + if !is_inside(x, y, z, offsets, sizes) + continue + end + + # Julia is 1-index, like Fortran :) + u[x - xoff + 2, ly + 1, lz + 1] = 0.25 + v[x - xoff + 2, ly + 1, lz + 1] = 0.33 + end + end + end +end + +function _calculate!(fields::Fields{T, N, <:CUDA.CuArray{T, N}}, + settings::Settings, + mcd::MPICartDomain) where {T, N} + function _calculate_kernel!(u, v, u_temp, v_temp, sizes, Du, Dv, F, K, + noise, dt) + + # local coordinates (this are 1-index already) + k = (CUDA.blockIdx().x - Int32(1)) * CUDA.blockDim().x + + CUDA.threadIdx().x + j = (CUDA.blockIdx().y - Int32(1)) * CUDA.blockDim().y + + CUDA.threadIdx().y + + # loop through non-ghost cells + if k >= 2 && k <= sizes[3] + 1 && j >= 2 && j <= sizes[2] + 1 + # bounds are inclusive + for i in 2:(sizes[1] + 1) + u_ijk = u[i, j, k] + v_ijk = v[i, j, k] + + du = Du * _laplacian(i, j, k, u) - u_ijk * v_ijk^2 + + F * (1.0 - u_ijk) + + noise * rand(Distributions.Uniform(-1, 1)) + + dv = Dv * _laplacian(i, j, k, v) + u_ijk * v_ijk^2 - + (F + K) * v_ijk + + # advance the next step + u_temp[i, j, k] = u_ijk + du * dt + v_temp[i, j, k] = v_ijk + dv * dt + end + end + end + + Du = convert(T, settings.Du) + Dv = convert(T, settings.Dv) + F = convert(T, settings.F) + K = convert(T, settings.k) + noise = convert(T, settings.noise) + dt = convert(T, settings.dt) + + cu_sizes = CUDA.CuArray(mcd.proc_sizes) + + threads = (16, 16) + blocks = (settings.L, settings.L) + + CUDA.@cuda threads=threads blocks=blocks _calculate_kernel!(fields.u, + fields.v, + fields.u_temp, + fields.v_temp, + cu_sizes, + Du, Dv, F, K, + noise, dt) + CUDA.synchronize() +end + +function get_fields(fields::Fields{T, N, <:CUDA.CuArray{T, N}}) where {T, N} + u = Array(fields.u) + u_no_ghost = u[(begin + 1):(end - 1), (begin + 1):(end - 1), + (begin + 1):(end - 1)] + + v = Array(fields.v) + v_no_ghost = v[(begin + 1):(end - 1), (begin + 1):(end - 1), + (begin + 1):(end - 1)] + return u_no_ghost, v_no_ghost +end diff --git a/examples/simulations/GrayScott.jl/src/simulation/Structs.jl b/examples/simulations/GrayScott.jl/src/simulation/Structs.jl new file mode 100644 index 0000000000..ca35fb5611 --- /dev/null +++ b/examples/simulations/GrayScott.jl/src/simulation/Structs.jl @@ -0,0 +1,102 @@ + +""" +Settings carry the settings from the simulation config file (json or yaml formats) + +Using Base.@kwdef macro for easy defaults and enable keyword arguments +Settings(Du = 0.2, noise = 0.2) +See: +https://discourse.julialang.org/t/default-value-of-some-fields-in-a-mutable-struct/33408/24?u=williamfgc +""" +Base.@kwdef mutable struct Settings + L::Int64 = 128 + steps::Int32 = 20000 + plotgap::Int32 = 200 + F::Float64 = 0.04 + k::Float64 = 0 + dt::Float64 = 0.2 + Du::Float64 = 0.05 + Dv::Float64 = 0.1 + noise::Float64 = 0.0 + output::String = "foo.bp" + checkpoint::Bool = false + checkpoint_freq::Int32 = 2000 + checkpoint_output::String = "ckpt.bp" + restart::Bool = false + restart_input::String = "ckpt.bp" + adios_config::String = "adios2.yaml" + adios_span::Bool = false + adios_memory_selection::Bool = false + mesh_type::String = "image" + precision::String = "Float64" + backend::String = "CPU" +end + +SettingsKeys = Set{String}([ + "L", + "steps", + "plotgap", + "F", + "k", + "dt", + "Du", + "Dv", + "noise", + "output", + "checkpoint", + "checkpoint_freq", + "checkpoint_output", + "restart", + "restart_input", + "adios_config", + "adios_span", + "adios_memory_selection", + "mesh_type", + "precision", + "backend", + ]) + +Base.@kwdef mutable struct MPICartDomain + cart_comm::MPI.Comm = MPI.COMM_NULL + + # Cartesian communicator info + # Could used StaticArrays.jl? + # start dims with zeros + dims::Vector{Int32} = zeros(Int32, 3) + coords::Vector{Int32} = zeros(Int32, 3) + + # local process mesh sizes and offsets in Cartesian domain info, using defaults + proc_sizes::Vector{Int64} = [128, 128, 128] + proc_offsets::Vector{Int64} = [1, 1, 1] + + # couldn't use NamedTuples as struct is mutable + proc_neighbors = Dict{String, Int32}("west" => -1, "east" => -1, "up" => -1, + "down" => -1, "north" => -1, + "south" => -1) +end + +""" +Carry the physical field outputs: u and v +Using AbstractArray to allow for Array, CuArray and ROCArray +""" +mutable struct Fields{T, N, A <: AbstractArray{T, N}} + u::A + v::A + u_temp::A + v_temp::A + # MPI Datatypes for halo exchange MPI.Datatype(T) + xy_face_t::MPI.Datatype + xz_face_t::MPI.Datatype + yz_face_t::MPI.Datatype +end + +""" +Carry the I/O information for outputs +""" +struct IOStream + adios::ADIOS2.Adios + io::ADIOS2.AIO + engine::ADIOS2.Engine + var_step::ADIOS2.Variable + var_U::ADIOS2.Variable + var_V::ADIOS2.Variable +end diff --git a/examples/simulations/GrayScott.jl/test/Project.toml b/examples/simulations/GrayScott.jl/test/Project.toml new file mode 100644 index 0000000000..c60df76b67 --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/Project.toml @@ -0,0 +1,3 @@ +[deps] +MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/examples/simulations/GrayScott.jl/test/functional/functional-GrayScott.jl b/examples/simulations/GrayScott.jl/test/functional/functional-GrayScott.jl new file mode 100644 index 0000000000..46a844a037 --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/functional/functional-GrayScott.jl @@ -0,0 +1,12 @@ + +import GrayScott +import Test: @testset, @test + +@testset "GrayScott" begin MPI.mpiexec() do runcmd + config_file = joinpath(dirname(Base.active_project()), "examples", + "settings-files.json") + + juliacmd = `julia --project gray-scott.jl $config_file` + + @test run(`mpirun -n 4 $juliacmd`).exitcode == 0 +end end \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/test/runtests.jl b/examples/simulations/GrayScott.jl/test/runtests.jl new file mode 100644 index 0000000000..e795c94ca9 --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/runtests.jl @@ -0,0 +1,26 @@ + +import MPI + +# Run all lightweight unit tests within a single MPI session +MPI.Init() + +verbose = false + +# unit tests for module GrayScott +include(joinpath("unit", "helper", "unit-helperMPI.jl")) + +include(joinpath("unit", "simulation", "unit-Inputs.jl")) +include(joinpath("unit", "simulation", "unit-Simulation.jl")) +include(joinpath("unit", "simulation", "unit-Simulation_CUDA.jl")) +include(joinpath("unit", "simulation", "unit-IO.jl")) + +# unit tests for analysis scripts +include(joinpath("unit", "analysis", "unit-pdfcalc.jl")) + +MPI.Finalize() + +# Command line tests. These are heavier tests launched as separate processes. +# The downside is that only global success can be tested and not internal states. + +# functional tests +# include(joinpath("functional", "functional-GrayScott.jl")) diff --git a/examples/simulations/GrayScott.jl/test/unit/analysis/unit-pdfcalc.jl b/examples/simulations/GrayScott.jl/test/unit/analysis/unit-pdfcalc.jl new file mode 100644 index 0000000000..87ea9b8478 --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/unit/analysis/unit-pdfcalc.jl @@ -0,0 +1,19 @@ + +import Test: @testset, @test, @test_throws + +include(joinpath(dirname(Base.active_project()), "src", "analysis", + "pdfcalc.jl")) + +@testset "unit-analysis.pdfcalc._parse_args" begin + inputs = _parse_arguments(["foo.bp", "bar.bp", "1500"]) + @test inputs["input"] == "foo.bp" + @test inputs["output"] == "bar.bp" + @test inputs["N"] == 1500 + @test inputs["output_inputdata"] == false + + inputs = _parse_arguments(["input.bp", "output.bp", "1000", "true"]) + @test inputs["input"] == "input.bp" + @test inputs["output"] == "output.bp" + @test inputs["N"] == 1000 + @test inputs["output_inputdata"] == true +end diff --git a/examples/simulations/GrayScott.jl/test/unit/helper/unit-helperMPI.jl b/examples/simulations/GrayScott.jl/test/unit/helper/unit-helperMPI.jl new file mode 100644 index 0000000000..33d9f2202f --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/unit/helper/unit-helperMPI.jl @@ -0,0 +1,12 @@ + +import Test: @testset, @test, @test_throws +import GrayScott: Helper + +@testset "unit-Helper.bcast_file_contents" begin + config_file = joinpath(dirname(Base.active_project()), "examples", + "settings-files.json") + + file_contents = Helper.bcast_file_contents(config_file, MPI.COMM_WORLD) + file_contents_expected = String(read(open(config_file, "r"))) + @test file_contents == file_contents_expected +end \ No newline at end of file diff --git a/examples/simulations/GrayScott.jl/test/unit/simulation/unit-IO.jl b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-IO.jl new file mode 100644 index 0000000000..5a33f90ed9 --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-IO.jl @@ -0,0 +1,36 @@ + +import Test: @testset, @test, @test_throws + +import ADIOS2 + +# import submodule +import GrayScott: IO +# import types +import GrayScott: Settings, MPICartDomain, Fields + +@testset "unit-IO.init" begin + settings = Settings() + mpi_cart_domain = MPICartDomain() + fields = Simulation.init_fields(settings, mpi_cart_domain, Float32) + + @test eltype(fields.u) == Float32 + @test eltype(fields.v) == Float32 + + stream = IO.init(settings, mpi_cart_domain, fields) + + @test ADIOS2.name(stream.engine) == "foo.bp" + IO.close!(stream) + + # @TODO: needs to be done from rank==0 only + # Base.Filesystem.rm("foo.bp", force = true, recursive = true) +end + +@testset "unit-IO.write" begin + settings = Settings() + settings.L = 6 + mpi_cart_domain = Simulation.init_domain(settings, MPI.COMM_WORLD) + fields = Simulation.init_fields(settings, mpi_cart_domain, Float32) + stream = IO.init(settings, mpi_cart_domain, fields) + IO.write_step!(stream, Int32(0), fields) + IO.close!(stream) +end diff --git a/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Inputs.jl b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Inputs.jl new file mode 100644 index 0000000000..fb77325de5 --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Inputs.jl @@ -0,0 +1,15 @@ + +import Test: @testset, @test, @test_throws +import GrayScott: Inputs + +# Unfortunately due to MPI being a Singleton, single MPI.Init() +# these unit tests don't run as independent files + +@testset "unit-Inputs.get_settings" begin + config_file = joinpath(dirname(Base.active_project()), "examples", + "settings-files.json") + Inputs.get_settings([config_file], MPI.COMM_WORLD) + + @test_throws(ArgumentError, + Inputs.get_settings(["hello.nojson"], MPI.COMM_WORLD)) +end diff --git a/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation.jl b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation.jl new file mode 100644 index 0000000000..ad43a8b49f --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation.jl @@ -0,0 +1,34 @@ + +import Test: @testset, @test, @test_throws +# import submodule +import GrayScott: Simulation +# import types +import GrayScott: Settings, MPICartDomain, Fields + +# Unfortunately due to MPI being a Singleton, single MPI.Init() +# these unit tests don't run as independent files + +@testset "unit-Simulation.init" begin + settings = Settings() + mpi_cart_domain = Simulation.init_domain(settings, MPI.COMM_WORLD) + fields = Simulation.init_fields(settings, mpi_cart_domain, Float32) + + @test typeof(fields) == Fields{Float32, 3, Array{Float32, 3}} +end + +@testset "unit-Simulation.iterate" begin + settings = Settings() + settings.L = 2 + mpi_cart_domain = Simulation.init_domain(settings, MPI.COMM_WORLD) + fields = Simulation.init_fields(settings, mpi_cart_domain, Float32) + + Simulation.iterate!(fields, settings, mpi_cart_domain) + + if verbose + sleep(0.01) + rank = MPI.Comm_rank(MPI.COMM_WORLD) + @show rank, fields.v + end +end + +#end diff --git a/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation_CUDA.jl b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation_CUDA.jl new file mode 100644 index 0000000000..e3c3a6fc07 --- /dev/null +++ b/examples/simulations/GrayScott.jl/test/unit/simulation/unit-Simulation_CUDA.jl @@ -0,0 +1,28 @@ + +import Test: @testset, @test, @test_throws +# import submodule +import GrayScott: Simulation +# import types +import GrayScott: Settings, MPICartDomain, Fields + +@testset "unit-Simulation.init_fields-cuda" begin + function test_init_cuda(L) + settings = Settings() + settings.L = L + mpi_cart_domain = Simulation.init_domain(settings, MPI.COMM_WORLD) + + fields = Simulation.init_fields(settings, mpi_cart_domain, Float32) + + settings.backend = "CUDA" + fields_cuda = Simulation.init_fields(settings, mpi_cart_domain, Float32) + + @test fields.u ≈ Array(fields_cuda.u) + @test fields.v ≈ Array(fields_cuda.v) + end + + test_init_cuda(8) + test_init_cuda(16) + test_init_cuda(32) + test_init_cuda(64) + test_init_cuda(128) +end \ No newline at end of file diff --git a/examples/simulations/gray-scott-kokkos/CMakeLists.txt b/examples/simulations/gray-scott-kokkos/CMakeLists.txt new file mode 100644 index 0000000000..b43362cf3f --- /dev/null +++ b/examples/simulations/gray-scott-kokkos/CMakeLists.txt @@ -0,0 +1,47 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +cmake_minimum_required(VERSION 3.12) +project(ADIOS2SimulationsGrayScottKokkosExample) + +# CXX Compiler settings only in for this example +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(NOT TARGET adios2_core) + set(_components CXX) + + find_package(MPI COMPONENTS C) + if(MPI_FOUND) + # Workaround for various MPI implementations forcing the link of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) + + list(APPEND _components MPI) + endif() + + find_package(Kokkos 3.7 QUIET) + if(Kokkos_FOUND AND DEFINED Kokkos_CXX_COMPILER) + set(CMAKE_CXX_COMPILER "${Kokkos_CXX_COMPILER}") + endif() + + find_package(ADIOS2 REQUIRED COMPONENTS ${_components}) +else() + if(DEFINED Kokkos_CXX_COMPILER) + set(CMAKE_CXX_COMPILER "${Kokkos_CXX_COMPILER}") + endif() +endif() + +if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_Kokkos) + add_executable(adios2_simulations_gray-scott-kokkos + main.cpp + gray-scott.cpp + settings.cpp + writer.cpp + restart.cpp + ) + kokkos_compilation(SOURCE gray-scott.cpp) + target_link_libraries(adios2_simulations_gray-scott-kokkos adios2::cxx11_mpi MPI::MPI_C Kokkos::kokkos) + install(TARGETS adios2_simulations_gray-scott-kokkos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/examples/simulations/gray-scott-kokkos/README.md b/examples/simulations/gray-scott-kokkos/README.md new file mode 100644 index 0000000000..24f6213b5e --- /dev/null +++ b/examples/simulations/gray-scott-kokkos/README.md @@ -0,0 +1,2 @@ +Kokkos version of Gray-Scott. +Please use the installed Gray-Scott example directory but run adios2-gray-scott-kokkos binary. diff --git a/examples/simulations/gray-scott-kokkos/gray-scott.cpp b/examples/simulations/gray-scott-kokkos/gray-scott.cpp new file mode 100644 index 0000000000..b6f6cd4b7c --- /dev/null +++ b/examples/simulations/gray-scott-kokkos/gray-scott.cpp @@ -0,0 +1,330 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * The solver is based on Hiroshi Watanabe's 2D Gray-Scott reaction diffusion + * code available at: https://github.com/kaityo256/sevendayshpc/tree/master/day5 + */ + +#include "gray-scott.h" + +#include +#include // runtime_error +#include + +GrayScott::GrayScott(const Settings &settings, MPI_Comm comm) +: settings(settings), comm(comm), rand_pool(5374857) +{ +} + +GrayScott::~GrayScott() {} + +void GrayScott::init() +{ + init_mpi(); + init_field(); +} + +void GrayScott::iterate() +{ + auto temp_u = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, u); + auto temp_v = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, v); + exchange(temp_u, temp_v); + Kokkos::deep_copy(u, temp_u); + Kokkos::deep_copy(v, temp_v); + + calc(); + + std::swap(u, u2); + std::swap(v, v2); +} + +void GrayScott::restart(Kokkos::View &u_in, + Kokkos::View &v_in) +{ + auto const expected_len = (size_x + 2) * (size_y + 2) * (size_z + 2); + if (u_in.size() == expected_len) + { + u = u_in; + v = v_in; + } + else + { + throw std::runtime_error("Restart with incompatible array size, expected " + + std::to_string(expected_len) + " got " + + std::to_string(u_in.size()) + " elements"); + } +} + +const Kokkos::View GrayScott::u_ghost() const { return u; } + +const Kokkos::View GrayScott::v_ghost() const { return v; } + +Kokkos::View GrayScott::u_noghost() const +{ + return data_noghost(u); +} + +Kokkos::View GrayScott::v_noghost() const +{ + return data_noghost(v); +} + +void GrayScott::u_noghost(Kokkos::View u_no_ghost) const +{ + data_noghost(u, u_no_ghost); +} + +void GrayScott::v_noghost(Kokkos::View v_no_ghost) const +{ + data_noghost(v, v_no_ghost); +} + +Kokkos::View +GrayScott::data_noghost(const Kokkos::View &data) const +{ + Kokkos::View buf("noghost_temp", size_x, size_y, size_z); + data_no_ghost_common(data, buf); + return buf; +} + +void GrayScott::data_noghost(const Kokkos::View &data, + Kokkos::View data_no_ghost) const +{ + data_no_ghost_common(data, data_no_ghost); +} + +void GrayScott::init_field() +{ + Kokkos::resize(u, size_x + 2, size_y + 2, size_z + 2); + Kokkos::deep_copy(u, 1.0); + Kokkos::resize(v, size_x + 2, size_y + 2, size_z + 2); + Kokkos::deep_copy(v, 0.0); + Kokkos::resize(u2, size_x + 2, size_y + 2, size_z + 2); + Kokkos::deep_copy(u2, 0.0); + Kokkos::resize(v2, size_x + 2, size_y + 2, size_z + 2); + Kokkos::deep_copy(v2, 0.0); + + const int d = 6; + auto const L = settings.L; + auto const settingsL = static_cast(settings.L); + auto const temp_u = u; + auto const temp_v = v; + size_t const ox = offset_x, oy = offset_y, oz = offset_z; + size_t const sx = size_x, sy = size_y; + auto const min_z = std::max(L / 2 - d, offset_z); + auto const max_z = std::min(L / 2 + d, offset_z + size_z); + Kokkos::parallel_for( + "init_buffers", Kokkos::RangePolicy<>(min_z, max_z), KOKKOS_LAMBDA(int z) { + for (int y = settingsL / 2 - d; y < settingsL / 2 + d; y++) + { + if (y < static_cast(oy)) + continue; + if (y >= static_cast(oy + sy)) + continue; + for (int x = settingsL / 2 - d; x < settingsL / 2 + d; x++) + { + if (x < static_cast(ox)) + continue; + if (x >= static_cast(ox + sx)) + continue; + temp_u(x - ox + 1, y - oy + 1, z - oz + 1) = 0.25; + temp_v(x - ox + 1, y - oy + 1, z - oz + 1) = 0.33; + } + } + }); +} + +void GrayScott::calc() +{ + auto const temp_u = u; + auto const temp_v = v; + auto const temp_u2 = u2; + auto const temp_v2 = v2; + auto const Du = settings.Du; + auto const Dv = settings.Dv; + auto const dt = settings.dt; + auto const F = settings.F; + auto const k = settings.k; + auto const noise = settings.noise; + size_t const sx = size_x, sy = size_y, sz = size_z; + auto const random_pool = rand_pool; + Kokkos::parallel_for( + "calc_gray_scott", Kokkos::RangePolicy<>(1, sz + 1), KOKKOS_LAMBDA(int z) { + RandomPool::generator_type generator = random_pool.get_state(); + double ts; + for (int y = 1; y < static_cast(sy) + 1; y++) + { + for (int x = 1; x < static_cast(sx) + 1; x++) + { + double du, dv; + // laplacian for u + ts = 0; + ts += temp_u(x - 1, y, z); + ts += temp_u(x + 1, y, z); + ts += temp_u(x, y - 1, z); + ts += temp_u(x, y + 1, z); + ts += temp_u(x, y, z - 1); + ts += temp_u(x, y, z + 1); + ts += -6.0 * temp_u(x, y, z); + ts /= 6.0; + du = Du * ts; + + // laplacian for v + ts = 0; + ts += temp_v(x - 1, y, z); + ts += temp_v(x + 1, y, z); + ts += temp_v(x, y - 1, z); + ts += temp_v(x, y + 1, z); + ts += temp_v(x, y, z - 1); + ts += temp_v(x, y, z + 1); + ts += -6.0 * temp_v(x, y, z); + ts /= 6.0; + dv = Dv * ts; + + du += (-temp_u(x, y, z) * temp_v(x, y, z) * temp_v(x, y, z) + + F * (1.0 - temp_u(x, y, z))); + dv += (temp_u(x, y, z) * temp_v(x, y, z) * temp_v(x, y, z) - + (F + k) * temp_v(x, y, z)); + du += noise * generator.frand(-1.f, 1.f); + temp_u2(x, y, z) = temp_u(x, y, z) + du * dt; + temp_v2(x, y, z) = temp_v(x, y, z) + dv * dt; + } + } + random_pool.free_state(generator); + }); +} + +void GrayScott::init_mpi() +{ + int dims[3] = {}; + const int periods[3] = {1, 1, 1}; + int coords[3] = {}; + + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &procs); + + MPI_Dims_create(procs, 3, dims); + npx = dims[0]; + npy = dims[1]; + npz = dims[2]; + + MPI_Cart_create(comm, 3, dims, periods, 0, &cart_comm); + MPI_Cart_coords(cart_comm, rank, 3, coords); + px = coords[0]; + py = coords[1]; + pz = coords[2]; + + size_x = settings.L / npx; + size_y = settings.L / npy; + size_z = settings.L / npz; + + if (px < settings.L % npx) + { + size_x++; + } + if (py < settings.L % npy) + { + size_y++; + } + if (pz < settings.L % npz) + { + size_z++; + } + + offset_x = (settings.L / npx * px) + std::min(settings.L % npx, px); + offset_y = (settings.L / npy * py) + std::min(settings.L % npy, py); + offset_z = (settings.L / npz * pz) + std::min(settings.L % npz, pz); + + MPI_Cart_shift(cart_comm, 0, 1, &west, &east); + MPI_Cart_shift(cart_comm, 1, 1, &down, &up); + MPI_Cart_shift(cart_comm, 2, 1, &south, &north); + + // XY faces: size_x * (size_y + 2) + MPI_Type_vector(static_cast(size_y + 2), static_cast(size_x), + static_cast(size_x + 2), MPI_DOUBLE, &xy_face_type); + MPI_Type_commit(&xy_face_type); + + // XZ faces: size_x * size_z + MPI_Type_vector(static_cast(size_z), static_cast(size_x), + static_cast((size_x + 2) * (size_y + 2)), MPI_DOUBLE, &xz_face_type); + MPI_Type_commit(&xz_face_type); + + // YZ faces: (size_y + 2) * (size_z + 2) + MPI_Type_vector(static_cast((size_y + 2) * (size_z + 2)), 1, static_cast(size_x + 2), + MPI_DOUBLE, &yz_face_type); + MPI_Type_commit(&yz_face_type); +} + +void GrayScott::exchange_xy( + Kokkos::View local_data) const +{ + MPI_Status st; + + // Send XY face z=size_z to north and receive z=0 from south + MPI_Sendrecv(&local_data.data()[l2i(1, 0, static_cast(size_z))], 1, xy_face_type, north, 1, + &local_data.data()[l2i(1, 0, 0)], 1, xy_face_type, south, 1, cart_comm, &st); + // Send XY face z=1 to south and receive z=size_z+1 from north + MPI_Sendrecv(&local_data.data()[l2i(1, 0, 1)], 1, xy_face_type, south, 1, + &local_data.data()[l2i(1, 0, static_cast(size_z + 1))], 1, xy_face_type, + north, 1, cart_comm, &st); +} + +void GrayScott::exchange_xz( + Kokkos::View local_data) const +{ + MPI_Status st; + + // Send XZ face y=size_y to up and receive y=0 from down + MPI_Sendrecv(&local_data.data()[l2i(1, static_cast(size_y), 1)], 1, xz_face_type, up, 2, + &local_data.data()[l2i(1, 0, 1)], 1, xz_face_type, down, 2, cart_comm, &st); + // Send XZ face y=1 to down and receive y=size_y+1 from up + MPI_Sendrecv(&local_data.data()[l2i(1, 1, 1)], 1, xz_face_type, down, 2, + &local_data.data()[l2i(1, static_cast(size_y + 1), 1)], 1, xz_face_type, up, + 2, cart_comm, &st); +} + +void GrayScott::exchange_yz( + Kokkos::View local_data) const +{ + MPI_Status st; + + // Send YZ face x=size_x to east and receive x=0 from west + MPI_Sendrecv(&local_data.data()[l2i(static_cast(size_x), 0, 0)], 1, yz_face_type, east, 3, + &local_data.data()[l2i(0, 0, 0)], 1, yz_face_type, west, 3, cart_comm, &st); + // Send YZ face x=1 to west and receive x=size_x+1 from east + MPI_Sendrecv(&local_data.data()[l2i(1, 0, 0)], 1, yz_face_type, west, 3, + &local_data.data()[l2i(static_cast(size_x + 1), 0, 0)], 1, yz_face_type, east, + 3, cart_comm, &st); +} + +void GrayScott::exchange(Kokkos::View u, + Kokkos::View v) const +{ + exchange_xy(u); + exchange_xz(u); + exchange_yz(u); + + exchange_xy(v); + exchange_xz(v); + exchange_yz(v); +} + +void GrayScott::data_no_ghost_common( + const Kokkos::View &data, + Kokkos::View data_no_ghost) const +{ + auto const sx = size_x; + auto const sy = size_y; + auto const sz = size_z; + Kokkos::parallel_for( + "updateBuffer", Kokkos::RangePolicy<>(1, sz + 1), KOKKOS_LAMBDA(int z) { + for (int y = 1; y < static_cast(sy) + 1; y++) + { + for (int x = 1; x < static_cast(sx) + 1; x++) + { + data_no_ghost(x - 1, y - 1, z - 1) = data(x, y, z); + } + } + }); +} diff --git a/examples/simulations/gray-scott-kokkos/gray-scott.h b/examples/simulations/gray-scott-kokkos/gray-scott.h new file mode 100644 index 0000000000..26553c8c07 --- /dev/null +++ b/examples/simulations/gray-scott-kokkos/gray-scott.h @@ -0,0 +1,102 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + +#ifndef __GRAY_SCOTT_H__ +#define __GRAY_SCOTT_H__ + +#include + +#include +#include +#include + +#include "settings.h" + +class GrayScott +{ +public: + // Dimension of process grid + size_t npx, npy, npz; + // Coordinate of this rank in process grid + size_t px, py, pz; + // Dimension of local array + size_t size_x, size_y, size_z; + // Offset of local array in the global array + size_t offset_x, offset_y, offset_z; + + GrayScott(const Settings &settings, MPI_Comm comm); + ~GrayScott(); + + void init(); + void iterate(); + void restart(Kokkos::View &u, + Kokkos::View &v); + + const Kokkos::View u_ghost() const; + const Kokkos::View v_ghost() const; + + Kokkos::View u_noghost() const; + Kokkos::View v_noghost() const; + + void u_noghost(Kokkos::View u_no_ghost) const; + void v_noghost(Kokkos::View v_no_ghost) const; + + Settings settings; + + Kokkos::View u, v, u2, v2; + + int rank, procs; + int west, east, up, down, north, south; + MPI_Comm comm; + MPI_Comm cart_comm; + + // MPI datatypes for halo exchange + MPI_Datatype xy_face_type; + MPI_Datatype xz_face_type; + MPI_Datatype yz_face_type; + + using RandomPool = Kokkos::Random_XorShift64_Pool; + RandomPool rand_pool; + + // Setup cartesian communicator data types + void init_mpi(); + // Setup initial conditions + void init_field(); + + // Process simulation for one timestep + void calc(); + + // Exchange faces with neighbors + void exchange(Kokkos::View u, + Kokkos::View v) const; + // Exchange XY faces with north/south + void + exchange_xy(Kokkos::View local_data) const; + // Exchange XZ faces with up/down + void + exchange_xz(Kokkos::View local_data) const; + // Exchange YZ faces with west/east + void + exchange_yz(Kokkos::View local_data) const; + + // Return a copy of data with ghosts removed + Kokkos::View + data_noghost(const Kokkos::View &data) const; + + // pointer version + void data_noghost(const Kokkos::View &data, + Kokkos::View no_ghost) const; + + // Convert local coordinate to local index + KOKKOS_FUNCTION int l2i(int x, int y, int z) const + { + return static_cast(x + y * (size_x + 2) + z * (size_x + 2) * (size_y + 2)); + } + + void data_no_ghost_common(const Kokkos::View &data, + Kokkos::View data_no_ghost) const; +}; + +#endif diff --git a/examples/simulations/gray-scott-kokkos/json.hpp b/examples/simulations/gray-scott-kokkos/json.hpp new file mode 100644 index 0000000000..1e7cf51e0a --- /dev/null +++ b/examples/simulations/gray-scott-kokkos/json.hpp @@ -0,0 +1,20274 @@ +/* + __ _____ _____ _____ + __| | __| | | | JSON for Modern C++ +| | |__ | | | | | | version 3.4.0 +|_____|_____|_____|_|___| https://github.com/nlohmann/json + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2013-2018 Niels Lohmann . + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef NLOHMANN_JSON_HPP +#define NLOHMANN_JSON_HPP + +#define NLOHMANN_JSON_VERSION_MAJOR 3 +#define NLOHMANN_JSON_VERSION_MINOR 4 +#define NLOHMANN_JSON_VERSION_PATCH 0 + +#include // all_of, find, for_each +#include // assert +#include // and, not, or +#include // nullptr_t, ptrdiff_t, size_t +#include // hash, less +#include // initializer_list +#include // istream, ostream +#include // iterator_traits, random_access_iterator_tag +#include // accumulate +#include // string, stoi, to_string +#include // declval, forward, move, pair, swap + +// #include +#ifndef NLOHMANN_JSON_FWD_HPP +#define NLOHMANN_JSON_FWD_HPP + +#include // int64_t, uint64_t +#include // map +#include // allocator +#include // string +#include // vector + +/*! +@brief namespace for Niels Lohmann +@see https://github.com/nlohmann +@since version 1.0.0 +*/ +namespace nlohmann +{ +/*! +@brief default JSONSerializer template argument + +This serializer ignores the template arguments and uses ADL +([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) +for serialization. +*/ +template +struct adl_serializer; + +template class ObjectType = + std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer> +class basic_json; + +/*! +@brief JSON Pointer + +A JSON pointer defines a string syntax for identifying a specific value +within a JSON document. It can be used with functions `at` and +`operator[]`. Furthermore, JSON pointers are the base for JSON patches. + +@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) + +@since version 2.0.0 +*/ +template +class json_pointer; + +/*! +@brief default JSON class + +This type is the default specialization of the @ref basic_json class which +uses the standard template types. + +@since version 1.0.0 +*/ +using json = basic_json<>; +} // namespace nlohmann + +#endif + +// #include + + +// This file contains all internal macro definitions +// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them + +// exclude unsupported compilers +#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) + #if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #endif +#endif + +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + +// disable documentation warnings on clang +#if defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdocumentation" +#endif + +// allow for portable deprecation warnings +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #define JSON_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) + #define JSON_DEPRECATED __declspec(deprecated) +#else + #define JSON_DEPRECATED +#endif + +// allow to disable exceptions +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) + #define JSON_INTERNAL_CATCH(exception) catch(exception) +#else + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) + #define JSON_INTERNAL_CATCH(exception) if(false) +#endif + +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_CATCH_USER +#endif +#if defined(JSON_INTERNAL_CATCH_USER) + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER +#endif + +// manual branch prediction +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #define JSON_LIKELY(x) __builtin_expect(!!(x), 1) + #define JSON_UNLIKELY(x) __builtin_expect(!!(x), 0) +#else + #define JSON_LIKELY(x) x + #define JSON_UNLIKELY(x) x +#endif + +// C++ language standard detection +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + +/*! +@brief macro to briefly define a mapping between an enum and JSON +@def NLOHMANN_JSON_SERIALIZE_ENUM +@since version 3.4.0 +*/ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [e](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [j](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ + } + +// Ugly macros to avoid uglier copy-paste when specializing basic_json. They +// may be removed in the future once the class is split. + +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template class ArrayType, \ + class StringType, class BooleanType, class NumberIntegerType, \ + class NumberUnsignedType, class NumberFloatType, \ + template class AllocatorType, \ + template class JSONSerializer> + +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json + +// #include + + +#include // not +#include // size_t +#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type + +namespace nlohmann +{ +namespace detail +{ +// alias templates to reduce boilerplate +template +using enable_if_t = typename std::enable_if::type; + +template +using uncvref_t = typename std::remove_cv::type>::type; + +// implementation of C++14 index_sequence and affiliates +// source: https://stackoverflow.com/a/32223343 +template +struct index_sequence +{ + using type = index_sequence; + using value_type = std::size_t; + static constexpr std::size_t size() noexcept + { + return sizeof...(Ints); + } +}; + +template +struct merge_and_renumber; + +template +struct merge_and_renumber, index_sequence> + : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; + +template +struct make_index_sequence + : merge_and_renumber < typename make_index_sequence < N / 2 >::type, + typename make_index_sequence < N - N / 2 >::type > {}; + +template<> struct make_index_sequence<0> : index_sequence<> {}; +template<> struct make_index_sequence<1> : index_sequence<0> {}; + +template +using index_sequence_for = make_index_sequence; + +// dispatch utility (taken from ranges-v3) +template struct priority_tag : priority_tag < N - 1 > {}; +template<> struct priority_tag<0> {}; + +// taken from ranges-v3 +template +struct static_const +{ + static constexpr T value{}; +}; + +template +constexpr T static_const::value; +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // not +#include // numeric_limits +#include // false_type, is_constructible, is_integral, is_same, true_type +#include // declval + +// #include + +// #include + +// #include + + +#include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template struct make_void +{ + using type = void; +}; +template using void_t = typename make_void::type; +} // namespace detail +} // namespace nlohmann + + +// http://en.cppreference.com/w/cpp/experimental/is_detected +namespace nlohmann +{ +namespace detail +{ +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + void operator=(nonesuch const&) = delete; +}; + +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template