Newer
Older
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* ADIOSTypes.h : public header that contains "using/typedef" alias, defaults
* and parameters options as enum classes
*
* Created on: Mar 23, 2017
* Author: Chuck Atkins chuck.atkins@kitware.com
* Norbert Podhorszki pnorbert@ornl.gov
* William F Godoy godoywf@ornl.gov
#ifndef ADIOS2_ADIOSTYPES_H_
#define ADIOS2_ADIOSTYPES_H_
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility> //std::pair
/** Variable shape type identifier, assigned automatically from the signature of
* DefineVariable */
enum class ShapeID
{
GlobalValue, ///< single global value, common case
GlobalArray, ///< global (across MPI_Comm) array, common case
JoinedArray, ///< global array with a common (joinable) dimension
LocalValue, ///< special case, local independent value
LocalArray ///< special case, local independent array
};
/** Used to set IO class */
enum class IOMode
{
Independent, ///< all I/O operations are independent per rank
Collective ///< expect collective I/O operations
};
enum Launch
{
Sync = 0,
Deferred = 1,
enum class ReadMultiplexPattern
{
GlobalReaders,
RoundRobin,
FirstInFirstOut,
OpenAllSteps
};
enum class StreamOpenMode
{
Wait,
NoWait
};
};
enum class TransportType
{
File,
WAN
};
/** Currently available engines, just for info purposes */
enum class IOEngine
{
Unknown,
BPFileWriter, ///< produces bp files
BPFileReader, ///< read bp files (not yet implemented)
HDF5Writer, ///<
HDF5Reader, ///<
ADIOS1Writer,
ADIOS1Reader,
DataManWriter,
DataManReader
};
enum class ReadMode
{
NonBlocking,
Blocking
};
enum class AdvanceMode
{
Append,
Update, // writer advance mode
NextAvailable,
LatestAvailable // reader advance mode
};
OK,
StepNotReady,
EndOfStream,
OtherError
};
/** Type of selection */
enum class SelectionType
{
BoundingBox, ///< Contiguous block of data defined by offsets and counts
/// per dimension
Points, ///< List of individual points
WriteBlock, ///< Selection of an individual block written by a writer
/// process
Auto ///< Let the engine decide what to return
};
// Types
using std::size_t;
using std::int8_t;
using std::int16_t;
using std::int32_t;
using std::int64_t;
using std::uint8_t;
using std::uint16_t;
using std::uint32_t;
using std::uint64_t;
// Complex
using cfloat = std::complex<float>;
using cdouble = std::complex<double>;
using cldouble = std::complex<long double>;
// Limit
constexpr size_t MaxSizeT = std::numeric_limits<size_t>::max();
const std::string DefaultFileLibrary("fstream");
const std::string DefaultFileLibrary("POSIX");
const std::string DefaultTimeUnit("Microseconds");
constexpr TimeUnit DefaultTimeUnitEnum(TimeUnit::Microseconds);
/** default initial bp buffer size, 16Kb, in bytes */
constexpr size_t DefaultInitialBufferSize = 16 * 1024;
/** default maximum bp buffer size, unlimited, in bytes.
* Needs to be studied for optimizing applications */
constexpr size_t DefaultMaxBufferSize = MaxSizeT - 1;
/** default buffer growth factor. Needs to be studied
constexpr float DefaultBufferGrowthFactor = 1.05f;
/** default size for writing/reading files using POSIX/fstream/stdio write
constexpr size_t DefaultMaxFileBatchSize = 2147381248;
constexpr char PathSeparator =
#ifdef _WIN32
'\\';
#else
'/';
#endif
// adios alias values and types
constexpr bool DebugON = true;
constexpr bool DebugOFF = false;
constexpr size_t UnknownDim = 0;
constexpr size_t JoinedDim = MaxSizeT - 1;
constexpr size_t LocalValueDim = MaxSizeT - 2;
constexpr size_t IrregularDim = MaxSizeT - 3;
using Dims = std::vector<size_t>;
using Params = std::map<std::string, std::string>;
using Steps = size_t;
template <class T>
using Box = std::pair<T, T>;
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// Get a fixed width integer type from a size specification
template <size_t Bytes, bool Signed>
struct FixedWidthInt;
template <>
struct FixedWidthInt<1, true>
{
using Type = std::int8_t;
};
template <>
struct FixedWidthInt<2, true>
{
using Type = std::int16_t;
};
template <>
struct FixedWidthInt<4, true>
{
using Type = std::int32_t;
};
template <>
struct FixedWidthInt<8, true>
{
using Type = std::int64_t;
};
template <>
struct FixedWidthInt<1, false>
{
using Type = std::uint8_t;
};
template <>
struct FixedWidthInt<2, false>
{
using Type = std::uint16_t;
};
template <>
struct FixedWidthInt<4, false>
{
using Type = std::uint32_t;
};
template <>
struct FixedWidthInt<8, false>
{
using Type = std::uint64_t;
};
// Some core type information that may be useful at compile time
template <typename T, typename Enable = void>
struct TypeInfo
{
using IOType = T;
using ValueType = T;
};
template <typename T>
struct TypeInfo<T, typename std::enable_if<std::is_integral<T>::value>::type>
{
using IOType =
typename FixedWidthInt<sizeof(T), std::is_signed<T>::value>::Type;
};
template <typename T>
struct TypeInfo<T,
typename std::enable_if<std::is_floating_point<T>::value>::type>
{
using IOType = T;
};
template <typename T>
struct TypeInfo<T, typename std::enable_if<std::is_same<
T, std::complex<typename T::value_type>>::value>::type>
{
using IOType = T;
using ValueType = typename T::value_type;
};
} // end namespace adios2
#endif /* ADIOS2_ADIOSTYPES_H_ */