Skip to content

Commit

Permalink
clang format to the correct version
Browse files Browse the repository at this point in the history
  • Loading branch information
anagainaru committed Jan 12, 2022
1 parent d6bc83e commit b0326af
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 30 deletions.
8 changes: 4 additions & 4 deletions source/adios2/engine/bp5/BP5Writer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ void BP5Writer::PutCommon(Variable<T> &variable, const T *values, bool sync)
BeginStep(StepMode::Update);
}
variable.SetData(values);
// if the user buffer is allocated on the GPU always use sync mode
bool isCudaBuffer = (variable.m_MemorySpace == MemorySpace::CUDA);
if (isCudaBuffer)
sync = true;
// if the user buffer is allocated on the GPU always use sync mode
bool isCudaBuffer = (variable.m_MemorySpace == MemorySpace::CUDA);
if (isCudaBuffer)
sync = true;

size_t *Shape = NULL;
size_t *Start = NULL;
Expand Down
4 changes: 2 additions & 2 deletions source/adios2/helper/adiosMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ template <class T>
void CopyFromGPUToBuffer(std::vector<char> &buffer, size_t &position,
const T *source, const size_t elements = 1) noexcept;
template <class T>
void CudaMemCopyToBuffer(char *buffer, size_t position,
const T *source, const size_t size) noexcept;
void CudaMemCopyToBuffer(char *buffer, size_t position, const T *source,
const size_t size) noexcept;

