File tree Expand file tree Collapse file tree 3 files changed +42
-15
lines changed Expand file tree Collapse file tree 3 files changed +42
-15
lines changed Original file line number Diff line number Diff line change 11
11
12
12
#include " src/__support/CPP/type_traits.h"
13
13
#include " src/__support/GPU/utils.h"
14
- #include " src/__support/macros/attributes.h" // LIBC_INLINE
14
+ #include " src/__support/macros/attributes.h"
15
15
#include " src/__support/macros/properties/architectures.h"
16
+ #include " src/__support/threads/sleep.h"
16
17
#include " src/string/memory_utils/generic/byte_per_byte.h"
17
18
#include " src/string/memory_utils/inline_memcpy.h"
18
19
19
20
namespace LIBC_NAMESPACE {
20
21
namespace rpc {
21
22
22
- // / Suspend the thread briefly to assist the thread scheduler during busy loops.
23
- LIBC_INLINE void sleep_briefly () {
24
- #if defined(LIBC_TARGET_ARCH_IS_NVPTX)
25
- if (__nvvm_reflect (" __CUDA_ARCH" ) >= 700 )
26
- LIBC_INLINE_ASM (" nanosleep.u32 64;" ::: " memory" );
27
- #elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
28
- __builtin_amdgcn_s_sleep (2 );
29
- #elif defined(LIBC_TARGET_ARCH_IS_X86)
30
- __builtin_ia32_pause ();
31
- #else
32
- // Simply do nothing if sleeping isn't supported on this platform.
33
- #endif
34
- }
35
-
36
23
// / Conditional to indicate if this process is running on the GPU.
37
24
LIBC_INLINE constexpr bool is_process_gpu () {
38
25
#if defined(LIBC_TARGET_ARCH_IS_GPU)
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ add_header_library(
4
4
mutex_common.h
5
5
)
6
6
7
+ add_header_library(
8
+ sleep
9
+ HDRS
10
+ sleep.h
11
+ )
12
+
7
13
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${LIBC_TARGET_OS} )
8
14
add_subdirectory (${LIBC_TARGET_OS} )
9
15
endif ()
Original file line number Diff line number Diff line change
1
+ // ===-- Utilities for suspending threads ----------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_SLEEP_H
10
+ #define LLVM_LIBC_SRC___SUPPORT_THREADS_SLEEP_H
11
+
12
+ #include " src/__support/macros/attributes.h"
13
+
14
+ namespace LIBC_NAMESPACE {
15
+
16
+ // / Suspend the thread briefly to assist the thread scheduler during busy loops.
17
+ LIBC_INLINE void sleep_briefly () {
18
+ #if defined(LIBC_TARGET_ARCH_IS_NVPTX)
19
+ if (__nvvm_reflect (" __CUDA_ARCH" ) >= 700 )
20
+ LIBC_INLINE_ASM (" nanosleep.u32 64;" ::: " memory" );
21
+ #elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
22
+ __builtin_amdgcn_s_sleep (2 );
23
+ #elif defined(LIBC_TARGET_ARCH_IS_X86)
24
+ __builtin_ia32_pause ();
25
+ #elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
26
+ __builtin_arm_isb (0xf );
27
+ #else
28
+ // Simply do nothing if sleeping isn't supported on this platform.
29
+ #endif
30
+ }
31
+
32
+ } // namespace LIBC_NAMESPACE
33
+
34
+ #endif // LLVM_LIBC_SRC___SUPPORT_THREADS_SLEEP_H
You can’t perform that action at this time.
0 commit comments