Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor template order allocMappedBufIfSupported #2162

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/alpaka/mem/buf/Traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ namespace alpaka
//! this function is provided for convenience in the cases where the difference is not relevant,
//! and the pinned/mapped memory is only used as a performance optimisation.
//!
//! \tparam TPlatform The platform from which the buffer is accessible.
//! \tparam TElem The element type of the returned buffer.
//! \tparam TIdx The linear index type of the buffer.
//! \tparam TExtent The extent type of the buffer.
//! \tparam TPlatform The platform from which the buffer is accessible.
//! \param host The host device to allocate the buffer on.
//! \param extent The extent of the buffer.
//! \return The newly allocated buffer.
template<typename TPlatform, typename TElem, typename TIdx, typename TExtent>
template<typename TElem, typename TIdx, typename TExtent, typename TPlatform>
ALPAKA_FN_HOST auto allocMappedBufIfSupported(
DevCpu const& host,
TPlatform const& platform,
Expand Down
6 changes: 3 additions & 3 deletions test/integ/axpy/src/axpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ TEMPLATE_LIST_TEST_CASE("axpy", "[axpy]", TestAccs)
<< std::endl;

// Allocate host memory buffers in pinned memory.
auto memBufHostX = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extent);
auto memBufHostOrigY = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extent);
auto memBufHostY = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extent);
auto memBufHostX = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extent);
auto memBufHostOrigY = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extent);
auto memBufHostY = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extent);
Val* const pBufHostX = alpaka::getPtrNative(memBufHostX);
Val* const pBufHostOrigY = alpaka::getPtrNative(memBufHostOrigY);
Val* const pBufHostY = alpaka::getPtrNative(memBufHostY);
Expand Down
3 changes: 1 addition & 2 deletions test/integ/hostOnlyAPI/src/hostOnlyAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ TEMPLATE_LIST_TEST_CASE("hostOnlyAPI", "[hostOnlyAPI]", TestAccs)
HostQueue hostQueue(host);

// host buffer
auto h_buffer1
= alpaka::allocMappedBufIfSupported<alpaka::Platform<Device>, int, Idx>(host, platformAcc, Vec1D{Idx{42}});
auto h_buffer1 = alpaka::allocMappedBufIfSupported<int, Idx>(host, platformAcc, Vec1D{Idx{42}});
INFO(
"host buffer allocated at " << alpaka::getPtrNative(h_buffer1) << " with "
<< alpaka::getExtentProduct(h_buffer1) << " element(s)");
Expand Down
2 changes: 1 addition & 1 deletion test/integ/mandelbrot/src/mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ TEMPLATE_LIST_TEST_CASE("mandelbrot", "[mandelbrot]", TestAccs)
<< std::endl;

// allocate host memory, potentially pinned for faster copy to/from the accelerator.
auto bufColorHost = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extent);
auto bufColorHost = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extent);

// Allocate the buffer on the accelerator.
auto bufColorAcc = alpaka::allocBuf<Val, Idx>(devAcc, extent);
Expand Down
2 changes: 1 addition & 1 deletion test/integ/matMul/src/matMul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ TEMPLATE_LIST_TEST_CASE("matMul", "[matMul]", TestAccs)
auto bufBHost = alpaka::createView(devHost, bufBHost1d.data(), extentB);

// Allocate C and set it to zero.
auto bufCHost = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extentC);
auto bufCHost = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extentC);
alpaka::memset(queueHost, bufCHost, 0u);

// Allocate the buffers on the accelerator.
Expand Down
6 changes: 3 additions & 3 deletions test/integ/separableCompilation/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ TEMPLATE_LIST_TEST_CASE("separableCompilation", "[separableCompilation]", TestAc
<< ", numElements:" << numElements << ")" << std::endl;

// Allocate host memory buffers, potentially pinned for faster copy to/from the accelerator.
auto memBufHostA = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extent);
auto memBufHostB = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extent);
auto memBufHostC = alpaka::allocMappedBufIfSupported<PlatformAcc, Val, Idx>(devHost, platformAcc, extent);
auto memBufHostA = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extent);
auto memBufHostB = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extent);
auto memBufHostC = alpaka::allocMappedBufIfSupported<Val, Idx>(devHost, platformAcc, extent);

// Initialize the host input vectors
for(Idx i = 0; i < numElements; ++i)
Expand Down
5 changes: 1 addition & 4 deletions test/unit/math/src/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ namespace alpaka
// Constructor needs to initialize all Buffer.
Buffer(DevAcc const& devAcc)
: devHost{alpaka::getDevByIdx(platformHost, 0)}
, hostBuffer{alpaka::allocMappedBufIfSupported<PlatformAcc, TData, Idx>(
devHost,
platformAcc,
Tcapacity)}
, hostBuffer{alpaka::allocMappedBufIfSupported<TData, Idx>(devHost, platformAcc, Tcapacity)}
, devBuffer{alpaka::allocBuf<TData, Idx>(devAcc, Tcapacity)}
, pHostBuffer{alpaka::getPtrNative(hostBuffer)}
, pDevBuffer{alpaka::getPtrNative(devBuffer)}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mem/fence/src/FenceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ TEMPLATE_LIST_TEST_CASE("FenceTest", "[fence]", TestAccs)

auto const numElements = Idx{2ul};
auto const extent = alpaka::Vec<Dim, Idx>{numElements};
auto vars_host = alpaka::allocMappedBufIfSupported<Platform, int, Idx>(host, platformAcc, extent);
auto vars_host = alpaka::allocMappedBufIfSupported<int, Idx>(host, platformAcc, extent);
auto vars_dev = alpaka::allocBuf<int, Idx>(dev, extent);
vars_host[0] = 1;
vars_host[1] = 2;
Expand Down