[Openmp-commits] [openmp] [NFC][OpenMP][OMPX] Use `__attribute__((__always_inline__))` instead of `inline` (PR #91294)

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Mon May 6 20:24:09 PDT 2024


https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/91294

>From 1545dfb46cae88a7c2704ed59744d6e21e93b646 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Mon, 6 May 2024 23:22:50 -0400
Subject: [PATCH] [NFC][OpenMP][OMPX] Use `__attribute__((__always_inline__))`
 instead of `inline`

---
 openmp/runtime/src/include/ompx.h.var | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/openmp/runtime/src/include/ompx.h.var b/openmp/runtime/src/include/ompx.h.var
index 5dd8e8355e4c..96b114bebf67 100644
--- a/openmp/runtime/src/include/ompx.h.var
+++ b/openmp/runtime/src/include/ompx.h.var
@@ -9,6 +9,8 @@
 #ifndef __OMPX_H
 #define __OMPX_H
 
+#define INLINE [[clang::always_inline]]
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -54,7 +56,7 @@ enum {
 ///{
 #pragma omp begin declare variant match(device = {kind(cpu)})
 #define _TGT_KERNEL_LANGUAGE_HOST_IMPL_GRID_C(NAME, VALUE)                     \
-  static inline int ompx_##NAME(int Dim) { return VALUE; }
+  static INLINE int ompx_##NAME(int Dim) { return VALUE; }
 
 _TGT_KERNEL_LANGUAGE_HOST_IMPL_GRID_C(thread_id,
                                       omp_get_ancestor_thread_num(Dim + 1))
@@ -67,7 +69,7 @@ _TGT_KERNEL_LANGUAGE_HOST_IMPL_GRID_C(grid_dim, 1)
 /// ompx_{sync_block}_{,divergent}
 ///{
 #define _TGT_KERNEL_LANGUAGE_HOST_IMPL_SYNC_C(RETTY, NAME, ARGS, BODY)         \
-  static inline RETTY ompx_##NAME(ARGS) { BODY; }
+  static INLINE RETTY ompx_##NAME(ARGS) { BODY; }
 
 _TGT_KERNEL_LANGUAGE_HOST_IMPL_SYNC_C(void, sync_block, int Ordering,
                                       _Pragma("omp barrier"));
@@ -82,7 +84,7 @@ _TGT_KERNEL_LANGUAGE_HOST_IMPL_SYNC_C(void, sync_block_divergent, int Ordering,
 
 /// ompx_{sync_block}_{,divergent}
 ///{
-#define _TGT_KERNEL_LANGUAGE_DECL_SYNC_C(RETTY, NAME, ARGS)         \
+#define _TGT_KERNEL_LANGUAGE_DECL_SYNC_C(RETTY, NAME, ARGS)                    \
   RETTY ompx_##NAME(ARGS);
 
 _TGT_KERNEL_LANGUAGE_DECL_SYNC_C(void, sync_block, int Ordering);
@@ -95,9 +97,9 @@ _TGT_KERNEL_LANGUAGE_DECL_SYNC_C(void, sync_block_divergent, int Ordering);
 ///{
 #define _TGT_KERNEL_LANGUAGE_DECL_GRID_C(NAME)                                 \
   int ompx_##NAME(int Dim);                                                    \
-  static inline int ompx_##NAME##_x() { return ompx_##NAME(ompx_dim_x); }      \
-  static inline int ompx_##NAME##_y() { return ompx_##NAME(ompx_dim_y); }      \
-  static inline int ompx_##NAME##_z() { return ompx_##NAME(ompx_dim_z); }
+  static INLINE int ompx_##NAME##_x() { return ompx_##NAME(ompx_dim_x); }      \
+  static INLINE int ompx_##NAME##_y() { return ompx_##NAME(ompx_dim_y); }      \
+  static INLINE int ompx_##NAME##_z() { return ompx_##NAME(ompx_dim_z); }
 
 _TGT_KERNEL_LANGUAGE_DECL_GRID_C(thread_id)
 _TGT_KERNEL_LANGUAGE_DECL_GRID_C(block_dim)
@@ -131,10 +133,10 @@ enum {
 /// ompx::{thread,block}_{id,dim}_{,x,y,z}
 ///{
 #define _TGT_KERNEL_LANGUAGE_HOST_IMPL_GRID_CXX(NAME)                          \
-  static inline int NAME(int Dim) noexcept { return ompx_##NAME(Dim); }        \
-  static inline int NAME##_x() noexcept { return NAME(ompx_dim_x); }           \
-  static inline int NAME##_y() noexcept { return NAME(ompx_dim_y); }           \
-  static inline int NAME##_z() noexcept { return NAME(ompx_dim_z); }
+  static INLINE int NAME(int Dim) noexcept { return ompx_##NAME(Dim); }        \
+  static INLINE int NAME##_x() noexcept { return NAME(ompx_dim_x); }           \
+  static INLINE int NAME##_y() noexcept { return NAME(ompx_dim_y); }           \
+  static INLINE int NAME##_z() noexcept { return NAME(ompx_dim_z); }
 
 _TGT_KERNEL_LANGUAGE_HOST_IMPL_GRID_CXX(thread_id)
 _TGT_KERNEL_LANGUAGE_HOST_IMPL_GRID_CXX(block_dim)
@@ -146,7 +148,7 @@ _TGT_KERNEL_LANGUAGE_HOST_IMPL_GRID_CXX(grid_dim)
 /// ompx_{sync_block}_{,divergent}
 ///{
 #define _TGT_KERNEL_LANGUAGE_HOST_IMPL_SYNC_CXX(RETTY, NAME, ARGS, CALL_ARGS)  \
-  static inline RETTY NAME(ARGS) {               \
+  static INLINE RETTY NAME(ARGS) {                                             \
     return ompx_##NAME(CALL_ARGS);                                             \
   }
 
@@ -162,4 +164,6 @@ _TGT_KERNEL_LANGUAGE_HOST_IMPL_SYNC_CXX(void, sync_block_divergent,
 
 ///}
 
+#undef INLINE
+
 #endif /* __OMPX_H */



More information about the Openmp-commits mailing list