Skip to content

Commit cbda72a

Browse files
authored
[NFC][libclc] Merge atomic extension built-ins with identical name into a single file (#134489)
llvm-diff shows there is no change to amdgcn--amdhsa.bc. Similar to how cl_khr_fp64 and cl_khr_fp16 implementations are put in a same file for math built-ins, this PR do the same to atom_* built-ins. The main motivation is to prevent that two files with same base name implementats different built-ins. In a follow-up PR, I'd like to relax libclc_configure_lib_source to only compare filename instead of path for overriding, since in our downstream the same category of built-ins, e.g. math, are organized in several different folders.
1 parent dffef04 commit cbda72a

File tree

93 files changed

+761
-994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+761
-994
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_base_atomics
10+
#define __CLC_FUNCTION atom_add
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_base_atomics
14+
15+
#ifdef cl_khr_local_int32_base_atomics
16+
#define __CLC_FUNCTION atom_add
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_base_atomics
20+
21+
#ifdef cl_khr_int64_base_atomics
22+
#define __CLC_FUNCTION atom_add
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_base_atomics
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_extended_atomics
10+
#define __CLC_FUNCTION atom_and
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_extended_atomics
14+
15+
#ifdef cl_khr_local_int32_extended_atomics
16+
#define __CLC_FUNCTION atom_and
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_extended_atomics
20+
21+
#ifdef cl_khr_int64_extended_atomics
22+
#define __CLC_FUNCTION atom_and
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_extended_atomics
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#ifdef cl_khr_global_int32_base_atomics
13+
_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile global int *p, int cmp,
14+
int val);
15+
_CLC_OVERLOAD _CLC_DECL unsigned int
16+
atom_cmpxchg(volatile global unsigned int *p, unsigned int cmp,
17+
unsigned int val);
18+
#endif // cl_khr_global_int32_base_atomics
19+
20+
#ifdef cl_khr_local_int32_base_atomics
21+
_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile local int *p, int cmp,
22+
int val);
23+
_CLC_OVERLOAD _CLC_DECL unsigned int
24+
atom_cmpxchg(volatile local unsigned int *p, unsigned int cmp,
25+
unsigned int val);
26+
#endif // cl_khr_local_int32_base_atomics
27+
28+
#ifdef cl_khr_int64_base_atomics
29+
_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile global long *p, long cmp,
30+
long val);
31+
_CLC_OVERLOAD _CLC_DECL unsigned long
32+
atom_cmpxchg(volatile global unsigned long *p, unsigned long cmp,
33+
unsigned long val);
34+
_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile local long *p, long cmp,
35+
long val);
36+
_CLC_OVERLOAD _CLC_DECL unsigned long
37+
atom_cmpxchg(volatile local unsigned long *p, unsigned long cmp,
38+
unsigned long val);
39+
#endif // cl_khr_int64_base_atomics
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#ifdef cl_khr_global_int32_base_atomics
13+
_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile global int *p);
14+
_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile global unsigned int *p);
15+
#endif // cl_khr_global_int32_base_atomics
16+
17+
#ifdef cl_khr_local_int32_base_atomics
18+
_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile local int *p);
19+
_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile local unsigned int *p);
20+
#endif // cl_khr_local_int32_base_atomics
21+
22+
#ifdef cl_khr_int64_base_atomics
23+
_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile global long *p);
24+
_CLC_OVERLOAD _CLC_DECL unsigned long
25+
atom_dec(volatile global unsigned long *p);
26+
_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile local long *p);
27+
_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile local unsigned long *p);
28+
#endif // cl_khr_int64_base_atomics

libclc/generic/include/clc/atom_decl_int32.inc renamed to libclc/generic/include/clc/atomic/atom_decl_int32.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
10-
_CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, TYPE);
9+
#include <clc/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
13+
_CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION(volatile ADDRSPACE TYPE *, TYPE);
1114

1215
__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, int)
1316
__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, uint)

