Skip to content

Commit 50bf6d7

Browse files
authored
Update cl_ext_float_atomics patch (#312)
Guard atomic_double with cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics.
1 parent 16ff905 commit 50bf6d7

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

patches/clang/0004-OpenCL-support-cl_ext_float_atomics.patch

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
From b66a2f5bde66c52ed00e30b926904c3bbce896fd Mon Sep 17 00:00:00 2001
1+
From 03199b43a351be2bf34efdf9e02851f9c2319180 Mon Sep 17 00:00:00 2001
22
From: haonanya <[email protected]>
3-
Date: Fri, 13 Aug 2021 10:10:36 +0800
3+
Date: Tue, 8 Feb 2022 11:06:45 +0800
44
Subject: [PATCH] support cl_ext_float_atomics
55

66
This backports https://reviews.llvm.org/D106343 and https://reviews.llvm.org/D109740
77

88
Signed-off-by: haonanya <[email protected]>
99
---
1010
clang/lib/Headers/opencl-c-base.h | 22 ++
11-
clang/lib/Headers/opencl-c.h | 372 ++++++++++++++++++++++++++
11+
clang/lib/Headers/opencl-c.h | 377 ++++++++++++++++++++++++++
1212
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(+)
1515

1616
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
1818
--- a/clang/lib/Headers/opencl-c-base.h
1919
+++ b/clang/lib/Headers/opencl-c-base.h
2020
@@ -14,6 +14,28 @@
@@ -31,7 +31,7 @@ index afa900ab24d9..3410fcd05ea0 100644
3131
+#define __opencl_c_ext_fp16_global_atomic_min_max 1
3232
+#define __opencl_c_ext_fp16_local_atomic_min_max 1
3333
+#endif
34-
+#ifdef cl_khr_fp64
34+
+#ifdef cl_khr_fp64
3535
+#define __opencl_c_ext_fp64_global_atomic_add 1
3636
+#define __opencl_c_ext_fp64_local_atomic_add 1
3737
+#define __opencl_c_ext_fp64_global_atomic_min_max 1
@@ -47,10 +47,10 @@ index afa900ab24d9..3410fcd05ea0 100644
4747
#ifndef __opencl_c_int64
4848
#define __opencl_c_int64 1
4949
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
5151
--- a/clang/lib/Headers/opencl-c.h
5252
+++ 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(
5454
// defined(cl_khr_int64_extended_atomics)
5555
#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5656

@@ -220,6 +220,7 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
220220
+#endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) && \
221221
+ defined(__opencl_c_ext_fp32_local_atomic_min_max)
222222
+
223+
+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
223224
+#if defined(__opencl_c_ext_fp64_global_atomic_min_max)
224225
+double __ovld atomic_fetch_min(volatile __global atomic_double *object,
225226
+ double operand);
@@ -270,6 +271,8 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
270271
+ memory_scope scope);
271272
+#endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) && \
272273
+ defined(__opencl_c_ext_fp64_local_atomic_min_max)
274+
+#endif // defined(cl_khr_int64_base_atomics) &&
275+
+ // defined(cl_khr_int64_extended_atomics)
273276
+
274277
+#if defined(__opencl_c_ext_fp16_global_atomic_add)
275278
+half __ovld atomic_fetch_add(volatile __global atomic_half *object,
@@ -373,6 +376,7 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
373376
+#endif // defined(__opencl_c_ext_fp32_global_atomic_add) && \
374377
+ defined(__opencl_c_ext_fp32_local_atomic_add)
375378
+
379+
+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
376380
+#if defined(__opencl_c_ext_fp64_global_atomic_add)
377381
+double __ovld atomic_fetch_add(volatile __global atomic_double *object,
378382
+ double operand);
@@ -423,7 +427,8 @@ index 67d900eb1c3d..c7dbcbf4e924 100644
423427
+ memory_scope scope);
424428
+#endif // defined(__opencl_c_ext_fp64_global_atomic_add) && \
425429
+ defined(__opencl_c_ext_fp64_local_atomic_add)
426-
+
430+
+#endif // defined(cl_khr_int64_base_atomics) &&
431+
+ // defined(cl_khr_int64_extended_atomics)
427432
+#endif // cl_ext_float_atomics
428433
+
429434
// atomic_store()
@@ -444,10 +449,10 @@ index 5092a4691b9b..efe8a466e734 100644
444449
Context.getAtomicType(Context.FloatTy));
445450
auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy);
446451
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
448453
--- a/clang/test/Headers/opencl-c-header.cl
449454
+++ 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);
451456
#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
452457

453458
// CHECK-MOD: Reading modules
@@ -535,7 +540,6 @@ index 2716076acdcf..33439f297d26 100644
535540
+#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
536541
+
537542
+#endif // defined(__SPIR__)
538-
+
539543
--
540-
2.17.1
544+
2.29.2
541545

0 commit comments

Comments
 (0)