Debian Codegraph @

libclc/opencl/lib/amdgcn-amdhsa/workitem/get_local_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_local_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 char *
24 __clc_amdgcn_dispatch_ptr(void) __asm("llvm.amdgcn.dispatch.ptr");
25 #endif
26
27 _CLC_DEF _CLC_OVERLOAD size_t get_local_size(uint dim) {
28 CONST_AS uint *ptr = (CONST_AS uint *)__dispatch_ptr();
29 switch (dim) {
30 case 0:
31 return ptr[1] & 0xffffu;
32 case 1:
33 return ptr[1] >> 16;
34 case 2:
35 return ptr[2] & 0xffffu;
36 }
37 return 1;
38 }