Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Third Party authored and psychocoderHPC committed Oct 28, 2024
1 parent c9c5ae9 commit fa52618
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 41 deletions.
23 changes: 14 additions & 9 deletions examples/mallocMC_example01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ auto main() -> int
// create arrays of arrays on the device
{
auto createArrayPointers
= [] ALPAKA_FN_ACC(const Acc& acc, int x, int y, ScatterAllocator::AllocatorHandle allocHandle) {
arA = (int**) allocHandle.malloc(acc, sizeof(int*) * x * y);
arB = (int**) allocHandle.malloc(acc, sizeof(int*) * x * y);
arC = (int**) allocHandle.malloc(acc, sizeof(int*) * x * y);
};
= [] ALPAKA_FN_ACC(const Acc& acc, int x, int y, ScatterAllocator::AllocatorHandle allocHandle)
{
arA = (int**) allocHandle.malloc(acc, sizeof(int*) * x * y);
arB = (int**) allocHandle.malloc(acc, sizeof(int*) * x * y);
arC = (int**) allocHandle.malloc(acc, sizeof(int*) * x * y);
};
const auto workDiv = alpaka::WorkDivMembers<Dim, Idx>{Idx{1}, Idx{1}, Idx{1}};
alpaka::enqueue(
queue,
Expand All @@ -121,7 +122,8 @@ auto main() -> int

// fill 2 of them all with ascending values
{
auto fillArrays = [] ALPAKA_FN_ACC(const Acc& acc, int length, ScatterAllocator::AllocatorHandle allocHandle) {
auto fillArrays = [] ALPAKA_FN_ACC(const Acc& acc, int length, ScatterAllocator::AllocatorHandle allocHandle)
{
const auto id = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0];

arA[id] = (int*) allocHandle.malloc(acc, length * sizeof(int));
Expand All @@ -145,7 +147,8 @@ auto main() -> int
{
auto sumsBufferAcc = alpaka::allocBuf<int, Idx>(dev, Idx{block * grid});

auto addArrays = [] ALPAKA_FN_ACC(const Acc& acc, int length, int* sums) {
auto addArrays = [] ALPAKA_FN_ACC(const Acc& acc, int length, int* sums)
{
const auto id = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0];

sums[id] = 0;
Expand Down Expand Up @@ -184,7 +187,8 @@ auto main() -> int
}

{
auto freeArrays = [] ALPAKA_FN_ACC(const Acc& acc, ScatterAllocator::AllocatorHandle allocHandle) {
auto freeArrays = [] ALPAKA_FN_ACC(const Acc& acc, ScatterAllocator::AllocatorHandle allocHandle)
{
const auto id = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0];
allocHandle.free(acc, arA[id]);
allocHandle.free(acc, arB[id]);
Expand All @@ -195,7 +199,8 @@ auto main() -> int
}

{
auto freeArrayPointers = [] ALPAKA_FN_ACC(const Acc& acc, ScatterAllocator::AllocatorHandle allocHandle) {
auto freeArrayPointers = [] ALPAKA_FN_ACC(const Acc& acc, ScatterAllocator::AllocatorHandle allocHandle)
{
allocHandle.free(acc, arA);
allocHandle.free(acc, arB);
allocHandle.free(acc, arC);
Expand Down
11 changes: 6 additions & 5 deletions src/include/mallocMC/creationPolicies/Scatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,8 @@ namespace mallocMC
0u,
minAllocation);
// Check if the chunk size can be used even if the size is not an exact match.
auto const isChunkSizeInRange = [&](uint32_t currentChunkSize) {
return currentChunkSize >= bytes && currentChunkSize <= maxchunksize;
};
auto const isChunkSizeInRange = [&](uint32_t currentChunkSize)
{ return currentChunkSize >= bytes && currentChunkSize <= maxchunksize; };
uint32_t useChunkSize = 0u;
if(beforeChunkSize == 0u)
{
Expand Down Expand Up @@ -1112,7 +1111,8 @@ namespace mallocMC
const AlpakaAcc& m_acc,
T_DeviceAllocator* m_heap,
void* m_heapmem,
size_t m_memsize) {
size_t m_memsize)
{
m_heap->pool = m_heapmem;
m_heap->initDeviceFunction(m_acc, m_heapmem, m_memsize);
};
Expand Down Expand Up @@ -1285,7 +1285,8 @@ namespace mallocMC
const AlpakaAcc& acc,
T_DeviceAllocator* heapPtr,
size_t numBytes,
unsigned* slots) -> void {
unsigned* slots) -> void
{
const auto gid = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc).sum();

const auto nWorker = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc).prod();
Expand Down
4 changes: 2 additions & 2 deletions src/include/mallocMC/oOMPolicies/BadAllocException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace mallocMC
static auto handleOOM(void* mem) -> void*
{
#if BOOST_LANG_CUDA || BOOST_COMP_HIP
//#if __CUDA_ARCH__ < 350
// #if __CUDA_ARCH__ < 350
# define PM_EXCEPTIONS_NOT_SUPPORTED_HERE
//#endif
// #endif
#endif

#ifdef PM_EXCEPTIONS_NOT_SUPPORTED_HERE
Expand Down
48 changes: 24 additions & 24 deletions tests/dimensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ void test1D()
queue,
alpaka::createTaskKernel<Acc>(
alpaka::WorkDivMembers<Dim, Idx>{Idx{1}, Idx{1}, Idx{1}},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle) {
deviceArray = (int**) allocHandle.malloc(acc, sizeof(int*) * dim * dim);
},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle)
{ deviceArray = (int**) allocHandle.malloc(acc, sizeof(int*) * dim * dim); },
N,
scatterAlloc.getAllocatorHandle()));

Expand All @@ -101,7 +100,8 @@ void test1D()
queue,
alpaka::createTaskKernel<Acc>(
alpaka::WorkDivMembers<Dim, Idx>{Idx{N}, Idx{N}, Idx{1}},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle) {
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle)
{
const auto i = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0];
deviceArray[i] = (int*) allocHandle.malloc(acc, sizeof(int));
},
Expand All @@ -117,7 +117,8 @@ void test1D()
queue,
alpaka::createTaskKernel<Acc>(
alpaka::WorkDivMembers<Dim, Idx>{Idx{N}, Idx{N}, Idx{1}},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle) {
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle)
{
const auto i = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0];
allocHandle.free(acc, deviceArray[i]);
},
Expand All @@ -128,9 +129,8 @@ void test1D()
queue,
alpaka::createTaskKernel<Acc>(
alpaka::WorkDivMembers<Dim, Idx>{Idx{1}, Idx{1}, Idx{1}},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle) {
allocHandle.free(acc, deviceArray);
},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle)
{ allocHandle.free(acc, deviceArray); },
scatterAlloc.getAllocatorHandle()));
}

