Skip to content

Commit

Permalink
use device type instead acc type
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonEhrig committed Apr 22, 2024
1 parent 1ee3b65 commit 13f9170
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 76 deletions.
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccCpuOmp2Blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ namespace alpaka
{
using type = alpaka::AccCpuOmp2Blocks<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace trait
} // namespace alpaka

Expand Down
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccCpuOmp2Threads.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,6 @@ namespace alpaka
{
using type = alpaka::AccCpuOmp2Threads<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace trait
} // namespace alpaka

Expand Down
7 changes: 0 additions & 7 deletions include/alpaka/acc/AccCpuSerial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "alpaka/acc/Tag.hpp"
#include "alpaka/core/Concepts.hpp"
#include "alpaka/dev/DevCpu.hpp"
#include "alpaka/mem/Visibility.hpp"

#include <memory>
#include <typeinfo>
Expand Down Expand Up @@ -203,12 +202,6 @@ namespace alpaka
{
using type = alpaka::AccCpuSerial<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace trait
} // namespace alpaka

Expand Down
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccCpuSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ namespace alpaka::trait
{
using type = alpaka::AccCpuSycl<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace alpaka::trait

#endif
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccCpuTbbBlocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@ namespace alpaka
{
using type = alpaka::AccCpuTbbBlocks<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace trait
} // namespace alpaka

Expand Down
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccCpuThreads.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,6 @@ namespace alpaka
{
using type = alpaka::AccCpuThreads<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace trait
} // namespace alpaka

Expand Down
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccFpgaSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ namespace alpaka::trait
{
using type = alpaka::AccFpgaSyclIntel<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleFpgaSyclIntel;
};
} // namespace alpaka::trait

#endif
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccGenericSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ namespace alpaka::trait
using type = TAcc<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleGenericSycl;
};

//! The SYCL accelerator device properties get trait specialization.
template<template<typename, typename> typename TAcc, typename TDim, typename TIdx>
struct GetAccDevProps<
Expand Down
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccGpuCudaRt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ namespace alpaka
{
using type = alpaka::AccGpuCudaRt<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleGpuCudaRt;
};
} // namespace trait
} // namespace alpaka

Expand Down
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccGpuHipRt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ namespace alpaka
{
using type = alpaka::AccGpuHipRt<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleGpuHipRt;
};
} // namespace trait
} // namespace alpaka

Expand Down
6 changes: 0 additions & 6 deletions include/alpaka/acc/AccGpuSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ namespace alpaka::trait
{
using type = alpaka::AccGpuSyclIntel<TDim, TIdx>;
};

template<typename TDim, typename TIdx>
struct MemVisibility<alpaka::AccCpuSerial<TDim, TIdx>>
{
using type = alpaka::MemVisibleGpuSyclIntel;
};
} // namespace alpaka::trait

#endif
2 changes: 2 additions & 0 deletions include/alpaka/alpaka.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
#include "alpaka/math/MathStdLib.hpp"
#include "alpaka/math/MathUniformCudaHipBuiltIn.hpp"
// mem
#include "alpaka/mem/Visibility.hpp"
#include "alpaka/mem/alloc/AllocCpuAligned.hpp"
#include "alpaka/mem/alloc/AllocCpuNew.hpp"
#include "alpaka/mem/alloc/Traits.hpp"
Expand Down Expand Up @@ -170,6 +171,7 @@
#include "alpaka/meta/Integral.hpp"
#include "alpaka/meta/IsArrayOrVector.hpp"
#include "alpaka/meta/IsStrictBase.hpp"
#include "alpaka/meta/IsTuple.hpp"
#include "alpaka/meta/NdLoop.hpp"
#include "alpaka/meta/NonZero.hpp"
#include "alpaka/meta/Set.hpp"
Expand Down
7 changes: 7 additions & 0 deletions include/alpaka/dev/DevCpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "alpaka/dev/Traits.hpp"
#include "alpaka/dev/common/QueueRegistry.hpp"
#include "alpaka/dev/cpu/SysInfo.hpp"
#include "alpaka/mem/Visibility.hpp"
#include "alpaka/mem/buf/Traits.hpp"
#include "alpaka/platform/Traits.hpp"
#include "alpaka/queue/Properties.hpp"
Expand Down Expand Up @@ -185,6 +186,12 @@ namespace alpaka
{
using type = PlatformCpu;
};

template<>
struct MemVisibility<DevCpu>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace trait

using QueueCpuNonBlocking = QueueGenericThreadsNonBlocking<DevCpu>;
Expand Down
9 changes: 9 additions & 0 deletions include/alpaka/dev/DevCpuSycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
namespace alpaka
{
using DevCpuSycl = DevGenericSycl<PlatformCpuSycl>;

namespace trait
{
template<>
struct MemVisibility<DevCpuSycl>
{
using type = alpaka::MemVisibleCPU;
};
} // namespace trait
} // namespace alpaka

#endif
9 changes: 9 additions & 0 deletions include/alpaka/dev/DevCudaRt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ namespace alpaka
{
//! The CUDA RT device handle.
using DevCudaRt = DevUniformCudaHipRt<ApiCudaRt>;

namespace trait
{
template<>
struct MemVisibility<DevCudaRt>
{
using type = alpaka::MemVisibleGpuCudaRt;
};
} // namespace trait
} // namespace alpaka

