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

Fix template arguments of SYCL buffer specializations #2426

Merged
merged 2 commits into from
Nov 21, 2024
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: 1 addition & 3 deletions include/alpaka/mem/buf/BufCpuSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

#pragma once

#include "alpaka/dev/DevCpuSycl.hpp"
#include "alpaka/mem/buf/BufGenericSycl.hpp"
#include "alpaka/platform/PlatformCpuSycl.hpp"

#if defined(ALPAKA_ACC_SYCL_ENABLED) && defined(ALPAKA_SYCL_ONEAPI_CPU)

namespace alpaka
{
template<typename TElem, typename TDim, typename TIdx>
using BufCpuSycl = BufGenericSycl<TElem, TDim, TIdx, PlatformCpuSycl>;
using BufCpuSycl = BufGenericSycl<TElem, TDim, TIdx, TagCpuSycl>;
} // namespace alpaka

#endif
4 changes: 1 addition & 3 deletions include/alpaka/mem/buf/BufFpgaSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

#pragma once

#include "alpaka/dev/DevFpgaSyclIntel.hpp"
#include "alpaka/mem/buf/BufGenericSycl.hpp"
#include "alpaka/platform/PlatformFpgaSyclIntel.hpp"

#if defined(ALPAKA_ACC_SYCL_ENABLED) && defined(ALPAKA_SYCL_ONEAPI_FPGA)

namespace alpaka
{
template<typename TElem, typename TDim, typename TIdx>
using BufFpgaSyclIntel = BufGenericSycl<TElem, TDim, TIdx, PlatformFpgaSyclIntel>;
using BufFpgaSyclIntel = BufGenericSycl<TElem, TDim, TIdx, TagFpgaSyclIntel>;
} // namespace alpaka

#endif
4 changes: 1 addition & 3 deletions include/alpaka/mem/buf/BufGpuSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

#pragma once

#include "alpaka/dev/DevGpuSyclIntel.hpp"
#include "alpaka/mem/buf/BufGenericSycl.hpp"
#include "alpaka/platform/PlatformGpuSyclIntel.hpp"

#if defined(ALPAKA_ACC_SYCL_ENABLED) && defined(ALPAKA_SYCL_ONEAPI_GPU)

namespace alpaka
{
template<typename TElem, typename TDim, typename TIdx>
using BufGpuSyclIntel = BufGenericSycl<TElem, TDim, TIdx, PlatformGpuSyclIntel>;
using BufGpuSyclIntel = BufGenericSycl<TElem, TDim, TIdx, TagGpuSyclIntel>;
} // namespace alpaka

#endif
61 changes: 57 additions & 4 deletions test/unit/mem/buf/src/BufTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,58 @@
#include <numeric>
#include <type_traits>

namespace buftest
{
template<typename TDim, typename TDev, typename TElem, typename TIdx, typename TExtent>
auto allocBuf(TDev dev, TExtent extent)
{
return alpaka::allocBuf<TElem, TIdx>(dev, extent);
}

template<typename TDim, typename TElem, typename TIdx, typename TExtent>
auto allocBuf(alpaka::DevCpu dev, TExtent extent) -> alpaka::BufCpu<TElem, TDim, TIdx>
{
return alpaka::allocBuf<TElem, TIdx>(dev, extent);
}

#if defined(ALPAKA_ACC_GPU_CUDA_ENABLED)
template<typename TDim, typename TElem, typename TIdx, typename TExtent>
auto allocBuf(alpaka::DevCudaRt dev, TExtent extent) -> alpaka::BufCudaRt<TElem, TDim, TIdx>
{
return alpaka::allocBuf<TElem, TIdx>(dev, extent);
}
#endif
#if defined(ALPAKA_ACC_GPU_HIP_ENABLED)
template<typename TDim, typename TElem, typename TIdx, typename TExtent>
auto allocBuf(alpaka::DevHipRt dev, TExtent extent) -> alpaka::BufHipRt<TElem, TDim, TIdx>
{
return alpaka::allocBuf<TElem, TIdx>(dev, extent);
}
#endif
#if defined(ALPAKA_ACC_SYCL_ENABLED) and defined(ALPAKA_SYCL_ONEAPI_CPU)
template<typename TDim, typename TElem, typename TIdx, typename TExtent>
auto allocBuf(alpaka::DevCpuSycl dev, TExtent extent) -> alpaka::BufCpuSycl<TElem, TDim, TIdx>
{
return alpaka::allocBuf<TElem, TIdx>(dev, extent);
}
#endif
#if defined(ALPAKA_ACC_SYCL_ENABLED) and defined(ALPAKA_SYCL_ONEAPI_GPU)
template<typename TDim, typename TElem, typename TIdx, typename TExtent>
auto allocBuf(alpaka::DevGpuSyclIntel dev, TExtent extent) -> alpaka::BufGpuSyclIntel<TElem, TDim, TIdx>
{
return alpaka::allocBuf<TElem, TIdx>(dev, extent);
}
#endif
#if defined(ALPAKA_ACC_SYCL_ENABLED) && defined(ALPAKA_SYCL_ONEAPI_FPGA)
template<typename TDim, typename TElem, typename TIdx, typename TExtent>
auto allocBuf(alpaka::DevFpgaSyclIntel dev, TExtent extent) -> alpaka::BufFpgaSyclIntel<TElem, TDim, TIdx>
{
return alpaka::allocBuf<TElem, TIdx>(dev, extent);
}
#endif

} // namespace buftest

template<typename TAcc>
static auto testBufferMutable(alpaka::Vec<alpaka::Dim<TAcc>, alpaka::Idx<TAcc>> const& extent) -> void
{
Expand Down Expand Up @@ -244,13 +296,14 @@ TEMPLATE_LIST_TEST_CASE("memBufMove", "[memBuf]", alpaka::test::TestAccs)
using Acc = TestType;
using Idx = alpaka::Idx<Acc>;
using Elem = std::size_t;
using DimExtent = alpaka::DimInt<0>;

auto const platformHost = alpaka::PlatformCpu{};
auto const devHost = alpaka::getDevByIdx(platformHost, 0);
auto const platformAcc = alpaka::Platform<Acc>{};
auto const dev = alpaka::getDevByIdx(platformAcc, 0);
auto queue = alpaka::Queue<Acc, alpaka::Blocking>{dev};
auto const extent = alpaka::Vec<alpaka::DimInt<0>, Idx>{};
auto const extent = alpaka::Vec<DimExtent, Idx>{};

auto write = [&](auto& buf, Elem value)
{
Expand All @@ -267,16 +320,16 @@ TEMPLATE_LIST_TEST_CASE("memBufMove", "[memBuf]", alpaka::test::TestAccs)

// move constructor
{
auto buf1 = alpaka::allocBuf<Elem, Idx>(dev, extent);
auto buf1 = buftest::allocBuf<DimExtent, Elem, Idx>(dev, extent);
write(buf1, 1);
auto buf2{std::move(buf1)};
CHECK(read(buf2) == 1);
} // both buffers destruct fine here

// move assignment (via swap)
{
auto buf1 = alpaka::allocBuf<Elem, Idx>(dev, extent);
auto buf2 = alpaka::allocBuf<Elem, Idx>(dev, extent);
auto buf1 = buftest::allocBuf<DimExtent, Elem, Idx>(dev, extent);
auto buf2 = buftest::allocBuf<DimExtent, Elem, Idx>(dev, extent);
write(buf1, 1);
write(buf2, 2);
using std::swap;
Expand Down
Loading