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