Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Sep 2020 19:35:31 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r365427 - in stable: 11/contrib/llvm-project/openmp/runtime/src 11/share/mk 12/contrib/llvm-project/openmp/runtime/src 12/share/mk
Message-ID:  <202009071935.087JZVZV029146@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Mon Sep  7 19:35:30 2020
New Revision: 365427
URL: https://svnweb.freebsd.org/changeset/base/365427

Log:
  MFC r364732:
  
  Merge commit cde8f4c16 from llvm git (by me):
  
    Move special va_list handling to kmp_os.h
  
    Instead of copying and pasting the same #ifdef expressions in
    multiple places, define a type and a pair of macros in kmp_os.h, to
    handle whether va_list is pointer-like or not:
  
    * kmp_va_list is the type to use for __kmp_fork_call()
    * kmp_va_deref() dereferences a va_list, if necessary
    * kmp_va_addr_of() takes the address of a va_list, if necessary
  
    Also add FreeBSD to the list of OSes that has a non pointer-like
    va_list. This can now be easily extended to other OSes too.
  
    Reviewed By: AndreyChurbanov
  
    Differential Revision: https://reviews.llvm.org/D86397
  
  This should enable building of LLVM's OpenMP on AArch64. Addition to
  share/mk will follow in a subsequent commit.
  
  PR:		248864
  
  MFC r364733:
  
  After r364732, we can now enable MK_OPENMP for aarch64 by default.
  
  PR:		248864

Modified:
  stable/11/contrib/llvm-project/openmp/runtime/src/kmp.h
  stable/11/contrib/llvm-project/openmp/runtime/src/kmp_csupport.cpp
  stable/11/contrib/llvm-project/openmp/runtime/src/kmp_gsupport.cpp
  stable/11/contrib/llvm-project/openmp/runtime/src/kmp_os.h
  stable/11/contrib/llvm-project/openmp/runtime/src/kmp_runtime.cpp
  stable/11/share/mk/src.opts.mk
