diff --git a/include/utilities/format/bp1/BP1Writer.h b/include/utilities/format/bp1/BP1Writer.h index 80412198e7e6dee0b5283dad92e7a6f65ec45b9b..d98bb9c5cf6d96cd2d943b880b0d2fe7c737d25a 100644 --- a/include/utilities/format/bp1/BP1Writer.h +++ b/include/utilities/format/bp1/BP1Writer.h @@ -17,6 +17,7 @@ #include <cstring> //std::memcpy /// \endcond +#include "ADIOSMacros.h" #include "utilities/format/bp1/BP1Base.h" #include "utilities/format/bp1/BP1Structs.h" @@ -279,6 +280,47 @@ private: capsule::STLVector &buffer) const noexcept; }; +#define declare_template_instantiation(T) \ + extern template void BP1Writer::WriteVariableMetadata( \ + const Variable<T> &variable, capsule::STLVector &heap, \ + BP1MetadataSet &metadataSet) const noexcept; +ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +#undef declare_template_instantiation + +// Explicit declaration of the template methods +//#define declare_template_instantiation(T) \ +//// extern template std::size_t BP1Writer::GetVariableIndexSize( \ +//// const Variable<T> &variable) const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +//#undef declare_template_instantiation +// extern template void BP1Writer::WriteVariableMetadata( \ +// const Variable<T> &variable, capsule::STLVector &heap, \ +// BP1MetadataSet &metadataSet) const noexcept; \ +// \ +// extern template void BP1Writer::WriteVariableMetadata( \ +// const Variable<std::complex<T>> &variable, capsule::STLVector &heap, \ +// BP1MetadataSet &metadataSet) const noexcept; \ +// \ +// extern template void BP1Writer::WriteVariablePayload( \ +// const Variable<T> &variable, capsule::STLVector &heap, \ +// const unsigned int nthreads) const noexcept; \ +// \ +// extern template Stats<T> BP1Writer::GetStats(const Variable<T> &variable) \ +// const noexcept; \ +// \ +// extern template Stats<T> BP1Writer::GetStats( \ +// const Variable<std::complex<T>> &variable) const noexcept; \ +// \ +// extern template void BP1Writer::WriteBoundsRecord( \ +// const bool isScalar, const Stats<T> &stats, std::vector<char> &buffer, \ +// std::uint8_t &characteristicsCounter, const bool addLength) \ +// const noexcept; \ +// \ +// extern template void BP1Writer::WriteCharacteristicRecord( \ +// const std::uint8_t characteristicID, const T &value, \ +// std::vector<char> &buffer, std::uint8_t &characteristicsCounter, \ +// const bool addLength) const noexcept; + } // end namespace format } // end namespace adios diff --git a/include/utilities/format/bp1/BP1Writer.tcc b/include/utilities/format/bp1/BP1Writer.tcc index 40581f792d7a4315848b46c1d4462d860a4cff11..18806b60d992d35aa3ac84f13993982581e6fd82 100644 --- a/include/utilities/format/bp1/BP1Writer.tcc +++ b/include/utilities/format/bp1/BP1Writer.tcc @@ -8,6 +8,8 @@ * Author: wfg */ +#include "BP1Writer.h" + namespace adios { namespace format @@ -51,15 +53,15 @@ std::size_t BP1Writer::GetVariableIndexSize(const Variable<T> &variable) const // need to add transform characteristics } -template <class T> -void BP1Writer::WriteVariableMetadata(const Variable<T> &variable, - capsule::STLVector &heap, - BP1MetadataSet &metadataSet) const - noexcept -{ - Stats<T> stats = GetStats(variable); - WriteVariableMetadataCommon(variable, stats, heap, metadataSet); -} +// template <class T> +// void BP1Writer::WriteVariableMetadata(const Variable<T> &variable, +// capsule::STLVector &heap, +// BP1MetadataSet &metadataSet) const +// noexcept +//{ +// Stats<T> stats = GetStats(variable); +// WriteVariableMetadataCommon(variable, stats, heap, metadataSet); +//} template <class T> void BP1Writer::WriteVariableMetadata(const Variable<std::complex<T>> &variable, @@ -90,7 +92,6 @@ void BP1Writer::WriteVariableMetadataCommon(const Variable<T> &variable, noexcept { stats.TimeIndex = metadataSet.TimeStep; - // Get new Index or point to existing index bool isNew = true; // flag to check if variable is new BP1Index &varIndex = @@ -263,8 +264,8 @@ BP1Writer::Stats<T> BP1Writer::GetStats(const Variable<T> &variable) const if (m_Verbosity == 0) { if (valuesSize >= 10000000) // ten million? this needs actual results - // //here we can make decisions for threads - // based on valuesSize + // //here we can make decisions for + // based on valuesSize GetMinMax(variable.m_AppValues, valuesSize, stats.Min, stats.Max, m_Threads); // here we can add cores from constructor else @@ -283,8 +284,8 @@ BP1Writer::GetStats(const Variable<std::complex<T>> &variable) const noexcept if (m_Verbosity == 0) { if (valuesSize >= 10000000) // ten million? this needs actual results - // //here we can make decisions for threads - // based on valuesSize + // //here we can make decisions for + // based on valuesSize GetMinMax(variable.m_AppValues, valuesSize, stats.Min, stats.Max, m_Threads); else diff --git a/source/utilities/format/bp1/BP1Writer.cpp b/source/utilities/format/bp1/BP1Writer.cpp index 58eb04b8a6a729ddd7464176ccf03c9f7c0dbdeb..10b4382c195a6459815c70ed92bf84735294ed78 100644 --- a/source/utilities/format/bp1/BP1Writer.cpp +++ b/source/utilities/format/bp1/BP1Writer.cpp @@ -417,5 +417,212 @@ void BP1Writer::FlattenMetadata(BP1MetadataSet &metadataSet, metadataSet.Log.TotalBytes.push_back(heap.m_DataAbsolutePosition); } +// TEMPLATES +// template <class T> +// std::size_t BP1Writer::GetVariableIndexSize(const Variable<T> &variable) +// const +// noexcept +//{ +// // size_t indexSize = varEntryLength + memberID + lengthGroupName + +// // groupName + lengthVariableName + lengthOfPath + path + datatype +// std::size_t indexSize = 23; // without characteristics +// indexSize += variable.m_Name.size(); +// +// // characteristics 3 and 4, check variable number of dimensions +// const std::size_t dimensions = +// variable.DimensionsSize(); // commas in CSV + 1 +// indexSize += 28 * dimensions; // 28 bytes per dimension +// indexSize += 1; // id +// +// // characteristics, offset + payload offset in data +// indexSize += 2 * (1 + 8); +// // characteristic 0, if scalar add value, for now only allowing string +// if (dimensions == 1) +// { +// indexSize += sizeof(T); +// indexSize += 1; // id +// // must have an if here +// indexSize += 2 + variable.m_Name.size(); +// indexSize += 1; // id +// } +// +// // characteristic statistics +// if (m_Verbosity == 0) // default, only min and max +// { +// indexSize += 2 * (sizeof(T) + 1); +// indexSize += 1 + 1; // id +// } +// +// return indexSize + 12; // extra 12 bytes in case of attributes +// // need to add transform characteristics +//} +//#define declare_template_instantiation(T) \ +// template std::size_t BP1Writer::GetVariableIndexSize( \ +// const Variable<T> &variable) const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +//#undef declare_template_instantiation + +template <class T> +void BP1Writer::WriteVariableMetadata(const Variable<T> &variable, + capsule::STLVector &heap, + BP1MetadataSet &metadataSet) const + noexcept +{ + Stats<T> stats = GetStats(variable); + WriteVariableMetadataCommon(variable, stats, heap, metadataSet); +} +#define declare_template_instantiation(T) \ + template void BP1Writer::WriteVariableMetadata( \ + const Variable<T> &variable, capsule::STLVector &heap, \ + BP1MetadataSet &metadataSet) const noexcept; +ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +#undef declare_template_instantiation + +// template <class T> +// void BP1Writer::WriteVariableMetadata(const Variable<std::complex<T>> +// &variable, +// capsule::STLVector &heap, +// BP1MetadataSet &metadataSet) const +// noexcept +//{ +// Stats<T> stats = GetStats(variable); +// WriteVariableMetadataCommon(variable, stats, heap, metadataSet); +//} +//#define declare_template_instantiation(T) \ +// template void BP1Writer::WriteVariableMetadata( \ +// const Variable<std::complex<T>> &variable, capsule::STLVector &heap, \ +// BP1MetadataSet &metadataSet) const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +//#undef declare_template_instantiation +// +// template <class T> +// void BP1Writer::WriteVariablePayload(const Variable<T> &variable, +// capsule::STLVector &heap, +// const unsigned int nthreads) const +// noexcept +//{ +// // EXPENSIVE part, might want to use threads if large, serial for now +// InsertToBuffer(heap.m_Data, variable.m_AppValues, variable.TotalSize()); +// heap.m_DataAbsolutePosition += variable.PayLoadSize(); +//} +//#define declare_template_instantiation(T) \ +// template void BP1Writer::WriteVariablePayload( \ +// const Variable<T> &variable, capsule::STLVector &heap, \ +// const unsigned int nthreads) const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +//#undef declare_template_instantiation +// +//// PRIVATE +// template <class T> +// BP1Writer::Stats<T> BP1Writer::GetStats(const Variable<T> &variable) const +// noexcept +//{ +// Stats<T> stats; +// const std::size_t valuesSize = variable.TotalSize(); +// +// if (m_Verbosity == 0) +// { +// if (valuesSize >= 10000000) // ten million? this needs actual results +// // //here we can make decisions for +// threads +// // based on valuesSize +// GetMinMax(variable.m_AppValues, valuesSize, stats.Min, stats.Max, +// m_Threads); // here we can add cores from constructor +// else +// GetMinMax(variable.m_AppValues, valuesSize, stats.Min, stats.Max); +// } +// return stats; +//} +//#define declare_template_instantiation(T) \ +// template BP1Writer::Stats<T> BP1Writer::GetStats( \ +// const Variable<T> &variable) const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +//#undef declare_template_instantiation +// +// template <class T> +// BP1Writer::Stats<T> +// BP1Writer::GetStats(const Variable<std::complex<T>> &variable) const noexcept +//{ +// Stats<T> stats; +// const std::size_t valuesSize = variable.TotalSize(); +// +// if (m_Verbosity == 0) +// { +// if (valuesSize >= 10000000) // ten million? this needs actual results +// // //here we can make decisions for +// threads +// // based on valuesSize +// GetMinMax(variable.m_AppValues, valuesSize, stats.Min, stats.Max, +// m_Threads); +// else +// GetMinMax(variable.m_AppValues, valuesSize, stats.Min, stats.Max); +// } +// return stats; +//} +//#define declare_template_instantiation(T) \ +// template BP1Writer::Stats<T> BP1Writer::GetStats( \ +// const Variable<std::complex<T>> &variable) const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +//#undef declare_template_instantiation +// +// template <class T> +// void BP1Writer::WriteBoundsRecord(const bool isScalar, const Stats<T> &stats, +// std::vector<char> &buffer, +// std::uint8_t &characteristicsCounter, +// const bool addLength) const noexcept +//{ +// if (isScalar == true) +// { +// WriteCharacteristicRecord(characteristic_value, stats.Min, buffer, +// characteristicsCounter, +// addLength); // stats.min = stats.max = value +// return; +// } +// +// if (m_Verbosity == 0) // default verbose +// { +// WriteCharacteristicRecord(characteristic_min, stats.Min, buffer, +// characteristicsCounter, addLength); +// WriteCharacteristicRecord(characteristic_max, stats.Max, buffer, +// characteristicsCounter, addLength); +// } +//} +//#define declare_template_instantiation(T) \ +// template void BP1Writer::WriteBoundsRecord( \ +// const bool isScalar, const Stats<T> &stats, std::vector<char> &buffer, \ +// std::uint8_t &characteristicsCounter, const bool addLength) \ +// const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(declare_template_instantiation) +//#undef declare_template_instantiation +// +// template <class T> +// void BP1Writer::WriteCharacteristicRecord(const std::uint8_t +// characteristicID, +// const T &value, +// std::vector<char> &buffer, +// std::uint8_t +// &characteristicsCounter, +// const bool addLength) const noexcept +//{ +// const std::uint8_t id = characteristicID; +// InsertToBuffer(buffer, &id); +// +// if (addLength == true) +// { +// const std::uint16_t lengthOfCharacteristic = sizeof(T); // id +// InsertToBuffer(buffer, &lengthOfCharacteristic); +// } +// +// InsertToBuffer(buffer, &value); +// ++characteristicsCounter; +//} +//#define define_template_instantiation(T) \ +// template void BP1Writer::WriteCharacteristicRecord( \ +// const std::uint8_t characteristicID, const T &value, \ +// std::vector<char> &buffer, std::uint8_t &characteristicsCounter, \ +// const bool addLength) const noexcept; +// ADIOS_FOREACH_TYPE_1ARG(define_template_instantiation) +//#undef define_template_instatiation + } // end namespace format } // end namespace adios