Expand Down Expand Up @@ -165,9 +165,8 @@ void test2D()
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle) {
deviceArray = (int**) allocHandle.malloc(acc, sizeof(int*) * dim * dim * dim * dim);
},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle)
{ deviceArray = (int**) allocHandle.malloc(acc, sizeof(int*) * dim * dim * dim * dim); },
N,
scatterAlloc.getAllocatorHandle()));

Expand All @@ -179,7 +178,8 @@ void test2D()
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle) {
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle)
{
const auto idx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
deviceArray[idx[0] * dim * dim + idx[1]] = (int*) allocHandle.malloc(acc, sizeof(int));
},
Expand All @@ -199,7 +199,8 @@ void test2D()
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle) {
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle)
{
const auto idx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
allocHandle.free(acc, deviceArray[idx[0] * dim * dim + idx[1]]);
},
Expand All @@ -214,9 +215,8 @@ void test2D()
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle) {
allocHandle.free(acc, deviceArray);
},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle)
{ allocHandle.free(acc, deviceArray); },
scatterAlloc.getAllocatorHandle()));
}

Expand Down Expand Up @@ -251,9 +251,8 @@ void test3D()
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle) {
deviceArray = (int**) allocHandle.malloc(acc, sizeof(int*) * dim * dim * dim * dim * dim * dim);
},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle)
{ deviceArray = (int**) allocHandle.malloc(acc, sizeof(int*) * dim * dim * dim * dim * dim * dim); },
N,
scatterAlloc.getAllocatorHandle()));

Expand All @@ -266,7 +265,8 @@ void test3D()
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle) {
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle)
{
const auto idx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
deviceArray[idx[0] * dim * dim * dim * dim + idx[1] * dim * dim + idx[0]]
= (int*) allocHandle.malloc(acc, sizeof(int));
Expand All @@ -288,7 +288,8 @@ void test3D()
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(N),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle) {
[] ALPAKA_FN_ACC(const Acc& acc, int dim, typename ScatterAllocator::AllocatorHandle allocHandle)
{
const auto idx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
allocHandle.free(acc, deviceArray[idx[0] * dim * dim * dim * dim + idx[1] * dim * dim + idx[0]]);
},
Expand All @@ -303,9 +304,8 @@ void test3D()
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1),
alpaka::Vec<Dim, Idx>::all(1)},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle) {
allocHandle.free(acc, deviceArray);
},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle)
{ allocHandle.free(acc, deviceArray); },
scatterAlloc.getAllocatorHandle()));
}

Expand Down
3 changes: 2 additions & 1 deletion tests/policies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void run()
queue,
alpaka::createTaskKernel<Acc>(
alpaka::WorkDivMembers<Dim, Idx>{Idx{1}, Idx{1}, Idx{1}},
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle) {
[] ALPAKA_FN_ACC(const Acc& acc, typename ScatterAllocator::AllocatorHandle allocHandle)
{
auto* ptr = allocHandle.malloc(acc, sizeof(int) * 1000);
allocHandle.free(acc, ptr);
},
Expand Down

0 comments on commit fa52618

Please sign in to comment.