Debian Codegraph @

libclc/opencl/lib/amdgcn-amdhsa/workitem/get_global_size.cl

raw
1 //===----------------------------------------------------------------------===//
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 #include <clc/opencl/workitem/get_global_size.h>
10
11 #if __clang_major__ >= 8
12 #define CONST_AS __constant
13 #elif __clang_major__ >= 7
14 #define CONST_AS __attribute__((address_space(4)))
15 #else
16 #define CONST_AS __attribute__((address_space(2)))
17 #endif
18
19 #if __clang_major__ >= 6
20 #define __dispatch_ptr __builtin_amdgcn_dispatch_ptr
21 #else
22 #define __dispatch_ptr __clc_amdgcn_dispatch_ptr
23 CONST_AS uchar *
24 __clc_amdgcn_dispatch_ptr(void) __asm("llvm.amdgcn.dispatch.ptr");
25 #endif
26
27 _CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) {
28 CONST_AS uint *ptr = (CONST_AS uint *)__dispatch_ptr();
29 if (dim < 3)
30 return ptr[3 + dim];
31 return 1;
32 }