libclc/generic/include/clc/atom_decl_int64.inc renamed to libclc/generic/include/clc/atomic/atom_decl_int64.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
10-
_CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, TYPE);
9+
#include <clc/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
13+
_CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION(volatile ADDRSPACE TYPE *, TYPE);
1114

1215
__CLC_DECLARE_ATOM(local, long)
1316
__CLC_DECLARE_ATOM(local, ulong)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#ifdef cl_khr_global_int32_base_atomics
13+
_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile global int *p);
14+
_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile global unsigned int *p);
15+
#endif // cl_khr_global_int32_base_atomics
16+
17+
#ifdef cl_khr_local_int32_base_atomics
18+
_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile local int *p);
19+
_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile local unsigned int *p);
20+
#endif // cl_khr_local_int32_base_atomics
21+
22+
#ifdef cl_khr_int64_base_atomics
23+
_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile global long *p);
24+
_CLC_OVERLOAD _CLC_DECL unsigned long
25+
atom_inc(volatile global unsigned long *p);
26+
_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile local long *p);
27+
_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile local unsigned long *p);
28+
#endif // cl_khr_int64_base_atomics
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_extended_atomics
10+
#define __CLC_FUNCTION atom_max
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_extended_atomics
14+
15+
#ifdef cl_khr_local_int32_extended_atomics
16+
#define __CLC_FUNCTION atom_max
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_extended_atomics
20+
21+
#ifdef cl_khr_int64_extended_atomics
22+
#define __CLC_FUNCTION atom_max
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_extended_atomics
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_extended_atomics
10+
#define __CLC_FUNCTION atom_min
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_extended_atomics
14+
15+
#ifdef cl_khr_local_int32_extended_atomics
16+
#define __CLC_FUNCTION atom_min
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_extended_atomics
20+
21+
#ifdef cl_khr_int64_extended_atomics
22+
#define __CLC_FUNCTION atom_min
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_extended_atomics
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_extended_atomics
10+
#define __CLC_FUNCTION atom_or
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_extended_atomics
14+
15+
#ifdef cl_khr_local_int32_extended_atomics
16+
#define __CLC_FUNCTION atom_or
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_extended_atomics
20+
21+
#ifdef cl_khr_int64_extended_atomics
22+
#define __CLC_FUNCTION atom_or
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_extended_atomics
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_base_atomics
10+
#define __CLC_FUNCTION atom_sub
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_base_atomics
14+
15+
#ifdef cl_khr_local_int32_base_atomics
16+
#define __CLC_FUNCTION atom_sub
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_base_atomics
20+
21+
#ifdef cl_khr_int64_base_atomics
22+
#define __CLC_FUNCTION atom_sub
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_base_atomics
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_base_atomics
10+
#define __CLC_FUNCTION atom_xchg
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_base_atomics
14+
15+
#ifdef cl_khr_local_int32_base_atomics
16+
#define __CLC_FUNCTION atom_xchg
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_base_atomics
20+
21+
#ifdef cl_khr_int64_base_atomics
22+
#define __CLC_FUNCTION atom_xchg
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_base_atomics
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#ifdef cl_khr_global_int32_extended_atomics
10+
#define __CLC_FUNCTION atom_xor
11+
#define __CLC_ADDRESS_SPACE global
12+
#include <clc/atomic/atom_decl_int32.inc>
13+
#endif // cl_khr_global_int32_extended_atomics
14+
15+
#ifdef cl_khr_local_int32_extended_atomics
16+
#define __CLC_FUNCTION atom_xor
17+
#define __CLC_ADDRESS_SPACE local
18+
#include <clc/atomic/atom_decl_int32.inc>
19+
#endif // cl_khr_local_int32_extended_atomics
20+
21+
#ifdef cl_khr_int64_extended_atomics
22+
#define __CLC_FUNCTION atom_xor
23+
#include <clc/atomic/atom_decl_int64.inc>
24+
#endif // cl_khr_int64_extended_atomics

libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

libclc/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)