alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
include
alpaka
api
host
memFence.hpp
Go to the documentation of this file.
1
/* Copyright 2025 Mehmet Yusufoglu, René Widera
2
* SPDX-License-Identifier: MPL-2.0
3
*/
4
5
#pragma once
6
7
#include "
alpaka/api/host/Api.hpp
"
8
#include "
alpaka/api/host/executor.hpp
"
9
#include "
alpaka/api/host/memoryOrder.hpp
"
10
#include "
alpaka/api/host/tag.hpp
"
11
#include "
alpaka/core/common.hpp
"
12
#include "
alpaka/onAcc/Acc.hpp
"
13
#include "
alpaka/onAcc/memoryOrder.hpp
"
14
#include "
alpaka/onAcc/scope.hpp
"
15
#include "
alpaka/tag.hpp
"
16
17
#include <atomic>
18
#include <type_traits>
19
20
namespace
alpaka::onAcc::internalCompute
21
{
22
namespace
detail
23
{
24
// suppress warning: `warning: 'atomic_thread_fence' is not supported with '-fsanitize=thread' [-Wtsan]`
25
#if defined(__GNUC__) && !defined(__clang__)
26
# pragma GCC diagnostic push
27
# pragma GCC diagnostic ignored "-Wtsan"
28
#endif
29
30
constexpr
void
hostMemoryFenceImpl
(
auto
const
&,
auto
const
scope
,
concepts::MemoryOrder
auto
const
order
)
31
{
32
using
ScopeT = std::remove_cvref_t<
decltype
(
scope
)>;
33
34
// Block scope requires no fence since threads within a block are simulated/single-threaded
35
if
constexpr
(!std::same_as<ScopeT, scope::Block>)
36
{
37
std::atomic_thread_fence(
MemOrderHost::get
(
order
));
38
}
39
}
40
#if defined(__GNUC__) && !defined(__clang__)
41
# pragma GCC diagnostic pop
42
#endif
43
}
// namespace detail
44
45
// Host API: dispatch to executor-specific implementation
46
template
<
typename
T_Scope, concepts::MemoryOrder T_Order>
47
struct
MemoryFence::Op
<
api
::Host, T_Scope, T_Order>
48
{
49
void
operator()
(
onAcc::concepts::Acc<api::Host>
auto
const
& acc, T_Scope
const
scope
, T_Order
const
order
)
50
const
51
{
52
detail::hostMemoryFenceImpl
(acc[object::exec],
scope
,
order
);
53
}
54
};
55
}
// namespace alpaka::onAcc::internalCompute
Acc.hpp
executor.hpp
memoryOrder.hpp
tag.hpp
common.hpp
alpaka::onAcc::concepts::Acc
Concept to check if a type is an accelerator.
Definition
Acc.hpp:119
alpaka::onAcc::concepts::MemoryOrder
Definition
memoryOrder.hpp:118
Api.hpp
alpaka::api
Definition
api.hpp:47
alpaka::onAcc::internalCompute::detail
Definition
memFence.hpp:23
alpaka::onAcc::internalCompute::detail::hostMemoryFenceImpl
constexpr void hostMemoryFenceImpl(auto const &, auto const scope, concepts::MemoryOrder auto const order)
Definition
memFence.hpp:30
alpaka::onAcc::internalCompute
Definition
atomic.hpp:56
alpaka::onAcc::order
Definition
memoryOrder.hpp:24
alpaka::onAcc::scope
Definition
scope.hpp:24
memoryOrder.hpp
scope.hpp
alpaka::onAcc::internalCompute::MemOrderHost::get
static constexpr auto get(TMemOrder const)
Definition
memoryOrder.hpp:17
alpaka::onAcc::internalCompute::MemoryFence::Op< api::Host, T_Scope, T_Order >::operator()
void operator()(onAcc::concepts::Acc< api::Host > auto const &acc, T_Scope const scope, T_Order const order) const
Definition
memFence.hpp:49
alpaka::onAcc::internalCompute::MemoryFence::Op
Definition
interface.hpp:104
tag.hpp
Generated on
for alpaka by
1.16.1