Skip to content
Merged
13 changes: 6 additions & 7 deletions libclc/clc/include/clc/atomic/atomic_decl.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@
#ifdef __CLC_NO_VALUE_ARG
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, \
int MemoryScope);
ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, int MemoryScope);
#elif defined(__CLC_RETURN_VOID)
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL void __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
int MemoryOrder, int MemoryScope);
ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, int MemoryOrder, \
int MemoryScope);
#elif defined(__CLC_COMPARE_EXCHANGE)
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \
ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \
__CLC_GENTYPE Value, int MemoryOrderEqual, int MemoryOrderUnequal, \
int MemoryScope);
#else
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
int MemoryOrder, int MemoryScope);
ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, int MemoryOrder, \
int MemoryScope);
#endif

__CLC_DECLARE_ATOMIC(global)
Expand Down
4 changes: 2 additions & 2 deletions libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atomic_compare_exchange( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \
ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \
__CLC_GENTYPE Value, int MemoryOrderEqual, int MemoryOrderUnequal, \
int MemoryScope) { \
__CLC_U_GENTYPE Comp = __CLC_AS_U_GENTYPE(Comparator); \
Expand All @@ -39,7 +39,7 @@

#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_atomic_compare_exchange( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \
ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \
__CLC_GENTYPE Value, int MemoryOrderEqual, int MemoryOrderUnequal, \
int MemoryScope) { \
__scoped_atomic_compare_exchange_n(Ptr, &Comparator, Value, false, \
Expand Down
14 changes: 6 additions & 8 deletions libclc/clc/lib/generic/atomic/clc_atomic_def.inc
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,30 @@
#ifdef __CLC_NO_VALUE_ARG
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, \
int MemoryScope) { \
ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, int MemoryScope) { \
return __CLC_AS_RETTYPE(__CLC_IMPL_FUNCTION( \
(ADDRSPACE __CLC_CASTTYPE *)Ptr, MemoryOrder, MemoryScope)); \
}
#elif defined(__CLC_INC_DEC)
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, \
int MemoryScope) { \
ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, int MemoryScope) { \
return __CLC_IMPL_FUNCTION(Ptr, (__CLC_GENTYPE)1, MemoryOrder, \
MemoryScope); \
}
#elif defined(__CLC_RETURN_VOID)
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DEF void __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
int MemoryOrder, int MemoryScope) { \
ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, int MemoryOrder, \
int MemoryScope) { \
__CLC_IMPL_FUNCTION((ADDRSPACE __CLC_CASTTYPE *)Ptr, \
__CLC_AS_CASTTYPE(Value), MemoryOrder, MemoryScope); \
}
#else
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
int MemoryOrder, int MemoryScope) { \
ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, int MemoryOrder, \
int MemoryScope) { \
return __CLC_AS_RETTYPE(__CLC_IMPL_FUNCTION( \
(ADDRSPACE __CLC_CASTTYPE *)Ptr, __CLC_AS_CASTTYPE(Value), \
MemoryOrder, MemoryScope)); \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_STRONG_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_STRONG_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_compare_exchange_strong
#define __CLC_COMPARE_EXCHANGE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_WEAK_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_WEAK_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_compare_exchange_weak
#define __CLC_COMPARE_EXCHANGE

Expand Down
91 changes: 82 additions & 9 deletions libclc/opencl/include/clc/opencl/atomic/atomic_decl.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,105 @@

#define __CLC_ATOMIC_GENTYPE __CLC_XCONCAT(atomic_, __CLC_GENTYPE)

#define __CLC_FUNCTION_EXPLICIT __CLC_XCONCAT(__CLC_FUNCTION, _explicit)

#ifdef __CLC_NO_VALUE_ARG
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, memory_order Order, \
memory_scope Scope);
#elif defined(__CLC_RETURN_VOID)
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL void __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
memory_order Order, memory_scope Scope);
#elif defined(__CLC_COMPARE_EXCHANGE)
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL bool __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, \
ADDRSPACE __CLC_GENTYPE *Expected, __CLC_GENTYPE Desired, \
memory_order Order, memory_scope Scope);
#else
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
memory_order Order, memory_scope Scope);
#endif

__CLC_DECL_ATOMIC(global)
__CLC_DECL_ATOMIC(local)
#if _CLC_GENERIC_AS_SUPPORTED
__CLC_DECL_ATOMIC()
#endif

#undef __CLC_DECL_ATOMIC

#if defined(__opencl_c_atomic_scope_device)

#ifdef __CLC_NO_VALUE_ARG
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, memory_order Order);
#elif defined(__CLC_RETURN_VOID)
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL void __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
memory_order Order);
#elif defined(__CLC_COMPARE_EXCHANGE)
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL bool __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, \
ADDRSPACE __CLC_GENTYPE *Expected, __CLC_GENTYPE Desired, \
memory_order Success, memory_order Failure);
#else
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION_EXPLICIT( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
memory_order Order);
#endif

__CLC_DECL_ATOMIC(global)
__CLC_DECL_ATOMIC(local)
#if _CLC_GENERIC_AS_SUPPORTED
__CLC_DECL_ATOMIC()
#endif

#undef __CLC_DECL_ATOMIC

#endif // defined(__opencl_c_atomic_scope_device)

#if defined(__opencl_c_atomic_order_seq_cst) && \
defined(__opencl_c_atomic_scope_device)

