Skip to content

Commit

Permalink
Splitting the read logic for device/host allocated buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
anagainaru committed Jan 24, 2022
1 parent 485ad81 commit 23bee7d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,19 @@ static int FindOffsetCM(size_t Dims, const size_t *Size, const size_t *Index)
* *******************************
*/

void BP5Deserializer::MemCopyData(char *OutData, const char *InData,
size_t Size, MemorySpace MemSpace)
{
#ifdef ADIOS2_HAVE_CUDA
if (MemSpace == MemorySpace::CUDA)
{
helper::CudaMemCopyToBuffer(OutData, 0, InData, Size);
return;
}
#endif
memcpy(OutData, InData, Size);
}

// Row major version
void BP5Deserializer::ExtractSelectionFromPartialRM(
int ElementSize, size_t Dims, const size_t *GlobalDims,
Expand Down Expand Up @@ -1343,7 +1356,7 @@ void BP5Deserializer::ExtractSelectionFromPartialRM(
size_t i;
for (i = 0; i < BlockCount; i++)
{
memcpy(OutData, InData, BlockSize * ElementSize);
MemCopyData(OutData, InData, BlockSize * ElementSize, MemSpace);
InData += SourceBlockStride;
OutData += DestBlockStride;
}
Expand Down Expand Up @@ -1444,7 +1457,7 @@ void BP5Deserializer::ExtractSelectionFromPartialCM(
OutData += DestBlockStartOffset;
for (int i = 0; i < BlockCount; i++)
{
memcpy(OutData, InData, BlockSize * ElementSize);
MemCopyData(OutData, InData, BlockSize * ElementSize, MemSpace);
InData += SourceBlockStride;
OutData += DestBlockStride;
}
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class BP5Deserializer : virtual public BP5Base
bool GetSingleValueFromMetadata(core::VariableBase &variable,
BP5VarRec *VarRec, void *DestData,
size_t Step, size_t WriterRank);
void MemCopyData(char *OutData, const char *InData, size_t Size,
MemorySpace MemSpace);
void ExtractSelectionFromPartialRM(
int ElementSize, size_t Dims, const size_t *GlobalDims,
const size_t *PartialOffsets, const size_t *PartialCounts,
Expand Down

0 comments on commit 23bee7d

Please sign in to comment.