alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
Device.hpp
Go to the documentation of this file.
1/* Copyright 2024 René Widera
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
10
11#if ALPAKA_LANG_HIP
13
14# include <type_traits>
15
16namespace alpaka::onHost
17{
18 namespace trait
19 {
20 template<typename T_Platform>
21 struct IsExecutorSupportedBy::Op<exec::GpuHip, unifiedCudaHip::Device<T_Platform>> : std::true_type
22 {
23 };
24 } // namespace trait
25} // namespace alpaka::onHost
26
28{
29 template<alpaka::concepts::DeviceKind T_DeviceKind, typename T_Any>
30 struct IsDataAccessible::SecondPath<api::Hip, T_DeviceKind, T_Any>
31 {
32 bool operator()(api::Hip usedApi, T_DeviceKind deviceKind, T_Any const& view) const
33 {
34 alpaka::unused(usedApi);
35 using ApiInterface = ApiHipRt;
36 typename ApiInterface::PointerAttr_t ptrAttributes;
37 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK(
38 ApiInterface,
39 ApiInterface::pointerGetAttributes(&ptrAttributes, onHost::data(view)));
40
41 if(ptrAttributes.type == ApiInterface::memoryTypeManaged)
42 return true;
43 if(ptrAttributes.type == ApiInterface::memoryTypeHost
44 && (deviceKind == deviceKind::cpu || deviceKind == deviceKind::numaCpu))
45 return true;
46
47 return false;
48 }
49 };
50} // namespace alpaka::onHost::internal
51
52#endif
constexpr auto cpu
Definition tag.hpp:170
constexpr auto numaCpu
Definition tag.hpp:180
constexpr Api api
Definition tag.hpp:24
Functionality which is usable on the host CPU controller thread.
Definition api.hpp:40
decltype(auto) data(auto &&any)
pointer to data of an object
bool operator()(T_DataApi, T_DeviceKind, T_Any const &) const