#ifdef __CLC_NO_VALUE_ARG
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr);
#elif defined(__CLC_RETURN_VOID)
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL void __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value);
#elif defined(__CLC_COMPARE_EXCHANGE)
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL bool __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, \
ADDRSPACE __CLC_GENTYPE *Expected, __CLC_GENTYPE Desired);
#else
#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \
#define __CLC_DECL_ATOMIC(ADDRSPACE) \
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \
volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value);
#endif

__CLC_DEFINE_ATOMIC(global)
__CLC_DEFINE_ATOMIC(local)
__CLC_DECL_ATOMIC(global)
__CLC_DECL_ATOMIC(local)
#if _CLC_GENERIC_AS_SUPPORTED
__CLC_DEFINE_ATOMIC()
__CLC_DECL_ATOMIC()
#endif

#undef __CLC_DEFINE_ATOMIC
#undef __CLC_DECL_ATOMIC

#endif // defined(__opencl_c_atomic_order_seq_cst) &&
// defined(__opencl_c_atomic_scope_device)

#endif // __CLC_HAVE_FP_ATOMIC || __CLC_HAVE_INT_ATOMIC

Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_EXCHANGE_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_EXCHANGE_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_exchange

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_ADD_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_ADD_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_fetch_add

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_AND_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_AND_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_fetch_and

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MAX_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MAX_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_fetch_max

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MIN_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MIN_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_fetch_min

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_OR_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_OR_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_fetch_or

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_SUB_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_SUB_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_fetch_sub

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_XOR_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_XOR_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_fetch_xor

#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc>
Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_LOAD_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_LOAD_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_load
#define __CLC_NO_VALUE_ARG

Expand Down
3 changes: 3 additions & 0 deletions libclc/opencl/include/clc/opencl/atomic/atomic_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_STORE_H__
#define __CLC_OPENCL_ATOMIC_ATOMIC_STORE_H__

#include <clc/opencl/opencl-base.h>
#include <clc/opencl/types.h>

#define __CLC_FUNCTION atomic_store
#define __CLC_RETURN_VOID

Expand Down
48 changes: 48 additions & 0 deletions libclc/opencl/include/clc/opencl/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_OPENCL_TYPES_H__
#define __CLC_OPENCL_TYPES_H__

// Copied from clang/lib/Headers/opencl-c-base.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't need copying? Use the builtin included declarations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't need copying? Use the builtin included declarations?

The copying is deleted. e3799b2 added -include opencl-c-base.h to compile flags for .cl files. Some types and constants in libclc are not needed anymore.
opencl-c-base.h only defines OpenCL types and constant, so it should be safe to use in libclc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't need copying? Use the builtin included declarations?

The copying is deleted. e3799b2 added -include opencl-c-base.h to compile flags for .cl files. Some types and constants in libclc are not needed anymore. opencl-c-base.h only defines OpenCL types and constant, so it should be safe to use in libclc.

I think we can also change OpenCL enum memory_scope to map 1:1 to Clang memory_scope like in following diff:

diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h
index 898026c66614..50c6c4ed3d27 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -295,13 +295,13 @@ typedef uint cl_mem_fence_flags;
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)

 typedef enum memory_scope {
-  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
-  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
-  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_work_item = __MEMORY_SCOPE_SINGLE,
+  memory_scope_work_group = __MEMORY_SCOPE_WRKGRP,
+  memory_scope_device = __MEMORY_SCOPE_DEVICE,
 #if defined(__opencl_c_atomic_scope_all_devices)
-  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+  memory_scope_all_svm_devices = __MEMORY_SCOPE_SYSTEM,
 #if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
-  memory_scope_all_devices = memory_scope_all_svm_devices,
+  memory_scope_all_devices = __MEMORY_SCOPE_SYSTEM,
 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 #endif // defined(__opencl_c_atomic_scope_all_devices)
 /**
@@ -311,7 +311,7 @@ typedef enum memory_scope {
  * KHR subgroups "Subgroups within a workgroup are independent, make forward progress with respect to each other"
  */
 #if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || defined(__opencl_c_subgroups)
-  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
+  memory_scope_sub_group = __MEMORY_SCOPE_WVFRNT
 #endif
 } memory_scope;

Then we don't need to include opencl-c-base.h for libclc. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we don't need to include opencl-c-base.h for libclc.

sorry, -include opencl-c-base.h is still needed. The above mapping change can only eliminates helper function __opencl_get_clang_memory_scope.


typedef enum memory_scope {
memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
#if defined(__opencl_c_atomic_scope_all_devices)
memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
memory_scope_all_devices = memory_scope_all_svm_devices,
#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >=
// 202100)
#endif // defined(__opencl_c_atomic_scope_all_devices)
/**
* Subgroups have different requirements on forward progress, so just test
* all the relevant macros.
* CL 3.0 sub-groups "they are not guaranteed to make independent forward
* progress" KHR subgroups "Subgroups within a workgroup are independent, make
* forward progress with respect to each other"
*/
#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || \
defined(__opencl_c_subgroups)
memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
#endif
} memory_scope;

typedef enum memory_order {
memory_order_relaxed = __ATOMIC_RELAXED,
memory_order_acquire = __ATOMIC_ACQUIRE,
memory_order_release = __ATOMIC_RELEASE,
memory_order_acq_rel = __ATOMIC_ACQ_REL,
#if defined(__opencl_c_atomic_order_seq_cst)
memory_order_seq_cst = __ATOMIC_SEQ_CST
#endif
} memory_order;

#endif // __CLC_OPENCL_TYPES_H__
Loading
Loading