xref: /aosp_15_r20/external/llvm-libc/src/__support/GPU/generic/utils.h (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-------------- Generic implementation of GPU utils ---------*- C++ -*-===//
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_GPU_GENERIC_UTILS_H
10 #define LLVM_LIBC_SRC___SUPPORT_GPU_GENERIC_UTILS_H
11 
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14 
15 #include <stdint.h>
16 
17 namespace LIBC_NAMESPACE_DECL {
18 namespace gpu {
19 
20 template <typename T> using Private = T;
21 template <typename T> using Constant = T;
22 template <typename T> using Shared = T;
23 template <typename T> using Global = T;
24 
get_num_blocks_x()25 LIBC_INLINE uint32_t get_num_blocks_x() { return 1; }
26 
get_num_blocks_y()27 LIBC_INLINE uint32_t get_num_blocks_y() { return 1; }
28 
get_num_blocks_z()29 LIBC_INLINE uint32_t get_num_blocks_z() { return 1; }
30 
get_num_blocks()31 LIBC_INLINE uint64_t get_num_blocks() { return 1; }
32 
get_block_id_x()33 LIBC_INLINE uint32_t get_block_id_x() { return 0; }
34 
get_block_id_y()35 LIBC_INLINE uint32_t get_block_id_y() { return 0; }
36 
get_block_id_z()37 LIBC_INLINE uint32_t get_block_id_z() { return 0; }
38 
get_block_id()39 LIBC_INLINE uint64_t get_block_id() { return 0; }
40 
get_num_threads_x()41 LIBC_INLINE uint32_t get_num_threads_x() { return 1; }
42 
get_num_threads_y()43 LIBC_INLINE uint32_t get_num_threads_y() { return 1; }
44 
get_num_threads_z()45 LIBC_INLINE uint32_t get_num_threads_z() { return 1; }
46 
get_num_threads()47 LIBC_INLINE uint64_t get_num_threads() { return 1; }
48 
get_thread_id_x()49 LIBC_INLINE uint32_t get_thread_id_x() { return 0; }
50 
get_thread_id_y()51 LIBC_INLINE uint32_t get_thread_id_y() { return 0; }
52 
get_thread_id_z()53 LIBC_INLINE uint32_t get_thread_id_z() { return 0; }
54 
get_thread_id()55 LIBC_INLINE uint64_t get_thread_id() { return 0; }
56 
get_lane_size()57 LIBC_INLINE uint32_t get_lane_size() { return 1; }
58 
get_lane_id()59 LIBC_INLINE uint32_t get_lane_id() { return 0; }
60 
get_lane_mask()61 LIBC_INLINE uint64_t get_lane_mask() { return 1; }
62 
broadcast_value(uint64_t,uint32_t x)63 LIBC_INLINE uint32_t broadcast_value(uint64_t, uint32_t x) { return x; }
64 
ballot(uint64_t,bool x)65 LIBC_INLINE uint64_t ballot(uint64_t, bool x) { return x; }
66 
sync_threads()67 LIBC_INLINE void sync_threads() {}
68 
sync_lane(uint64_t)69 LIBC_INLINE void sync_lane(uint64_t) {}
70 
shuffle(uint64_t,uint32_t,uint32_t x)71 LIBC_INLINE uint32_t shuffle(uint64_t, uint32_t, uint32_t x) { return x; }
72 
processor_clock()73 LIBC_INLINE uint64_t processor_clock() { return 0; }
74 
fixed_frequency_clock()75 LIBC_INLINE uint64_t fixed_frequency_clock() { return 0; }
76 
end_program()77 [[noreturn]] LIBC_INLINE void end_program() { __builtin_unreachable(); }
78 
get_cluster_id()79 LIBC_INLINE uint32_t get_cluster_id() { return 0; }
80 
81 } // namespace gpu
82 } // namespace LIBC_NAMESPACE_DECL
83 
84 #endif // LLVM_LIBC_SRC___SUPPORT_GPU_GENERIC_UTILS_H
85