This repository was archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathbarrier.hpp
More file actions
96 lines (84 loc) · 2.92 KB
/
Copy pathbarrier.hpp
File metadata and controls
96 lines (84 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*******************************************************************************
* Copyright (c) 2022-2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
/// @file
/// C++ API
#pragma once
#include <common/core/common.hpp>
namespace gpu::xetla {
/// @addtogroup xetla_core_barrier
/// @{
/// sw_barrier, insert software scheduling barrier, for better code control
///
void sw_barrier() {
#if __INTEL_LLVM_COMPILER >= 20250000
#else
__ESIMD_NS::fence<__ESIMD_NS::fence_mask::sw_barrier>();
#endif
}
/// @brief Initialize the number of named barrier index for a kernel.
/// Available only on PVC. Only need to initialize once at the beginning.
///
/// @tparam NbarCount - number of named barriers.
template <uint8_t NbarCount>
__XETLA_API void xetla_nbarrier_init() {
if constexpr (NbarCount != 0) {
#if __INTEL_LLVM_COMPILER >= 20250000
__ESIMD_NS::named_barrier_init<NbarCount>();
#else
__ESIMD_ENS::named_barrier_init<NbarCount>();
#endif
}
}
/// @brief Perform signal operation for the given named barrier id.
/// Available only on PVC.
///
/// @param barrier_id [in] is the named barrier id.
///
/// @param producer_consumer_mode [in] is 2-bit flag to indicate if it's
/// producer-consumer mode(0x0) or producer mode (0x1) or consumer mode (0x2).
/// User must ensure the input value is set correctly and higher order bits are
/// cleared.
///
/// @param num_producers [in] is the number of producers.
///
/// @param num_consumers [in] is the number of consumers.
__XETLA_API void named_barrier_signal(
uint8_t barrier_id,
uint8_t producer_consumer_mode,
uint32_t num_producers,
uint32_t num_consumers) {
#if __INTEL_LLVM_COMPILER >= 20250000
__ESIMD_NS::named_barrier_signal(
barrier_id, producer_consumer_mode, num_producers, num_consumers);
#else
__ESIMD_ENS::named_barrier_signal(
barrier_id, producer_consumer_mode, num_producers, num_consumers);
#endif
}
/// @brief Wait on a named barrier.
/// Available only on PVC
///
/// @param barrier_id [in] is the named barrier id.
/// It’s value cannot exceed the total count of initialized named barriers.
__XETLA_API void named_barrier_wait(uint8_t barrier_id) {
#if __INTEL_LLVM_COMPILER >= 20250000
__ESIMD_NS::named_barrier_wait(barrier_id);
#else
__ESIMD_ENS::named_barrier_wait(barrier_id);
#endif
}
/// @} xetla_core_barrier
} // namespace gpu::xetla