/**
* Wrapper around cudaMemcpy needed for isolating CUDA interface dependency
Expand Down
22 changes: 12 additions & 10 deletions source/adios2/toolkit/format/bp5/BP5Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,13 @@ static void GetMinMax(const void *Data, size_t ElemCount, const DataType Type,
}
#ifdef ADIOS2_HAVE_CUDA
#define pertype(T, N) \
else if (MemSpace == MemorySpace::CUDA && Type == helper::GetDataType<T>())\
{ \
const size_t size = ElemCount * sizeof(T); \
const T *values = (const T *)Data; \
helper::CUDAMinMax(values, ElemCount, MinMax.MinUnion.field_##N, \
MinMax.MaxUnion.field_##N); \
else if (MemSpace == MemorySpace::CUDA && \
Type == helper::GetDataType<T>()) \
{ \
const size_t size = ElemCount * sizeof(T); \
const T *values = (const T *)Data; \
helper::CUDAMinMax(values, ElemCount, MinMax.MinUnion.field_##N, \
MinMax.MaxUnion.field_##N); \
}
ADIOS2_FOREACH_MINMAX_STDTYPE_2ARGS(pertype)
#undef pertype
Expand Down Expand Up @@ -681,7 +682,7 @@ void BP5Serializer::Marshal(void *Variable, const char *Name,
if ((m_StatsLevel > 0) && !Span)
{
GetMinMax(Data, ElemCount, (DataType)Rec->Type, MinMax,
VB->m_MemorySpace);
VB->m_MemorySpace);
}

if (Rec->OperatorType)
Expand Down Expand Up @@ -710,9 +711,10 @@ void BP5Serializer::Marshal(void *Variable, const char *Name,
{
if (!DeferAddToVec)
{
DataOffset = m_PriorDataBufferSizeTotal +
CurDataBuffer->AddToVec(ElemCount * ElemSize, Data,
ElemSize, Sync, VB->m_MemorySpace);
DataOffset =
m_PriorDataBufferSizeTotal +
CurDataBuffer->AddToVec(ElemCount * ElemSize, Data,
ElemSize, Sync, VB->m_MemorySpace);
}
}
else
Expand Down
3 changes: 2 additions & 1 deletion source/adios2/toolkit/format/buffer/BufferV.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class BufferV
virtual void Reset();

virtual size_t AddToVec(const size_t size, const void *buf, size_t align,
bool CopyReqd, MemorySpace MemSpace=MemorySpace::Host) = 0;
bool CopyReqd,
MemorySpace MemSpace = MemorySpace::Host) = 0;

struct BufferPos
{
Expand Down
21 changes: 11 additions & 10 deletions source/adios2/toolkit/format/buffer/chunk/ChunkV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

#include "ChunkV.h"
#include "adios2/toolkit/format/buffer/BufferV.h"
#include "adios2/helper/adiosFunctions.h"
#include "adios2/toolkit/format/buffer/BufferV.h"

#include <algorithm>
#include <assert.h>
Expand Down Expand Up @@ -121,7 +121,7 @@ size_t ChunkV::AddToVec(const size_t size, const void *buf, size_t align,
if (AppendPossible)
{
// We can use current chunk, just append the data;
CopyDataToBuffer(size, buf, m_TailChunkPos, MemSpace);
CopyDataToBuffer(size, buf, m_TailChunkPos, MemSpace);
DataV.back().Size += size;
m_TailChunkPos += size;
}
Expand All @@ -133,7 +133,7 @@ size_t ChunkV::AddToVec(const size_t size, const void *buf, size_t align,
NewSize = size;
m_TailChunk = (char *)malloc(NewSize);
m_Chunks.push_back(m_TailChunk);
CopyDataToBuffer(size, buf, 0, MemSpace);
CopyDataToBuffer(size, buf, 0, MemSpace);
m_TailChunkPos = size;
VecEntry entry = {false, m_TailChunk, 0, size};
DataV.push_back(entry);
Expand All @@ -144,15 +144,16 @@ size_t ChunkV::AddToVec(const size_t size, const void *buf, size_t align,
}

void ChunkV::CopyDataToBuffer(const size_t size, const void *buf, size_t pos,
MemorySpace MemSpace){
MemorySpace MemSpace)
{
#ifdef ADIOS2_HAVE_CUDA
if(MemSpace == MemorySpace::CUDA)
{
helper::CudaMemCopyToBuffer(m_TailChunk, pos, buf, size);
return;
}
if (MemSpace == MemorySpace::CUDA)
{
helper::CudaMemCopyToBuffer(m_TailChunk, pos, buf, size);
return;
}
#endif
memcpy(m_TailChunk + pos, buf, size);
memcpy(m_TailChunk + pos, buf, size);
}

BufferV::BufferPos ChunkV::Allocate(const size_t size, size_t align)
Expand Down
5 changes: 3 additions & 2 deletions source/adios2/toolkit/format/buffer/chunk/ChunkV.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ class ChunkV : public BufferV
virtual std::vector<core::iovec> DataVec() noexcept;

virtual size_t AddToVec(const size_t size, const void *buf, size_t align,
bool CopyReqd, MemorySpace MemSpace=MemorySpace::Host);
bool CopyReqd,
MemorySpace MemSpace = MemorySpace::Host);

virtual BufferPos Allocate(const size_t size, size_t align);
virtual void DownsizeLastAlloc(const size_t oldSize, const size_t newSize);

virtual void *GetPtr(int bufferIdx, size_t posInBuffer);

void CopyExternalToInternal();
void CopyDataToBuffer(const size_t size, const void *buf, size_t pos,
void CopyDataToBuffer(const size_t size, const void *buf, size_t pos,
MemorySpace MemSpace);

private:
Expand Down
3 changes: 2 additions & 1 deletion source/adios2/toolkit/format/buffer/malloc/MallocV.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class MallocV : public BufferV
virtual void Reset();

virtual size_t AddToVec(const size_t size, const void *buf, size_t align,
bool CopyReqd, MemorySpace MemSpace=MemorySpace::Host);
bool CopyReqd,
MemorySpace MemSpace = MemorySpace::Host);

virtual BufferPos Allocate(const size_t size, size_t align);
void DownsizeLastAlloc(const size_t oldSize, const size_t newSize);
Expand Down

0 comments on commit b0326af

Please sign in to comment.