#endif // ALPAKA_ACC_GPU_CUDA_ENABLED
9 changes: 9 additions & 0 deletions include/alpaka/dev/DevFpgaSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
namespace alpaka
{
using DevFpgaSyclIntel = DevGenericSycl<PlatformFpgaSyclIntel>;

namespace trait
{
template<>
struct MemVisibility<DevFpgaSyclIntel>
{
using type = alpaka::MemVisibleFpgaSyclIntel;
};
} // namespace trait
} // namespace alpaka

#endif
9 changes: 9 additions & 0 deletions include/alpaka/dev/DevGpuSyclIntel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
namespace alpaka
{
using DevGpuSyclIntel = DevGenericSycl<PlatformGpuSyclIntel>;

namespace trait
{
template<>
struct MemVisibility<DevGpuSyclIntel>
{
using type = alpaka::MemVisibleGpuSyclIntel;
};
} // namespace trait
} // namespace alpaka

#endif
9 changes: 9 additions & 0 deletions include/alpaka/dev/DevHipRt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ namespace alpaka
{
//! The HIP RT device handle.
using DevHipRt = DevUniformCudaHipRt<ApiHipRt>;

namespace trait
{
template<>
struct MemVisibility<DevHipRt>
{
using type = alpaka::MemVisibleGpuHipRt;
};
} // namespace trait
} // namespace alpaka

#endif // ALPAKA_ACC_GPU_HIP_ENABLED
67 changes: 62 additions & 5 deletions include/alpaka/mem/Visibility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

#pragma once

#include "alpaka/meta/ForEachType.hpp"
#include "alpaka/meta/IsTuple.hpp"
#include "alpaka/meta/TypeListOps.hpp"

#include <iostream>
#include <sstream>
#include <string>

#define CREATE_MEM_VISIBILITY(mem_name) \
struct mem_name \
{ \
static std::string get_name() \
static std::string name() \
{ \
return #mem_name; \
} \
Expand All @@ -31,17 +35,70 @@ namespace alpaka
//! Get memory visibility from a type.
//! Normally it is acc or buffer type.
//!
//! \tparam Type which implements the trait
//! \return Memory visibility type
//! \tparam TType which implements the trait
template<typename TType>
struct MemVisibility;
} // namespace trait

template<typename TAcc, typename TBuf>
namespace detail
{
struct AppendMemTypeName
{
template<typename TTYPE>
void operator()(std::vector<std::string>& vs)
{
vs.push_back(TTYPE::name());
}
};
} // namespace detail

template<typename TType>
static std::string getMemVisiblityName()
{
using MemVisibilityType = typename alpaka::trait::MemVisibility<std::decay_t<TType>>::type;
if constexpr(alpaka::meta::isTuple<MemVisibilityType>())
{
std::vector<std::string> vs;
alpaka::meta::forEachType<MemVisibilityType>(detail::AppendMemTypeName{}, vs);

std::stringstream ss;
ss << "<";
for(auto i = 0; i < vs.size(); ++i)
{
if(i == (vs.size() - 1))
{
ss << vs[i] << ">";
}
else
{
ss << vs[i] << ", ";
}
}
return ss.str();
}
else
{
return MemVisibilityType::name();
}
}

template<typename TType>
static std::string getMemVisiblityName(TType)
{
return getMemVisiblityName<TType>();
}

template<typename TDev, typename TBuf>
inline constexpr bool hasSameMemView()
{
return alpaka::meta::Contains<
typename alpaka::trait::MemVisibility<TBuf>::type,
typename alpaka::trait::MemVisibility<TAcc>::type>::value;
typename alpaka::trait::MemVisibility<TDev>::type>::value;
}

template<typename TDev, typename TBuf>
inline constexpr bool hasSameMemView(TDev, TBuf)
{
return hasSameMemView<std::decay_t<TDev>, std::decay_t<TBuf>>();
}
} // namespace alpaka
13 changes: 9 additions & 4 deletions include/alpaka/mem/buf/BufCudaRt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
#pragma once

#include "alpaka/core/ApiCudaRt.hpp"
#include "alpaka/mem/Visibility.hpp"
#include "alpaka/mem/buf/BufUniformCudaHipRt.hpp"


#ifdef ALPAKA_ACC_GPU_CUDA_ENABLED

namespace alpaka
{
template<typename TElem, typename TDim, typename TIdx>
using BufCudaRt = BufUniformCudaHipRt<ApiCudaRt, TElem, TDim, TIdx>;

template<typename TElem, typename TDim, typename TIdx>
struct MemVisibility<BufCudaRt<TElem, TDim, TIdx>>
namespace trait
{
using type = std::tuple<alpaka::MemVisibleGpuCudaRt>;
};
template<typename TElem, typename TDim, typename TIdx>
struct MemVisibility<BufCudaRt<TElem, TDim, TIdx>>
{
using type = std::tuple<alpaka::MemVisibleGpuCudaRt>;
};
} // namespace trait
} // namespace alpaka

#endif // ALPAKA_ACC_GPU_CUDA_ENABLED
Loading

0 comments on commit 13f9170

Please sign in to comment.