Directory Properties:
  stable/11/   (props changed)
  stable/11/contrib/llvm-project/openmp/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/contrib/llvm-project/openmp/runtime/src/kmp.h
  stable/12/contrib/llvm-project/openmp/runtime/src/kmp_csupport.cpp
  stable/12/contrib/llvm-project/openmp/runtime/src/kmp_gsupport.cpp
  stable/12/contrib/llvm-project/openmp/runtime/src/kmp_os.h
  stable/12/contrib/llvm-project/openmp/runtime/src/kmp_runtime.cpp
  stable/12/share/mk/src.opts.mk
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/contrib/llvm-project/openmp/runtime/src/kmp.h
==============================================================================
--- stable/11/contrib/llvm-project/openmp/runtime/src/kmp.h	Mon Sep  7 19:29:06 2020	(r365426)
+++ stable/11/contrib/llvm-project/openmp/runtime/src/kmp.h	Mon Sep  7 19:35:30 2020	(r365427)
@@ -3463,13 +3463,7 @@ enum fork_context_e {
 extern int __kmp_fork_call(ident_t *loc, int gtid,
                            enum fork_context_e fork_context, kmp_int32 argc,
                            microtask_t microtask, launch_t invoker,
-/* TODO: revert workaround for Intel(R) 64 tracker #96 */
-#if (KMP_ARCH_ARM || KMP_ARCH_X86_64 || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-                           va_list *ap
-#else
-                           va_list ap
-#endif
-                           );
+                           kmp_va_list ap);
 
 extern void __kmp_join_call(ident_t *loc, int gtid
 #if OMPT_SUPPORT

Modified: stable/11/contrib/llvm-project/openmp/runtime/src/kmp_csupport.cpp
==============================================================================
--- stable/11/contrib/llvm-project/openmp/runtime/src/kmp_csupport.cpp	Mon Sep  7 19:29:06 2020	(r365426)
+++ stable/11/contrib/llvm-project/openmp/runtime/src/kmp_csupport.cpp	Mon Sep  7 19:35:30 2020	(r365427)
@@ -308,13 +308,7 @@ void __kmpc_fork_call(ident_t *loc, kmp_int32 argc, km
     __kmp_fork_call(loc, gtid, fork_context_intel, argc,
                     VOLATILE_CAST(microtask_t) microtask, // "wrapped" task
                     VOLATILE_CAST(launch_t) __kmp_invoke_task_func,
-/* TODO: revert workaround for Intel(R) 64 tracker #96 */
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-                    &ap
-#else
-                    ap
-#endif
-                    );
+                    kmp_va_addr_of(ap));
 #if INCLUDE_SSC_MARKS
     SSC_MARK_JOINING();
 #endif
@@ -408,16 +402,10 @@ void __kmpc_fork_teams(ident_t *loc, kmp_int32 argc, k
   KMP_DEBUG_ASSERT(this_thr->th.th_teams_size.nteams >= 1);
   KMP_DEBUG_ASSERT(this_thr->th.th_teams_size.nth >= 1);
 
-  __kmp_fork_call(loc, gtid, fork_context_intel, argc,
-                  VOLATILE_CAST(microtask_t)
-                      __kmp_teams_master, // "wrapped" task
-                  VOLATILE_CAST(launch_t) __kmp_invoke_teams_master,
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-                  &ap
-#else
-                  ap
-#endif
-                  );
+  __kmp_fork_call(
+      loc, gtid, fork_context_intel, argc,
+      VOLATILE_CAST(microtask_t) __kmp_teams_master, // "wrapped" task
+      VOLATILE_CAST(launch_t) __kmp_invoke_teams_master, kmp_va_addr_of(ap));
   __kmp_join_call(loc, gtid
 #if OMPT_SUPPORT
                   ,

Modified: stable/11/contrib/llvm-project/openmp/runtime/src/kmp_gsupport.cpp
==============================================================================
--- stable/11/contrib/llvm-project/openmp/runtime/src/kmp_gsupport.cpp	Mon Sep  7 19:29:06 2020	(r365426)
+++ stable/11/contrib/llvm-project/openmp/runtime/src/kmp_gsupport.cpp	Mon Sep  7 19:35:30 2020	(r365427)
@@ -376,13 +376,7 @@ static
   va_start(ap, argc);
 
   rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc, wrapper,
-                       __kmp_invoke_task_func,
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-                       &ap
-#else
-                       ap
-#endif
-                       );
+                       __kmp_invoke_task_func, kmp_va_addr_of(ap));
 
   va_end(ap);
 

Modified: stable/11/contrib/llvm-project/openmp/runtime/src/kmp_os.h
==============================================================================
--- stable/11/contrib/llvm-project/openmp/runtime/src/kmp_os.h	Mon Sep  7 19:29:06 2020	(r365426)
+++ stable/11/contrib/llvm-project/openmp/runtime/src/kmp_os.h	Mon Sep  7 19:35:30 2020	(r365427)
@@ -200,6 +200,18 @@ typedef kmp_uint32 kmp_uint;
 #define KMP_INT_MAX ((kmp_int32)0x7FFFFFFF)
 #define KMP_INT_MIN ((kmp_int32)0x80000000)
 
+// stdarg handling
+#if (KMP_ARCH_ARM || KMP_ARCH_X86_64 || KMP_ARCH_AARCH64) &&                   \
+    (KMP_OS_FREEBSD || KMP_OS_LINUX)
+typedef va_list *kmp_va_list;
+#define kmp_va_deref(ap) (*(ap))
+#define kmp_va_addr_of(ap) (&(ap))
+#else
+typedef va_list kmp_va_list;
+#define kmp_va_deref(ap) (ap)
+#define kmp_va_addr_of(ap) (ap)
+#endif
+
 #ifdef __cplusplus
 // macros to cast out qualifiers and to re-interpret types
 #define CCAST(type, var) const_cast<type>(var)

Modified: stable/11/contrib/llvm-project/openmp/runtime/src/kmp_runtime.cpp
==============================================================================
--- stable/11/contrib/llvm-project/openmp/runtime/src/kmp_runtime.cpp	Mon Sep  7 19:29:06 2020	(r365426)
+++ stable/11/contrib/llvm-project/openmp/runtime/src/kmp_runtime.cpp	Mon Sep  7 19:35:30 2020	(r365427)
@@ -1389,13 +1389,7 @@ void __kmp_serialized_parallel(ident_t *loc, kmp_int32
 int __kmp_fork_call(ident_t *loc, int gtid,
                     enum fork_context_e call_context, // Intel, GNU, ...
                     kmp_int32 argc, microtask_t microtask, launch_t invoker,
-/* TODO: revert workaround for Intel(R) 64 tracker #96 */
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-                    va_list *ap
-#else
-                    va_list ap
-#endif
-                    ) {
+                    kmp_va_list ap) {
   void **argv;
   int i;
   int master_tid;
@@ -1505,12 +1499,7 @@ int __kmp_fork_call(ident_t *loc, int gtid,
       parent_team->t.t_argc = argc;
       argv = (void **)parent_team->t.t_argv;
       for (i = argc - 1; i >= 0; --i)
-/* TODO: revert workaround for Intel(R) 64 tracker #96 */
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-        *argv++ = va_arg(*ap, void *);
-#else
-        *argv++ = va_arg(ap, void *);
-#endif
+        *argv++ = va_arg(kmp_va_deref(ap), void *);
       // Increment our nested depth levels, but not increase the serialization
       if (parent_team == master_th->th.th_serial_team) {
         // AC: we are in serialized parallel
@@ -1804,12 +1793,7 @@ int __kmp_fork_call(ident_t *loc, int gtid,
           argv = (void **)team->t.t_argv;
           if (ap) {
             for (i = argc - 1; i >= 0; --i)
-// TODO: revert workaround for Intel(R) 64 tracker #96
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-              *argv++ = va_arg(*ap, void *);
-#else
-              *argv++ = va_arg(ap, void *);
-#endif
+              *argv++ = va_arg(kmp_va_deref(ap), void *);
           } else {
             for (i = 0; i < argc; ++i)
               // Get args from parent team for teams construct
@@ -1840,12 +1824,7 @@ int __kmp_fork_call(ident_t *loc, int gtid,
         } else {
           argv = args;
           for (i = argc - 1; i >= 0; --i)
-// TODO: revert workaround for Intel(R) 64 tracker #96
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-            *argv++ = va_arg(*ap, void *);
-#else
-            *argv++ = va_arg(ap, void *);
-#endif
+            *argv++ = va_arg(kmp_va_deref(ap), void *);
           KMP_MB();
 
 #if OMPT_SUPPORT
@@ -2130,12 +2109,7 @@ int __kmp_fork_call(ident_t *loc, int gtid,
     argv = (void **)team->t.t_argv;
     if (ap) {
       for (i = argc - 1; i >= 0; --i) {
-// TODO: revert workaround for Intel(R) 64 tracker #96
-#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-        void *new_argv = va_arg(*ap, void *);
-#else
-        void *new_argv = va_arg(ap, void *);
-#endif
+        void *new_argv = va_arg(kmp_va_deref(ap), void *);
         KMP_CHECK_UPDATE(*argv, new_argv);
         argv++;
       }

Modified: stable/11/share/mk/src.opts.mk
==============================================================================
--- stable/11/share/mk/src.opts.mk	Mon Sep  7 19:29:06 2020	(r365426)
+++ stable/11/share/mk/src.opts.mk	Mon Sep  7 19:35:30 2020	(r365427)
@@ -342,7 +342,8 @@ __DEFAULT_NO_OPTIONS+=OFED
 .endif
 
 .if ${COMPILER_FEATURES:Mc++11} && \
-    (${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc64")
+    (${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
+     ${__T} == "powerpc64")
 __DEFAULT_YES_OPTIONS+=OPENMP
 .else
 __DEFAULT_NO_OPTIONS+=OPENMP



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009071935.087JZVZV029146>