Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / src / __support / GPU / generic / utils.h
blobb701db482bbe98d3e2d0bb3b634d6983baada504
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC___SUPPORT_GPU_GENERIC_IO_H
10 #define LLVM_LIBC_SRC___SUPPORT_GPU_GENERIC_IO_H
12 #include "src/__support/common.h"
14 #include <stdint.h>
16 namespace LIBC_NAMESPACE {
17 namespace gpu {
19 constexpr const uint64_t LANE_SIZE = 1;
21 template <typename T> using Private = T;
22 template <typename T> using Constant = T;
23 template <typename T> using Shared = T;
24 template <typename T> using Global = T;
26 LIBC_INLINE uint32_t get_num_blocks_x() { return 1; }
28 LIBC_INLINE uint32_t get_num_blocks_y() { return 1; }
30 LIBC_INLINE uint32_t get_num_blocks_z() { return 1; }
32 LIBC_INLINE uint64_t get_num_blocks() { return 1; }
34 LIBC_INLINE uint32_t get_block_id_x() { return 0; }
36 LIBC_INLINE uint32_t get_block_id_y() { return 0; }
38 LIBC_INLINE uint32_t get_block_id_z() { return 0; }
40 LIBC_INLINE uint64_t get_block_id() { return 0; }
42 LIBC_INLINE uint32_t get_num_threads_x() { return 1; }
44 LIBC_INLINE uint32_t get_num_threads_y() { return 1; }
46 LIBC_INLINE uint32_t get_num_threads_z() { return 1; }
48 LIBC_INLINE uint64_t get_num_threads() { return 1; }
50 LIBC_INLINE uint32_t get_thread_id_x() { return 0; }
52 LIBC_INLINE uint32_t get_thread_id_y() { return 0; }
54 LIBC_INLINE uint32_t get_thread_id_z() { return 0; }
56 LIBC_INLINE uint64_t get_thread_id() { return 0; }
58 LIBC_INLINE uint32_t get_lane_size() { return LANE_SIZE; }
60 LIBC_INLINE uint32_t get_lane_id() { return 0; }
62 LIBC_INLINE uint64_t get_lane_mask() { return 1; }
64 LIBC_INLINE uint32_t broadcast_value(uint64_t, uint32_t x) { return x; }
66 LIBC_INLINE uint64_t ballot(uint64_t, bool x) { return x; }
68 LIBC_INLINE void sync_threads() {}
70 LIBC_INLINE void sync_lane(uint64_t) {}
72 LIBC_INLINE uint64_t processor_clock() { return 0; }
74 LIBC_INLINE uint64_t fixed_frequency_clock() { return 0; }
76 [[noreturn]] LIBC_INLINE void end_program() { __builtin_unreachable(); }
78 } // namespace gpu
79 } // namespace LIBC_NAMESPACE
81 #endif