Skip to content

Commit

Permalink
template SYCL objects and device selectors on the Tag
Browse files Browse the repository at this point in the history
- template the Device, Queue, Event, Acc, Buf, Platform, EventHostManualTriggerSycl and device selectors on the Tag
- adapt the default queue for the tests
- avoid code duplication for SYCL where possible
  • Loading branch information
AuroraPerego committed Sep 2, 2024
1 parent 513d8c0 commit da1061b
Show file tree
Hide file tree
Showing 38 changed files with 1,052 additions and 1,107 deletions.
3 changes: 1 addition & 2 deletions include/alpaka/acc/AccCpuSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "alpaka/acc/AccGenericSycl.hpp"
#include "alpaka/acc/Tag.hpp"
#include "alpaka/core/Sycl.hpp"
#include "alpaka/platform/PlatformCpuSycl.hpp"

#include <string>
#include <utility>
Expand All @@ -20,7 +19,7 @@ namespace alpaka
//!
//! This accelerator allows parallel kernel execution on a oneAPI-capable CPU target device.
template<typename TDim, typename TIdx>
using AccCpuSycl = AccGenericSycl<detail::SyclCpuSelector, TDim, TIdx>;
using AccCpuSycl = AccGenericSycl<TagCpuSycl, TDim, TIdx>;

