alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
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
10#include "alpaka/onAcc/Acc.hpp"
13
14#include <type_traits>
15
16#if ALPAKA_LANG_HIP
17
19{
20 /** Specializations should not have to be enabled for backend combinations without HIP
21 * Removing this top level guard will not cause issues if intrinsics like __builtin_amdgcn_fence are protected
22 * inside the specialization.
23 */
24 template<typename T_Api, typename T_Scope, concepts::MemoryOrder T_Order>
25 requires std::same_as<T_Api, api::Hip>
26 struct MemoryFence::Op<T_Api, T_Scope, T_Order>
27 {
28 ALPAKA_FN_ACC constexpr void operator()(
29 onAcc::concepts::Acc auto const&,
30 T_Scope const,
31 [[maybe_unused]] T_Order const order) const
32 {
33 // Host pass is not allowed.
34# if ALPAKA_ARCH_AMD
35 if constexpr(std::is_same_v<T_Scope, scope::Block>)
36 {
37 __builtin_amdgcn_fence(MemOrderHip::get(order), "workgroup");
38 }
39 else if constexpr(std::is_same_v<T_Scope, scope::Device>)
40 {
41 __builtin_amdgcn_fence(MemOrderHip::get(order), "agent");
42 }
43 else if constexpr(std::is_same_v<T_Scope, scope::System>)
44 {
45 // empty string refers to system
46 __builtin_amdgcn_fence(MemOrderHip::get(order), "");
47 }
48# endif
49 }
50 };
51} // namespace alpaka::onAcc::internalCompute
52
53#endif // ALPAKA_LANG_HIP
#define ALPAKA_FN_ACC
All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_F...
Definition common.hpp:30
constexpr void operator()(T_Acc const &acc, T_MemoryOrder const order, T_Scope const scope) const