Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraPerego committed Feb 19, 2024
1 parent 5389a57 commit db4e2dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
8 changes: 5 additions & 3 deletions include/alpaka/mem/global/DeviceGlobalGenericSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace alpaka
TExtent extent)
{
using Elem = alpaka::Elem<std::remove_reference_t<TViewDst>>;
auto size = static_cast<std::size_t>(getHeight(extent)) * static_cast<std::size_t>(getDepth(extent)) * static_cast<std::size_t>(getWidth(extent)) * sizeof(Elem);
auto size = static_cast<std::size_t>(getHeight(extent)) * static_cast<std::size_t>(getDepth(extent))
* static_cast<std::size_t>(getWidth(extent)) * sizeof(Elem);
queue.getNativeHandle().memcpy(reinterpret_cast<void*>(getPtrNative(viewDst)), viewSrc, size);
}

Expand All @@ -54,8 +55,9 @@ namespace alpaka
TExtent extent)
{
using Elem = alpaka::Elem<TViewSrc>;
auto size = static_cast<std::size_t>(getHeight(extent)) * static_cast<std::size_t>(getDepth(extent)) * static_cast<std::size_t>(getWidth(extent)) * sizeof(Elem);
queue.getNativeHandle().memcpy(viewDst, reinterpret_cast<void const*>(getPtrNative(viewSrc)), size);
auto size = static_cast<std::size_t>(getHeight(extent)) * static_cast<std::size_t>(getDepth(extent))
* static_cast<std::size_t>(getWidth(extent)) * sizeof(Elem);
queue.getNativeHandle().memcpy(viewDst, reinterpret_cast<void const*>(getPtrNative(viewSrc)), size);
}
} // namespace alpaka
#endif
22 changes: 14 additions & 8 deletions test/unit/mem/view/src/ViewStaticAccMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ using Idx = std::uint32_t;
// from a different compilation unit and should be moved to a common header.
// Here they are used to silence clang`s -Wmissing-variable-declarations warning
// that forces every non-static variable to be declared with extern before the are defined.
//extern ALPAKA_STATIC_ACC_MEM_GLOBAL(Elem[3][2], g_globalMemory2DUninitialized);
// extern ALPAKA_STATIC_ACC_MEM_GLOBAL(Elem[3][2], g_globalMemory2DUninitialized);
ALPAKA_STATIC_ACC_MEM_GLOBAL(Elem[3][2], g_globalMemory2DUninitialized);

// These forward declarations are only necessary when you want to access those variables
// from a different compilation unit and should be moved to a common header.
// Here they are used to silence clang`s -Wmissing-variable-declarations warning
// that forces every non-static variable to be declared with extern before the are defined.
//extern ALPAKA_STATIC_ACC_MEM_CONSTANT(Elem[3][2], g_constantMemory2DUninitialized);
// extern ALPAKA_STATIC_ACC_MEM_CONSTANT(Elem[3][2], g_constantMemory2DUninitialized);
ALPAKA_STATIC_ACC_MEM_CONSTANT(Elem[3][2], g_constantMemory2DUninitialized);

//! Uses static device memory on the accelerator defined globally for the whole compilation unit.
Expand All @@ -44,7 +44,10 @@ struct StaticDeviceMemoryTestKernel
auto const val = offset;

ALPAKA_CHECK(*success, val == *((&g_globalMemory2DUninitialized<TAcc>.get())[0][0] + offset));
printf("%u = %u\n", val, *((&g_globalMemory2DUninitialized<TAcc>.get())[0][0] + offset)); // compila anche senza get()
printf(
"%u = %u\n",
val,
*((&g_globalMemory2DUninitialized<TAcc>.get())[0][0] + offset)); // compila anche senza get()
}
};

Expand All @@ -61,7 +64,10 @@ struct ConstantDeviceMemoryTestKernel
auto const val = offset;

ALPAKA_CHECK(*success, val == *((&g_constantMemory2DUninitialized<TAcc>.get())[0][0] + offset));
printf("%u = %u\n", val, *((&g_constantMemory2DUninitialized<TAcc>.get())[0][0] + offset)); // compila anche senza get()
printf(
"%u = %u\n",
val,
*((&g_constantMemory2DUninitialized<TAcc>.get())[0][0] + offset)); // compila anche senza get()
}
};

Expand All @@ -73,8 +79,8 @@ TEMPLATE_LIST_TEST_CASE("staticDeviceMemoryGlobal", "[viewStaticAccMem]", TestAc
using DevAcc = alpaka::Dev<Acc>;

auto const platformAcc = alpaka::Platform<Acc>{};
std::cout << " acc:" << alpaka::core::demangled<Acc> << std::endl;

std::cout << " acc:" << alpaka::core::demangled<Acc> << std::endl;
auto const devAcc = alpaka::getDevByIdx(platformAcc, 0);

alpaka::Vec<Dim, Idx> const extent(3u, 2u);
Expand Down Expand Up @@ -102,8 +108,8 @@ TEMPLATE_LIST_TEST_CASE("staticDeviceMemoryGlobal", "[viewStaticAccMem]", TestAc
auto bufHost2 = alpaka::createView(devHost, data2.data(), extent);
alpaka::memcpy(queueAcc, bufHost2, g_globalMemory2DUninitialized<Acc>, extent);
alpaka::wait(queueAcc);
for (auto& el : data2)
std::cout << el << " ";
for(auto& el : data2)
std::cout << el << " ";
std::cout << std::endl;
}
}
Expand Down

0 comments on commit db4e2dc

Please sign in to comment.