namespace trait
{
Expand Down
3 changes: 1 addition & 2 deletions include/alpaka/acc/AccFpgaSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "alpaka/acc/AccGenericSycl.hpp"
#include "alpaka/acc/Tag.hpp"
#include "alpaka/core/Sycl.hpp"
#include "alpaka/platform/PlatformFpgaSyclIntel.hpp"

#include <string>
#include <utility>
Expand All @@ -20,7 +19,7 @@ namespace alpaka
//!
//! This accelerator allows parallel kernel execution on a oneAPI-capable Intel FPGA target device.
template<typename TDim, typename TIdx>
using AccFpgaSyclIntel = AccGenericSycl<detail::IntelFpgaSelector, TDim, TIdx>;
using AccFpgaSyclIntel = AccGenericSycl<TagFpgaSyclIntel, TDim, TIdx>;

namespace trait
{
Expand Down
75 changes: 32 additions & 43 deletions include/alpaka/acc/AccGenericSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@

namespace alpaka
{
template<typename TSelector, typename TAcc, typename TDim, typename TIdx, typename TKernelFnObj, typename... TArgs>
template<typename TTag, typename TAcc, typename TDim, typename TIdx, typename TKernelFnObj, typename... TArgs>
class TaskKernelGenericSycl;

//! The SYCL accelerator.
//!
//! This accelerator allows parallel kernel execution on SYCL devices.
template<typename TSelector, typename TDim, typename TIdx>
template<typename TTag, typename TDim, typename TIdx>
class AccGenericSycl
: public WorkDivGenericSycl<TDim, TIdx>
, public gb::IdxGbGenericSycl<TDim, TIdx>
Expand Down Expand Up @@ -103,30 +103,29 @@ namespace alpaka
namespace alpaka::trait
{
//! The SYCL accelerator type trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct AccType<AccGenericSycl<TSelector, TDim, TIdx>>
template<typename TTag, typename TDim, typename TIdx>
struct AccType<AccGenericSycl<TTag, TDim, TIdx>>
{
using type = AccGenericSycl<TSelector, TDim, TIdx>;
using type = AccGenericSycl<TTag, TDim, TIdx>;
};

//! The SYCL single thread accelerator type trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct IsSingleThreadAcc<AccGenericSycl<TSelector, TDim, TIdx>> : std::false_type
template<typename TTag, typename TDim, typename TIdx>
struct IsSingleThreadAcc<AccGenericSycl<TTag, TDim, TIdx>> : std::false_type
{
};

//! The SYCL multi thread accelerator type trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct IsMultiThreadAcc<AccGenericSycl<TSelector, TDim, TIdx>> : std::true_type
template<typename TTag, typename TDim, typename TIdx>
struct IsMultiThreadAcc<AccGenericSycl<TTag, TDim, TIdx>> : std::true_type
{
};

//! The SYCL accelerator device properties get trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct GetAccDevProps<AccGenericSycl<TSelector, TDim, TIdx>>
template<typename TTag, typename TDim, typename TIdx>
struct GetAccDevProps<AccGenericSycl<TTag, TDim, TIdx>>
{
static auto getAccDevProps(DevGenericSycl<PlatformGenericSycl<TSelector>> const& dev)
-> AccDevProps<TDim, TIdx>
static auto getAccDevProps(DevGenericSycl<TTag> const& dev) -> AccDevProps<TDim, TIdx>
{
auto const device = dev.getNativeHandle().first;
auto const max_threads_dim
Expand Down Expand Up @@ -160,63 +159,53 @@ namespace alpaka::trait
};

//! The SYCL accelerator name trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct GetAccName<AccGenericSycl<TSelector, TDim, TIdx>>
template<typename TTag, typename TDim, typename TIdx>
struct GetAccName<AccGenericSycl<TTag, TDim, TIdx>>
{
static auto getAccName() -> std::string
{
// TODO implement TSelector::name
return std::string("Acc") + TSelector::name + "<" + std::to_string(TDim::value) + ","
+ core::demangled<TIdx> + ">";
return std::string("Acc") + detail::SYCLDeviceSelector<TTag>::name + "<" + std::to_string(TDim::value)
+ "," + core::demangled<TIdx> + ">";
}
};

//! The SYCL accelerator device type trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct DevType<AccGenericSycl<TSelector, TDim, TIdx>>
template<typename TTag, typename TDim, typename TIdx>
struct DevType<AccGenericSycl<TTag, TDim, TIdx>>
{
using type = DevGenericSycl<PlatformGenericSycl<TSelector>>;
using type = DevGenericSycl<TTag>;
};

//! The SYCL accelerator dimension getter trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct DimType<AccGenericSycl<TSelector, TDim, TIdx>>
template<typename TTag, typename TDim, typename TIdx>
struct DimType<AccGenericSycl<TTag, TDim, TIdx>>
{
using type = TDim;
};

//! The SYCL accelerator execution task type trait specialization.
template<
typename TSelector,
typename TDim,
typename TIdx,
typename TWorkDiv,
typename TKernelFnObj,
typename... TArgs>
struct CreateTaskKernel<AccGenericSycl<TSelector, TDim, TIdx>, TWorkDiv, TKernelFnObj, TArgs...>
template<typename TTag, typename TDim, typename TIdx, typename TWorkDiv, typename TKernelFnObj, typename... TArgs>
struct CreateTaskKernel<AccGenericSycl<TTag, TDim, TIdx>, TWorkDiv, TKernelFnObj, TArgs...>
{
static auto createTaskKernel(TWorkDiv const& workDiv, TKernelFnObj const& kernelFnObj, TArgs&&... args)
{
return TaskKernelGenericSycl<
TSelector,
AccGenericSycl<TSelector, TDim, TIdx>,
TDim,
TIdx,
TKernelFnObj,
TArgs...>{workDiv, kernelFnObj, std::forward<TArgs>(args)...};
return TaskKernelGenericSycl<TTag, AccGenericSycl<TTag, TDim, TIdx>, TDim, TIdx, TKernelFnObj, TArgs...>{
workDiv,
kernelFnObj,
std::forward<TArgs>(args)...};
}
};

//! The SYCL execution task platform type trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct PlatformType<AccGenericSycl<TSelector, TDim, TIdx>>
template<typename TTag, typename TDim, typename TIdx>
struct PlatformType<AccGenericSycl<TTag, TDim, TIdx>>
{
using type = PlatformGenericSycl<TSelector>;
using type = PlatformGenericSycl<TTag>;
};

//! The SYCL accelerator idx type trait specialization.
template<typename TSelector, typename TDim, typename TIdx>
struct IdxType<AccGenericSycl<TSelector, TDim, TIdx>>
template<typename TTag, typename TDim, typename TIdx>
struct IdxType<AccGenericSycl<TTag, TDim, TIdx>>
{
using type = TIdx;
};
Expand Down
3 changes: 1 addition & 2 deletions include/alpaka/acc/AccGpuSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "alpaka/acc/AccGenericSycl.hpp"
#include "alpaka/acc/Tag.hpp"
#include "alpaka/core/Sycl.hpp"
#include "alpaka/platform/PlatformGpuSyclIntel.hpp"

#include <string>
#include <utility>
Expand All @@ -20,7 +19,7 @@ namespace alpaka
//!
//! This accelerator allows parallel kernel execution on a oneAPI-capable Intel GPU target device.
template<typename TDim, typename TIdx>
using AccGpuSyclIntel = AccGenericSycl<detail::IntelGpuSelector, TDim, TIdx>;
using AccGpuSyclIntel = AccGenericSycl<TagGpuSyclIntel, TDim, TIdx>;

namespace trait
{
Expand Down
4 changes: 2 additions & 2 deletions include/alpaka/dev/DevCpuSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#pragma once

#include "alpaka/acc/Tag.hpp"
#include "alpaka/dev/DevGenericSycl.hpp"
#include "alpaka/platform/PlatformCpuSycl.hpp"

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

namespace alpaka
{
using DevCpuSycl = DevGenericSycl<PlatformCpuSycl>;
using DevCpuSycl = DevGenericSycl<TagCpuSycl>;
} // namespace alpaka

#endif
4 changes: 2 additions & 2 deletions include/alpaka/dev/DevFpgaSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#pragma once

#include "alpaka/acc/Tag.hpp"
#include "alpaka/dev/DevGenericSycl.hpp"
#include "alpaka/platform/PlatformFpgaSyclIntel.hpp"

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

namespace alpaka
{
using DevFpgaSyclIntel = DevGenericSycl<PlatformFpgaSyclIntel>;
using DevFpgaSyclIntel = DevGenericSycl<TagFpgaSyclIntel>;
} // namespace alpaka

#endif
Loading

0 comments on commit da1061b

Please sign in to comment.