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()25LIBC_INLINE uint32_t get_num_blocks_x() { return 1; } 26 get_num_blocks_y()27LIBC_INLINE uint32_t get_num_blocks_y() { return 1; } 28 get_num_blocks_z()29LIBC_INLINE uint32_t get_num_blocks_z() { return 1; } 30 get_num_blocks()31LIBC_INLINE uint64_t get_num_blocks() { return 1; } 32 get_block_id_x()33LIBC_INLINE uint32_t get_block_id_x() { return 0; } 34 get_block_id_y()35LIBC_INLINE uint32_t get_block_id_y() { return 0; } 36 get_block_id_z()37LIBC_INLINE uint32_t get_block_id_z() { return 0; } 38 get_block_id()39LIBC_INLINE uint64_t get_block_id() { return 0; } 40 get_num_threads_x()41LIBC_INLINE uint32_t get_num_threads_x() { return 1; } 42 get_num_threads_y()43LIBC_INLINE uint32_t get_num_threads_y() { return 1; } 44 get_num_threads_z()45LIBC_INLINE uint32_t get_num_threads_z() { return 1; } 46 get_num_threads()47LIBC_INLINE uint64_t get_num_threads() { return 1; } 48 get_thread_id_x()49LIBC_INLINE uint32_t get_thread_id_x() { return 0; } 50 get_thread_id_y()51LIBC_INLINE uint32_t get_thread_id_y() { return 0; } 52 get_thread_id_z()53LIBC_INLINE uint32_t get_thread_id_z() { return 0; } 54 get_thread_id()55LIBC_INLINE uint64_t get_thread_id() { return 0; } 56 get_lane_size()57LIBC_INLINE uint32_t get_lane_size() { return 1; } 58 get_lane_id()59LIBC_INLINE uint32_t get_lane_id() { return 0; } 60 get_lane_mask()61LIBC_INLINE uint64_t get_lane_mask() { return 1; } 62 broadcast_value(uint64_t,uint32_t x)63LIBC_INLINE uint32_t broadcast_value(uint64_t, uint32_t x) { return x; } 64 ballot(uint64_t,bool x)65LIBC_INLINE uint64_t ballot(uint64_t, bool x) { return x; } 66 sync_threads()67LIBC_INLINE void sync_threads() {} 68 sync_lane(uint64_t)69LIBC_INLINE void sync_lane(uint64_t) {} 70 shuffle(uint64_t,uint32_t,uint32_t x)71LIBC_INLINE uint32_t shuffle(uint64_t, uint32_t, uint32_t x) { return x; } 72 processor_clock()73LIBC_INLINE uint64_t processor_clock() { return 0; } 74 fixed_frequency_clock()75LIBC_INLINE uint64_t fixed_frequency_clock() { return 0; } 76 end_program()77[[noreturn]] LIBC_INLINE void end_program() { __builtin_unreachable(); } 78 get_cluster_id()79LIBC_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