Skip to content

Commit

Permalink
Added support for static SYCL members inside Platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Parsifal-2045 committed Jan 18, 2023
1 parent 1f874de commit 4894703
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 39 deletions.
18 changes: 8 additions & 10 deletions include/alpaka/mem/buf/BufGenericSycl.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2022 Jan Stephan
/* Copyright 2022 Jan Stephan, Luca Ferragina, Aurora Perego
*
* This file is part of Alpaka.
*
Expand Down Expand Up @@ -224,22 +224,20 @@ namespace alpaka::trait
};

//! The pinned/mapped memory allocation trait specialization for the SYCL devices.
template<typename TElem, typename TDim, typename TIdx, typename TPltf>
struct BufAllocMapped<TElem, TDim, TIdx, DevGenericSycl<TPltf>>
template<typename TPltf, typename TElem, typename TDim, typename TIdx>
struct BufAllocMapped
{
template<typename TExtent>
ALPAKA_FN_HOST static auto allocMappedBuf(
DevCpu const& host,
DevGenericSycl<TPltf> const& dev,
TExtent const& extent) -> BufCpu<TElem, TDim, TIdx>
ALPAKA_FN_HOST static auto allocMappedBuf(DevCpu const& host, TExtent const& extent)
-> BufCpu<TElem, TDim, TIdx>
{
ALPAKA_DEBUG_MINIMAL_LOG_SCOPE;

// Allocate SYCL page-locked memory on the host, mapped into the TPltf address space and
// accessible to all devices in the TPltf.
TElem* memPtr
= sycl::malloc_host<TElem>(static_cast<std::size_t>(getExtentProduct(extent)), dev.get_context());
auto deleter = [&dev](TElem* ptr) { sycl::free(ptr, dev.get_context()); };
auto ctx = TPltf::syclContext();
TElem* memPtr = sycl::malloc_host<TElem>(static_cast<std::size_t>(getExtentProduct(extent)), ctx);
auto deleter = [ctx](TElem* ptr) { sycl::free(ptr, ctx); };

return BufCpu<TElem, TDim, TIdx>(host, memPtr, std::move(deleter), extent);
}
Expand Down
8 changes: 1 addition & 7 deletions include/alpaka/pltf/PltfCpuSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ namespace alpaka
} // namespace detail

//! The SYCL device manager.
class PltfCpuSyclIntel : public PltfGenericSycl
{
public:
PltfCpuSyclIntel() = delete;

using selector = detail::IntelCpuSelector;
};
using PltfCpuSyclIntel = PltfGenericSycl<detail::IntelCpuSelector>;
} // namespace alpaka

namespace alpaka::trait
Expand Down
2 changes: 0 additions & 2 deletions include/alpaka/pltf/PltfFpgaSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
# include <CL/sycl.hpp>
# include <sycl/ext/intel/fpga_extensions.hpp>

# include <string>

namespace alpaka
{
//! The SYCL device manager.
Expand Down
8 changes: 1 addition & 7 deletions include/alpaka/pltf/PltfFpgaSyclXilinx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ namespace alpaka
} // namespace detail

//! The SYCL device manager.
class PltfFpgaSyclXilinx : public PltfGenericSycl
{
public:
PltfFpgaSyclXilinx() = delete;

using selector = detail::XilinxFpgaSelector;
};
using PltfFgpaSyclIntel = PltfGenericSycl<detail::XilinxFpgaSelector>;
} // namespace alpaka

namespace alpaka::trait
Expand Down
12 changes: 6 additions & 6 deletions include/alpaka/pltf/PltfGenericSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,26 @@ namespace alpaka
namespace alpaka::trait
{
//! The SYCL platform device count get trait specialization.
template<typename TPltf>
struct GetDevCount<TPltf, std::enable_if_t<std::is_base_of_v<PltfGenericSycl, TPltf>>>
template<typename TSelector>
struct GetDevCount<alpaka::PltfGenericSycl<TSelector>>
{
static auto getDevCount() -> std::size_t
{
ALPAKA_DEBUG_FULL_LOG_SCOPE;

return alpaka::experimental::PltfGenericSycl<TSelector>::syclDevices().size();
return alpaka::PltfGenericSycl<TSelector>::syclDevices().size();
}
};

//! The SYCL platform device get trait specialization.
template<typename TPltf>
struct GetDevByIdx<TPltf, std::enable_if_t<std::is_base_of_v<PltfGenericSycl, TPltf>>>
template<typename TSelector>
struct GetDevByIdx<alpaka::PltfGenericSycl<TSelector>>
{
static auto getDevByIdx(std::size_t const& devIdx)
{
ALPAKA_DEBUG_FULL_LOG_SCOPE;

using SyclPltf = alpaka::experimental::PltfGenericSycl<TSelector>;
using SyclPltf = alpaka::PltfGenericSycl<TSelector>;

auto const dev_num = getDevCount<SyclPltf>();

Expand Down
8 changes: 1 addition & 7 deletions include/alpaka/pltf/PltfGpuSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ namespace alpaka
} // namespace detail

//! The SYCL device manager.
class PltfGpuSyclIntel : public PltfGenericSycl
{
public:
PltfGpuSyclIntel() = delete;

using selector = detail::IntelGpuSelector;
};
using PltfGpuSyclIntel = PltfGenericSycl<detail::IntelGpuSelector>;
} // namespace alpaka

namespace alpaka::trait
Expand Down

0 comments on commit 4894703

Please sign in to comment.