Skip to content

Commit d84898f

Browse files
committed
Move ADIOS2 version macros to their own header
1 parent 7da2e8e commit d84898f

File tree

4 files changed

+55
-43
lines changed

4 files changed

+55
-43
lines changed

include/openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#pragma once
2323

2424
#include "openPMD/Error.hpp"
25+
#include "openPMD/IO/ADIOS/macros.hpp"
2526
#include "openPMD/config.hpp"
2627

2728
#if openPMD_HAVE_ADIOS2
@@ -35,18 +36,6 @@
3536
#include <stdexcept>
3637
#include <utility>
3738
#include <vector>
38-
39-
/*
40-
* ADIOS2 v2.8 brings mode::ReadRandomAccess
41-
*/
42-
#define HAS_ADIOS_2_8 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 208)
43-
/*
44-
* ADIOS2 v2.9 brings modifiable attributes (technically already in v2.8, but
45-
* there are too many bugs, so we only support it beginning with v2.9).
46-
* Group table feature requires ADIOS2 v2.9.
47-
*/
48-
#define HAS_ADIOS_2_9 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209)
49-
5039
#endif
5140

5241
namespace openPMD
@@ -150,7 +139,7 @@ namespace detail
150139
case adios2::Mode::Write:
151140
return false;
152141
case adios2::Mode::Read:
153-
#if HAS_ADIOS_2_8
142+
#if openPMD_HAS_ADIOS_2_8
154143
case adios2::Mode::ReadRandomAccess:
155144
#endif
156145
return true;
@@ -169,7 +158,7 @@ namespace detail
169158
case adios2::Mode::Write:
170159
return true;
171160
case adios2::Mode::Read:
172-
#if HAS_ADIOS_2_8
161+
#if openPMD_HAS_ADIOS_2_8
173162
case adios2::Mode::ReadRandomAccess:
174163
#endif
175164
return false;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include "openPMD/config.hpp"
4+
5+
#if openPMD_HAVE_ADIOS2
6+
7+
#include <adios2.h>
8+
9+
/*
10+
* ADIOS2 v2.8 brings mode::ReadRandomAccess
11+
*/
12+
#define openPMD_HAS_ADIOS_2_8 \
13+
(ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 208)
14+
/*
15+
* ADIOS2 v2.9 brings modifiable attributes (technically already in v2.8, but
16+
* there are too many bugs, so we only support it beginning with v2.9).
17+
* Group table feature requires ADIOS2 v2.9.
18+
*/
19+
#define openPMD_HAS_ADIOS_2_9 \
20+
(ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209)
21+
22+
#else
23+
24+
#define openPMD_HAS_ADIOS_2_8 0
25+
#define openPMD_HAS_ADIOS_2_9 0
26+
27+
#endif

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void ADIOS2IOHandlerImpl::init(json::TracingJSON cfg)
210210
defaultOperators = std::move(operators.value());
211211
}
212212
}
213-
#if !HAS_ADIOS_2_9
213+
#if !openPMD_HAS_ADIOS_2_9
214214
if (m_modifiableAttributes == ModifiableAttributes::Yes)
215215
{
216216
throw error::OperationUnsupportedInBackend(
@@ -879,7 +879,7 @@ void ADIOS2IOHandlerImpl::writeDataset(
879879
void ADIOS2IOHandlerImpl::writeAttribute(
880880
Writable *writable, const Parameter<Operation::WRITE_ATT> &parameters)
881881
{
882-
#if HAS_ADIOS_2_9
882+
#if openPMD_HAS_ADIOS_2_9
883883
switch (useGroupTable())
884884
{
885885
case UseGroupTable::No:
@@ -1354,7 +1354,7 @@ adios2::Mode ADIOS2IOHandlerImpl::adios2AccessMode(std::string const &fullPath)
13541354
{
13551355
case Access::CREATE:
13561356
return adios2::Mode::Write;
1357-
#if HAS_ADIOS_2_8
1357+
#if openPMD_HAS_ADIOS_2_8
13581358
case Access::READ_LINEAR:
13591359
return adios2::Mode::Read;
13601360
case Access::READ_ONLY:
@@ -1368,7 +1368,7 @@ adios2::Mode ADIOS2IOHandlerImpl::adios2AccessMode(std::string const &fullPath)
13681368
if (auxiliary::directory_exists(fullPath) ||
13691369
auxiliary::file_exists(fullPath))
13701370
{
1371-
#if HAS_ADIOS_2_8
1371+
#if openPMD_HAS_ADIOS_2_8
13721372
return adios2::Mode::ReadRandomAccess;
13731373
#else
13741374
return adios2::Mode::Read;
@@ -1707,7 +1707,7 @@ namespace detail
17071707
adios2::IO IO = filedata.m_IO;
17081708
impl->m_dirty.emplace(std::move(file));
17091709

1710-
#if HAS_ADIOS_2_9
1710+
#if openPMD_HAS_ADIOS_2_9
17111711
if (impl->m_modifiableAttributes ==
17121712
ADIOS2IOHandlerImpl::ModifiableAttributes::No &&
17131713
parameters.changesOverSteps ==
@@ -1773,7 +1773,7 @@ namespace detail
17731773
}
17741774

17751775
auto &value = std::get<T>(parameters.resource);
1776-
#if HAS_ADIOS_2_9
1776+
#if openPMD_HAS_ADIOS_2_9
17771777
bool modifiable = impl->m_modifiableAttributes ==
17781778
ADIOS2IOHandlerImpl::ModifiableAttributes::Yes ||
17791779
parameters.changesOverSteps !=
@@ -1787,7 +1787,7 @@ namespace detail
17871787

17881788
auto defineAttribute =
17891789
[&IO, &fullName, &modifiable, &impl](auto const &...args) {
1790-
#if HAS_ADIOS_2_9
1790+
#if openPMD_HAS_ADIOS_2_9
17911791
auto attr = IO.DefineAttribute(
17921792
fullName,
17931793
args...,
@@ -2333,7 +2333,7 @@ namespace detail
23332333
* BP3 or HDF5, or by BP5 without group table and normal read
23342334
* mode. Need to fall back to random access parsing.
23352335
*/
2336-
#if HAS_ADIOS_2_8
2336+
#if openPMD_HAS_ADIOS_2_8
23372337
m_mode = adios2::Mode::ReadRandomAccess;
23382338
#endif
23392339
break;
@@ -2411,7 +2411,7 @@ namespace detail
24112411
if (writeOnly(m_mode))
24122412
{
24132413

2414-
#if HAS_ADIOS_2_9
2414+
#if openPMD_HAS_ADIOS_2_9
24152415
if (!m_impl->m_useGroupTable.has_value())
24162416
{
24172417
switch (m_impl->m_iterationEncoding)
@@ -2726,7 +2726,7 @@ namespace detail
27262726
adios2::Engine(m_IO.Open(m_file, tempMode)));
27272727
break;
27282728
}
2729-
#if HAS_ADIOS_2_8
2729+
#if openPMD_HAS_ADIOS_2_8
27302730
case adios2::Mode::ReadRandomAccess:
27312731
#endif
27322732
case adios2::Mode::Read: {
@@ -3293,7 +3293,7 @@ namespace detail
32933293
case UseGroupTable::No:
32943294
break;
32953295
case UseGroupTable::Yes:
3296-
#if HAS_ADIOS_2_9
3296+
#if openPMD_HAS_ADIOS_2_9
32973297
{
32983298
if (writeOnly(m_mode))
32993299
{

test/SerialIOTest.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
#define OPENPMD_protected public:
77
#endif
88

9+
#include "openPMD/IO/ADIOS/macros.hpp"
910
#include "openPMD/auxiliary/Environment.hpp"
1011
#include "openPMD/auxiliary/Filesystem.hpp"
1112
#include "openPMD/auxiliary/StringManip.hpp"
1213
#include "openPMD/openPMD.hpp"
1314

14-
#if openPMD_HAVE_ADIOS2
15-
#include <adios2.h>
16-
#define HAS_ADIOS_2_8 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209)
17-
#define HAS_ADIOS_2_9 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209)
18-
#endif
1915
#include <catch2/catch.hpp>
2016

2117
#include <algorithm>
@@ -563,9 +559,9 @@ TEST_CASE("close_iteration_interleaved_test", "[serial]")
563559
// run this test for ADIOS2 & JSON only
564560
if (t == "h5")
565561
continue;
566-
#if HAS_ADIOS_2_9
562+
#if openPMD_HAS_ADIOS_2_9
567563
close_iteration_interleaved_test(t, IterationEncoding::variableBased);
568-
#endif // HAS_ADIOS_2_9
564+
#endif // openPMD_HAS_ADIOS_2_9
569565
}
570566
}
571567

@@ -4903,7 +4899,7 @@ TEST_CASE("bp4_steps", "[serial][adios2]")
49034899
// dontUseSteps,
49044900
// Access::READ_LINEAR);
49054901

4906-
#if HAS_ADIOS_2_9
4902+
#if openPMD_HAS_ADIOS_2_9
49074903
/*
49084904
* Do this whole thing once more, but this time use the new attribute
49094905
* layout.
@@ -5350,7 +5346,7 @@ TEST_CASE("git_adios2_sample_test", "[serial][adios2]")
53505346
}
53515347
}
53525348

5353-
#if HAS_ADIOS_2_9
5349+
#if openPMD_HAS_ADIOS_2_9
53545350
void adios2_group_table(
53555351
std::string const &jsonWrite,
53565352
std::string const &jsonRead,
@@ -5699,7 +5695,7 @@ TEST_CASE("variableBasedParticleData", "[serial][adios2]")
56995695
{
57005696
variableBasedParticleData();
57015697
}
5702-
#endif // HAS_ADIOS_2_9
5698+
#endif // openPMD_HAS_ADIOS_2_9
57035699
#endif // openPMD_HAS_ADIOS2
57045700

57055701
#if openPMD_HAVE_ADIOS2
@@ -6025,7 +6021,7 @@ TEST_CASE("iterate_nonstreaming_series", "[serial][adios2]")
60256021
}
60266022
#endif
60276023
}
6028-
#if openPMD_HAVE_ADIOS2 && HAS_ADIOS_2_9
6024+
#if openPMD_HAVE_ADIOS2 && openPMD_HAS_ADIOS_2_9
60296025
iterate_nonstreaming_series(
60306026
"../samples/iterate_nonstreaming_series_variablebased.bp",
60316027
true,
@@ -6404,7 +6400,7 @@ TEST_CASE("deferred_parsing", "[serial]")
64046400
}
64056401
}
64066402

6407-
#if HAS_ADIOS_2_9
6403+
#if openPMD_HAS_ADIOS_2_9
64086404
void chaotic_stream(std::string filename, bool variableBased)
64096405
{
64106406
/*
@@ -6482,7 +6478,7 @@ TEST_CASE("chaotic_stream", "[serial]")
64826478
chaotic_stream("../samples/chaotic_stream_vbased." + t, true);
64836479
}
64846480
}
6485-
#endif // HAS_ADIOS_2_9
6481+
#endif // openPMD_HAS_ADIOS_2_9
64866482

64876483
#ifdef openPMD_USE_INVASIVE_TESTS
64886484
void unfinished_iteration_test(
@@ -6598,7 +6594,7 @@ TEST_CASE("unfinished_iteration_test", "[serial]")
65986594
#if openPMD_HAVE_ADIOS2
65996595
unfinished_iteration_test(
66006596
"bp", IterationEncoding::groupBased, R"({"backend": "adios2"})");
6601-
#if HAS_ADIOS_2_9
6597+
#if openPMD_HAS_ADIOS_2_9
66026598
unfinished_iteration_test(
66036599
"bp5",
66046600
IterationEncoding::variableBased,
@@ -6611,7 +6607,7 @@ TEST_CASE("unfinished_iteration_test", "[serial]")
66116607
}
66126608
}
66136609
)");
6614-
#endif // HAS_ADIOS_2_9
6610+
#endif // openPMD_HAS_ADIOS_2_9
66156611
unfinished_iteration_test(
66166612
"bp", IterationEncoding::fileBased, R"({"backend": "adios2"})");
66176613
#endif
@@ -7098,7 +7094,7 @@ TEST_CASE("append_mode", "[serial]")
70987094
false,
70997095
ParseMode::LinearWithoutSnapshot,
71007096
jsonConfigOld);
7101-
#if HAS_ADIOS_2_9
7097+
#if openPMD_HAS_ADIOS_2_9
71027098
append_mode(
71037099
"../samples/append/append_groupbased." + t,
71047100
false,
@@ -7127,7 +7123,7 @@ TEST_CASE("append_mode", "[serial]")
71277123
}
71287124
}
71297125

7130-
#if HAS_ADIOS_2_8
7126+
#if openPMD_HAS_ADIOS_2_9
71317127
void append_mode_filebased(std::string const &extension)
71327128
{
71337129
std::string jsonConfig = R"END(
@@ -7207,7 +7203,7 @@ TEST_CASE("append_mode_filebased", "[serial]")
72077203
append_mode_filebased(t);
72087204
}
72097205
}
7210-
#endif // HAS_ADIOS_2_8
7206+
#endif // openPMD_HAS_ADIOS_2_8
72117207

72127208
void groupbased_read_write(std::string const &ext)
72137209
{

0 commit comments

Comments
 (0)