1
- From b66a2f5bde66c52ed00e30b926904c3bbce896fd Mon Sep 17 00:00:00 2001
1
+ From 03199b43a351be2bf34efdf9e02851f9c2319180 Mon Sep 17 00:00:00 2001
2
2
From: haonanya <
[email protected] >
3
- Date: Fri, 13 Aug 2021 10:10:36 +0800
3
+ Date: Tue, 8 Feb 2022 11:06:45 +0800
4
4
Subject: [PATCH] support cl_ext_float_atomics
5
5
6
6
This backports https://reviews.llvm.org/D106343 and https://reviews.llvm.org/D109740
7
7
8
8
Signed-off-by: haonanya <
[email protected] >
9
9
---
10
10
clang/lib/Headers/opencl-c-base.h | 22 ++
11
- clang/lib/Headers/opencl-c.h | 372 ++++++++++++++++++++++++++
11
+ clang/lib/Headers/opencl-c.h | 377 ++++++++++++++++++++++++++
12
12
clang/lib/Sema/Sema.cpp | 3 +
13
- clang/test/Headers/opencl-c-header.cl | 85 ++++++
14
- 4 files changed, 482 insertions(+)
13
+ clang/test/Headers/opencl-c-header.cl | 84 ++++++
14
+ 4 files changed, 486 insertions(+)
15
15
16
16
diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h
17
- index afa900ab24d9..3410fcd05ea0 100644
17
+ index afa900ab24d9..97466103f8cc 100644
18
18
--- a/clang/lib/Headers/opencl-c-base.h
19
19
+++ b/clang/lib/Headers/opencl-c-base.h
20
20
@@ -14,6 +14,28 @@
@@ -31,7 +31,7 @@ index afa900ab24d9..3410fcd05ea0 100644
31
31
+ #define __opencl_c_ext_fp16_global_atomic_min_max 1
32
32
+ #define __opencl_c_ext_fp16_local_atomic_min_max 1
33
33
+ #endif
34
- + #ifdef cl_khr_fp64
34
+ + #ifdef cl_khr_fp64
35
35
+ #define __opencl_c_ext_fp64_global_atomic_add 1
36
36
+ #define __opencl_c_ext_fp64_local_atomic_add 1
37
37
+ #define __opencl_c_ext_fp64_global_atomic_min_max 1
@@ -47,10 +47,10 @@ index afa900ab24d9..3410fcd05ea0 100644
47
47
#ifndef __opencl_c_int64
48
48
#define __opencl_c_int64 1
49
49
diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
50
- index 67d900eb1c3d..c7dbcbf4e924 100644
50
+ index 67d900eb1c3d..1c2c21a30ce6 100644
51
51
--- a/clang/lib/Headers/opencl-c.h
52
52
+++ b/clang/lib/Headers/opencl-c.h
53
- @@ -14354,6 +14354,378 @@ intptr_t __ovld atomic_fetch_max_explicit(
53
+ @@ -14354,6 +14354,383 @@ intptr_t __ovld atomic_fetch_max_explicit(
54
54
// defined(cl_khr_int64_extended_atomics)
55
55
#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
56
56
@@ -220,6 +220,7 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
220
220
+ #endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) && \
221
221
+ defined(__opencl_c_ext_fp32_local_atomic_min_max)
222
222
+
223
+ + #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
223
224
+ #if defined(__opencl_c_ext_fp64_global_atomic_min_max)
224
225
+ double __ovld atomic_fetch_min(volatile __global atomic_double *object,
225
226
+ double operand);
@@ -270,6 +271,8 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
270
271
+ memory_scope scope);
271
272
+ #endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) && \
272
273
+ defined(__opencl_c_ext_fp64_local_atomic_min_max)
274
+ + #endif // defined(cl_khr_int64_base_atomics) &&
275
+ + // defined(cl_khr_int64_extended_atomics)
273
276
+
274
277
+ #if defined(__opencl_c_ext_fp16_global_atomic_add)
275
278
+ half __ovld atomic_fetch_add(volatile __global atomic_half *object,
@@ -373,6 +376,7 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
373
376
+ #endif // defined(__opencl_c_ext_fp32_global_atomic_add) && \
374
377
+ defined(__opencl_c_ext_fp32_local_atomic_add)
375
378
+
379
+ + #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
376
380
+ #if defined(__opencl_c_ext_fp64_global_atomic_add)
377
381
+ double __ovld atomic_fetch_add(volatile __global atomic_double *object,
378
382
+ double operand);
@@ -423,7 +427,8 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
423
427
+ memory_scope scope);
424
428
+ #endif // defined(__opencl_c_ext_fp64_global_atomic_add) && \
425
429
+ defined(__opencl_c_ext_fp64_local_atomic_add)
426
- +
430
+ + #endif // defined(cl_khr_int64_base_atomics) &&
431
+ + // defined(cl_khr_int64_extended_atomics)
427
432
+ #endif // cl_ext_float_atomics
428
433
+
429
434
// atomic_store()
@@ -444,10 +449,10 @@ index 5092a4691b9b..efe8a466e734 100644
444
449
Context.getAtomicType(Context.FloatTy));
445
450
auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy);
446
451
diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl
447
- index 2716076acdcf..33439f297d26 100644
452
+ index 2716076acdcf..513b2186a298 100644
448
453
--- a/clang/test/Headers/opencl-c-header.cl
449
454
+++ b/clang/test/Headers/opencl-c-header.cl
450
- @@ -98,3 +98,88 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
455
+ @@ -98,3 +98,87 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
451
456
#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
452
457
453
458
// CHECK-MOD: Reading modules
@@ -535,7 +540,6 @@ index 2716076acdcf..33439f297d26 100644
535
540
+ #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
536
541
+
537
542
+ #endif // defined(__SPIR__)
538
- +
539
543
- -
540
- 2.17.1
544
+ 2.29.2
541
545
0 commit comments