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_CUDA
12
14
15# include <type_traits>
16
17namespace alpaka::onHost
18{
19 namespace trait
20 {
21 template<typename T_Platform>
22 struct IsExecutorSupportedBy::Op<exec::GpuCuda, unifiedCudaHip::Device<T_Platform>> : std::true_type
23 {
24 };
25 } // namespace trait
26} // namespace alpaka::onHost
27
28namespace alpaka::onHost::internal
29{
30 template<alpaka::concepts::DeviceKind T_DeviceKind, typename T_Any>
31 struct IsDataAccessible::SecondPath<api::Cuda, T_DeviceKind, T_Any>
32 {
33 bool operator()(api::Cuda usedApi, T_DeviceKind deviceKind, T_Any const& view) const
34 {
35 alpaka::unused(usedApi);
36 using ApiInterface = ApiCudaRt;
37 typename ApiInterface::PointerAttr_t ptrAttributes;
38 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK(
39 ApiInterface,
40 ApiInterface::pointerGetAttributes(&ptrAttributes, onHost::data(view)));
41
42 if(ptrAttributes.type == ApiInterface::memoryTypeManaged)
43 return true;
44 if(ptrAttributes.type == ApiInterface::memoryTypeHost
45 && (deviceKind == deviceKind::cpu || deviceKind == deviceKind::numaCpu))
46 return true;
47
48 return false;
49 }
50 };
51} // namespace alpaka::onHost::internal
52
53#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