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

source code of libc/src/__support/GPU/generic/utils.h