Skip to content

Commit

Permalink
Attributes: Allow Complex Types
Browse files Browse the repository at this point in the history
This is a quick hack, but it demonstrates that complex
attribute types are no problem, just as in ADIOS1.
  • Loading branch information
ax3l committed Dec 19, 2019
1 parent cc5f742 commit b62b286
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
10 changes: 5 additions & 5 deletions source/adios2/common/ADIOSMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

#define ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_1ARG(MACRO) \
MACRO(std::string) \
ADIOS2_FOREACH_ATTRIBUTE_PRIMITIVE_STDTYPE_1ARG(MACRO)
ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(MACRO)

#define ADIOS2_FOREACH_STDTYPE_1ARG(MACRO) \
MACRO(std::string) \
Expand Down Expand Up @@ -214,7 +214,9 @@
MACRO(uint64_t, uint64) \
MACRO(float, float) \
MACRO(double, double) \
MACRO(long double, ldouble)
MACRO(long double, ldouble) \
MACRO(std::complex<float>, cfloat) \
MACRO(std::complex<double>, cdouble)

#define ADIOS2_FOREACH_PRIMITVE_STDTYPE_2ARGS(MACRO) \
MACRO(int8_t, int8) \
Expand All @@ -232,9 +234,7 @@
MACRO(std::complex<double>, cdouble)

#define ADIOS2_FOREACH_STDTYPE_2ARGS(MACRO) \
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_2ARGS(MACRO) \
MACRO(std::complex<float>, cfloat) \
MACRO(std::complex<double>, cdouble)
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_2ARGS(MACRO)

#define ADIOS2_FOREACH_COMPLEX_TYPE_2ARGS(MACRO) \
MACRO(std::complex<float>, CFloat) \
Expand Down
18 changes: 18 additions & 0 deletions source/adios2/engine/ssc/SscReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
#include "adios2/helper/adiosFunctions.h"
#include "nlohmann/json.hpp"

#include <complex>


// JSON std::complex handling
namespace std
{
template< class T >
void to_json(nlohmann::json &j, const std::complex< T > &p) {
j = nlohmann::json {p.real(), p.imag()};
}

template< class T >
void from_json(const nlohmann::json &j, std::complex< T > &p) {
p.real(j.at(0));
p.imag(j.at(1));
}
} // end namespace std

namespace adios2
{
namespace core
Expand Down
18 changes: 18 additions & 0 deletions source/adios2/engine/ssc/SscWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@
#include "adios2/helper/adiosComm.h"
#include "nlohmann/json.hpp"

#include <complex>


// JSON std::complex handling
namespace std
{
template< class T >
void to_json(nlohmann::json &j, const std::complex< T > &p) {
j = nlohmann::json {p.real(), p.imag()};
}

template< class T >
void from_json(const nlohmann::json &j, std::complex< T > &p) {
p.real(j.at(0));
p.imag(j.at(1));
}
} // end namespace std

namespace adios2
{
namespace core
Expand Down
17 changes: 17 additions & 0 deletions source/adios2/toolkit/format/dataman/DataManSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,28 @@
#include "adios2/helper/adiosComm.h"
#include "adios2/toolkit/profiling/taustubs/tautimer.hpp"

#include <complex>
#include <mutex>
#include <unordered_map>

#include <nlohmann/json.hpp>


// JSON std::complex handling
namespace std
{
template< class T >
void to_json(nlohmann::json &j, const std::complex< T > &p) {
j = nlohmann::json {p.real(), p.imag()};
}

template< class T >
void from_json(const nlohmann::json &j, std::complex< T > &p) {
p.real(j.at(0));
p.imag(j.at(1));
}
} // end namespace std

// A - Address
// C - Count
// D - Data Object ID or File Name
Expand Down

0 comments on commit b62b286

Please sign in to comment.