Skip to content

Commit

Permalink
Fix DataMan Serializer to handle m_MemSpace being "Detect" instead of…
Browse files Browse the repository at this point in the history
… "Host" when GPU support is not enabled
  • Loading branch information
eisenhauer committed Mar 19, 2024
1 parent 3e3e551 commit 0221798
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
17 changes: 17 additions & 0 deletions source/adios2/common/ADIOSTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
namespace adios2
{

std::string ToString(MemorySpace value)
{
switch (value)
{
case MemorySpace::Detect:
return "MemorySpace::Detect";
case MemorySpace::Host:
return "MemorySpace::Host";
#ifdef ADIOS2_HAVE_GPU_SUPPORT
case MemorySpace::LocalValue:
return "MemorySpace::CPU";
#endif
default:
return "ToString: Unknown MemorySpace";
}
}

std::string ToString(ShapeID value)
{
switch (value)
Expand Down
1 change: 1 addition & 0 deletions source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ std::string ToString(SelectionType value);
std::string ToString(DataType type);
std::string ToString(const Dims &dims);
std::string ToString(const Box<Dims> &box);
std::string ToString(const MemorySpace value);

/**
* os << [adios2_type] enables output of adios2 enums/classes directly
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/toolkit/format/dataman/DataManSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void DataManSerializer::PutData(const std::string *inputData, const std::string
helper::CopyFromGPUToBuffer(localBuffer->data(), localBuffer->size() - inputData->size(),
inputData->data(), varMemSpace, inputData->size());
#endif
if (varMemSpace == MemorySpace::Host)
if ((varMemSpace == MemorySpace::Host) || (varMemSpace == MemorySpace::Detect))
std::memcpy(localBuffer->data() + localBuffer->size() - inputData->size(),
inputData->data(), inputData->size());

Expand Down
4 changes: 2 additions & 2 deletions source/adios2/toolkit/format/dataman/DataManSerializer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void DataManSerializer::CalculateMinMax(const T *data, const Dims &count,
if (varMemSpace == MemorySpace::GPU)
helper::GetGPUMinMax(data, size, min, max);
#endif
if (varMemSpace == MemorySpace::Host)
if ((varMemSpace == MemorySpace::Host) || (varMemSpace == MemorySpace::Detect))
{
for (size_t j = 0; j < size; ++j)
{
Expand Down Expand Up @@ -184,7 +184,7 @@ void DataManSerializer::PutData(const T *inputData, const std::string &varName,
helper::CopyFromGPUToBuffer(localBuffer->data(), localBuffer->size() - datasize,
inputData, varMemSpace, datasize);
#endif
if (varMemSpace == MemorySpace::Host)
if ((varMemSpace == MemorySpace::Host) || (varMemSpace == MemorySpace::Detect))
std::memcpy(localBuffer->data() + localBuffer->size() - datasize, inputData, datasize);
}

Expand Down

0 comments on commit 0221798

Please sign in to comment.