[Openmp-commits] [openmp] r302929 - Clang-format and whitespace cleanup of source code

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Fri May 12 11:01:35 PDT 2017


Modified: openmp/trunk/runtime/src/kmp_dispatch.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_dispatch.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_dispatch.cpp (original)
+++ openmp/trunk/runtime/src/kmp_dispatch.cpp Fri May 12 13:01:32 2017
@@ -13,32 +13,28 @@
 //===----------------------------------------------------------------------===//
 
 
-/*
- * Dynamic scheduling initialization and dispatch.
+/* Dynamic scheduling initialization and dispatch.
  *
  * NOTE: __kmp_nth is a constant inside of any dispatch loop, however
  *       it may change values between parallel regions.  __kmp_max_nth
  *       is the largest value __kmp_nth may take, 1 is the smallest.
- *
  */
 
-/* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
-
-// Need to raise Win version from XP to Vista here for support of InterlockedExchange64
+// Need to raise Win version from XP to Vista here for support of
+// InterlockedExchange64
 #if defined(_WIN32_WINNT) && defined(_M_IX86)
 #undef _WIN32_WINNT
 #define _WIN32_WINNT 0x0502
 #endif
 
 #include "kmp.h"
+#include "kmp_error.h"
 #include "kmp_i18n.h"
 #include "kmp_itt.h"
-#include "kmp_str.h"
-#include "kmp_error.h"
 #include "kmp_stats.h"
+#include "kmp_str.h"
 #if KMP_OS_WINDOWS && KMP_ARCH_X86
-    #include <float.h>
+#include <float.h>
 #endif
 
 #if OMPT_SUPPORT
@@ -47,2350 +43,2338 @@
 #endif
 
 /* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
 
 #if KMP_STATIC_STEAL_ENABLED
 
-    // replaces dispatch_private_info{32,64} structures and dispatch_private_info{32,64}_t types
-    template< typename T >
-    struct dispatch_private_infoXX_template {
-        typedef typename traits_t< T >::unsigned_t  UT;
-        typedef typename traits_t< T >::signed_t    ST;
-        UT count;                // unsigned
-        T  ub;
-        /* Adding KMP_ALIGN_CACHE here doesn't help / can hurt performance */
-        T  lb;
-        ST st;                   // signed
-        UT tc;                   // unsigned
-        T  static_steal_counter; // for static_steal only; maybe better to put after ub
-
-        /* parm[1-4] are used in different ways by different scheduling algorithms */
-
-        // KMP_ALIGN( 32 ) ensures ( if the KMP_ALIGN macro is turned on )
-        //    a) parm3 is properly aligned and
-        //    b) all parm1-4 are in the same cache line.
-        // Because of parm1-4 are used together, performance seems to be better
-        // if they are in the same line (not measured though).
-
-        struct KMP_ALIGN( 32 ) { // compiler does not accept sizeof(T)*4
-            T  parm1;
-            T  parm2;
-            T  parm3;
-            T  parm4;
-        };
-
-        UT ordered_lower; // unsigned
-        UT ordered_upper; // unsigned
-        #if KMP_OS_WINDOWS
-        T  last_upper;
-        #endif /* KMP_OS_WINDOWS */
-    };
+// replaces dispatch_private_info{32,64} structures and
+// dispatch_private_info{32,64}_t types
+template <typename T> struct dispatch_private_infoXX_template {
+  typedef typename traits_t<T>::unsigned_t UT;
+  typedef typename traits_t<T>::signed_t ST;
+  UT count; // unsigned
+  T ub;
+  /* Adding KMP_ALIGN_CACHE here doesn't help / can hurt performance */
+  T lb;
+  ST st; // signed
+  UT tc; // unsigned
+  T static_steal_counter; // for static_steal only; maybe better to put after ub
+
+  /* parm[1-4] are used in different ways by different scheduling algorithms */
+
+  // KMP_ALIGN( 32 ) ensures ( if the KMP_ALIGN macro is turned on )
+  //    a) parm3 is properly aligned and
+  //    b) all parm1-4 are in the same cache line.
+  // Because of parm1-4 are used together, performance seems to be better
+  // if they are in the same line (not measured though).
+
+  struct KMP_ALIGN(32) { // compiler does not accept sizeof(T)*4
+    T parm1;
+    T parm2;
+    T parm3;
+    T parm4;
+  };
+
+  UT ordered_lower; // unsigned
+  UT ordered_upper; // unsigned
+#if KMP_OS_WINDOWS
+  T last_upper;
+#endif /* KMP_OS_WINDOWS */
+};
 
 #else /* KMP_STATIC_STEAL_ENABLED */
 
-    // replaces dispatch_private_info{32,64} structures and dispatch_private_info{32,64}_t types
-    template< typename T >
-    struct dispatch_private_infoXX_template {
-        typedef typename traits_t< T >::unsigned_t  UT;
-        typedef typename traits_t< T >::signed_t    ST;
-        T  lb;
-        T  ub;
-        ST st;            // signed
-        UT tc;            // unsigned
-
-        T  parm1;
-        T  parm2;
-        T  parm3;
-        T  parm4;
-
-        UT count;         // unsigned
-
-        UT ordered_lower; // unsigned
-        UT ordered_upper; // unsigned
-        #if KMP_OS_WINDOWS
-	T  last_upper;
-        #endif /* KMP_OS_WINDOWS */
-    };
+// replaces dispatch_private_info{32,64} structures and
+// dispatch_private_info{32,64}_t types
+template <typename T> struct dispatch_private_infoXX_template {
+  typedef typename traits_t<T>::unsigned_t UT;
+  typedef typename traits_t<T>::signed_t ST;
+  T lb;
+  T ub;
+  ST st; // signed
+  UT tc; // unsigned
+
+  T parm1;
+  T parm2;
+  T parm3;
+  T parm4;
+
+  UT count; // unsigned
+
+  UT ordered_lower; // unsigned
+  UT ordered_upper; // unsigned
+#if KMP_OS_WINDOWS
+  T last_upper;
+#endif /* KMP_OS_WINDOWS */
+};
 
 #endif /* KMP_STATIC_STEAL_ENABLED */
 
 // replaces dispatch_private_info structure and dispatch_private_info_t type
-template< typename T >
-struct KMP_ALIGN_CACHE dispatch_private_info_template {
-    // duplicate alignment here, otherwise size of structure is not correct in our compiler
-    union KMP_ALIGN_CACHE private_info_tmpl {
-        dispatch_private_infoXX_template< T > p;
-        dispatch_private_info64_t             p64;
-    } u;
-    enum sched_type schedule;  /* scheduling algorithm */
-    kmp_uint32      ordered;   /* ordered clause specified */
-    kmp_uint32      ordered_bumped;
-    kmp_int32   ordered_dummy[KMP_MAX_ORDERED-3]; // to retain the structure size after making order
-    dispatch_private_info * next; /* stack of buffers for nest of serial regions */
-    kmp_uint32      nomerge;   /* don't merge iters if serialized */
-    kmp_uint32      type_size;
-    enum cons_type  pushed_ws;
+template <typename T> struct KMP_ALIGN_CACHE dispatch_private_info_template {
+  // duplicate alignment here, otherwise size of structure is not correct in our
+  // compiler
+  union KMP_ALIGN_CACHE private_info_tmpl {
+    dispatch_private_infoXX_template<T> p;
+    dispatch_private_info64_t p64;
+  } u;
+  enum sched_type schedule; /* scheduling algorithm */
+  kmp_uint32 ordered; /* ordered clause specified */
+  kmp_uint32 ordered_bumped;
+  // To retain the structure size after making ordered_iteration scalar
+  kmp_int32 ordered_dummy[KMP_MAX_ORDERED - 3];
+  dispatch_private_info *next; /* stack of buffers for nest of serial regions */
+  kmp_uint32 nomerge; /* don't merge iters if serialized */
+  kmp_uint32 type_size;
+  enum cons_type pushed_ws;
 };
 
-
-// replaces dispatch_shared_info{32,64} structures and dispatch_shared_info{32,64}_t types
-template< typename UT >
-struct dispatch_shared_infoXX_template {
-    /* chunk index under dynamic, number of idle threads under static-steal;
-       iteration index otherwise */
-    volatile UT     iteration;
-    volatile UT     num_done;
-    volatile UT     ordered_iteration;
-    UT   ordered_dummy[KMP_MAX_ORDERED-3]; // to retain the structure size making ordered_iteration scalar
+// replaces dispatch_shared_info{32,64} structures and
+// dispatch_shared_info{32,64}_t types
+template <typename UT> struct dispatch_shared_infoXX_template {
+  /* chunk index under dynamic, number of idle threads under static-steal;
+     iteration index otherwise */
+  volatile UT iteration;
+  volatile UT num_done;
+  volatile UT ordered_iteration;
+  // to retain the structure size making ordered_iteration scalar
+  UT ordered_dummy[KMP_MAX_ORDERED - 3];
 };
 
 // replaces dispatch_shared_info structure and dispatch_shared_info_t type
-template< typename UT >
-struct dispatch_shared_info_template {
-    // we need union here to keep the structure size
-    union shared_info_tmpl {
-        dispatch_shared_infoXX_template< UT >  s;
-        dispatch_shared_info64_t               s64;
-    } u;
-    volatile kmp_uint32     buffer_index;
+template <typename UT> struct dispatch_shared_info_template {
+  // we need union here to keep the structure size
+  union shared_info_tmpl {
+    dispatch_shared_infoXX_template<UT> s;
+    dispatch_shared_info64_t s64;
+  } u;
+  volatile kmp_uint32 buffer_index;
 #if OMP_45_ENABLED
-    volatile kmp_int32      doacross_buf_idx;  // teamwise index
-    kmp_uint32             *doacross_flags;    // array of iteration flags (0/1)
-    kmp_int32               doacross_num_done; // count finished threads
+  volatile kmp_int32 doacross_buf_idx; // teamwise index
+  kmp_uint32 *doacross_flags; // array of iteration flags (0/1)
+  kmp_int32 doacross_num_done; // count finished threads
 #endif
 #if KMP_USE_HWLOC
-    // When linking with libhwloc, the ORDERED EPCC test slowsdown on big
-    // machines (> 48 cores). Performance analysis showed that a cache thrash
-    // was occurring and this padding helps alleviate the problem.
-    char padding[64];
+  // When linking with libhwloc, the ORDERED EPCC test slowsdown on big
+  // machines (> 48 cores). Performance analysis showed that a cache thrash
+  // was occurring and this padding helps alleviate the problem.
+  char padding[64];
 #endif
 };
 
 /* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
 
 #undef USE_TEST_LOCKS
 
 // test_then_add template (general template should NOT be used)
-template< typename T >
-static __forceinline T
-test_then_add( volatile T *p, T d );
-
-template<>
-__forceinline kmp_int32
-test_then_add< kmp_int32 >( volatile kmp_int32 *p, kmp_int32 d )
-{
-    kmp_int32 r;
-    r = KMP_TEST_THEN_ADD32( p, d );
-    return r;
-}
+template <typename T> static __forceinline T test_then_add(volatile T *p, T d);
 
-template<>
-__forceinline kmp_int64
-test_then_add< kmp_int64 >( volatile kmp_int64 *p, kmp_int64 d )
-{
-    kmp_int64 r;
-    r = KMP_TEST_THEN_ADD64( p, d );
-    return r;
+template <>
+__forceinline kmp_int32 test_then_add<kmp_int32>(volatile kmp_int32 *p,
+                                                 kmp_int32 d) {
+  kmp_int32 r;
+  r = KMP_TEST_THEN_ADD32(p, d);
+  return r;
+}
+
+template <>
+__forceinline kmp_int64 test_then_add<kmp_int64>(volatile kmp_int64 *p,
+                                                 kmp_int64 d) {
+  kmp_int64 r;
+  r = KMP_TEST_THEN_ADD64(p, d);
+  return r;
 }
 
 // test_then_inc_acq template (general template should NOT be used)
-template< typename T >
-static __forceinline T
-test_then_inc_acq( volatile T *p );
-
-template<>
-__forceinline kmp_int32
-test_then_inc_acq< kmp_int32 >( volatile kmp_int32 *p )
-{
-    kmp_int32 r;
-    r = KMP_TEST_THEN_INC_ACQ32( p );
-    return r;
+template <typename T> static __forceinline T test_then_inc_acq(volatile T *p);
+
+template <>
+__forceinline kmp_int32 test_then_inc_acq<kmp_int32>(volatile kmp_int32 *p) {
+  kmp_int32 r;
+  r = KMP_TEST_THEN_INC_ACQ32(p);
+  return r;
 }
 
-template<>
-__forceinline kmp_int64
-test_then_inc_acq< kmp_int64 >( volatile kmp_int64 *p )
-{
-    kmp_int64 r;
-    r = KMP_TEST_THEN_INC_ACQ64( p );
-    return r;
+template <>
+__forceinline kmp_int64 test_then_inc_acq<kmp_int64>(volatile kmp_int64 *p) {
+  kmp_int64 r;
+  r = KMP_TEST_THEN_INC_ACQ64(p);
+  return r;
 }
 
 // test_then_inc template (general template should NOT be used)
-template< typename T >
-static __forceinline T
-test_then_inc( volatile T *p );
-
-template<>
-__forceinline kmp_int32
-test_then_inc< kmp_int32 >( volatile kmp_int32 *p )
-{
-    kmp_int32 r;
-    r = KMP_TEST_THEN_INC32( p );
-    return r;
+template <typename T> static __forceinline T test_then_inc(volatile T *p);
+
+template <>
+__forceinline kmp_int32 test_then_inc<kmp_int32>(volatile kmp_int32 *p) {
+  kmp_int32 r;
+  r = KMP_TEST_THEN_INC32(p);
+  return r;
 }
 
-template<>
-__forceinline kmp_int64
-test_then_inc< kmp_int64 >( volatile kmp_int64 *p )
-{
-    kmp_int64 r;
-    r = KMP_TEST_THEN_INC64( p );
-    return r;
+template <>
+__forceinline kmp_int64 test_then_inc<kmp_int64>(volatile kmp_int64 *p) {
+  kmp_int64 r;
+  r = KMP_TEST_THEN_INC64(p);
+  return r;
 }
 
 // compare_and_swap template (general template should NOT be used)
-template< typename T >
-static __forceinline kmp_int32
-compare_and_swap( volatile T *p, T c, T s );
-
-template<>
-__forceinline kmp_int32
-compare_and_swap< kmp_int32 >( volatile kmp_int32 *p, kmp_int32 c, kmp_int32 s )
-{
-    return KMP_COMPARE_AND_STORE_REL32( p, c, s );
-}
-
-template<>
-__forceinline kmp_int32
-compare_and_swap< kmp_int64 >( volatile kmp_int64 *p, kmp_int64 c, kmp_int64 s )
-{
-    return KMP_COMPARE_AND_STORE_REL64( p, c, s );
+template <typename T>
+static __forceinline kmp_int32 compare_and_swap(volatile T *p, T c, T s);
+
+template <>
+__forceinline kmp_int32 compare_and_swap<kmp_int32>(volatile kmp_int32 *p,
+                                                    kmp_int32 c, kmp_int32 s) {
+  return KMP_COMPARE_AND_STORE_REL32(p, c, s);
 }
 
-/*
-    Spin wait loop that first does pause, then yield.
+template <>
+__forceinline kmp_int32 compare_and_swap<kmp_int64>(volatile kmp_int64 *p,
+                                                    kmp_int64 c, kmp_int64 s) {
+  return KMP_COMPARE_AND_STORE_REL64(p, c, s);
+}
+
+/* Spin wait loop that first does pause, then yield.
     Waits until function returns non-zero when called with *spinner and check.
     Does NOT put threads to sleep.
 #if USE_ITT_BUILD
     Arguments:
-        obj -- is higher-level synchronization object to report to ittnotify. It is used to report
-            locks consistently. For example, if lock is acquired immediately, its address is
-            reported to ittnotify via KMP_FSYNC_ACQUIRED(). However, it lock cannot be acquired
-            immediately and lock routine calls to KMP_WAIT_YIELD(), the later should report the same
-            address, not an address of low-level spinner.
+        obj -- is higher-level synchronization object to report to ittnotify.
+        It is used to report locks consistently. For example, if lock is
+        acquired immediately, its address is reported to ittnotify via
+        KMP_FSYNC_ACQUIRED(). However, it lock cannot be acquired immediately
+        and lock routine calls to KMP_WAIT_YIELD(), the later should report the
+        same address, not an address of low-level spinner.
 #endif // USE_ITT_BUILD
 */
-template< typename UT >
+template <typename UT>
 // ToDo: make inline function (move to header file for icl)
-static UT  // unsigned 4- or 8-byte type
-__kmp_wait_yield( volatile UT * spinner,
-                  UT            checker,
-                  kmp_uint32 (* pred)( UT, UT )
-                  USE_ITT_BUILD_ARG(void        * obj)    // Higher-level synchronization object, or NULL.
-                  )
-{
-    // note: we may not belong to a team at this point
-    register volatile UT         * spin          = spinner;
-    register          UT           check         = checker;
-    register          kmp_uint32   spins;
-    register          kmp_uint32 (*f) ( UT, UT ) = pred;
-    register          UT           r;
-
-    KMP_FSYNC_SPIN_INIT( obj, (void*) spin );
-    KMP_INIT_YIELD( spins );
-    // main wait spin loop
-    while(!f(r = *spin, check))
-    {
-        KMP_FSYNC_SPIN_PREPARE( obj );
-        /* GEH - remove this since it was accidentally introduced when kmp_wait was split.
-           It causes problems with infinite recursion because of exit lock */
-        /* if ( TCR_4(__kmp_global.g.g_done) && __kmp_global.g.g_abort)
-            __kmp_abort_thread(); */
-
-        // if we are oversubscribed,
-        // or have waited a bit (and KMP_LIBRARY=throughput, then yield
-        // pause is in the following code
-        KMP_YIELD( TCR_4(__kmp_nth) > __kmp_avail_proc );
-        KMP_YIELD_SPIN( spins );
-    }
-    KMP_FSYNC_SPIN_ACQUIRED( obj );
-    return r;
-}
-
-template< typename UT >
-static kmp_uint32 __kmp_eq( UT value, UT checker) {
-    return value == checker;
-}
-
-template< typename UT >
-static kmp_uint32 __kmp_neq( UT value, UT checker) {
-    return value != checker;
+static UT // unsigned 4- or 8-byte type
+    __kmp_wait_yield(
+        volatile UT *spinner, UT checker,
+        kmp_uint32 (*pred)(UT, UT) USE_ITT_BUILD_ARG(
+            void *obj) // Higher-level synchronization object, or NULL.
+        ) {
+  // note: we may not belong to a team at this point
+  register volatile UT *spin = spinner;
+  register UT check = checker;
+  register kmp_uint32 spins;
+  register kmp_uint32 (*f)(UT, UT) = pred;
+  register UT r;
+
+  KMP_FSYNC_SPIN_INIT(obj, (void *)spin);
+  KMP_INIT_YIELD(spins);
+  // main wait spin loop
+  while (!f(r = *spin, check)) {
+    KMP_FSYNC_SPIN_PREPARE(obj);
+    /* GEH - remove this since it was accidentally introduced when kmp_wait was
+       split. It causes problems with infinite recursion because of exit lock */
+    /* if ( TCR_4(__kmp_global.g.g_done) && __kmp_global.g.g_abort)
+        __kmp_abort_thread(); */
+
+    // if we are oversubscribed, or have waited a bit (and
+    // KMP_LIBRARY=throughput, then yield. pause is in the following code
+    KMP_YIELD(TCR_4(__kmp_nth) > __kmp_avail_proc);
+    KMP_YIELD_SPIN(spins);
+  }
+  KMP_FSYNC_SPIN_ACQUIRED(obj);
+  return r;
+}
+
+template <typename UT> static kmp_uint32 __kmp_eq(UT value, UT checker) {
+  return value == checker;
+}
+
+template <typename UT> static kmp_uint32 __kmp_neq(UT value, UT checker) {
+  return value != checker;
+}
+
+template <typename UT> static kmp_uint32 __kmp_lt(UT value, UT checker) {
+  return value < checker;
 }
 
-template< typename UT >
-static kmp_uint32 __kmp_lt( UT value, UT checker) {
-    return value < checker;
+template <typename UT> static kmp_uint32 __kmp_ge(UT value, UT checker) {
+  return value >= checker;
 }
 
-template< typename UT >
-static kmp_uint32 __kmp_ge( UT value, UT checker) {
-    return value >= checker;
+template <typename UT> static kmp_uint32 __kmp_le(UT value, UT checker) {
+  return value <= checker;
 }
 
-template< typename UT >
-static kmp_uint32 __kmp_le( UT value, UT checker) {
-    return value <= checker;
-}
-
-
-/* ------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------ */
 
-static void
-__kmp_dispatch_deo_error( int *gtid_ref, int *cid_ref, ident_t *loc_ref )
-{
-    kmp_info_t *th;
-
-    KMP_DEBUG_ASSERT( gtid_ref );
-
-    if ( __kmp_env_consistency_check ) {
-        th = __kmp_threads[*gtid_ref];
-        if ( th -> th.th_root -> r.r_active
-          && ( th -> th.th_dispatch -> th_dispatch_pr_current -> pushed_ws != ct_none ) ) {
+static void __kmp_dispatch_deo_error(int *gtid_ref, int *cid_ref,
+                                     ident_t *loc_ref) {
+  kmp_info_t *th;
+
+  KMP_DEBUG_ASSERT(gtid_ref);
+
+  if (__kmp_env_consistency_check) {
+    th = __kmp_threads[*gtid_ref];
+    if (th->th.th_root->r.r_active &&
+        (th->th.th_dispatch->th_dispatch_pr_current->pushed_ws != ct_none)) {
 #if KMP_USE_DYNAMIC_LOCK
-            __kmp_push_sync( *gtid_ref, ct_ordered_in_pdo, loc_ref, NULL, 0 );
+      __kmp_push_sync(*gtid_ref, ct_ordered_in_pdo, loc_ref, NULL, 0);
 #else
-            __kmp_push_sync( *gtid_ref, ct_ordered_in_pdo, loc_ref, NULL );
+      __kmp_push_sync(*gtid_ref, ct_ordered_in_pdo, loc_ref, NULL);
 #endif
-        }
     }
+  }
 }
 
-template< typename UT >
-static void
-__kmp_dispatch_deo( int *gtid_ref, int *cid_ref, ident_t *loc_ref )
-{
-    typedef typename traits_t< UT >::signed_t    ST;
-    dispatch_private_info_template< UT > * pr;
-
-    int gtid = *gtid_ref;
-//    int  cid = *cid_ref;
-    kmp_info_t *th = __kmp_threads[ gtid ];
-    KMP_DEBUG_ASSERT( th -> th.th_dispatch );
-
-    KD_TRACE(100, ("__kmp_dispatch_deo: T#%d called\n", gtid ) );
-    if ( __kmp_env_consistency_check ) {
-        pr = reinterpret_cast< dispatch_private_info_template< UT >* >
-            ( th -> th.th_dispatch -> th_dispatch_pr_current );
-        if ( pr -> pushed_ws != ct_none ) {
+template <typename UT>
+static void __kmp_dispatch_deo(int *gtid_ref, int *cid_ref, ident_t *loc_ref) {
+  typedef typename traits_t<UT>::signed_t ST;
+  dispatch_private_info_template<UT> *pr;
+
+  int gtid = *gtid_ref;
+  //    int  cid = *cid_ref;
+  kmp_info_t *th = __kmp_threads[gtid];
+  KMP_DEBUG_ASSERT(th->th.th_dispatch);
+
+  KD_TRACE(100, ("__kmp_dispatch_deo: T#%d called\n", gtid));
+  if (__kmp_env_consistency_check) {
+    pr = reinterpret_cast<dispatch_private_info_template<UT> *>(
+        th->th.th_dispatch->th_dispatch_pr_current);
+    if (pr->pushed_ws != ct_none) {
 #if KMP_USE_DYNAMIC_LOCK
-            __kmp_push_sync( gtid, ct_ordered_in_pdo, loc_ref, NULL, 0 );
+      __kmp_push_sync(gtid, ct_ordered_in_pdo, loc_ref, NULL, 0);
 #else
-            __kmp_push_sync( gtid, ct_ordered_in_pdo, loc_ref, NULL );
+      __kmp_push_sync(gtid, ct_ordered_in_pdo, loc_ref, NULL);
 #endif
-        }
     }
+  }
 
-    if ( ! th -> th.th_team -> t.t_serialized ) {
-        dispatch_shared_info_template< UT >  * sh = reinterpret_cast< dispatch_shared_info_template< UT >* >
-            ( th -> th.th_dispatch -> th_dispatch_sh_current );
-        UT  lower;
-
-        if ( ! __kmp_env_consistency_check ) {
-                pr = reinterpret_cast< dispatch_private_info_template< UT >* >
-                    ( th -> th.th_dispatch -> th_dispatch_pr_current );
-        }
-        lower = pr->u.p.ordered_lower;
-
-        #if ! defined( KMP_GOMP_COMPAT )
-            if ( __kmp_env_consistency_check ) {
-                if ( pr->ordered_bumped ) {
-                    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-                    __kmp_error_construct2(
-                        kmp_i18n_msg_CnsMultipleNesting,
-                        ct_ordered_in_pdo, loc_ref,
-                        & p->stack_data[ p->w_top ]
-                    );
-                }
-            }
-        #endif /* !defined(KMP_GOMP_COMPAT) */
-
-        KMP_MB();
-        #ifdef KMP_DEBUG
-        {
-            const char * buff;
-            // create format specifiers before the debug output
-            buff = __kmp_str_format(
-                "__kmp_dispatch_deo: T#%%d before wait: ordered_iter:%%%s lower:%%%s\n",
-                traits_t< UT >::spec, traits_t< UT >::spec );
-            KD_TRACE(1000, ( buff, gtid, sh->u.s.ordered_iteration, lower ) );
-            __kmp_str_free( &buff );
-        }
-        #endif
-
-        __kmp_wait_yield< UT >( &sh->u.s.ordered_iteration, lower, __kmp_ge< UT >
-                                USE_ITT_BUILD_ARG( NULL )
-                                );
-        KMP_MB();  /* is this necessary? */
-        #ifdef KMP_DEBUG
-        {
-            const char * buff;
-            // create format specifiers before the debug output
-            buff = __kmp_str_format(
-                "__kmp_dispatch_deo: T#%%d after wait: ordered_iter:%%%s lower:%%%s\n",
-                traits_t< UT >::spec, traits_t< UT >::spec );
-            KD_TRACE(1000, ( buff, gtid, sh->u.s.ordered_iteration, lower ) );
-            __kmp_str_free( &buff );
-        }
-        #endif
+  if (!th->th.th_team->t.t_serialized) {
+    dispatch_shared_info_template<UT> *sh =
+        reinterpret_cast<dispatch_shared_info_template<UT> *>(
+            th->th.th_dispatch->th_dispatch_sh_current);
+    UT lower;
+
+    if (!__kmp_env_consistency_check) {
+      pr = reinterpret_cast<dispatch_private_info_template<UT> *>(
+          th->th.th_dispatch->th_dispatch_pr_current);
+    }
+    lower = pr->u.p.ordered_lower;
+
+#if !defined(KMP_GOMP_COMPAT)
+    if (__kmp_env_consistency_check) {
+      if (pr->ordered_bumped) {
+        struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+        __kmp_error_construct2(kmp_i18n_msg_CnsMultipleNesting,
+                               ct_ordered_in_pdo, loc_ref,
+                               &p->stack_data[p->w_top]);
+      }
     }
-    KD_TRACE(100, ("__kmp_dispatch_deo: T#%d returned\n", gtid ) );
-}
+#endif /* !defined(KMP_GOMP_COMPAT) */
 
-static void
-__kmp_dispatch_dxo_error( int *gtid_ref, int *cid_ref, ident_t *loc_ref )
-{
-    kmp_info_t *th;
-
-    if ( __kmp_env_consistency_check ) {
-        th = __kmp_threads[*gtid_ref];
-        if ( th -> th.th_dispatch -> th_dispatch_pr_current -> pushed_ws != ct_none ) {
-            __kmp_pop_sync( *gtid_ref, ct_ordered_in_pdo, loc_ref );
-        }
+    KMP_MB();
+#ifdef KMP_DEBUG
+    {
+      const char *buff;
+      // create format specifiers before the debug output
+      buff = __kmp_str_format("__kmp_dispatch_deo: T#%%d before wait: "
+                              "ordered_iter:%%%s lower:%%%s\n",
+                              traits_t<UT>::spec, traits_t<UT>::spec);
+      KD_TRACE(1000, (buff, gtid, sh->u.s.ordered_iteration, lower));
+      __kmp_str_free(&buff);
     }
-}
+#endif
 
-template< typename UT >
-static void
-__kmp_dispatch_dxo( int *gtid_ref, int *cid_ref, ident_t *loc_ref )
-{
-    typedef typename traits_t< UT >::signed_t    ST;
-    dispatch_private_info_template< UT > * pr;
-
-    int gtid = *gtid_ref;
-//    int  cid = *cid_ref;
-    kmp_info_t *th = __kmp_threads[ gtid ];
-    KMP_DEBUG_ASSERT( th -> th.th_dispatch );
-
-    KD_TRACE(100, ("__kmp_dispatch_dxo: T#%d called\n", gtid ) );
-    if ( __kmp_env_consistency_check ) {
-        pr = reinterpret_cast< dispatch_private_info_template< UT >* >
-            ( th -> th.th_dispatch -> th_dispatch_pr_current );
-        if ( pr -> pushed_ws != ct_none ) {
-            __kmp_pop_sync( gtid, ct_ordered_in_pdo, loc_ref );
-        }
+    __kmp_wait_yield<UT>(&sh->u.s.ordered_iteration, lower,
+                         __kmp_ge<UT> USE_ITT_BUILD_ARG(NULL));
+    KMP_MB(); /* is this necessary? */
+#ifdef KMP_DEBUG
+    {
+      const char *buff;
+      // create format specifiers before the debug output
+      buff = __kmp_str_format("__kmp_dispatch_deo: T#%%d after wait: "
+                              "ordered_iter:%%%s lower:%%%s\n",
+                              traits_t<UT>::spec, traits_t<UT>::spec);
+      KD_TRACE(1000, (buff, gtid, sh->u.s.ordered_iteration, lower));
+      __kmp_str_free(&buff);
     }
+#endif
+  }
+  KD_TRACE(100, ("__kmp_dispatch_deo: T#%d returned\n", gtid));
+}
 
-    if ( ! th -> th.th_team -> t.t_serialized ) {
-        dispatch_shared_info_template< UT >  * sh = reinterpret_cast< dispatch_shared_info_template< UT >* >
-            ( th -> th.th_dispatch -> th_dispatch_sh_current );
-
-        if ( ! __kmp_env_consistency_check ) {
-            pr = reinterpret_cast< dispatch_private_info_template< UT >* >
-                ( th -> th.th_dispatch -> th_dispatch_pr_current );
-        }
-
-        KMP_FSYNC_RELEASING( & sh->u.s.ordered_iteration );
-        #if ! defined( KMP_GOMP_COMPAT )
-            if ( __kmp_env_consistency_check ) {
-                if ( pr->ordered_bumped != 0 ) {
-                    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-                    /* How to test it? - OM */
-                    __kmp_error_construct2(
-                        kmp_i18n_msg_CnsMultipleNesting,
-                        ct_ordered_in_pdo, loc_ref,
-                        & p->stack_data[ p->w_top ]
-                    );
-                }
-            }
-        #endif /* !defined(KMP_GOMP_COMPAT) */
-
-        KMP_MB();       /* Flush all pending memory write invalidates.  */
-
-        pr->ordered_bumped += 1;
-
-        KD_TRACE(1000, ("__kmp_dispatch_dxo: T#%d bumping ordered ordered_bumped=%d\n",
-                        gtid, pr->ordered_bumped ) );
-
-        KMP_MB();       /* Flush all pending memory write invalidates.  */
-
-        /* TODO use general release procedure? */
-        test_then_inc< ST >( (volatile ST *) & sh->u.s.ordered_iteration );
-
-        KMP_MB();       /* Flush all pending memory write invalidates.  */
+static void __kmp_dispatch_dxo_error(int *gtid_ref, int *cid_ref,
+                                     ident_t *loc_ref) {
+  kmp_info_t *th;
+
+  if (__kmp_env_consistency_check) {
+    th = __kmp_threads[*gtid_ref];
+    if (th->th.th_dispatch->th_dispatch_pr_current->pushed_ws != ct_none) {
+      __kmp_pop_sync(*gtid_ref, ct_ordered_in_pdo, loc_ref);
+    }
+  }
+}
+
+template <typename UT>
+static void __kmp_dispatch_dxo(int *gtid_ref, int *cid_ref, ident_t *loc_ref) {
+  typedef typename traits_t<UT>::signed_t ST;
+  dispatch_private_info_template<UT> *pr;
+
+  int gtid = *gtid_ref;
+  //    int  cid = *cid_ref;
+  kmp_info_t *th = __kmp_threads[gtid];
+  KMP_DEBUG_ASSERT(th->th.th_dispatch);
+
+  KD_TRACE(100, ("__kmp_dispatch_dxo: T#%d called\n", gtid));
+  if (__kmp_env_consistency_check) {
+    pr = reinterpret_cast<dispatch_private_info_template<UT> *>(
+        th->th.th_dispatch->th_dispatch_pr_current);
+    if (pr->pushed_ws != ct_none) {
+      __kmp_pop_sync(gtid, ct_ordered_in_pdo, loc_ref);
+    }
+  }
+
+  if (!th->th.th_team->t.t_serialized) {
+    dispatch_shared_info_template<UT> *sh =
+        reinterpret_cast<dispatch_shared_info_template<UT> *>(
+            th->th.th_dispatch->th_dispatch_sh_current);
+
+    if (!__kmp_env_consistency_check) {
+      pr = reinterpret_cast<dispatch_private_info_template<UT> *>(
+          th->th.th_dispatch->th_dispatch_pr_current);
+    }
+
+    KMP_FSYNC_RELEASING(&sh->u.s.ordered_iteration);
+#if !defined(KMP_GOMP_COMPAT)
+    if (__kmp_env_consistency_check) {
+      if (pr->ordered_bumped != 0) {
+        struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+        /* How to test it? - OM */
+        __kmp_error_construct2(kmp_i18n_msg_CnsMultipleNesting,
+                               ct_ordered_in_pdo, loc_ref,
+                               &p->stack_data[p->w_top]);
+      }
     }
-    KD_TRACE(100, ("__kmp_dispatch_dxo: T#%d returned\n", gtid ) );
-}
+#endif /* !defined(KMP_GOMP_COMPAT) */
 
-/* Computes and returns x to the power of y, where y must a non-negative integer */
-template< typename UT >
-static __forceinline long double
-__kmp_pow(long double x, UT y) {
-    long double s=1.0L;
+    KMP_MB(); /* Flush all pending memory write invalidates.  */
 
-    KMP_DEBUG_ASSERT(x > 0.0 && x < 1.0);
-    //KMP_DEBUG_ASSERT(y >= 0); // y is unsigned
-    while(y) {
-        if ( y & 1 )
-            s *= x;
-        x *= x;
-        y >>= 1;
-    }
-    return s;
-}
+    pr->ordered_bumped += 1;
 
-/* Computes and returns the number of unassigned iterations after idx chunks have been assigned
-   (the total number of unassigned iterations in chunks with index greater than or equal to idx).
-   __forceinline seems to be broken so that if we __forceinline this function, the behavior is wrong
-   (one of the unit tests, sch_guided_analytical_basic.cpp, fails)
-*/
-template< typename T >
-static __inline typename traits_t< T >::unsigned_t
-__kmp_dispatch_guided_remaining(
-    T                                  tc,
-    typename traits_t< T >::floating_t base,
-    typename traits_t< T >::unsigned_t idx
-) {
-    /* Note: On Windows* OS on IA-32 architecture and Intel(R) 64, at
-       least for ICL 8.1, long double arithmetic may not really have
-       long double precision, even with /Qlong_double.  Currently, we
-       workaround that in the caller code, by manipulating the FPCW for
-       Windows* OS on IA-32 architecture.  The lack of precision is not
-       expected to be a correctness issue, though.
-    */
-    typedef typename traits_t< T >::unsigned_t  UT;
-
-    long double x = tc * __kmp_pow< UT >(base, idx);
-    UT r = (UT) x;
-    if ( x == r )
-        return r;
-    return r + 1;
+    KD_TRACE(1000,
+             ("__kmp_dispatch_dxo: T#%d bumping ordered ordered_bumped=%d\n",
+              gtid, pr->ordered_bumped));
+
+    KMP_MB(); /* Flush all pending memory write invalidates.  */
+
+    /* TODO use general release procedure? */
+    test_then_inc<ST>((volatile ST *)&sh->u.s.ordered_iteration);
+
+    KMP_MB(); /* Flush all pending memory write invalidates.  */
+  }
+  KD_TRACE(100, ("__kmp_dispatch_dxo: T#%d returned\n", gtid));
+}
+
+// Computes and returns x to the power of y, where y must a non-negative integer
+template <typename UT>
+static __forceinline long double __kmp_pow(long double x, UT y) {
+  long double s = 1.0L;
+
+  KMP_DEBUG_ASSERT(x > 0.0 && x < 1.0);
+  // KMP_DEBUG_ASSERT(y >= 0); // y is unsigned
+  while (y) {
+    if (y & 1)
+      s *= x;
+    x *= x;
+    y >>= 1;
+  }
+  return s;
+}
+
+/* Computes and returns the number of unassigned iterations after idx chunks
+   have been assigned (the total number of unassigned iterations in chunks with
+   index greater than or equal to idx). __forceinline seems to be broken so that
+   if we __forceinline this function, the behavior is wrong
+   (one of the unit tests, sch_guided_analytical_basic.cpp, fails) */
+template <typename T>
+static __inline typename traits_t<T>::unsigned_t
+__kmp_dispatch_guided_remaining(T tc, typename traits_t<T>::floating_t base,
+                                typename traits_t<T>::unsigned_t idx) {
+  /* Note: On Windows* OS on IA-32 architecture and Intel(R) 64, at least for
+     ICL 8.1, long double arithmetic may not really have long double precision,
+     even with /Qlong_double.  Currently, we workaround that in the caller code,
+     by manipulating the FPCW for Windows* OS on IA-32 architecture.  The lack
+     of precision is not expected to be a correctness issue, though. */
+  typedef typename traits_t<T>::unsigned_t UT;
+
+  long double x = tc * __kmp_pow<UT>(base, idx);
+  UT r = (UT)x;
+  if (x == r)
+    return r;
+  return r + 1;
 }
 
 // Parameters of the guided-iterative algorithm:
 //   p2 = n * nproc * ( chunk + 1 )  // point of switching to dynamic
 //   p3 = 1 / ( n * nproc )          // remaining iterations multiplier
-// by default n = 2. For example with n = 3 the chunks distribution will be more flat.
+// by default n = 2. For example with n = 3 the chunks distribution will be more
+// flat.
 // With n = 1 first chunk is the same as for static schedule, e.g. trip / nproc.
 static int guided_int_param = 2;
-static double guided_flt_param = 0.5;// = 1.0 / guided_int_param;
+static double guided_flt_param = 0.5; // = 1.0 / guided_int_param;
 
 // UT - unsigned flavor of T, ST - signed flavor of T,
 // DBL - double if sizeof(T)==4, or long double if sizeof(T)==8
-template< typename T >
+template <typename T>
 static void
-__kmp_dispatch_init(
-    ident_t                        * loc,
-    int                              gtid,
-    enum sched_type                  schedule,
-    T                                lb,
-    T                                ub,
-    typename traits_t< T >::signed_t st,
-    typename traits_t< T >::signed_t chunk,
-    int                              push_ws
-) {
-    typedef typename traits_t< T >::unsigned_t  UT;
-    typedef typename traits_t< T >::signed_t    ST;
-    typedef typename traits_t< T >::floating_t  DBL;
-
-    int                                            active;
-    T                                              tc;
-    kmp_info_t *                                   th;
-    kmp_team_t *                                   team;
-    kmp_uint32                                     my_buffer_index;
-    dispatch_private_info_template< T >          * pr;
-    dispatch_shared_info_template< UT > volatile * sh;
+__kmp_dispatch_init(ident_t *loc, int gtid, enum sched_type schedule, T lb,
+                    T ub, typename traits_t<T>::signed_t st,
+                    typename traits_t<T>::signed_t chunk, int push_ws) {
+  typedef typename traits_t<T>::unsigned_t UT;
+  typedef typename traits_t<T>::signed_t ST;
+  typedef typename traits_t<T>::floating_t DBL;
+
+  int active;
+  T tc;
+  kmp_info_t *th;
+  kmp_team_t *team;
+  kmp_uint32 my_buffer_index;
+  dispatch_private_info_template<T> *pr;
+  dispatch_shared_info_template<UT> volatile *sh;
+
+  KMP_BUILD_ASSERT(sizeof(dispatch_private_info_template<T>) ==
+                   sizeof(dispatch_private_info));
+  KMP_BUILD_ASSERT(sizeof(dispatch_shared_info_template<UT>) ==
+                   sizeof(dispatch_shared_info));
 
-    KMP_BUILD_ASSERT( sizeof( dispatch_private_info_template< T > ) == sizeof( dispatch_private_info ) );
-    KMP_BUILD_ASSERT( sizeof( dispatch_shared_info_template< UT > ) == sizeof( dispatch_shared_info ) );
-
-    if ( ! TCR_4( __kmp_init_parallel ) )
-        __kmp_parallel_initialize();
+  if (!TCR_4(__kmp_init_parallel))
+    __kmp_parallel_initialize();
 
 #if INCLUDE_SSC_MARKS
-    SSC_MARK_DISPATCH_INIT();
+  SSC_MARK_DISPATCH_INIT();
 #endif
-    #ifdef KMP_DEBUG
-    {
-        const char * buff;
-        // create format specifiers before the debug output
-        buff = __kmp_str_format(
-            "__kmp_dispatch_init: T#%%d called: schedule:%%d chunk:%%%s lb:%%%s ub:%%%s st:%%%s\n",
-            traits_t< ST >::spec, traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec );
-        KD_TRACE(10, ( buff, gtid, schedule, chunk, lb, ub, st ) );
-        __kmp_str_free( &buff );
-    }
-    #endif
-    /* setup data */
-    th     = __kmp_threads[ gtid ];
-    team   = th -> th.th_team;
-    active = ! team -> t.t_serialized;
-    th->th.th_ident = loc;
+#ifdef KMP_DEBUG
+  {
+    const char *buff;
+    // create format specifiers before the debug output
+    buff = __kmp_str_format("__kmp_dispatch_init: T#%%d called: schedule:%%d "
+                            "chunk:%%%s lb:%%%s ub:%%%s st:%%%s\n",
+                            traits_t<ST>::spec, traits_t<T>::spec,
+                            traits_t<T>::spec, traits_t<ST>::spec);
+    KD_TRACE(10, (buff, gtid, schedule, chunk, lb, ub, st));
+    __kmp_str_free(&buff);
+  }
+#endif
+  /* setup data */
+  th = __kmp_threads[gtid];
+  team = th->th.th_team;
+  active = !team->t.t_serialized;
+  th->th.th_ident = loc;
 
 #if USE_ITT_BUILD
-    kmp_uint64 cur_chunk = chunk;
-    int itt_need_metadata_reporting = __itt_metadata_add_ptr && __kmp_forkjoin_frames_mode == 3 &&
-        KMP_MASTER_GTID(gtid) &&
+  kmp_uint64 cur_chunk = chunk;
+  int itt_need_metadata_reporting = __itt_metadata_add_ptr &&
+                                    __kmp_forkjoin_frames_mode == 3 &&
+                                    KMP_MASTER_GTID(gtid) &&
 #if OMP_40_ENABLED
-        th->th.th_teams_microtask == NULL &&
+                                    th->th.th_teams_microtask == NULL &&
 #endif
-        team->t.t_active_level == 1;
+                                    team->t.t_active_level == 1;
 #endif
-    if ( ! active ) {
-        pr = reinterpret_cast< dispatch_private_info_template< T >* >
-            ( th -> th.th_dispatch -> th_disp_buffer ); /* top of the stack */
-    } else {
-        KMP_DEBUG_ASSERT( th->th.th_dispatch ==
-                &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid] );
-
-        my_buffer_index = th->th.th_dispatch->th_disp_index ++;
-
-        /* What happens when number of threads changes, need to resize buffer? */
-        pr = reinterpret_cast< dispatch_private_info_template< T >  * >
-            ( &th -> th.th_dispatch -> th_disp_buffer[ my_buffer_index % __kmp_dispatch_num_buffers ] );
-        sh = reinterpret_cast< dispatch_shared_info_template< UT > volatile * >
-            ( &team -> t.t_disp_buffer[ my_buffer_index % __kmp_dispatch_num_buffers ] );
-    }
-
-    #if  ( KMP_STATIC_STEAL_ENABLED )
-    if ( SCHEDULE_HAS_NONMONOTONIC(schedule) )
-        // AC: we now have only one implementation of stealing, so use it
-        schedule = kmp_sch_static_steal;
-    else
-    #endif
-        schedule = SCHEDULE_WITHOUT_MODIFIERS(schedule);
-
-    /* Pick up the nomerge/ordered bits from the scheduling type */
-    if ( (schedule >= kmp_nm_lower) && (schedule < kmp_nm_upper) ) {
-        pr->nomerge = TRUE;
-        schedule = (enum sched_type)(((int)schedule) - (kmp_nm_lower - kmp_sch_lower));
-    } else {
-        pr->nomerge = FALSE;
-    }
-    pr->type_size = traits_t<T>::type_size; // remember the size of variables
-    if ( kmp_ord_lower & schedule ) {
-        pr->ordered = TRUE;
-        schedule = (enum sched_type)(((int)schedule) - (kmp_ord_lower - kmp_sch_lower));
-    } else {
-        pr->ordered = FALSE;
-    }
+  if (!active) {
+    pr = reinterpret_cast<dispatch_private_info_template<T> *>(
+        th->th.th_dispatch->th_disp_buffer); /* top of the stack */
+  } else {
+    KMP_DEBUG_ASSERT(th->th.th_dispatch ==
+                     &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid]);
+
+    my_buffer_index = th->th.th_dispatch->th_disp_index++;
+
+    /* What happens when number of threads changes, need to resize buffer? */
+    pr = reinterpret_cast<dispatch_private_info_template<T> *>(
+        &th->th.th_dispatch
+             ->th_disp_buffer[my_buffer_index % __kmp_dispatch_num_buffers]);
+    sh = reinterpret_cast<dispatch_shared_info_template<UT> volatile *>(
+        &team->t.t_disp_buffer[my_buffer_index % __kmp_dispatch_num_buffers]);
+  }
+
+#if (KMP_STATIC_STEAL_ENABLED)
+  if (SCHEDULE_HAS_NONMONOTONIC(schedule))
+    // AC: we now have only one implementation of stealing, so use it
+    schedule = kmp_sch_static_steal;
+  else
+#endif
+    schedule = SCHEDULE_WITHOUT_MODIFIERS(schedule);
 
-    if ( schedule == kmp_sch_static ) {
+  /* Pick up the nomerge/ordered bits from the scheduling type */
+  if ((schedule >= kmp_nm_lower) && (schedule < kmp_nm_upper)) {
+    pr->nomerge = TRUE;
+    schedule =
+        (enum sched_type)(((int)schedule) - (kmp_nm_lower - kmp_sch_lower));
+  } else {
+    pr->nomerge = FALSE;
+  }
+  pr->type_size = traits_t<T>::type_size; // remember the size of variables
+  if (kmp_ord_lower & schedule) {
+    pr->ordered = TRUE;
+    schedule =
+        (enum sched_type)(((int)schedule) - (kmp_ord_lower - kmp_sch_lower));
+  } else {
+    pr->ordered = FALSE;
+  }
+
+  if (schedule == kmp_sch_static) {
+    schedule = __kmp_static;
+  } else {
+    if (schedule == kmp_sch_runtime) {
+      // Use the scheduling specified by OMP_SCHEDULE (or __kmp_sch_default if
+      // not specified)
+      schedule = team->t.t_sched.r_sched_type;
+      // Detail the schedule if needed (global controls are differentiated
+      // appropriately)
+      if (schedule == kmp_sch_guided_chunked) {
+        schedule = __kmp_guided;
+      } else if (schedule == kmp_sch_static) {
         schedule = __kmp_static;
-    } else {
-        if ( schedule == kmp_sch_runtime ) {
-            // Use the scheduling specified by OMP_SCHEDULE (or __kmp_sch_default if not specified)
-            schedule = team -> t.t_sched.r_sched_type;
-            // Detail the schedule if needed (global controls are differentiated appropriately)
-            if ( schedule == kmp_sch_guided_chunked ) {
-                schedule = __kmp_guided;
-            } else if ( schedule == kmp_sch_static ) {
-                schedule = __kmp_static;
-            }
-            // Use the chunk size specified by OMP_SCHEDULE (or default if not specified)
-            chunk = team -> t.t_sched.chunk;
+      }
+      // Use the chunk size specified by OMP_SCHEDULE (or default if not
+      // specified)
+      chunk = team->t.t_sched.chunk;
 #if USE_ITT_BUILD
-            cur_chunk = chunk;
+      cur_chunk = chunk;
 #endif
-            #ifdef KMP_DEBUG
-            {
-                const char * buff;
-                // create format specifiers before the debug output
-                buff = __kmp_str_format(
-                    "__kmp_dispatch_init: T#%%d new: schedule:%%d chunk:%%%s\n",
-                    traits_t< ST >::spec );
-                KD_TRACE(10, ( buff, gtid, schedule, chunk ) );
-                __kmp_str_free( &buff );
-            }
-            #endif
-        } else {
-            if ( schedule == kmp_sch_guided_chunked ) {
-                schedule = __kmp_guided;
-            }
-            if ( chunk <= 0 ) {
-                chunk = KMP_DEFAULT_CHUNK;
-            }
-        }
-
-        if ( schedule == kmp_sch_auto ) {
-            // mapping and differentiation: in the __kmp_do_serial_initialize()
-            schedule = __kmp_auto;
-            #ifdef KMP_DEBUG
-            {
-                const char * buff;
-                // create format specifiers before the debug output
-                buff = __kmp_str_format(
-                    "__kmp_dispatch_init: kmp_sch_auto: T#%%d new: schedule:%%d chunk:%%%s\n",
-                    traits_t< ST >::spec );
-                KD_TRACE(10, ( buff, gtid, schedule, chunk ) );
-                __kmp_str_free( &buff );
-            }
-            #endif
-        }
-
-        /* guided analytical not safe for too many threads */
-        if ( schedule == kmp_sch_guided_analytical_chunked && th->th.th_team_nproc > 1<<20 ) {
-            schedule = kmp_sch_guided_iterative_chunked;
-            KMP_WARNING( DispatchManyThreads );
-        }
-        pr->u.p.parm1 = chunk;
+#ifdef KMP_DEBUG
+      {
+        const char *buff;
+        // create format specifiers before the debug output
+        buff = __kmp_str_format(
+            "__kmp_dispatch_init: T#%%d new: schedule:%%d chunk:%%%s\n",
+            traits_t<ST>::spec);
+        KD_TRACE(10, (buff, gtid, schedule, chunk));
+        __kmp_str_free(&buff);
+      }
+#endif
+    } else {
+      if (schedule == kmp_sch_guided_chunked) {
+        schedule = __kmp_guided;
+      }
+      if (chunk <= 0) {
+        chunk = KMP_DEFAULT_CHUNK;
+      }
     }
-    KMP_ASSERT2( (kmp_sch_lower < schedule && schedule < kmp_sch_upper),
-                "unknown scheduling type" );
 
-    pr->u.p.count = 0;
-
-    if ( __kmp_env_consistency_check ) {
-        if ( st == 0 ) {
-            __kmp_error_construct(
-                kmp_i18n_msg_CnsLoopIncrZeroProhibited,
-                ( pr->ordered ? ct_pdo_ordered : ct_pdo ), loc
-            );
-        }
-    }
-    // compute trip count
-    if ( st == 1 ) {   // most common case
-        if ( ub >= lb ) {
-            tc = ub - lb + 1;
-        } else {   // ub < lb
-            tc = 0;            // zero-trip
-        }
-    } else if ( st < 0 ) {
-        if ( lb >= ub ) {
-            // AC: cast to unsigned is needed for loops like (i=2B; i>-2B; i-=1B),
-            //     where the division needs to be unsigned regardless of the result type
-            tc = (UT)(lb - ub) / (-st) + 1;
-        } else {   // lb < ub
-            tc = 0;            // zero-trip
-        }
-    } else {       // st > 0
-        if ( ub >= lb ) {
-            // AC: cast to unsigned is needed for loops like (i=-2B; i<2B; i+=1B),
-            //     where the division needs to be unsigned regardless of the result type
-            tc = (UT)(ub - lb) / st + 1;
-        } else {   // ub < lb
-            tc = 0;            // zero-trip
-        }
+    if (schedule == kmp_sch_auto) {
+      // mapping and differentiation: in the __kmp_do_serial_initialize()
+      schedule = __kmp_auto;
+#ifdef KMP_DEBUG
+      {
+        const char *buff;
+        // create format specifiers before the debug output
+        buff = __kmp_str_format("__kmp_dispatch_init: kmp_sch_auto: T#%%d new: "
+                                "schedule:%%d chunk:%%%s\n",
+                                traits_t<ST>::spec);
+        KD_TRACE(10, (buff, gtid, schedule, chunk));
+        __kmp_str_free(&buff);
+      }
+#endif
     }
 
-    // Any half-decent optimizer will remove this test when the blocks are empty since the macros expand to nothing
-    // when statistics are disabled.
-    if (schedule == __kmp_static)
-    {
-        KMP_COUNT_BLOCK(OMP_FOR_static);
-        KMP_COUNT_VALUE(FOR_static_iterations, tc);
-    }
-    else
-    {
-        KMP_COUNT_BLOCK(OMP_FOR_dynamic);
-        KMP_COUNT_VALUE(FOR_dynamic_iterations, tc);
-    }
+    /* guided analytical not safe for too many threads */
+    if (schedule == kmp_sch_guided_analytical_chunked &&
+        th->th.th_team_nproc > 1 << 20) {
+      schedule = kmp_sch_guided_iterative_chunked;
+      KMP_WARNING(DispatchManyThreads);
+    }
+    pr->u.p.parm1 = chunk;
+  }
+  KMP_ASSERT2((kmp_sch_lower < schedule && schedule < kmp_sch_upper),
+              "unknown scheduling type");
+
+  pr->u.p.count = 0;
+
+  if (__kmp_env_consistency_check) {
+    if (st == 0) {
+      __kmp_error_construct(kmp_i18n_msg_CnsLoopIncrZeroProhibited,
+                            (pr->ordered ? ct_pdo_ordered : ct_pdo), loc);
+    }
+  }
+  // compute trip count
+  if (st == 1) { // most common case
+    if (ub >= lb) {
+      tc = ub - lb + 1;
+    } else { // ub < lb
+      tc = 0; // zero-trip
+    }
+  } else if (st < 0) {
+    if (lb >= ub) {
+      // AC: cast to unsigned is needed for loops like (i=2B; i>-2B; i-=1B),
+      // where the division needs to be unsigned regardless of the result type
+      tc = (UT)(lb - ub) / (-st) + 1;
+    } else { // lb < ub
+      tc = 0; // zero-trip
+    }
+  } else { // st > 0
+    if (ub >= lb) {
+      // AC: cast to unsigned is needed for loops like (i=-2B; i<2B; i+=1B),
+      // where the division needs to be unsigned regardless of the result type
+      tc = (UT)(ub - lb) / st + 1;
+    } else { // ub < lb
+      tc = 0; // zero-trip
+    }
+  }
+
+  // Any half-decent optimizer will remove this test when the blocks are empty
+  // since the macros expand to nothing when statistics are disabled.
+  if (schedule == __kmp_static) {
+    KMP_COUNT_BLOCK(OMP_FOR_static);
+    KMP_COUNT_VALUE(FOR_static_iterations, tc);
+  } else {
+    KMP_COUNT_BLOCK(OMP_FOR_dynamic);
+    KMP_COUNT_VALUE(FOR_dynamic_iterations, tc);
+  }
+
+  pr->u.p.lb = lb;
+  pr->u.p.ub = ub;
+  pr->u.p.st = st;
+  pr->u.p.tc = tc;
 
-    pr->u.p.lb = lb;
-    pr->u.p.ub = ub;
-    pr->u.p.st = st;
-    pr->u.p.tc = tc;
+#if KMP_OS_WINDOWS
+  pr->u.p.last_upper = ub + st;
+#endif /* KMP_OS_WINDOWS */
 
-    #if KMP_OS_WINDOWS
-    pr->u.p.last_upper = ub + st;
-    #endif /* KMP_OS_WINDOWS */
+  /* NOTE: only the active parallel region(s) has active ordered sections */
 
-    /* NOTE: only the active parallel region(s) has active ordered sections */
+  if (active) {
+    if (pr->ordered == 0) {
+      th->th.th_dispatch->th_deo_fcn = __kmp_dispatch_deo_error;
+      th->th.th_dispatch->th_dxo_fcn = __kmp_dispatch_dxo_error;
+    } else {
+      pr->ordered_bumped = 0;
 
-    if ( active ) {
-        if ( pr->ordered == 0 ) {
-            th -> th.th_dispatch -> th_deo_fcn = __kmp_dispatch_deo_error;
-            th -> th.th_dispatch -> th_dxo_fcn = __kmp_dispatch_dxo_error;
-        } else {
-            pr->ordered_bumped = 0;
+      pr->u.p.ordered_lower = 1;
+      pr->u.p.ordered_upper = 0;
 
-            pr->u.p.ordered_lower = 1;
-            pr->u.p.ordered_upper = 0;
+      th->th.th_dispatch->th_deo_fcn = __kmp_dispatch_deo<UT>;
+      th->th.th_dispatch->th_dxo_fcn = __kmp_dispatch_dxo<UT>;
+    }
+  }
 
-            th -> th.th_dispatch -> th_deo_fcn = __kmp_dispatch_deo< UT >;
-            th -> th.th_dispatch -> th_dxo_fcn = __kmp_dispatch_dxo< UT >;
-        }
+  if (__kmp_env_consistency_check) {
+    enum cons_type ws = pr->ordered ? ct_pdo_ordered : ct_pdo;
+    if (push_ws) {
+      __kmp_push_workshare(gtid, ws, loc);
+      pr->pushed_ws = ws;
+    } else {
+      __kmp_check_workshare(gtid, ws, loc);
+      pr->pushed_ws = ct_none;
     }
+  }
 
-    if ( __kmp_env_consistency_check ) {
-        enum cons_type ws = pr->ordered ? ct_pdo_ordered : ct_pdo;
-        if ( push_ws ) {
-            __kmp_push_workshare( gtid, ws, loc );
-            pr->pushed_ws = ws;
+  switch (schedule) {
+#if (KMP_STATIC_STEAL_ENABLED)
+  case kmp_sch_static_steal: {
+    T nproc = th->th.th_team_nproc;
+    T ntc, init;
+
+    KD_TRACE(100,
+             ("__kmp_dispatch_init: T#%d kmp_sch_static_steal case\n", gtid));
+
+    ntc = (tc % chunk ? 1 : 0) + tc / chunk;
+    if (nproc > 1 && ntc >= nproc) {
+      KMP_COUNT_BLOCK(OMP_FOR_static_steal);
+      T id = __kmp_tid_from_gtid(gtid);
+      T small_chunk, extras;
+
+      small_chunk = ntc / nproc;
+      extras = ntc % nproc;
+
+      init = id * small_chunk + (id < extras ? id : extras);
+      pr->u.p.count = init;
+      pr->u.p.ub = init + small_chunk + (id < extras ? 1 : 0);
+
+      pr->u.p.parm2 = lb;
+      // pr->pfields.parm3 = 0; // it's not used in static_steal
+      pr->u.p.parm4 = (id + 1) % nproc; // remember neighbour tid
+      pr->u.p.st = st;
+      if (traits_t<T>::type_size > 4) {
+        // AC: TODO: check if 16-byte CAS available and use it to
+        // improve performance (probably wait for explicit request
+        // before spending time on this).
+        // For now use dynamically allocated per-thread lock,
+        // free memory in __kmp_dispatch_next when status==0.
+        KMP_DEBUG_ASSERT(th->th.th_dispatch->th_steal_lock == NULL);
+        th->th.th_dispatch->th_steal_lock =
+            (kmp_lock_t *)__kmp_allocate(sizeof(kmp_lock_t));
+        __kmp_init_lock(th->th.th_dispatch->th_steal_lock);
+      }
+      break;
+    } else {
+      KD_TRACE(100, ("__kmp_dispatch_init: T#%d falling-through to "
+                     "kmp_sch_static_balanced\n",
+                     gtid));
+      schedule = kmp_sch_static_balanced;
+      /* too few iterations: fall-through to kmp_sch_static_balanced */
+    } // if
+    /* FALL-THROUGH to static balanced */
+  } // case
+#endif
+  case kmp_sch_static_balanced: {
+    T nproc = th->th.th_team_nproc;
+    T init, limit;
+
+    KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_static_balanced case\n",
+                   gtid));
+
+    if (nproc > 1) {
+      T id = __kmp_tid_from_gtid(gtid);
+
+      if (tc < nproc) {
+        if (id < tc) {
+          init = id;
+          limit = id;
+          pr->u.p.parm1 = (id == tc - 1); /* parm1 stores *plastiter */
         } else {
-            __kmp_check_workshare( gtid, ws, loc );
-            pr->pushed_ws = ct_none;
-        }
+          pr->u.p.count = 1; /* means no more chunks to execute */
+          pr->u.p.parm1 = FALSE;
+          break;
+        }
+      } else {
+        T small_chunk = tc / nproc;
+        T extras = tc % nproc;
+        init = id * small_chunk + (id < extras ? id : extras);
+        limit = init + small_chunk - (id < extras ? 0 : 1);
+        pr->u.p.parm1 = (id == nproc - 1);
+      }
+    } else {
+      if (tc > 0) {
+        init = 0;
+        limit = tc - 1;
+        pr->u.p.parm1 = TRUE;
+      } else { // zero trip count
+        pr->u.p.count = 1; /* means no more chunks to execute */
+        pr->u.p.parm1 = FALSE;
+        break;
+      }
+    }
+#if USE_ITT_BUILD
+    // Calculate chunk for metadata report
+    if (itt_need_metadata_reporting)
+      cur_chunk = limit - init + 1;
+#endif
+    if (st == 1) {
+      pr->u.p.lb = lb + init;
+      pr->u.p.ub = lb + limit;
+    } else {
+      // calculated upper bound, "ub" is user-defined upper bound
+      T ub_tmp = lb + limit * st;
+      pr->u.p.lb = lb + init * st;
+      // adjust upper bound to "ub" if needed, so that MS lastprivate will match
+      // it exactly
+      if (st > 0) {
+        pr->u.p.ub = (ub_tmp + st > ub ? ub : ub_tmp);
+      } else {
+        pr->u.p.ub = (ub_tmp + st < ub ? ub : ub_tmp);
+      }
     }
+    if (pr->ordered) {
+      pr->u.p.ordered_lower = init;
+      pr->u.p.ordered_upper = limit;
+    }
+    break;
+  } // case
+  case kmp_sch_guided_iterative_chunked: {
+    T nproc = th->th.th_team_nproc;
+    KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_guided_iterative_chunked"
+                   " case\n",
+                   gtid));
+
+    if (nproc > 1) {
+      if ((2L * chunk + 1) * nproc >= tc) {
+        /* chunk size too large, switch to dynamic */
+        schedule = kmp_sch_dynamic_chunked;
+      } else {
+        // when remaining iters become less than parm2 - switch to dynamic
+        pr->u.p.parm2 = guided_int_param * nproc * (chunk + 1);
+        *(double *)&pr->u.p.parm3 =
+            guided_flt_param / nproc; // may occupy parm3 and parm4
+      }
+    } else {
+      KD_TRACE(100, ("__kmp_dispatch_init: T#%d falling-through to "
+                     "kmp_sch_static_greedy\n",
+                     gtid));
+      schedule = kmp_sch_static_greedy;
+      /* team->t.t_nproc == 1: fall-through to kmp_sch_static_greedy */
+      KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_static_greedy case\n",
+                     gtid));
+      pr->u.p.parm1 = tc;
+    } // if
+  } // case
+  break;
+  case kmp_sch_guided_analytical_chunked: {
+    T nproc = th->th.th_team_nproc;
+    KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_guided_analytical_chunked"
+                   " case\n",
+                   gtid));
+    if (nproc > 1) {
+      if ((2L * chunk + 1) * nproc >= tc) {
+        /* chunk size too large, switch to dynamic */
+        schedule = kmp_sch_dynamic_chunked;
+      } else {
+        /* commonly used term: (2 nproc - 1)/(2 nproc) */
+        DBL x;
 
-    switch ( schedule ) {
-    #if  ( KMP_STATIC_STEAL_ENABLED )
-    case kmp_sch_static_steal:
-        {
-            T nproc = th->th.th_team_nproc;
-            T ntc, init;
+#if KMP_OS_WINDOWS && KMP_ARCH_X86
+        /* Linux* OS already has 64-bit computation by default for long double,
+           and on Windows* OS on Intel(R) 64, /Qlong_double doesn't work. On
+           Windows* OS on IA-32 architecture, we need to set precision to 64-bit
+           instead of the default 53-bit. Even though long double doesn't work
+           on Windows* OS on Intel(R) 64, the resulting lack of precision is not
+           expected to impact the correctness of the algorithm, but this has not
+           been mathematically proven. */
+        // save original FPCW and set precision to 64-bit, as
+        // Windows* OS on IA-32 architecture defaults to 53-bit
+        unsigned int oldFpcw = _control87(0, 0);
+        _control87(_PC_64, _MCW_PC); // 0,0x30000
+#endif
+        /* value used for comparison in solver for cross-over point */
+        long double target = ((long double)chunk * 2 + 1) * nproc / tc;
 
-            KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_static_steal case\n", gtid ) );
+        /* crossover point--chunk indexes equal to or greater than
+           this point switch to dynamic-style scheduling */
+        UT cross;
+
+        /* commonly used term: (2 nproc - 1)/(2 nproc) */
+        x = (long double)1.0 - (long double)0.5 / nproc;
+
+#ifdef KMP_DEBUG
+        { // test natural alignment
+          struct _test_a {
+            char a;
+            union {
+              char b;
+              DBL d;
+            };
+          } t;
+          ptrdiff_t natural_alignment =
+              (ptrdiff_t)&t.b - (ptrdiff_t)&t - (ptrdiff_t)1;
+          //__kmp_warn( " %llx %llx %lld", (long long)&t.d, (long long)&t, (long
+          // long)natural_alignment );
+          KMP_DEBUG_ASSERT(
+              (((ptrdiff_t)&pr->u.p.parm3) & (natural_alignment)) == 0);
+        }
+#endif // KMP_DEBUG
 
-            ntc = (tc % chunk ? 1 : 0) + tc / chunk;
-            if ( nproc > 1 && ntc >= nproc ) {
-                KMP_COUNT_BLOCK(OMP_FOR_static_steal);
-                T id = __kmp_tid_from_gtid(gtid);
-                T small_chunk, extras;
-
-                small_chunk = ntc / nproc;
-                extras = ntc % nproc;
-
-                init = id * small_chunk + ( id < extras ? id : extras );
-                pr->u.p.count = init;
-                pr->u.p.ub = init + small_chunk + ( id < extras ? 1 : 0 );
-
-                pr->u.p.parm2 = lb;
-                //pr->pfields.parm3 = 0; // it's not used in static_steal
-                pr->u.p.parm4 = (id + 1) % nproc; // remember neighbour tid
-                pr->u.p.st = st;
-                if ( traits_t<T>::type_size > 4 ) {
-                    // AC: TODO: check if 16-byte CAS available and use it to
-                    // improve performance (probably wait for explicit request
-                    // before spending time on this).
-                    // For now use dynamically allocated per-thread lock,
-                    // free memory in __kmp_dispatch_next when status==0.
-                    KMP_DEBUG_ASSERT(th->th.th_dispatch->th_steal_lock == NULL);
-                    th->th.th_dispatch->th_steal_lock =
-                        (kmp_lock_t*)__kmp_allocate(sizeof(kmp_lock_t));
-                    __kmp_init_lock(th->th.th_dispatch->th_steal_lock);
-                }
-                break;
-            } else {
-                KD_TRACE(100, ("__kmp_dispatch_init: T#%d falling-through to kmp_sch_static_balanced\n",
-                               gtid ) );
-                schedule = kmp_sch_static_balanced;
-                /* too few iterations: fall-through to kmp_sch_static_balanced */
-            } // if
-            /* FALL-THROUGH to static balanced */
-        } // case
-    #endif
-    case kmp_sch_static_balanced:
-        {
-            T nproc = th->th.th_team_nproc;
-            T init, limit;
+        /* save the term in thread private dispatch structure */
+        *(DBL *)&pr->u.p.parm3 = x;
 
-            KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_static_balanced case\n",
-                            gtid ) );
+        /* solve for the crossover point to the nearest integer i for which C_i
+           <= chunk */
+        {
+          UT left, right, mid;
+          long double p;
 
-            if ( nproc > 1 ) {
-                T id = __kmp_tid_from_gtid(gtid);
+          /* estimate initial upper and lower bound */
 
-                if ( tc < nproc ) {
-                    if ( id < tc ) {
-                        init = id;
-                        limit = id;
-                        pr->u.p.parm1 = (id == tc - 1);  /* parm1 stores *plastiter */
-                    } else {
-                        pr->u.p.count = 1;  /* means no more chunks to execute */
-                        pr->u.p.parm1 = FALSE;
-                        break;
-                    }
-                } else {
-                    T small_chunk = tc / nproc;
-                    T extras = tc % nproc;
-                    init = id * small_chunk + (id < extras ? id : extras);
-                    limit = init + small_chunk - (id < extras ? 0 : 1);
-                    pr->u.p.parm1 = (id == nproc - 1);
-                }
+          /* doesn't matter what value right is as long as it is positive, but
+             it affects performance of the solver */
+          right = 229;
+          p = __kmp_pow<UT>(x, right);
+          if (p > target) {
+            do {
+              p *= p;
+              right <<= 1;
+            } while (p > target && right < (1 << 27));
+            /* lower bound is previous (failed) estimate of upper bound */
+            left = right >> 1;
+          } else {
+            left = 0;
+          }
+
+          /* bisection root-finding method */
+          while (left + 1 < right) {
+            mid = (left + right) / 2;
+            if (__kmp_pow<UT>(x, mid) > target) {
+              left = mid;
             } else {
-                if ( tc > 0 ) {
-                    init = 0;
-                    limit = tc - 1;
-                    pr->u.p.parm1 = TRUE;
-                } else {
-                    // zero trip count
-                    pr->u.p.count = 1;  /* means no more chunks to execute */
-                    pr->u.p.parm1 = FALSE;
-                    break;
-                }
+              right = mid;
             }
-#if USE_ITT_BUILD
-            // Calculate chunk for metadata report
-            if ( itt_need_metadata_reporting )
-                cur_chunk = limit - init + 1;
-#endif
-            if ( st == 1 ) {
-                pr->u.p.lb = lb + init;
-                pr->u.p.ub = lb + limit;
-            } else {
-                T ub_tmp = lb + limit * st;   // calculated upper bound, "ub" is user-defined upper bound
-                pr->u.p.lb = lb + init * st;
-                // adjust upper bound to "ub" if needed, so that MS lastprivate will match it exactly
-                if ( st > 0 ) {
-                    pr->u.p.ub = ( ub_tmp + st > ub ? ub : ub_tmp );
-                } else {
-                    pr->u.p.ub = ( ub_tmp + st < ub ? ub : ub_tmp );
-                }
-            }
-            if ( pr->ordered ) {
-                pr->u.p.ordered_lower = init;
-                pr->u.p.ordered_upper = limit;
-            }
-            break;
-        } // case
-    case kmp_sch_guided_iterative_chunked :
-        {
-            T nproc = th->th.th_team_nproc;
-            KD_TRACE(100,("__kmp_dispatch_init: T#%d kmp_sch_guided_iterative_chunked case\n",gtid));
+          } // while
+          cross = right;
+        }
+        /* assert sanity of computed crossover point */
+        KMP_ASSERT(cross && __kmp_pow<UT>(x, cross - 1) > target &&
+                   __kmp_pow<UT>(x, cross) <= target);
 
-            if ( nproc > 1 ) {
-                if ( (2L * chunk + 1 ) * nproc >= tc ) {
-                    /* chunk size too large, switch to dynamic */
-                    schedule = kmp_sch_dynamic_chunked;
-                } else {
-                    // when remaining iters become less than parm2 - switch to dynamic
-                    pr->u.p.parm2 = guided_int_param * nproc * ( chunk + 1 );
-                    *(double*)&pr->u.p.parm3 = guided_flt_param / nproc;   // may occupy parm3 and parm4
-                }
-            } else {
-                KD_TRACE(100,("__kmp_dispatch_init: T#%d falling-through to kmp_sch_static_greedy\n",gtid));
-                schedule = kmp_sch_static_greedy;
-                /* team->t.t_nproc == 1: fall-through to kmp_sch_static_greedy */
-                KD_TRACE(100,("__kmp_dispatch_init: T#%d kmp_sch_static_greedy case\n",gtid));
-                pr->u.p.parm1 = tc;
-            } // if
-        } // case
-        break;
-    case kmp_sch_guided_analytical_chunked:
-        {
-            T nproc = th->th.th_team_nproc;
-            KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_guided_analytical_chunked case\n", gtid));
+        /* save the crossover point in thread private dispatch structure */
+        pr->u.p.parm2 = cross;
 
-            if ( nproc > 1 ) {
-                if ( (2L * chunk + 1 ) * nproc >= tc ) {
-                    /* chunk size too large, switch to dynamic */
-                    schedule = kmp_sch_dynamic_chunked;
-                } else {
-                    /* commonly used term: (2 nproc - 1)/(2 nproc) */
-                    DBL x;
+// C75803
+#if ((KMP_OS_LINUX || KMP_OS_WINDOWS) && KMP_ARCH_X86) && (!defined(KMP_I8))
+#define GUIDED_ANALYTICAL_WORKAROUND (*(DBL *)&pr->u.p.parm3)
+#else
+#define GUIDED_ANALYTICAL_WORKAROUND (x)
+#endif
+        /* dynamic-style scheduling offset */
+        pr->u.p.count = tc - __kmp_dispatch_guided_remaining(
+                                 tc, GUIDED_ANALYTICAL_WORKAROUND, cross) -
+                        cross * chunk;
+#if KMP_OS_WINDOWS && KMP_ARCH_X86
+        // restore FPCW
+        _control87(oldFpcw, _MCW_PC);
+#endif
+      } // if
+    } else {
+      KD_TRACE(100, ("__kmp_dispatch_init: T#%d falling-through to "
+                     "kmp_sch_static_greedy\n",
+                     gtid));
+      schedule = kmp_sch_static_greedy;
+      /* team->t.t_nproc == 1: fall-through to kmp_sch_static_greedy */
+      pr->u.p.parm1 = tc;
+    } // if
+  } // case
+  break;
+  case kmp_sch_static_greedy:
+    KD_TRACE(100,
+             ("__kmp_dispatch_init: T#%d kmp_sch_static_greedy case\n", gtid));
+    pr->u.p.parm1 = (th->th.th_team_nproc > 1)
+                        ? (tc + th->th.th_team_nproc - 1) / th->th.th_team_nproc
+                        : tc;
+    break;
+  case kmp_sch_static_chunked:
+  case kmp_sch_dynamic_chunked:
+    if (pr->u.p.parm1 <= 0) {
+      pr->u.p.parm1 = KMP_DEFAULT_CHUNK;
+    }
+    KD_TRACE(100, ("__kmp_dispatch_init: T#%d "
+                   "kmp_sch_static_chunked/kmp_sch_dynamic_chunked cases\n",
+                   gtid));
+    break;
+  case kmp_sch_trapezoidal: {
+    /* TSS: trapezoid self-scheduling, minimum chunk_size = parm1 */
+
+    T parm1, parm2, parm3, parm4;
+    KD_TRACE(100,
+             ("__kmp_dispatch_init: T#%d kmp_sch_trapezoidal case\n", gtid));
+
+    parm1 = chunk;
+
+    /* F : size of the first cycle */
+    parm2 = (tc / (2 * th->th.th_team_nproc));
+
+    if (parm2 < 1) {
+      parm2 = 1;
+    }
+
+    /* L : size of the last cycle.  Make sure the last cycle is not larger
+       than the first cycle. */
+    if (parm1 < 1) {
+      parm1 = 1;
+    } else if (parm1 > parm2) {
+      parm1 = parm2;
+    }
+
+    /* N : number of cycles */
+    parm3 = (parm2 + parm1);
+    parm3 = (2 * tc + parm3 - 1) / parm3;
+
+    if (parm3 < 2) {
+      parm3 = 2;
+    }
+
+    /* sigma : decreasing incr of the trapezoid */
+    parm4 = (parm3 - 1);
+    parm4 = (parm2 - parm1) / parm4;
+
+    // pointless check, because parm4 >= 0 always
+    // if ( parm4 < 0 ) {
+    //    parm4 = 0;
+    //}
+
+    pr->u.p.parm1 = parm1;
+    pr->u.p.parm2 = parm2;
+    pr->u.p.parm3 = parm3;
+    pr->u.p.parm4 = parm4;
+  } // case
+  break;
+
+  default: {
+    __kmp_msg(kmp_ms_fatal, // Severity
+              KMP_MSG(UnknownSchedTypeDetected), // Primary message
+              KMP_HNT(GetNewerLibrary), // Hint
+              __kmp_msg_null // Variadic argument list terminator
+              );
+  } break;
+  } // switch
+  pr->schedule = schedule;
+  if (active) {
+    /* The name of this buffer should be my_buffer_index when it's free to use
+     * it */
+
+    KD_TRACE(100, ("__kmp_dispatch_init: T#%d before wait: my_buffer_index:%d "
+                   "sh->buffer_index:%d\n",
+                   gtid, my_buffer_index, sh->buffer_index));
+    __kmp_wait_yield<kmp_uint32>(&sh->buffer_index, my_buffer_index,
+                                 __kmp_eq<kmp_uint32> USE_ITT_BUILD_ARG(NULL));
+    // Note: KMP_WAIT_YIELD() cannot be used there: buffer index and
+    // my_buffer_index are *always* 32-bit integers.
+    KMP_MB(); /* is this necessary? */
+    KD_TRACE(100, ("__kmp_dispatch_init: T#%d after wait: my_buffer_index:%d "
+                   "sh->buffer_index:%d\n",
+                   gtid, my_buffer_index, sh->buffer_index));
 
-                    #if KMP_OS_WINDOWS && KMP_ARCH_X86
-                    /* Linux* OS already has 64-bit computation by default for
-		       long double, and on Windows* OS on Intel(R) 64,
-		       /Qlong_double doesn't work.  On Windows* OS
-		       on IA-32 architecture, we need to set precision to
-		       64-bit instead of the default 53-bit. Even though long
-		       double doesn't work on Windows* OS on Intel(R) 64, the
-		       resulting lack of precision is not expected to impact
-		       the correctness of the algorithm, but this has not been
-		       mathematically proven.
-                    */
-                    // save original FPCW and set precision to 64-bit, as
-                    // Windows* OS on IA-32 architecture defaults to 53-bit
-                    unsigned int oldFpcw = _control87(0,0);
-                    _control87(_PC_64,_MCW_PC); // 0,0x30000
-                    #endif
-                    /* value used for comparison in solver for cross-over point */
-                    long double target = ((long double)chunk * 2 + 1) * nproc / tc;
-
-                    /* crossover point--chunk indexes equal to or greater than
-		       this point switch to dynamic-style scheduling */
-                    UT   cross;
-
-                    /* commonly used term: (2 nproc - 1)/(2 nproc) */
-                    x = (long double)1.0 - (long double)0.5 / nproc;
-
-                    #ifdef KMP_DEBUG
-                    { // test natural alignment
-                        struct _test_a {
-                            char a;
-                            union {
-                                char b;
-                                DBL  d;
-                            };
-                        } t;
-                        ptrdiff_t natural_alignment = (ptrdiff_t)&t.b - (ptrdiff_t)&t - (ptrdiff_t)1;
-                        //__kmp_warn( " %llx %llx %lld", (long long)&t.d, (long long)&t, (long long)natural_alignment );
-                        KMP_DEBUG_ASSERT( ( ( (ptrdiff_t)&pr->u.p.parm3 ) & ( natural_alignment ) ) == 0 );
-                    }
-                    #endif // KMP_DEBUG
-
-                    /* save the term in thread private dispatch structure */
-                    *(DBL*)&pr->u.p.parm3 = x;
-
-                    /* solve for the crossover point to the nearest integer i for which C_i <= chunk */
-                    {
-                        UT          left, right, mid;
-                        long double p;
-
-                        /* estimate initial upper and lower bound */
-
-                        /* doesn't matter what value right is as long as it is positive, but
-                           it affects performance of the solver
-                        */
-                        right = 229;
-                        p = __kmp_pow< UT >(x,right);
-                        if ( p > target ) {
-                            do{
-                                p *= p;
-                                right <<= 1;
-                            } while(p>target && right < (1<<27));
-                            left = right >> 1; /* lower bound is previous (failed) estimate of upper bound */
-                        } else {
-                            left = 0;
-                        }
-
-                        /* bisection root-finding method */
-                        while ( left + 1 < right ) {
-                            mid = (left + right) / 2;
-                            if ( __kmp_pow< UT >(x,mid) > target ) {
-                                left = mid;
-                            } else {
-                                right = mid;
-                            }
-                        } // while
-                        cross = right;
-                    }
-                    /* assert sanity of computed crossover point */
-                    KMP_ASSERT(cross && __kmp_pow< UT >(x, cross - 1) > target && __kmp_pow< UT >(x, cross) <= target);
-
-                    /* save the crossover point in thread private dispatch structure */
-                    pr->u.p.parm2 = cross;
-
-                    // C75803
-                    #if ( ( KMP_OS_LINUX || KMP_OS_WINDOWS ) && KMP_ARCH_X86 ) && ( ! defined( KMP_I8 ) )
-                        #define GUIDED_ANALYTICAL_WORKAROUND (*( DBL * )&pr->u.p.parm3)
-                    #else
-                        #define GUIDED_ANALYTICAL_WORKAROUND (x)
-                    #endif
-                    /* dynamic-style scheduling offset */
-                    pr->u.p.count = tc - __kmp_dispatch_guided_remaining(tc, GUIDED_ANALYTICAL_WORKAROUND, cross) - cross * chunk;
-                    #if KMP_OS_WINDOWS && KMP_ARCH_X86
-                        // restore FPCW
-                        _control87(oldFpcw,_MCW_PC);
-                    #endif
-                } // if
-            } else {
-                KD_TRACE(100, ("__kmp_dispatch_init: T#%d falling-through to kmp_sch_static_greedy\n",
-                               gtid ) );
-                schedule = kmp_sch_static_greedy;
-                /* team->t.t_nproc == 1: fall-through to kmp_sch_static_greedy */
-                pr->u.p.parm1 = tc;
-            } // if
-        } // case
+    th->th.th_dispatch->th_dispatch_pr_current = (dispatch_private_info_t *)pr;
+    th->th.th_dispatch->th_dispatch_sh_current = (dispatch_shared_info_t *)sh;
+#if USE_ITT_BUILD
+    if (pr->ordered) {
+      __kmp_itt_ordered_init(gtid);
+    }; // if
+    // Report loop metadata
+    if (itt_need_metadata_reporting) {
+      // Only report metadata by master of active team at level 1
+      kmp_uint64 schedtype = 0;
+      switch (schedule) {
+      case kmp_sch_static_chunked:
+      case kmp_sch_static_balanced: // Chunk is calculated in the switch above
         break;
-    case kmp_sch_static_greedy:
-        KD_TRACE(100,("__kmp_dispatch_init: T#%d kmp_sch_static_greedy case\n",gtid));
-            pr->u.p.parm1 = ( th->th.th_team_nproc > 1 ) ?
-                ( tc + th->th.th_team_nproc - 1 ) / th->th.th_team_nproc :
-                tc;
+      case kmp_sch_static_greedy:
+        cur_chunk = pr->u.p.parm1;
         break;
-    case kmp_sch_static_chunked :
-    case kmp_sch_dynamic_chunked :
-        if ( pr->u.p.parm1 <= 0 ) {
-            pr->u.p.parm1 = KMP_DEFAULT_CHUNK;
-        }
-        KD_TRACE(100,("__kmp_dispatch_init: T#%d kmp_sch_static_chunked/kmp_sch_dynamic_chunked cases\n", gtid));
+      case kmp_sch_dynamic_chunked:
+        schedtype = 1;
         break;
-    case kmp_sch_trapezoidal :
-        {
-            /* TSS: trapezoid self-scheduling, minimum chunk_size = parm1 */
-
-            T parm1, parm2, parm3, parm4;
-            KD_TRACE(100, ("__kmp_dispatch_init: T#%d kmp_sch_trapezoidal case\n", gtid ) );
-
-            parm1 = chunk;
-
-            /* F : size of the first cycle */
-            parm2 = ( tc / (2 * th->th.th_team_nproc) );
-
-            if ( parm2 < 1 ) {
-                parm2 = 1;
-            }
-
-            /* L : size of the last cycle.  Make sure the last cycle
-             *     is not larger than the first cycle.
-             */
-            if ( parm1 < 1 ) {
-                parm1 = 1;
-            } else if ( parm1 > parm2 ) {
-                parm1 = parm2;
-            }
-
-            /* N : number of cycles */
-            parm3 = ( parm2 + parm1 );
-            parm3 = ( 2 * tc + parm3 - 1) / parm3;
-
-            if ( parm3 < 2 ) {
-                parm3 = 2;
-            }
-
-            /* sigma : decreasing incr of the trapezoid */
-            parm4 = ( parm3 - 1 );
-            parm4 = ( parm2 - parm1 ) / parm4;
-
-            // pointless check, because parm4 >= 0 always
-            //if ( parm4 < 0 ) {
-            //    parm4 = 0;
-            //}
-
-            pr->u.p.parm1 = parm1;
-            pr->u.p.parm2 = parm2;
-            pr->u.p.parm3 = parm3;
-            pr->u.p.parm4 = parm4;
-        } // case
+      case kmp_sch_guided_iterative_chunked:
+      case kmp_sch_guided_analytical_chunked:
+        schedtype = 2;
         break;
-
-    default:
-        {
-            __kmp_msg(
-                kmp_ms_fatal,                        // Severity
-                KMP_MSG( UnknownSchedTypeDetected ), // Primary message
-                KMP_HNT( GetNewerLibrary ),          // Hint
-                __kmp_msg_null                       // Variadic argument list terminator
-            );
-        }
+      default:
+        // Should we put this case under "static"?
+        // case kmp_sch_static_steal:
+        schedtype = 3;
         break;
-    } // switch
-    pr->schedule = schedule;
-    if ( active ) {
-        /* The name of this buffer should be my_buffer_index when it's free to use it */
-
-        KD_TRACE(100, ("__kmp_dispatch_init: T#%d before wait: my_buffer_index:%d sh->buffer_index:%d\n",
-                        gtid, my_buffer_index, sh->buffer_index) );
-        __kmp_wait_yield< kmp_uint32 >( & sh->buffer_index, my_buffer_index, __kmp_eq< kmp_uint32 >
-                                        USE_ITT_BUILD_ARG( NULL )
-                                        );
-            // Note: KMP_WAIT_YIELD() cannot be used there: buffer index and my_buffer_index are
-            // *always* 32-bit integers.
-        KMP_MB();  /* is this necessary? */
-        KD_TRACE(100, ("__kmp_dispatch_init: T#%d after wait: my_buffer_index:%d sh->buffer_index:%d\n",
-                        gtid, my_buffer_index, sh->buffer_index) );
-
-        th -> th.th_dispatch -> th_dispatch_pr_current = (dispatch_private_info_t*) pr;
-        th -> th.th_dispatch -> th_dispatch_sh_current = (dispatch_shared_info_t*)  sh;
-#if USE_ITT_BUILD
-        if ( pr->ordered ) {
-            __kmp_itt_ordered_init( gtid );
-        }; // if
-        // Report loop metadata
-        if ( itt_need_metadata_reporting ) {
-            // Only report metadata by master of active team at level 1
-            kmp_uint64 schedtype = 0;
-            switch ( schedule ) {
-            case kmp_sch_static_chunked:
-            case kmp_sch_static_balanced:// Chunk is calculated in the switch above
-                break;
-            case kmp_sch_static_greedy:
-                cur_chunk = pr->u.p.parm1;
-                break;
-            case kmp_sch_dynamic_chunked:
-                schedtype = 1;
-                break;
-            case kmp_sch_guided_iterative_chunked:
-            case kmp_sch_guided_analytical_chunked:
-                schedtype = 2;
-                break;
-            default:
-//            Should we put this case under "static"?
-//            case kmp_sch_static_steal:
-                schedtype = 3;
-                break;
-            }
-            __kmp_itt_metadata_loop(loc, schedtype, tc, cur_chunk);
-        }
+      }
+      __kmp_itt_metadata_loop(loc, schedtype, tc, cur_chunk);
+    }
 #endif /* USE_ITT_BUILD */
-    }; // if
+  }; // if
 
-    #ifdef KMP_DEBUG
-    {
-        const char * buff;
-        // create format specifiers before the debug output
-        buff = __kmp_str_format(
-            "__kmp_dispatch_init: T#%%d returning: schedule:%%d ordered:%%%s lb:%%%s ub:%%%s" \
-            " st:%%%s tc:%%%s count:%%%s\n\tordered_lower:%%%s ordered_upper:%%%s" \
-            " parm1:%%%s parm2:%%%s parm3:%%%s parm4:%%%s\n",
-            traits_t< UT >::spec, traits_t< T >::spec, traits_t< T >::spec,
-            traits_t< ST >::spec, traits_t< UT >::spec, traits_t< UT >::spec,
-            traits_t< UT >::spec, traits_t< UT >::spec, traits_t< T >::spec,
-            traits_t< T >::spec, traits_t< T >::spec, traits_t< T >::spec );
-        KD_TRACE(10, ( buff,
-            gtid, pr->schedule, pr->ordered, pr->u.p.lb, pr->u.p.ub,
-            pr->u.p.st, pr->u.p.tc, pr->u.p.count,
-            pr->u.p.ordered_lower, pr->u.p.ordered_upper, pr->u.p.parm1,
-            pr->u.p.parm2, pr->u.p.parm3, pr->u.p.parm4 ) );
-        __kmp_str_free( &buff );
-    }
-    #endif
-    #if ( KMP_STATIC_STEAL_ENABLED )
-      // It cannot be guaranteed that after execution of a loop with some other schedule kind
-      // all the parm3 variables will contain the same value.
-      // Even if all parm3 will be the same, it still exists a bad case like using 0 and 1
-      // rather than program life-time increment.
-      // So the dedicated variable is required. The 'static_steal_counter' is used.
-      if( schedule == kmp_sch_static_steal ) {
-        // Other threads will inspect this variable when searching for a victim.
-        // This is a flag showing that other threads may steal from this thread since then.
-        volatile T * p = &pr->u.p.static_steal_counter;
-        *p = *p + 1;
-      }
-    #endif // ( KMP_STATIC_STEAL_ENABLED )
+#ifdef KMP_DEBUG
+  {
+    const char *buff;
+    // create format specifiers before the debug output
+    buff = __kmp_str_format(
+        "__kmp_dispatch_init: T#%%d returning: schedule:%%d ordered:%%%s "
+        "lb:%%%s ub:%%%s"
+        " st:%%%s tc:%%%s count:%%%s\n\tordered_lower:%%%s ordered_upper:%%%s"
+        " parm1:%%%s parm2:%%%s parm3:%%%s parm4:%%%s\n",
+        traits_t<UT>::spec, traits_t<T>::spec, traits_t<T>::spec,
+        traits_t<ST>::spec, traits_t<UT>::spec, traits_t<UT>::spec,
+        traits_t<UT>::spec, traits_t<UT>::spec, traits_t<T>::spec,
+        traits_t<T>::spec, traits_t<T>::spec, traits_t<T>::spec);
+    KD_TRACE(10, (buff, gtid, pr->schedule, pr->ordered, pr->u.p.lb, pr->u.p.ub,
+                  pr->u.p.st, pr->u.p.tc, pr->u.p.count, pr->u.p.ordered_lower,
+                  pr->u.p.ordered_upper, pr->u.p.parm1, pr->u.p.parm2,
+                  pr->u.p.parm3, pr->u.p.parm4));
+    __kmp_str_free(&buff);
+  }
+#endif
+#if (KMP_STATIC_STEAL_ENABLED)
+  // It cannot be guaranteed that after execution of a loop with some other
+  // schedule kind all the parm3 variables will contain the same value. Even if
+  // all parm3 will be the same, it still exists a bad case like using 0 and 1
+  // rather than program life-time increment. So the dedicated variable is
+  // required. The 'static_steal_counter' is used.
+  if (schedule == kmp_sch_static_steal) {
+    // Other threads will inspect this variable when searching for a victim.
+    // This is a flag showing that other threads may steal from this thread
+    // since then.
+    volatile T *p = &pr->u.p.static_steal_counter;
+    *p = *p + 1;
+  }
+#endif // ( KMP_STATIC_STEAL_ENABLED )
 
 #if OMPT_SUPPORT && OMPT_TRACE
-    if (ompt_enabled &&
-        ompt_callbacks.ompt_callback(ompt_event_loop_begin)) {
-        ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
-        ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
-        ompt_callbacks.ompt_callback(ompt_event_loop_begin)(
-            team_info->parallel_id, task_info->task_id, team_info->microtask);
-    }
+  if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) {
+    ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
+    ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
+    ompt_callbacks.ompt_callback(ompt_event_loop_begin)(
+        team_info->parallel_id, task_info->task_id, team_info->microtask);
+  }
 #endif
 }
 
-/*
- * For ordered loops, either __kmp_dispatch_finish() should be called after
+/* For ordered loops, either __kmp_dispatch_finish() should be called after
  * every iteration, or __kmp_dispatch_finish_chunk() should be called after
  * every chunk of iterations.  If the ordered section(s) were not executed
  * for this iteration (or every iteration in this chunk), we need to set the
- * ordered iteration counters so that the next thread can proceed.
- */
-template< typename UT >
-static void
-__kmp_dispatch_finish( int gtid, ident_t *loc )
-{
-    typedef typename traits_t< UT >::signed_t ST;
-    kmp_info_t *th = __kmp_threads[ gtid ];
-
-    KD_TRACE(100, ("__kmp_dispatch_finish: T#%d called\n", gtid ) );
-    if ( ! th -> th.th_team -> t.t_serialized ) {
-
-        dispatch_private_info_template< UT > * pr =
-            reinterpret_cast< dispatch_private_info_template< UT >* >
-            ( th->th.th_dispatch->th_dispatch_pr_current );
-        dispatch_shared_info_template< UT > volatile * sh =
-            reinterpret_cast< dispatch_shared_info_template< UT >volatile* >
-            ( th->th.th_dispatch->th_dispatch_sh_current );
-        KMP_DEBUG_ASSERT( pr );
-        KMP_DEBUG_ASSERT( sh );
-        KMP_DEBUG_ASSERT( th->th.th_dispatch ==
-                 &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid] );
-
-        if ( pr->ordered_bumped ) {
-            KD_TRACE(1000, ("__kmp_dispatch_finish: T#%d resetting ordered_bumped to zero\n",
-                            gtid ) );
-            pr->ordered_bumped = 0;
-        } else {
-            UT lower = pr->u.p.ordered_lower;
+ * ordered iteration counters so that the next thread can proceed. */
+template <typename UT>
+static void __kmp_dispatch_finish(int gtid, ident_t *loc) {
+  typedef typename traits_t<UT>::signed_t ST;
+  kmp_info_t *th = __kmp_threads[gtid];
+
+  KD_TRACE(100, ("__kmp_dispatch_finish: T#%d called\n", gtid));
+  if (!th->th.th_team->t.t_serialized) {
+
+    dispatch_private_info_template<UT> *pr =
+        reinterpret_cast<dispatch_private_info_template<UT> *>(
+            th->th.th_dispatch->th_dispatch_pr_current);
+    dispatch_shared_info_template<UT> volatile *sh =
+        reinterpret_cast<dispatch_shared_info_template<UT> volatile *>(
+            th->th.th_dispatch->th_dispatch_sh_current);
+    KMP_DEBUG_ASSERT(pr);
+    KMP_DEBUG_ASSERT(sh);
+    KMP_DEBUG_ASSERT(th->th.th_dispatch ==
+                     &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid]);
+
+    if (pr->ordered_bumped) {
+      KD_TRACE(
+          1000,
+          ("__kmp_dispatch_finish: T#%d resetting ordered_bumped to zero\n",
+           gtid));
+      pr->ordered_bumped = 0;
+    } else {
+      UT lower = pr->u.p.ordered_lower;
 
-            #ifdef KMP_DEBUG
-            {
-                const char * buff;
-                // create format specifiers before the debug output
-                buff = __kmp_str_format(
-                    "__kmp_dispatch_finish: T#%%d before wait: ordered_iteration:%%%s lower:%%%s\n",
-                    traits_t< UT >::spec, traits_t< UT >::spec );
-                KD_TRACE(1000, ( buff, gtid, sh->u.s.ordered_iteration, lower ) );
-                __kmp_str_free( &buff );
-            }
-            #endif
+#ifdef KMP_DEBUG
+      {
+        const char *buff;
+        // create format specifiers before the debug output
+        buff = __kmp_str_format("__kmp_dispatch_finish: T#%%d before wait: "
+                                "ordered_iteration:%%%s lower:%%%s\n",
+                                traits_t<UT>::spec, traits_t<UT>::spec);
+        KD_TRACE(1000, (buff, gtid, sh->u.s.ordered_iteration, lower));
+        __kmp_str_free(&buff);
+      }
+#endif
 
-            __kmp_wait_yield< UT >(&sh->u.s.ordered_iteration, lower, __kmp_ge< UT >
-                                   USE_ITT_BUILD_ARG(NULL)
-                                   );
-            KMP_MB();  /* is this necessary? */
-            #ifdef KMP_DEBUG
-            {
-                const char * buff;
-                // create format specifiers before the debug output
-                buff = __kmp_str_format(
-                    "__kmp_dispatch_finish: T#%%d after wait: ordered_iteration:%%%s lower:%%%s\n",
-                    traits_t< UT >::spec, traits_t< UT >::spec );
-                KD_TRACE(1000, ( buff, gtid, sh->u.s.ordered_iteration, lower ) );
-                __kmp_str_free( &buff );
-            }
-            #endif
+      __kmp_wait_yield<UT>(&sh->u.s.ordered_iteration, lower,
+                           __kmp_ge<UT> USE_ITT_BUILD_ARG(NULL));
+      KMP_MB(); /* is this necessary? */
+#ifdef KMP_DEBUG
+      {
+        const char *buff;
+        // create format specifiers before the debug output
+        buff = __kmp_str_format("__kmp_dispatch_finish: T#%%d after wait: "
+                                "ordered_iteration:%%%s lower:%%%s\n",
+                                traits_t<UT>::spec, traits_t<UT>::spec);
+        KD_TRACE(1000, (buff, gtid, sh->u.s.ordered_iteration, lower));
+        __kmp_str_free(&buff);
+      }
+#endif
 
-            test_then_inc< ST >( (volatile ST *) & sh->u.s.ordered_iteration );
-        } // if
+      test_then_inc<ST>((volatile ST *)&sh->u.s.ordered_iteration);
     } // if
-    KD_TRACE(100, ("__kmp_dispatch_finish: T#%d returned\n", gtid ) );
+  } // if
+  KD_TRACE(100, ("__kmp_dispatch_finish: T#%d returned\n", gtid));
 }
 
 #ifdef KMP_GOMP_COMPAT
 
-template< typename UT >
-static void
-__kmp_dispatch_finish_chunk( int gtid, ident_t *loc )
-{
-    typedef typename traits_t< UT >::signed_t ST;
-    kmp_info_t *th = __kmp_threads[ gtid ];
-
-    KD_TRACE(100, ("__kmp_dispatch_finish_chunk: T#%d called\n", gtid ) );
-    if ( ! th -> th.th_team -> t.t_serialized ) {
-//        int cid;
-        dispatch_private_info_template< UT > * pr =
-            reinterpret_cast< dispatch_private_info_template< UT >* >
-            ( th->th.th_dispatch->th_dispatch_pr_current );
-        dispatch_shared_info_template< UT > volatile * sh =
-            reinterpret_cast< dispatch_shared_info_template< UT >volatile* >
-            ( th->th.th_dispatch->th_dispatch_sh_current );
-        KMP_DEBUG_ASSERT( pr );
-        KMP_DEBUG_ASSERT( sh );
-        KMP_DEBUG_ASSERT( th->th.th_dispatch ==
-                 &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid] );
-
-//        for (cid = 0; cid < KMP_MAX_ORDERED; ++cid) {
-            UT lower = pr->u.p.ordered_lower;
-            UT upper = pr->u.p.ordered_upper;
-            UT inc = upper - lower + 1;
-
-            if ( pr->ordered_bumped == inc ) {
-                KD_TRACE(1000, ("__kmp_dispatch_finish: T#%d resetting ordered_bumped to zero\n",
-                  gtid ) );
-                pr->ordered_bumped = 0;
-            } else {
-                inc -= pr->ordered_bumped;
+template <typename UT>
+static void __kmp_dispatch_finish_chunk(int gtid, ident_t *loc) {
+  typedef typename traits_t<UT>::signed_t ST;
+  kmp_info_t *th = __kmp_threads[gtid];
+
+  KD_TRACE(100, ("__kmp_dispatch_finish_chunk: T#%d called\n", gtid));
+  if (!th->th.th_team->t.t_serialized) {
+    //        int cid;
+    dispatch_private_info_template<UT> *pr =
+        reinterpret_cast<dispatch_private_info_template<UT> *>(
+            th->th.th_dispatch->th_dispatch_pr_current);
+    dispatch_shared_info_template<UT> volatile *sh =
+        reinterpret_cast<dispatch_shared_info_template<UT> volatile *>(
+            th->th.th_dispatch->th_dispatch_sh_current);
+    KMP_DEBUG_ASSERT(pr);
+    KMP_DEBUG_ASSERT(sh);
+    KMP_DEBUG_ASSERT(th->th.th_dispatch ==
+                     &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid]);
+
+    //        for (cid = 0; cid < KMP_MAX_ORDERED; ++cid) {
+    UT lower = pr->u.p.ordered_lower;
+    UT upper = pr->u.p.ordered_upper;
+    UT inc = upper - lower + 1;
+
+    if (pr->ordered_bumped == inc) {
+      KD_TRACE(
+          1000,
+          ("__kmp_dispatch_finish: T#%d resetting ordered_bumped to zero\n",
+           gtid));
+      pr->ordered_bumped = 0;
+    } else {
+      inc -= pr->ordered_bumped;
 
-                #ifdef KMP_DEBUG
-                {
-                    const char * buff;
-                    // create format specifiers before the debug output
-                    buff = __kmp_str_format(
-                        "__kmp_dispatch_finish_chunk: T#%%d before wait: " \
-                        "ordered_iteration:%%%s lower:%%%s upper:%%%s\n",
-                        traits_t< UT >::spec, traits_t< UT >::spec, traits_t< UT >::spec );
-                    KD_TRACE(1000, ( buff, gtid, sh->u.s.ordered_iteration, lower, upper ) );
-                    __kmp_str_free( &buff );
-                }
-                #endif
+#ifdef KMP_DEBUG
+      {
+        const char *buff;
+        // create format specifiers before the debug output
+        buff = __kmp_str_format(
+            "__kmp_dispatch_finish_chunk: T#%%d before wait: "
+            "ordered_iteration:%%%s lower:%%%s upper:%%%s\n",
+            traits_t<UT>::spec, traits_t<UT>::spec, traits_t<UT>::spec);
+        KD_TRACE(1000, (buff, gtid, sh->u.s.ordered_iteration, lower, upper));
+        __kmp_str_free(&buff);
+      }
+#endif
+
+      __kmp_wait_yield<UT>(&sh->u.s.ordered_iteration, lower,
+                           __kmp_ge<UT> USE_ITT_BUILD_ARG(NULL));
 
-                __kmp_wait_yield< UT >(&sh->u.s.ordered_iteration, lower, __kmp_ge< UT >
-                                       USE_ITT_BUILD_ARG(NULL)
-                                       );
-
-                KMP_MB();  /* is this necessary? */
-                KD_TRACE(1000, ("__kmp_dispatch_finish_chunk: T#%d resetting ordered_bumped to zero\n",
-                  gtid ) );
-                pr->ordered_bumped = 0;
+      KMP_MB(); /* is this necessary? */
+      KD_TRACE(1000, ("__kmp_dispatch_finish_chunk: T#%d resetting "
+                      "ordered_bumped to zero\n",
+                      gtid));
+      pr->ordered_bumped = 0;
 //!!!!! TODO check if the inc should be unsigned, or signed???
-                #ifdef KMP_DEBUG
-                {
-                    const char * buff;
-                    // create format specifiers before the debug output
-                    buff = __kmp_str_format(
-                        "__kmp_dispatch_finish_chunk: T#%%d after wait: " \
-                        "ordered_iteration:%%%s inc:%%%s lower:%%%s upper:%%%s\n",
-                        traits_t< UT >::spec, traits_t< UT >::spec, traits_t< UT >::spec, traits_t< UT >::spec );
-                    KD_TRACE(1000, ( buff, gtid, sh->u.s.ordered_iteration, inc, lower, upper ) );
-                    __kmp_str_free( &buff );
-                }
-                #endif
+#ifdef KMP_DEBUG
+      {
+        const char *buff;
+        // create format specifiers before the debug output
+        buff = __kmp_str_format(
+            "__kmp_dispatch_finish_chunk: T#%%d after wait: "
+            "ordered_iteration:%%%s inc:%%%s lower:%%%s upper:%%%s\n",
+            traits_t<UT>::spec, traits_t<UT>::spec, traits_t<UT>::spec,
+            traits_t<UT>::spec);
+        KD_TRACE(1000,
+                 (buff, gtid, sh->u.s.ordered_iteration, inc, lower, upper));
+        __kmp_str_free(&buff);
+      }
+#endif
 
-                test_then_add< ST >( (volatile ST *) & sh->u.s.ordered_iteration, inc);
-            }
-//        }
+      test_then_add<ST>((volatile ST *)&sh->u.s.ordered_iteration, inc);
     }
-    KD_TRACE(100, ("__kmp_dispatch_finish_chunk: T#%d returned\n", gtid ) );
+    //        }
+  }
+  KD_TRACE(100, ("__kmp_dispatch_finish_chunk: T#%d returned\n", gtid));
 }
 
 #endif /* KMP_GOMP_COMPAT */
 
-/* Define a macro for exiting __kmp_dispatch_next(). If status is 0
- * (no more work), then tell OMPT the loop is over. In some cases
- * kmp_dispatch_fini() is not called. */
+/* Define a macro for exiting __kmp_dispatch_next(). If status is 0 (no more
+   work), then tell OMPT the loop is over. In some cases kmp_dispatch_fini()
+   is not called. */
 #if OMPT_SUPPORT && OMPT_TRACE
 #define OMPT_LOOP_END                                                          \
-    if (status == 0) {                                                         \
-        if (ompt_enabled &&                     \
-            ompt_callbacks.ompt_callback(ompt_event_loop_end)) {               \
-            ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);        \
-            ompt_task_info_t *task_info = __ompt_get_taskinfo(0);              \
-            ompt_callbacks.ompt_callback(ompt_event_loop_end)(                 \
-                team_info->parallel_id, task_info->task_id);                   \
-        }                                                                      \
-    }
+  if (status == 0) {                                                           \
+    if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_loop_end)) {   \
+      ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);              \
+      ompt_task_info_t *task_info = __ompt_get_taskinfo(0);                    \
+      ompt_callbacks.ompt_callback(ompt_event_loop_end)(                       \
+          team_info->parallel_id, task_info->task_id);                         \
+    }                                                                          \
+  }
 #else
 #define OMPT_LOOP_END // no-op
 #endif
 
-template< typename T >
-static int
-__kmp_dispatch_next(
-    ident_t *loc, int gtid, kmp_int32 *p_last, T *p_lb, T *p_ub, typename traits_t< T >::signed_t *p_st
-) {
-
-    typedef typename traits_t< T >::unsigned_t  UT;
-    typedef typename traits_t< T >::signed_t    ST;
-    typedef typename traits_t< T >::floating_t  DBL;
-
-    // This is potentially slightly misleading, schedule(runtime) will appear here even if the actual runtme schedule
-    // is static. (Which points out a disadavantage of schedule(runtime): even when static scheduling is used it costs
-    // more than a compile time choice to use static scheduling would.)
-    KMP_TIME_PARTITIONED_BLOCK(FOR_dynamic_scheduling);
-
-    int                                   status;
-    dispatch_private_info_template< T > * pr;
-    kmp_info_t                          * th   = __kmp_threads[ gtid ];
-    kmp_team_t                          * team = th -> th.th_team;
+template <typename T>
+static int __kmp_dispatch_next(ident_t *loc, int gtid, kmp_int32 *p_last,
+                               T *p_lb, T *p_ub,
+                               typename traits_t<T>::signed_t *p_st) {
+
+  typedef typename traits_t<T>::unsigned_t UT;
+  typedef typename traits_t<T>::signed_t ST;
+  typedef typename traits_t<T>::floating_t DBL;
+
+  // This is potentially slightly misleading, schedule(runtime) will appear here
+  // even if the actual runtme schedule is static. (Which points out a
+  // disadavantage of schedule(runtime): even when static scheduling is used it
+  // costs more than a compile time choice to use static scheduling would.)
+  KMP_TIME_PARTITIONED_BLOCK(FOR_dynamic_scheduling);
+
+  int status;
+  dispatch_private_info_template<T> *pr;
+  kmp_info_t *th = __kmp_threads[gtid];
+  kmp_team_t *team = th->th.th_team;
+
+  KMP_DEBUG_ASSERT(p_lb && p_ub && p_st); // AC: these cannot be NULL
+#ifdef KMP_DEBUG
+  {
+    const char *buff;
+    // create format specifiers before the debug output
+    buff = __kmp_str_format("__kmp_dispatch_next: T#%%d called p_lb:%%%s "
+                            "p_ub:%%%s p_st:%%%s p_last: %%p\n",
+                            traits_t<T>::spec, traits_t<T>::spec,
+                            traits_t<ST>::spec);
+    KD_TRACE(1000, (buff, gtid, *p_lb, *p_ub, p_st ? *p_st : 0, p_last));
+    __kmp_str_free(&buff);
+  }
+#endif
+
+  if (team->t.t_serialized) {
+    /* NOTE: serialize this dispatch becase we are not at the active level */
+    pr = reinterpret_cast<dispatch_private_info_template<T> *>(
+        th->th.th_dispatch->th_disp_buffer); /* top of the stack */
+    KMP_DEBUG_ASSERT(pr);
+
+    if ((status = (pr->u.p.tc != 0)) == 0) {
+      *p_lb = 0;
+      *p_ub = 0;
+      //            if ( p_last != NULL )
+      //                *p_last = 0;
+      if (p_st != NULL)
+        *p_st = 0;
+      if (__kmp_env_consistency_check) {
+        if (pr->pushed_ws != ct_none) {
+          pr->pushed_ws = __kmp_pop_workshare(gtid, pr->pushed_ws, loc);
+        }
+      }
+    } else if (pr->nomerge) {
+      kmp_int32 last;
+      T start;
+      UT limit, trip, init;
+      ST incr;
+      T chunk = pr->u.p.parm1;
+
+      KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_dynamic_chunked case\n",
+                     gtid));
+
+      init = chunk * pr->u.p.count++;
+      trip = pr->u.p.tc - 1;
+
+      if ((status = (init <= trip)) == 0) {
+        *p_lb = 0;
+        *p_ub = 0;
+        //                if ( p_last != NULL )
+        //                    *p_last = 0;
+        if (p_st != NULL)
+          *p_st = 0;
+        if (__kmp_env_consistency_check) {
+          if (pr->pushed_ws != ct_none) {
+            pr->pushed_ws = __kmp_pop_workshare(gtid, pr->pushed_ws, loc);
+          }
+        }
+      } else {
+        start = pr->u.p.lb;
+        limit = chunk + init - 1;
+        incr = pr->u.p.st;
+
+        if ((last = (limit >= trip)) != 0) {
+          limit = trip;
+#if KMP_OS_WINDOWS
+          pr->u.p.last_upper = pr->u.p.ub;
+#endif /* KMP_OS_WINDOWS */
+        }
+        if (p_last != NULL)
+          *p_last = last;
+        if (p_st != NULL)
+          *p_st = incr;
+        if (incr == 1) {
+          *p_lb = start + init;
+          *p_ub = start + limit;
+        } else {
+          *p_lb = start + init * incr;
+          *p_ub = start + limit * incr;
+        }
 
-    KMP_DEBUG_ASSERT( p_lb && p_ub && p_st ); // AC: these cannot be NULL
-    #ifdef KMP_DEBUG
+        if (pr->ordered) {
+          pr->u.p.ordered_lower = init;
+          pr->u.p.ordered_upper = limit;
+#ifdef KMP_DEBUG
+          {
+            const char *buff;
+            // create format specifiers before the debug output
+            buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                    "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                    traits_t<UT>::spec, traits_t<UT>::spec);
+            KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                            pr->u.p.ordered_upper));
+            __kmp_str_free(&buff);
+          }
+#endif
+        } // if
+      } // if
+    } else {
+      pr->u.p.tc = 0;
+      *p_lb = pr->u.p.lb;
+      *p_ub = pr->u.p.ub;
+#if KMP_OS_WINDOWS
+      pr->u.p.last_upper = *p_ub;
+#endif /* KMP_OS_WINDOWS */
+      if (p_last != NULL)
+        *p_last = TRUE;
+      if (p_st != NULL)
+        *p_st = pr->u.p.st;
+    } // if
+#ifdef KMP_DEBUG
     {
-        const char * buff;
-        // create format specifiers before the debug output
-        buff = __kmp_str_format(
-            "__kmp_dispatch_next: T#%%d called p_lb:%%%s p_ub:%%%s p_st:%%%s p_last: %%p\n",
-            traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec );
-        KD_TRACE(1000, ( buff, gtid, *p_lb, *p_ub, p_st ? *p_st : 0, p_last ) );
-        __kmp_str_free( &buff );
-    }
-    #endif
-
-    if ( team -> t.t_serialized ) {
-        /* NOTE: serialize this dispatch becase we are not at the active level */
-        pr = reinterpret_cast< dispatch_private_info_template< T >* >
-            ( th -> th.th_dispatch -> th_disp_buffer ); /* top of the stack */
-        KMP_DEBUG_ASSERT( pr );
-
-        if ( (status = (pr->u.p.tc != 0)) == 0 ) {
-            *p_lb = 0;
-            *p_ub = 0;
-//            if ( p_last != NULL )
-//                *p_last = 0;
-            if ( p_st != NULL )
-                *p_st = 0;
-            if ( __kmp_env_consistency_check ) {
-                if ( pr->pushed_ws != ct_none ) {
-                    pr->pushed_ws = __kmp_pop_workshare( gtid, pr->pushed_ws, loc );
-                }
-            }
-        } else if ( pr->nomerge ) {
-            kmp_int32 last;
-            T         start;
-            UT        limit, trip, init;
-            ST        incr;
-            T         chunk = pr->u.p.parm1;
-
-            KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_dynamic_chunked case\n", gtid ) );
-
-            init = chunk * pr->u.p.count++;
-            trip = pr->u.p.tc - 1;
-
-            if ( (status = (init <= trip)) == 0 ) {
-                *p_lb = 0;
-                *p_ub = 0;
-//                if ( p_last != NULL )
-//                    *p_last = 0;
-                if ( p_st != NULL )
-                    *p_st = 0;
-                if ( __kmp_env_consistency_check ) {
-                    if ( pr->pushed_ws != ct_none ) {
-                        pr->pushed_ws = __kmp_pop_workshare( gtid, pr->pushed_ws, loc );
-                    }
-                }
-            } else {
-                start = pr->u.p.lb;
-                limit = chunk + init - 1;
-                incr  = pr->u.p.st;
-
-                if ( (last = (limit >= trip)) != 0 ) {
-                    limit = trip;
-                    #if KMP_OS_WINDOWS
-                    pr->u.p.last_upper = pr->u.p.ub;
-                    #endif /* KMP_OS_WINDOWS */
+      const char *buff;
+      // create format specifiers before the debug output
+      buff = __kmp_str_format(
+          "__kmp_dispatch_next: T#%%d serialized case: p_lb:%%%s "
+          "p_ub:%%%s p_st:%%%s p_last:%%p %%d  returning:%%d\n",
+          traits_t<T>::spec, traits_t<T>::spec, traits_t<ST>::spec);
+      KD_TRACE(10, (buff, gtid, *p_lb, *p_ub, *p_st, p_last, *p_last, status));
+      __kmp_str_free(&buff);
+    }
+#endif
+#if INCLUDE_SSC_MARKS
+    SSC_MARK_DISPATCH_NEXT();
+#endif
+    OMPT_LOOP_END;
+    return status;
+  } else {
+    kmp_int32 last = 0;
+    dispatch_shared_info_template<UT> *sh;
+    T start;
+    ST incr;
+    UT limit, trip, init;
+
+    KMP_DEBUG_ASSERT(th->th.th_dispatch ==
+                     &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid]);
+
+    pr = reinterpret_cast<dispatch_private_info_template<T> *>(
+        th->th.th_dispatch->th_dispatch_pr_current);
+    KMP_DEBUG_ASSERT(pr);
+    sh = reinterpret_cast<dispatch_shared_info_template<UT> *>(
+        th->th.th_dispatch->th_dispatch_sh_current);
+    KMP_DEBUG_ASSERT(sh);
+
+    if (pr->u.p.tc == 0) {
+      // zero trip count
+      status = 0;
+    } else {
+      switch (pr->schedule) {
+#if (KMP_STATIC_STEAL_ENABLED)
+      case kmp_sch_static_steal: {
+        T chunk = pr->u.p.parm1;
+        int nproc = th->th.th_team_nproc;
+
+        KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_static_steal case\n",
+                       gtid));
+
+        trip = pr->u.p.tc - 1;
+
+        if (traits_t<T>::type_size > 4) {
+          // use lock for 8-byte and CAS for 4-byte induction
+          // variable. TODO (optional): check and use 16-byte CAS
+          kmp_lock_t *lck = th->th.th_dispatch->th_steal_lock;
+          KMP_DEBUG_ASSERT(lck != NULL);
+          if (pr->u.p.count < (UT)pr->u.p.ub) {
+            __kmp_acquire_lock(lck, gtid);
+            // try to get own chunk of iterations
+            init = (pr->u.p.count)++;
+            status = (init < (UT)pr->u.p.ub);
+            __kmp_release_lock(lck, gtid);
+          } else {
+            status = 0; // no own chunks
+          }
+          if (!status) { // try to steal
+            kmp_info_t **other_threads = team->t.t_threads;
+            int while_limit = nproc; // nproc attempts to find a victim
+            int while_index = 0;
+            // TODO: algorithm of searching for a victim
+            // should be cleaned up and measured
+            while ((!status) && (while_limit != ++while_index)) {
+              T remaining;
+              T victimIdx = pr->u.p.parm4;
+              T oldVictimIdx = victimIdx ? victimIdx - 1 : nproc - 1;
+              dispatch_private_info_template<T> *victim =
+                  reinterpret_cast<dispatch_private_info_template<T> *>(
+                      other_threads[victimIdx]
+                          ->th.th_dispatch->th_dispatch_pr_current);
+              while ((victim == NULL || victim == pr ||
+                      (*(volatile T *)&victim->u.p.static_steal_counter !=
+                       *(volatile T *)&pr->u.p.static_steal_counter)) &&
+                     oldVictimIdx != victimIdx) {
+                victimIdx = (victimIdx + 1) % nproc;
+                victim = reinterpret_cast<dispatch_private_info_template<T> *>(
+                    other_threads[victimIdx]
+                        ->th.th_dispatch->th_dispatch_pr_current);
+              };
+              if (!victim ||
+                  (*(volatile T *)&victim->u.p.static_steal_counter !=
+                   *(volatile T *)&pr->u.p.static_steal_counter)) {
+                continue; // try once more (nproc attempts in total)
+                // no victim is ready yet to participate in stealing
+                // because all victims are still in kmp_init_dispatch
+              }
+              if (victim->u.p.count + 2 > (UT)victim->u.p.ub) {
+                pr->u.p.parm4 = (victimIdx + 1) % nproc; // shift start tid
+                continue; // not enough chunks to steal, goto next victim
+              }
+
+              lck = other_threads[victimIdx]->th.th_dispatch->th_steal_lock;
+              KMP_ASSERT(lck != NULL);
+              __kmp_acquire_lock(lck, gtid);
+              limit = victim->u.p.ub; // keep initial ub
+              if (victim->u.p.count >= limit ||
+                  (remaining = limit - victim->u.p.count) < 2) {
+                __kmp_release_lock(lck, gtid);
+                pr->u.p.parm4 = (victimIdx + 1) % nproc; // next victim
+                continue; // not enough chunks to steal
+              }
+              // stealing succeded, reduce victim's ub by 1/4 of undone chunks
+              // or by 1
+              if (remaining > 3) {
+                KMP_COUNT_VALUE(FOR_static_steal_stolen, remaining >> 2);
+                init = (victim->u.p.ub -=
+                        (remaining >> 2)); // steal 1/4 of remaining
+              } else {
+                KMP_COUNT_VALUE(FOR_static_steal_stolen, 1);
+                init =
+                    (victim->u.p.ub -= 1); // steal 1 chunk of 2 or 3 remaining
+              }
+              __kmp_release_lock(lck, gtid);
+
+              KMP_DEBUG_ASSERT(init + 1 <= limit);
+              pr->u.p.parm4 = victimIdx; // remember victim to steal from
+              status = 1;
+              while_index = 0;
+              // now update own count and ub with stolen range but init chunk
+              __kmp_acquire_lock(th->th.th_dispatch->th_steal_lock, gtid);
+              pr->u.p.count = init + 1;
+              pr->u.p.ub = limit;
+              __kmp_release_lock(th->th.th_dispatch->th_steal_lock, gtid);
+            } // while (search for victim)
+          } // if (try to find victim and steal)
+        } else {
+          // 4-byte induction variable, use 8-byte CAS for pair (count, ub)
+          typedef union {
+            struct {
+              UT count;
+              T ub;
+            } p;
+            kmp_int64 b;
+          } union_i4;
+          // All operations on 'count' or 'ub' must be combined atomically
+          // together.
+          {
+            union_i4 vold, vnew;
+            vold.b = *(volatile kmp_int64 *)(&pr->u.p.count);
+            vnew = vold;
+            vnew.p.count++;
+            while (!KMP_COMPARE_AND_STORE_ACQ64(
+                (volatile kmp_int64 *)&pr->u.p.count,
+                *VOLATILE_CAST(kmp_int64 *) & vold.b,
+                *VOLATILE_CAST(kmp_int64 *) & vnew.b)) {
+              KMP_CPU_PAUSE();
+              vold.b = *(volatile kmp_int64 *)(&pr->u.p.count);
+              vnew = vold;
+              vnew.p.count++;
+            }
+            vnew = vold;
+            init = vnew.p.count;
+            status = (init < (UT)vnew.p.ub);
+          }
+
+          if (!status) {
+            kmp_info_t **other_threads = team->t.t_threads;
+            int while_limit = nproc; // nproc attempts to find a victim
+            int while_index = 0;
+
+            // TODO: algorithm of searching for a victim
+            // should be cleaned up and measured
+            while ((!status) && (while_limit != ++while_index)) {
+              union_i4 vold, vnew;
+              kmp_int32 remaining;
+              T victimIdx = pr->u.p.parm4;
+              T oldVictimIdx = victimIdx ? victimIdx - 1 : nproc - 1;
+              dispatch_private_info_template<T> *victim =
+                  reinterpret_cast<dispatch_private_info_template<T> *>(
+                      other_threads[victimIdx]
+                          ->th.th_dispatch->th_dispatch_pr_current);
+              while ((victim == NULL || victim == pr ||
+                      (*(volatile T *)&victim->u.p.static_steal_counter !=
+                       *(volatile T *)&pr->u.p.static_steal_counter)) &&
+                     oldVictimIdx != victimIdx) {
+                victimIdx = (victimIdx + 1) % nproc;
+                victim = reinterpret_cast<dispatch_private_info_template<T> *>(
+                    other_threads[victimIdx]
+                        ->th.th_dispatch->th_dispatch_pr_current);
+              };
+              if (!victim ||
+                  (*(volatile T *)&victim->u.p.static_steal_counter !=
+                   *(volatile T *)&pr->u.p.static_steal_counter)) {
+                continue; // try once more (nproc attempts in total)
+                // no victim is ready yet to participate in stealing
+                // because all victims are still in kmp_init_dispatch
+              }
+              pr->u.p.parm4 = victimIdx; // new victim found
+              while (1) { // CAS loop if victim has enough chunks to steal
+                vold.b = *(volatile kmp_int64 *)(&victim->u.p.count);
+                vnew = vold;
+
+                KMP_DEBUG_ASSERT((vnew.p.ub - 1) * (UT)chunk <= trip);
+                if (vnew.p.count >= (UT)vnew.p.ub ||
+                    (remaining = vnew.p.ub - vnew.p.count) < 2) {
+                  pr->u.p.parm4 =
+                      (victimIdx + 1) % nproc; // shift start victim id
+                  break; // not enough chunks to steal, goto next victim
                 }
-                if ( p_last != NULL )
-                    *p_last = last;
-                if ( p_st != NULL )
-                    *p_st = incr;
-                if ( incr == 1 ) {
-                    *p_lb = start + init;
-                    *p_ub = start + limit;
+                if (remaining > 3) {
+                  vnew.p.ub -= (remaining >> 2); // try to steal 1/4 remaining
                 } else {
-                    *p_lb = start + init * incr;
-                    *p_ub = start + limit * incr;
+                  vnew.p.ub -= 1; // steal 1 chunk of 2 or 3 remaining
                 }
-
-                if ( pr->ordered ) {
-                    pr->u.p.ordered_lower = init;
-                    pr->u.p.ordered_upper = limit;
-                    #ifdef KMP_DEBUG
-                    {
-                        const char * buff;
-                        // create format specifiers before the debug output
-                        buff = __kmp_str_format(
-                            "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                            traits_t< UT >::spec, traits_t< UT >::spec );
-                        KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                        __kmp_str_free( &buff );
-                    }
-                    #endif
-                } // if
-            } // if
+                KMP_DEBUG_ASSERT((vnew.p.ub - 1) * (UT)chunk <= trip);
+                // TODO: Should this be acquire or release?
+                if (KMP_COMPARE_AND_STORE_ACQ64(
+                        (volatile kmp_int64 *)&victim->u.p.count,
+                        *VOLATILE_CAST(kmp_int64 *) & vold.b,
+                        *VOLATILE_CAST(kmp_int64 *) & vnew.b)) {
+                  // stealing succeeded
+                  KMP_COUNT_VALUE(FOR_static_steal_stolen,
+                                  vold.p.ub - vnew.p.ub);
+                  status = 1;
+                  while_index = 0;
+                  // now update own count and ub
+                  init = vnew.p.ub;
+                  vold.p.count = init + 1;
+#if KMP_ARCH_X86
+                  KMP_XCHG_FIXED64((volatile kmp_int64 *)(&pr->u.p.count),
+                                   vold.b);
+#else
+                  *(volatile kmp_int64 *)(&pr->u.p.count) = vold.b;
+#endif
+                  break;
+                } // if (check CAS result)
+                KMP_CPU_PAUSE(); // CAS failed, repeat attempt
+              } // while (try to steal from particular victim)
+            } // while (search for victim)
+          } // if (try to find victim and steal)
+        } // if (4-byte induction variable)
+        if (!status) {
+          *p_lb = 0;
+          *p_ub = 0;
+          if (p_st != NULL)
+            *p_st = 0;
         } else {
-            pr->u.p.tc = 0;
-            *p_lb = pr->u.p.lb;
-            *p_ub = pr->u.p.ub;
-            #if KMP_OS_WINDOWS
-            pr->u.p.last_upper = *p_ub;
-            #endif /* KMP_OS_WINDOWS */
-            if ( p_last != NULL )
-                *p_last = TRUE;
-            if ( p_st != NULL )
-                *p_st = pr->u.p.st;
+          start = pr->u.p.parm2;
+          init *= chunk;
+          limit = chunk + init - 1;
+          incr = pr->u.p.st;
+          KMP_COUNT_VALUE(FOR_static_steal_chunks, 1);
+
+          KMP_DEBUG_ASSERT(init <= trip);
+          if ((last = (limit >= trip)) != 0)
+            limit = trip;
+          if (p_st != NULL)
+            *p_st = incr;
+
+          if (incr == 1) {
+            *p_lb = start + init;
+            *p_ub = start + limit;
+          } else {
+            *p_lb = start + init * incr;
+            *p_ub = start + limit * incr;
+          }
+
+          if (pr->ordered) {
+            pr->u.p.ordered_lower = init;
+            pr->u.p.ordered_upper = limit;
+#ifdef KMP_DEBUG
+            {
+              const char *buff;
+              // create format specifiers before the debug output
+              buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                      "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                      traits_t<UT>::spec, traits_t<UT>::spec);
+              KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                              pr->u.p.ordered_upper));
+              __kmp_str_free(&buff);
+            }
+#endif
+          } // if
         } // if
-        #ifdef KMP_DEBUG
-        {
-            const char * buff;
+        break;
+      } // case
+#endif // ( KMP_STATIC_STEAL_ENABLED )
+      case kmp_sch_static_balanced: {
+        KD_TRACE(
+            100,
+            ("__kmp_dispatch_next: T#%d kmp_sch_static_balanced case\n", gtid));
+        if ((status = !pr->u.p.count) !=
+            0) { /* check if thread has any iteration to do */
+          pr->u.p.count = 1;
+          *p_lb = pr->u.p.lb;
+          *p_ub = pr->u.p.ub;
+          last = pr->u.p.parm1;
+          if (p_st != NULL)
+            *p_st = pr->u.p.st;
+        } else { /* no iterations to do */
+          pr->u.p.lb = pr->u.p.ub + pr->u.p.st;
+        }
+        if (pr->ordered) {
+#ifdef KMP_DEBUG
+          {
+            const char *buff;
             // create format specifiers before the debug output
-            buff = __kmp_str_format(
-                "__kmp_dispatch_next: T#%%d serialized case: p_lb:%%%s " \
-                "p_ub:%%%s p_st:%%%s p_last:%%p %%d  returning:%%d\n",
-                traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec );
-            KD_TRACE(10, ( buff, gtid, *p_lb, *p_ub, *p_st, p_last, *p_last, status) );
-            __kmp_str_free( &buff );
-        }
-        #endif
-#if INCLUDE_SSC_MARKS
-        SSC_MARK_DISPATCH_NEXT();
+            buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                    "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                    traits_t<UT>::spec, traits_t<UT>::spec);
+            KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                            pr->u.p.ordered_upper));
+            __kmp_str_free(&buff);
+          }
 #endif
-        OMPT_LOOP_END;
-        return status;
-    } else {
-        kmp_int32 last = 0;
-        dispatch_shared_info_template< UT > *sh;
-        T         start;
-        ST        incr;
-        UT        limit, trip, init;
-
-        KMP_DEBUG_ASSERT( th->th.th_dispatch ==
-                &th->th.th_team->t.t_dispatch[th->th.th_info.ds.ds_tid] );
-
-        pr = reinterpret_cast< dispatch_private_info_template< T >* >
-            ( th->th.th_dispatch->th_dispatch_pr_current );
-        KMP_DEBUG_ASSERT( pr );
-        sh = reinterpret_cast< dispatch_shared_info_template< UT >* >
-            ( th->th.th_dispatch->th_dispatch_sh_current );
-        KMP_DEBUG_ASSERT( sh );
+        } // if
+      } // case
+      break;
+      case kmp_sch_static_greedy: /* original code for kmp_sch_static_greedy was
+                                     merged here */
+      case kmp_sch_static_chunked: {
+        T parm1;
+
+        KD_TRACE(100, ("__kmp_dispatch_next: T#%d "
+                       "kmp_sch_static_[affinity|chunked] case\n",
+                       gtid));
+        parm1 = pr->u.p.parm1;
+
+        trip = pr->u.p.tc - 1;
+        init = parm1 * (pr->u.p.count + __kmp_tid_from_gtid(gtid));
+
+        if ((status = (init <= trip)) != 0) {
+          start = pr->u.p.lb;
+          incr = pr->u.p.st;
+          limit = parm1 + init - 1;
+
+          if ((last = (limit >= trip)) != 0)
+            limit = trip;
+
+          if (p_st != NULL)
+            *p_st = incr;
+
+          pr->u.p.count += th->th.th_team_nproc;
+
+          if (incr == 1) {
+            *p_lb = start + init;
+            *p_ub = start + limit;
+          } else {
+            *p_lb = start + init * incr;
+            *p_ub = start + limit * incr;
+          }
+
+          if (pr->ordered) {
+            pr->u.p.ordered_lower = init;
+            pr->u.p.ordered_upper = limit;
+#ifdef KMP_DEBUG
+            {
+              const char *buff;
+              // create format specifiers before the debug output
+              buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                      "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                      traits_t<UT>::spec, traits_t<UT>::spec);
+              KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                              pr->u.p.ordered_upper));
+              __kmp_str_free(&buff);
+            }
+#endif
+          } // if
+        } // if
+      } // case
+      break;
+
+      case kmp_sch_dynamic_chunked: {
+        T chunk = pr->u.p.parm1;
 
-        if ( pr->u.p.tc == 0 ) {
-            // zero trip count
+        KD_TRACE(
+            100,
+            ("__kmp_dispatch_next: T#%d kmp_sch_dynamic_chunked case\n", gtid));
+
+        init = chunk * test_then_inc_acq<ST>((volatile ST *)&sh->u.s.iteration);
+        trip = pr->u.p.tc - 1;
+
+        if ((status = (init <= trip)) == 0) {
+          *p_lb = 0;
+          *p_ub = 0;
+          if (p_st != NULL)
+            *p_st = 0;
+        } else {
+          start = pr->u.p.lb;
+          limit = chunk + init - 1;
+          incr = pr->u.p.st;
+
+          if ((last = (limit >= trip)) != 0)
+            limit = trip;
+
+          if (p_st != NULL)
+            *p_st = incr;
+
+          if (incr == 1) {
+            *p_lb = start + init;
+            *p_ub = start + limit;
+          } else {
+            *p_lb = start + init * incr;
+            *p_ub = start + limit * incr;
+          }
+
+          if (pr->ordered) {
+            pr->u.p.ordered_lower = init;
+            pr->u.p.ordered_upper = limit;
+#ifdef KMP_DEBUG
+            {
+              const char *buff;
+              // create format specifiers before the debug output
+              buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                      "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                      traits_t<UT>::spec, traits_t<UT>::spec);
+              KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                              pr->u.p.ordered_upper));
+              __kmp_str_free(&buff);
+            }
+#endif
+          } // if
+        } // if
+      } // case
+      break;
+
+      case kmp_sch_guided_iterative_chunked: {
+        T chunkspec = pr->u.p.parm1;
+        KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_guided_chunked "
+                       "iterative case\n",
+                       gtid));
+        trip = pr->u.p.tc;
+        // Start atomic part of calculations
+        while (1) {
+          ST remaining; // signed, because can be < 0
+          init = sh->u.s.iteration; // shared value
+          remaining = trip - init;
+          if (remaining <= 0) { // AC: need to compare with 0 first
+            // nothing to do, don't try atomic op
             status = 0;
+            break;
+          }
+          if ((T)remaining <
+              pr->u.p.parm2) { // compare with K*nproc*(chunk+1), K=2 by default
+            // use dynamic-style shcedule
+            // atomically inrement iterations, get old value
+            init = test_then_add<ST>((ST *)&sh->u.s.iteration, (ST)chunkspec);
+            remaining = trip - init;
+            if (remaining <= 0) {
+              status = 0; // all iterations got by other threads
+            } else { // got some iterations to work on
+              status = 1;
+              if ((T)remaining > chunkspec) {
+                limit = init + chunkspec - 1;
+              } else {
+                last = 1; // the last chunk
+                limit = init + remaining - 1;
+              } // if
+            } // if
+            break;
+          } // if
+          limit = init + (UT)(remaining *
+                              *(double *)&pr->u.p.parm3); // divide by K*nproc
+          if (compare_and_swap<ST>((ST *)&sh->u.s.iteration, (ST)init,
+                                   (ST)limit)) {
+            // CAS was successful, chunk obtained
+            status = 1;
+            --limit;
+            break;
+          } // if
+        } // while
+        if (status != 0) {
+          start = pr->u.p.lb;
+          incr = pr->u.p.st;
+          if (p_st != NULL)
+            *p_st = incr;
+          *p_lb = start + init * incr;
+          *p_ub = start + limit * incr;
+          if (pr->ordered) {
+            pr->u.p.ordered_lower = init;
+            pr->u.p.ordered_upper = limit;
+#ifdef KMP_DEBUG
+            {
+              const char *buff;
+              // create format specifiers before the debug output
+              buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                      "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                      traits_t<UT>::spec, traits_t<UT>::spec);
+              KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                              pr->u.p.ordered_upper));
+              __kmp_str_free(&buff);
+            }
+#endif
+          } // if
         } else {
-            switch (pr->schedule) {
-            #if ( KMP_STATIC_STEAL_ENABLED )
-            case kmp_sch_static_steal:
-                {
-                    T chunk = pr->u.p.parm1;
-                    int nproc = th->th.th_team_nproc;
-
-                    KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_static_steal case\n", gtid) );
-
-                    trip = pr->u.p.tc - 1;
-
-                    if ( traits_t<T>::type_size > 4 ) {
-                        // use lock for 8-byte and CAS for 4-byte induction
-                        // variable. TODO (optional): check and use 16-byte CAS
-                        kmp_lock_t * lck = th->th.th_dispatch->th_steal_lock;
-                        KMP_DEBUG_ASSERT(lck != NULL);
-                        if( pr->u.p.count < (UT)pr->u.p.ub ) {
-                            __kmp_acquire_lock(lck, gtid);
-                            // try to get own chunk of iterations
-                            init   = ( pr->u.p.count )++;
-                            status = ( init < (UT)pr->u.p.ub );
-                            __kmp_release_lock(lck, gtid);
-                        } else {
-                            status = 0; // no own chunks
-                        }
-                        if( !status ) { // try to steal
-                            kmp_info_t   **other_threads = team->t.t_threads;
-                            int          while_limit = nproc; // nproc attempts to find a victim
-                            int          while_index = 0;
-                            // TODO: algorithm of searching for a victim
-                            // should be cleaned up and measured
-                            while ( ( !status ) && ( while_limit != ++while_index ) ) {
-                                T remaining;
-                                T victimIdx    = pr->u.p.parm4;
-                                T oldVictimIdx = victimIdx ? victimIdx - 1 : nproc - 1;
-                                dispatch_private_info_template< T > * victim =
-                                    reinterpret_cast< dispatch_private_info_template< T >* >
-                                    (other_threads[victimIdx]->th.th_dispatch->th_dispatch_pr_current);
-                                while( ( victim == NULL || victim == pr ||
-                                    ( *(volatile T*)&victim->u.p.static_steal_counter !=
-                                    *(volatile T*)&pr->u.p.static_steal_counter ) ) &&
-                                    oldVictimIdx != victimIdx )
-                                {
-                                    victimIdx = (victimIdx + 1) % nproc;
-                                    victim = reinterpret_cast< dispatch_private_info_template< T >* >
-                                        (other_threads[victimIdx]->th.th_dispatch->th_dispatch_pr_current);
-                                };
-                                if( !victim ||
-                                    ( *(volatile T *)&victim->u.p.static_steal_counter !=
-                                    *(volatile T *)&pr->u.p.static_steal_counter ) )
-                                {
-                                    continue; // try once more (nproc attempts in total)
-                                    // no victim is ready yet to participate in stealing
-                                    // because all victims are still in kmp_init_dispatch
-                                }
-                                if( victim->u.p.count + 2 > (UT)victim->u.p.ub ) {
-                                    pr->u.p.parm4 = (victimIdx + 1) % nproc; // shift start tid
-                                    continue; // not enough chunks to steal, goto next victim
-                                }
-
-                                lck = other_threads[victimIdx]->th.th_dispatch->th_steal_lock;
-                                KMP_ASSERT(lck != NULL);
-                                __kmp_acquire_lock(lck, gtid);
-                                limit = victim->u.p.ub; // keep initial ub
-                                if( victim->u.p.count >= limit ||
-                                    (remaining = limit - victim->u.p.count) < 2 )
-                                {
-                                    __kmp_release_lock(lck, gtid);
-                                    pr->u.p.parm4 = (victimIdx + 1) % nproc; // next victim
-                                    continue; // not enough chunks to steal
-                                }
-                                // stealing succeded, reduce victim's ub by 1/4 of undone chunks or by 1
-                                if( remaining > 3 ) {
-                                    KMP_COUNT_VALUE(FOR_static_steal_stolen, remaining>>2);
-                                    init = ( victim->u.p.ub -= (remaining>>2) ); // steal 1/4 of remaining
-                                } else {
-                                    KMP_COUNT_VALUE(FOR_static_steal_stolen, 1);
-                                    init = ( victim->u.p.ub -= 1 ); // steal 1 chunk of 2 or 3 remaining
-                                }
-                                __kmp_release_lock(lck, gtid);
-
-                                KMP_DEBUG_ASSERT(init + 1 <= limit);
-                                pr->u.p.parm4 = victimIdx; // remember victim to steal from
-                                status = 1;
-                                while_index = 0;
-                                // now update own count and ub with stolen range but init chunk
-                                __kmp_acquire_lock(th->th.th_dispatch->th_steal_lock, gtid);
-                                pr->u.p.count = init + 1;
-                                pr->u.p.ub = limit;
-                                __kmp_release_lock(th->th.th_dispatch->th_steal_lock, gtid);
-                            } // while (search for victim)
-                        } // if (try to find victim and steal)
-                    } else {
-                        // 4-byte induction variable, use 8-byte CAS for pair (count, ub)
-                        typedef union {
-                            struct {
-                                UT count;
-                                T  ub;
-                            } p;
-                            kmp_int64 b;
-                        } union_i4;
-                        // All operations on 'count' or 'ub' must be combined atomically together.
-                        {
-                            union_i4 vold, vnew;
-                            vold.b = *( volatile kmp_int64 * )(&pr->u.p.count);
-                            vnew = vold;
-                            vnew.p.count++;
-                            while( ! KMP_COMPARE_AND_STORE_ACQ64(
-                                        ( volatile kmp_int64* )&pr->u.p.count,
-                                        *VOLATILE_CAST(kmp_int64 *)&vold.b,
-                                        *VOLATILE_CAST(kmp_int64 *)&vnew.b ) ) {
-                                KMP_CPU_PAUSE();
-                                vold.b = *( volatile kmp_int64 * )(&pr->u.p.count);
-                                vnew = vold;
-                                vnew.p.count++;
-                            }
-                            vnew = vold;
-                            init   = vnew.p.count;
-                            status = ( init < (UT)vnew.p.ub ) ;
-                        }
-
-                        if( !status ) {
-                            kmp_info_t   **other_threads = team->t.t_threads;
-                            int          while_limit = nproc; // nproc attempts to find a victim
-                            int          while_index = 0;
-
-                            // TODO: algorithm of searching for a victim
-                            // should be cleaned up and measured
-                            while ( ( !status ) && ( while_limit != ++while_index ) ) {
-                                union_i4  vold, vnew;
-                                kmp_int32 remaining;
-                                T         victimIdx    = pr->u.p.parm4;
-                                T oldVictimIdx = victimIdx ? victimIdx - 1 : nproc - 1;
-                                dispatch_private_info_template< T > * victim =
-                                    reinterpret_cast< dispatch_private_info_template< T >* >
-                                    (other_threads[victimIdx]->th.th_dispatch->th_dispatch_pr_current);
-                                while( (victim == NULL || victim == pr ||
-                                    (*(volatile T*)&victim->u.p.static_steal_counter !=
-                                    *(volatile T*)&pr->u.p.static_steal_counter)) &&
-                                    oldVictimIdx != victimIdx )
-                                {
-                                    victimIdx = (victimIdx + 1) % nproc;
-                                    victim = reinterpret_cast< dispatch_private_info_template< T >* >
-                                        ( other_threads[victimIdx]->th.th_dispatch->th_dispatch_pr_current );
-                                };
-                                if( !victim ||
-                                    ( *(volatile T *)&victim->u.p.static_steal_counter !=
-                                    *(volatile T *)&pr->u.p.static_steal_counter ) )
-                                {
-                                    continue; // try once more (nproc attempts in total)
-                                    // no victim is ready yet to participate in stealing
-                                    // because all victims are still in kmp_init_dispatch
-                                }
-                                pr->u.p.parm4 = victimIdx; // new victim found
-                                while( 1 ) { // CAS loop if victim has enough chunks to steal
-                                    vold.b = *( volatile kmp_int64 * )( &victim->u.p.count );
-                                    vnew = vold;
-
-                                    KMP_DEBUG_ASSERT( (vnew.p.ub - 1) * (UT)chunk <= trip );
-                                    if ( vnew.p.count >= (UT)vnew.p.ub ||
-                                        (remaining = vnew.p.ub - vnew.p.count) < 2 )
-                                    {
-                                        pr->u.p.parm4 = (victimIdx + 1) % nproc; // shift start victim id
-                                        break; // not enough chunks to steal, goto next victim
-                                    }
-                                    if( remaining > 3 ) {
-                                        vnew.p.ub -= (remaining>>2); // try to steal 1/4 of remaining
-                                    } else {
-                                        vnew.p.ub -= 1; // steal 1 chunk of 2 or 3 remaining
-                                    }
-                                    KMP_DEBUG_ASSERT((vnew.p.ub - 1) * (UT)chunk <= trip);
-                                    // TODO: Should this be acquire or release?
-                                    if ( KMP_COMPARE_AND_STORE_ACQ64(
-                                            ( volatile kmp_int64 * )&victim->u.p.count,
-                                            *VOLATILE_CAST(kmp_int64 *)&vold.b,
-                                            *VOLATILE_CAST(kmp_int64 *)&vnew.b ) ) {
-                                        // stealing succedded
-                                        KMP_COUNT_VALUE(FOR_static_steal_stolen, vold.p.ub-vnew.p.ub);
-                                        status = 1;
-                                        while_index = 0;
-                                        // now update own count and ub
-                                        init = vnew.p.ub;
-                                        vold.p.count = init + 1;
-                                        #if KMP_ARCH_X86
-                                        KMP_XCHG_FIXED64(( volatile kmp_int64 * )(&pr->u.p.count), vold.b);
-                                        #else
-                                        *( volatile kmp_int64 * )(&pr->u.p.count) = vold.b;
-                                        #endif
-                                        break;
-                                    } // if (check CAS result)
-                                    KMP_CPU_PAUSE(); // CAS failed, repeate attempt
-                                } // while (try to steal from particular victim)
-                            } // while (search for victim)
-                        } // if (try to find victim and steal)
-                    } // if (4-byte induction variable)
-                    if ( !status ) {
-                        *p_lb = 0;
-                        *p_ub = 0;
-                        if ( p_st != NULL ) *p_st = 0;
-                    } else {
-                        start = pr->u.p.parm2;
-                        init *= chunk;
-                        limit = chunk + init - 1;
-                        incr  = pr->u.p.st;
-                        KMP_COUNT_VALUE(FOR_static_steal_chunks, 1);
-
-                        KMP_DEBUG_ASSERT(init <= trip);
-                        if ( (last = (limit >= trip)) != 0 )
-                            limit = trip;
-                        if ( p_st != NULL ) *p_st = incr;
-
-                        if ( incr == 1 ) {
-                            *p_lb = start + init;
-                            *p_ub = start + limit;
-                        } else {
-                            *p_lb = start + init * incr;
-                            *p_ub = start + limit * incr;
-                        }
-
-                        if ( pr->ordered ) {
-                            pr->u.p.ordered_lower = init;
-                            pr->u.p.ordered_upper = limit;
-                            #ifdef KMP_DEBUG
-                            {
-                                const char * buff;
-                                // create format specifiers before the debug output
-                                buff = __kmp_str_format(
-                                    "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                                    traits_t< UT >::spec, traits_t< UT >::spec );
-                                KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                                __kmp_str_free( &buff );
-                            }
-                            #endif
-                        } // if
-                    } // if
-                    break;
-                } // case
-            #endif // ( KMP_STATIC_STEAL_ENABLED )
-            case kmp_sch_static_balanced:
-                {
-                    KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_static_balanced case\n", gtid) );
-                    if ( (status = !pr->u.p.count) != 0 ) {  /* check if thread has any iteration to do */
-                        pr->u.p.count = 1;
-                        *p_lb = pr->u.p.lb;
-                        *p_ub = pr->u.p.ub;
-                        last = pr->u.p.parm1;
-                        if ( p_st != NULL )
-                            *p_st = pr->u.p.st;
-                    } else {  /* no iterations to do */
-                        pr->u.p.lb = pr->u.p.ub + pr->u.p.st;
-                    }
-                    if ( pr->ordered ) {
-                        #ifdef KMP_DEBUG
-                        {
-                            const char * buff;
-                            // create format specifiers before the debug output
-                            buff = __kmp_str_format(
-                                "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                                traits_t< UT >::spec, traits_t< UT >::spec );
-                            KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                            __kmp_str_free( &buff );
-                        }
-                        #endif
-                    } // if
-                } // case
-                break;
-            case kmp_sch_static_greedy:  /* original code for kmp_sch_static_greedy was merged here */
-            case kmp_sch_static_chunked:
-                {
-                    T parm1;
-
-                    KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_static_[affinity|chunked] case\n",
-                                   gtid ) );
-                    parm1 = pr->u.p.parm1;
-
-                    trip  = pr->u.p.tc - 1;
-                    init  = parm1 * (pr->u.p.count + __kmp_tid_from_gtid(gtid));
-
-                    if ( (status = (init <= trip)) != 0 ) {
-                        start = pr->u.p.lb;
-                        incr  = pr->u.p.st;
-                        limit = parm1 + init - 1;
-
-                        if ( (last = (limit >= trip)) != 0 )
-                            limit = trip;
-
-                        if ( p_st != NULL ) *p_st = incr;
-
-                        pr->u.p.count += th->th.th_team_nproc;
-
-                        if ( incr == 1 ) {
-                            *p_lb = start + init;
-                            *p_ub = start + limit;
-                        }
-                        else {
-                            *p_lb = start + init * incr;
-                            *p_ub = start + limit * incr;
-                        }
-
-                        if ( pr->ordered ) {
-                            pr->u.p.ordered_lower = init;
-                            pr->u.p.ordered_upper = limit;
-                            #ifdef KMP_DEBUG
-                            {
-                                const char * buff;
-                                // create format specifiers before the debug output
-                                buff = __kmp_str_format(
-                                    "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                                    traits_t< UT >::spec, traits_t< UT >::spec );
-                                KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                                __kmp_str_free( &buff );
-                            }
-                            #endif
-                        } // if
-                    } // if
-                } // case
-                break;
-
-            case kmp_sch_dynamic_chunked:
-                {
-                    T chunk = pr->u.p.parm1;
-
-                    KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_dynamic_chunked case\n",
-                                   gtid ) );
-
-                    init = chunk * test_then_inc_acq< ST >((volatile ST *) & sh->u.s.iteration );
-                    trip = pr->u.p.tc - 1;
-
-                    if ( (status = (init <= trip)) == 0 ) {
-                        *p_lb = 0;
-                        *p_ub = 0;
-                        if ( p_st != NULL ) *p_st = 0;
-                    } else {
-                        start = pr->u.p.lb;
-                        limit = chunk + init - 1;
-                        incr  = pr->u.p.st;
-
-                        if ( (last = (limit >= trip)) != 0 )
-                            limit = trip;
-
-                        if ( p_st != NULL ) *p_st = incr;
-
-                        if ( incr == 1 ) {
-                            *p_lb = start + init;
-                            *p_ub = start + limit;
-                        } else {
-                            *p_lb = start + init * incr;
-                            *p_ub = start + limit * incr;
-                        }
-
-                        if ( pr->ordered ) {
-                            pr->u.p.ordered_lower = init;
-                            pr->u.p.ordered_upper = limit;
-                            #ifdef KMP_DEBUG
-                            {
-                                const char * buff;
-                                // create format specifiers before the debug output
-                                buff = __kmp_str_format(
-                                    "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                                    traits_t< UT >::spec, traits_t< UT >::spec );
-                                KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                                __kmp_str_free( &buff );
-                            }
-                            #endif
-                        } // if
-                    } // if
-                } // case
-                break;
-
-            case kmp_sch_guided_iterative_chunked:
-                {
-                    T  chunkspec = pr->u.p.parm1;
-                    KD_TRACE(100,
-                        ("__kmp_dispatch_next: T#%d kmp_sch_guided_chunked iterative case\n",gtid));
-                    trip  = pr->u.p.tc;
-                    // Start atomic part of calculations
-                    while(1) {
-                        ST  remaining;             // signed, because can be < 0
-                        init = sh->u.s.iteration;  // shared value
-                        remaining = trip - init;
-                        if ( remaining <= 0 ) {    // AC: need to compare with 0 first
-                            // nothing to do, don't try atomic op
-                            status = 0;
-                            break;
-                        }
-                        if ( (T)remaining < pr->u.p.parm2 ) { // compare with K*nproc*(chunk+1), K=2 by default
-                            // use dynamic-style shcedule
-                            // atomically inrement iterations, get old value
-                            init = test_then_add<ST>( (ST*)&sh->u.s.iteration, (ST)chunkspec );
-                            remaining = trip - init;
-                            if (remaining <= 0) {
-                                status = 0;    // all iterations got by other threads
-                            } else {
-                                // got some iterations to work on
-                                status = 1;
-                                if ( (T)remaining > chunkspec ) {
-                                    limit = init + chunkspec - 1;
-                                } else {
-                                    last = 1;   // the last chunk
-                                    limit = init + remaining - 1;
-                                } // if
-                            } // if
-                            break;
-                        } // if
-                        limit = init + (UT)( remaining * *(double*)&pr->u.p.parm3 ); // divide by K*nproc
-                        if ( compare_and_swap<ST>( (ST*)&sh->u.s.iteration, (ST)init, (ST)limit ) ) {
-                            // CAS was successful, chunk obtained
-                            status = 1;
-                            --limit;
-                            break;
-                        } // if
-                    } // while
-                    if ( status != 0 ) {
-                        start = pr->u.p.lb;
-                        incr = pr->u.p.st;
-                        if ( p_st != NULL )
-                            *p_st = incr;
-                        *p_lb = start + init * incr;
-                        *p_ub = start + limit * incr;
-                        if ( pr->ordered ) {
-                            pr->u.p.ordered_lower = init;
-                            pr->u.p.ordered_upper = limit;
-                            #ifdef KMP_DEBUG
-                            {
-                                const char * buff;
-                                // create format specifiers before the debug output
-                                buff = __kmp_str_format(
-                                    "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                                    traits_t< UT >::spec, traits_t< UT >::spec );
-                                KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                                __kmp_str_free( &buff );
-                            }
-                            #endif
-                        } // if
-                    } else {
-                        *p_lb = 0;
-                        *p_ub = 0;
-                        if ( p_st != NULL )
-                            *p_st = 0;
-                    } // if
-                } // case
-                break;
-
-            case kmp_sch_guided_analytical_chunked:
-                {
-                    T   chunkspec = pr->u.p.parm1;
-                    UT chunkIdx;
-    #if KMP_OS_WINDOWS && KMP_ARCH_X86
-                    /* for storing original FPCW value for Windows* OS on
-		       IA-32 architecture 8-byte version */
-                    unsigned int oldFpcw;
-                    unsigned int fpcwSet = 0;
-    #endif
-                    KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_guided_chunked analytical case\n",
-                                   gtid ) );
-
-                    trip  = pr->u.p.tc;
-
-                    KMP_DEBUG_ASSERT(th->th.th_team_nproc > 1);
-                    KMP_DEBUG_ASSERT((2UL * chunkspec + 1) * (UT)th->th.th_team_nproc < trip);
-
-                    while(1) { /* this while loop is a safeguard against unexpected zero chunk sizes */
-                        chunkIdx = test_then_inc_acq< ST >((volatile ST *) & sh->u.s.iteration );
-                        if ( chunkIdx >= (UT)pr->u.p.parm2 ) {
-                            --trip;
-                            /* use dynamic-style scheduling */
-                            init = chunkIdx * chunkspec + pr->u.p.count;
-                            /* need to verify init > 0 in case of overflow in the above calculation */
-                            if ( (status = (init > 0 && init <= trip)) != 0 ) {
-                                limit = init + chunkspec -1;
-
-                                if ( (last = (limit >= trip)) != 0 )
-                                    limit = trip;
-                            }
-                            break;
-                        } else {
-                            /* use exponential-style scheduling */
-                            /* The following check is to workaround the lack of long double precision on Windows* OS.
-                               This check works around the possible effect that init != 0 for chunkIdx == 0.
-                             */
-    #if KMP_OS_WINDOWS && KMP_ARCH_X86
-                            /* If we haven't already done so, save original
-			       FPCW and set precision to 64-bit, as Windows* OS
-			       on IA-32 architecture defaults to 53-bit */
-                            if ( !fpcwSet ) {
-                                oldFpcw = _control87(0,0);
-                                _control87(_PC_64,_MCW_PC);
-                                fpcwSet = 0x30000;
-                            }
-    #endif
-                            if ( chunkIdx ) {
-                                init = __kmp_dispatch_guided_remaining< T >(
-                                           trip, *( DBL * )&pr->u.p.parm3, chunkIdx );
-                                KMP_DEBUG_ASSERT(init);
-                                init = trip - init;
-                            } else
-                                init = 0;
-                            limit = trip - __kmp_dispatch_guided_remaining< T >(
-                                               trip, *( DBL * )&pr->u.p.parm3, chunkIdx + 1 );
-                            KMP_ASSERT(init <= limit);
-                            if ( init < limit ) {
-                                KMP_DEBUG_ASSERT(limit <= trip);
-                                --limit;
-                                status = 1;
-                                break;
-                            } // if
-                        } // if
-                    } // while (1)
-    #if KMP_OS_WINDOWS && KMP_ARCH_X86
-                    /* restore FPCW if necessary
-                       AC: check fpcwSet flag first because oldFpcw can be uninitialized here
-                    */
-                    if ( fpcwSet && ( oldFpcw & fpcwSet ) )
-                        _control87(oldFpcw,_MCW_PC);
-    #endif
-                    if ( status != 0 ) {
-                        start = pr->u.p.lb;
-                        incr = pr->u.p.st;
-                        if ( p_st != NULL )
-                            *p_st = incr;
-                        *p_lb = start + init * incr;
-                        *p_ub = start + limit * incr;
-                        if ( pr->ordered ) {
-                            pr->u.p.ordered_lower = init;
-                            pr->u.p.ordered_upper = limit;
-                            #ifdef KMP_DEBUG
-                            {
-                                const char * buff;
-                                // create format specifiers before the debug output
-                                buff = __kmp_str_format(
-                                    "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                                    traits_t< UT >::spec, traits_t< UT >::spec );
-                                KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                                __kmp_str_free( &buff );
-                            }
-                            #endif
-                        }
-                    } else {
-                        *p_lb = 0;
-                        *p_ub = 0;
-                        if ( p_st != NULL )
-                            *p_st = 0;
-                    }
-                } // case
-                break;
-
-            case kmp_sch_trapezoidal:
-                {
-                    UT   index;
-                    T    parm2 = pr->u.p.parm2;
-                    T    parm3 = pr->u.p.parm3;
-                    T    parm4 = pr->u.p.parm4;
-                    KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_trapezoidal case\n",
-                                   gtid ) );
-
-                    index = test_then_inc< ST >( (volatile ST *) & sh->u.s.iteration );
-
-                    init = ( index * ( (2*parm2) - (index-1)*parm4 ) ) / 2;
-                    trip = pr->u.p.tc - 1;
-
-                    if ( (status = ((T)index < parm3 && init <= trip)) == 0 ) {
-                        *p_lb = 0;
-                        *p_ub = 0;
-                        if ( p_st != NULL ) *p_st = 0;
-                    } else {
-                        start = pr->u.p.lb;
-                        limit = ( (index+1) * ( 2*parm2 - index*parm4 ) ) / 2 - 1;
-                        incr  = pr->u.p.st;
-
-                        if ( (last = (limit >= trip)) != 0 )
-                            limit = trip;
-
-                        if ( p_st != NULL ) *p_st = incr;
-
-                        if ( incr == 1 ) {
-                            *p_lb = start + init;
-                            *p_ub = start + limit;
-                        } else {
-                            *p_lb = start + init * incr;
-                            *p_ub = start + limit * incr;
-                        }
-
-                        if ( pr->ordered ) {
-                            pr->u.p.ordered_lower = init;
-                            pr->u.p.ordered_upper = limit;
-                            #ifdef KMP_DEBUG
-                            {
-                                const char * buff;
-                                // create format specifiers before the debug output
-                                buff = __kmp_str_format(
-                                    "__kmp_dispatch_next: T#%%d ordered_lower:%%%s ordered_upper:%%%s\n",
-                                    traits_t< UT >::spec, traits_t< UT >::spec );
-                                KD_TRACE(1000, ( buff, gtid, pr->u.p.ordered_lower, pr->u.p.ordered_upper ) );
-                                __kmp_str_free( &buff );
-                            }
-                            #endif
-                        } // if
-                    } // if
-                } // case
-                break;
-            default:
-                {
-                    status = 0; // to avoid complaints on uninitialized variable use
-                    __kmp_msg(
-                        kmp_ms_fatal,                        // Severity
-                        KMP_MSG( UnknownSchedTypeDetected ), // Primary message
-                        KMP_HNT( GetNewerLibrary ),          // Hint
-                        __kmp_msg_null                       // Variadic argument list terminator
-                    );
-                }
-                break;
-            } // switch
-        } // if tc == 0;
+          *p_lb = 0;
+          *p_ub = 0;
+          if (p_st != NULL)
+            *p_st = 0;
+        } // if
+      } // case
+      break;
 
-        if ( status == 0 ) {
-            UT   num_done;
+      case kmp_sch_guided_analytical_chunked: {
+        T chunkspec = pr->u.p.parm1;
+        UT chunkIdx;
+#if KMP_OS_WINDOWS && KMP_ARCH_X86
+        /* for storing original FPCW value for Windows* OS on
+           IA-32 architecture 8-byte version */
+        unsigned int oldFpcw;
+        unsigned int fpcwSet = 0;
+#endif
+        KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_guided_chunked "
+                       "analytical case\n",
+                       gtid));
+
+        trip = pr->u.p.tc;
+
+        KMP_DEBUG_ASSERT(th->th.th_team_nproc > 1);
+        KMP_DEBUG_ASSERT((2UL * chunkspec + 1) * (UT)th->th.th_team_nproc <
+                         trip);
+
+        while (1) { /* this while loop is a safeguard against unexpected zero
+                       chunk sizes */
+          chunkIdx = test_then_inc_acq<ST>((volatile ST *)&sh->u.s.iteration);
+          if (chunkIdx >= (UT)pr->u.p.parm2) {
+            --trip;
+            /* use dynamic-style scheduling */
+            init = chunkIdx * chunkspec + pr->u.p.count;
+            /* need to verify init > 0 in case of overflow in the above
+             * calculation */
+            if ((status = (init > 0 && init <= trip)) != 0) {
+              limit = init + chunkspec - 1;
 
-            num_done = test_then_inc< ST >( (volatile ST *) & sh->u.s.num_done );
-            #ifdef KMP_DEBUG
+              if ((last = (limit >= trip)) != 0)
+                limit = trip;
+            }
+            break;
+          } else {
+/* use exponential-style scheduling */
+/* The following check is to workaround the lack of long double precision on
+   Windows* OS.
+   This check works around the possible effect that init != 0 for chunkIdx == 0.
+ */
+#if KMP_OS_WINDOWS && KMP_ARCH_X86
+            /* If we haven't already done so, save original FPCW and set
+               precision to 64-bit, as Windows* OS on IA-32 architecture
+               defaults to 53-bit */
+            if (!fpcwSet) {
+              oldFpcw = _control87(0, 0);
+              _control87(_PC_64, _MCW_PC);
+              fpcwSet = 0x30000;
+            }
+#endif
+            if (chunkIdx) {
+              init = __kmp_dispatch_guided_remaining<T>(
+                  trip, *(DBL *)&pr->u.p.parm3, chunkIdx);
+              KMP_DEBUG_ASSERT(init);
+              init = trip - init;
+            } else
+              init = 0;
+            limit = trip - __kmp_dispatch_guided_remaining<T>(
+                               trip, *(DBL *)&pr->u.p.parm3, chunkIdx + 1);
+            KMP_ASSERT(init <= limit);
+            if (init < limit) {
+              KMP_DEBUG_ASSERT(limit <= trip);
+              --limit;
+              status = 1;
+              break;
+            } // if
+          } // if
+        } // while (1)
+#if KMP_OS_WINDOWS && KMP_ARCH_X86
+        /* restore FPCW if necessary
+           AC: check fpcwSet flag first because oldFpcw can be uninitialized
+           here */
+        if (fpcwSet && (oldFpcw & fpcwSet))
+          _control87(oldFpcw, _MCW_PC);
+#endif
+        if (status != 0) {
+          start = pr->u.p.lb;
+          incr = pr->u.p.st;
+          if (p_st != NULL)
+            *p_st = incr;
+          *p_lb = start + init * incr;
+          *p_ub = start + limit * incr;
+          if (pr->ordered) {
+            pr->u.p.ordered_lower = init;
+            pr->u.p.ordered_upper = limit;
+#ifdef KMP_DEBUG
             {
-                const char * buff;
-                // create format specifiers before the debug output
-                buff = __kmp_str_format(
-                    "__kmp_dispatch_next: T#%%d increment num_done:%%%s\n",
-                    traits_t< UT >::spec );
-                KD_TRACE(100, ( buff, gtid, sh->u.s.num_done ) );
-                __kmp_str_free( &buff );
+              const char *buff;
+              // create format specifiers before the debug output
+              buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                      "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                      traits_t<UT>::spec, traits_t<UT>::spec);
+              KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                              pr->u.p.ordered_upper));
+              __kmp_str_free(&buff);
             }
-            #endif
-
-            if ( (ST)num_done == th->th.th_team_nproc - 1 ) {
-                #if ( KMP_STATIC_STEAL_ENABLED )
-                if( pr->schedule == kmp_sch_static_steal && traits_t<T>::type_size > 4 ) {
-                    int i;
-                    kmp_info_t **other_threads = team->t.t_threads;
-                    // loop complete, safe to destroy locks used for stealing
-                    for( i = 0; i < th->th.th_team_nproc; ++i ) {
-                        kmp_lock_t * lck = other_threads[i]->th.th_dispatch->th_steal_lock;
-                        KMP_ASSERT(lck != NULL);
-                        __kmp_destroy_lock( lck );
-                        __kmp_free( lck );
-                        other_threads[i]->th.th_dispatch->th_steal_lock = NULL;
-                    }
-                }
-                #endif
-                /* NOTE: release this buffer to be reused */
+#endif
+          }
+        } else {
+          *p_lb = 0;
+          *p_ub = 0;
+          if (p_st != NULL)
+            *p_st = 0;
+        }
+      } // case
+      break;
+
+      case kmp_sch_trapezoidal: {
+        UT index;
+        T parm2 = pr->u.p.parm2;
+        T parm3 = pr->u.p.parm3;
+        T parm4 = pr->u.p.parm4;
+        KD_TRACE(100, ("__kmp_dispatch_next: T#%d kmp_sch_trapezoidal case\n",
+                       gtid));
+
+        index = test_then_inc<ST>((volatile ST *)&sh->u.s.iteration);
+
+        init = (index * ((2 * parm2) - (index - 1) * parm4)) / 2;
+        trip = pr->u.p.tc - 1;
+
+        if ((status = ((T)index < parm3 && init <= trip)) == 0) {
+          *p_lb = 0;
+          *p_ub = 0;
+          if (p_st != NULL)
+            *p_st = 0;
+        } else {
+          start = pr->u.p.lb;
+          limit = ((index + 1) * (2 * parm2 - index * parm4)) / 2 - 1;
+          incr = pr->u.p.st;
+
+          if ((last = (limit >= trip)) != 0)
+            limit = trip;
+
+          if (p_st != NULL)
+            *p_st = incr;
+
+          if (incr == 1) {
+            *p_lb = start + init;
+            *p_ub = start + limit;
+          } else {
+            *p_lb = start + init * incr;
+            *p_ub = start + limit * incr;
+          }
+
+          if (pr->ordered) {
+            pr->u.p.ordered_lower = init;
+            pr->u.p.ordered_upper = limit;
+#ifdef KMP_DEBUG
+            {
+              const char *buff;
+              // create format specifiers before the debug output
+              buff = __kmp_str_format("__kmp_dispatch_next: T#%%d "
+                                      "ordered_lower:%%%s ordered_upper:%%%s\n",
+                                      traits_t<UT>::spec, traits_t<UT>::spec);
+              KD_TRACE(1000, (buff, gtid, pr->u.p.ordered_lower,
+                              pr->u.p.ordered_upper));
+              __kmp_str_free(&buff);
+            }
+#endif
+          } // if
+        } // if
+      } // case
+      break;
+      default: {
+        status = 0; // to avoid complaints on uninitialized variable use
+        __kmp_msg(kmp_ms_fatal, // Severity
+                  KMP_MSG(UnknownSchedTypeDetected), // Primary message
+                  KMP_HNT(GetNewerLibrary), // Hint
+                  __kmp_msg_null // Variadic argument list terminator
+                  );
+      } break;
+      } // switch
+    } // if tc == 0;
+
+    if (status == 0) {
+      UT num_done;
+
+      num_done = test_then_inc<ST>((volatile ST *)&sh->u.s.num_done);
+#ifdef KMP_DEBUG
+      {
+        const char *buff;
+        // create format specifiers before the debug output
+        buff = __kmp_str_format(
+            "__kmp_dispatch_next: T#%%d increment num_done:%%%s\n",
+            traits_t<UT>::spec);
+        KD_TRACE(100, (buff, gtid, sh->u.s.num_done));
+        __kmp_str_free(&buff);
+      }
+#endif
 
-                KMP_MB();       /* Flush all pending memory write invalidates.  */
+      if ((ST)num_done == th->th.th_team_nproc - 1) {
+#if (KMP_STATIC_STEAL_ENABLED)
+        if (pr->schedule == kmp_sch_static_steal &&
+            traits_t<T>::type_size > 4) {
+          int i;
+          kmp_info_t **other_threads = team->t.t_threads;
+          // loop complete, safe to destroy locks used for stealing
+          for (i = 0; i < th->th.th_team_nproc; ++i) {
+            kmp_lock_t *lck = other_threads[i]->th.th_dispatch->th_steal_lock;
+            KMP_ASSERT(lck != NULL);
+            __kmp_destroy_lock(lck);
+            __kmp_free(lck);
+            other_threads[i]->th.th_dispatch->th_steal_lock = NULL;
+          }
+        }
+#endif
+        /* NOTE: release this buffer to be reused */
 
-                sh->u.s.num_done = 0;
-                sh->u.s.iteration = 0;
+        KMP_MB(); /* Flush all pending memory write invalidates.  */
 
-                /* TODO replace with general release procedure? */
-                if ( pr->ordered ) {
-                    sh->u.s.ordered_iteration = 0;
-                }
+        sh->u.s.num_done = 0;
+        sh->u.s.iteration = 0;
 
-                KMP_MB();       /* Flush all pending memory write invalidates.  */
+        /* TODO replace with general release procedure? */
+        if (pr->ordered) {
+          sh->u.s.ordered_iteration = 0;
+        }
 
-                sh -> buffer_index += __kmp_dispatch_num_buffers;
-                KD_TRACE(100, ("__kmp_dispatch_next: T#%d change buffer_index:%d\n",
-                                gtid, sh->buffer_index) );
+        KMP_MB(); /* Flush all pending memory write invalidates.  */
 
-                KMP_MB();       /* Flush all pending memory write invalidates.  */
+        sh->buffer_index += __kmp_dispatch_num_buffers;
+        KD_TRACE(100, ("__kmp_dispatch_next: T#%d change buffer_index:%d\n",
+                       gtid, sh->buffer_index));
 
-            } // if
-            if ( __kmp_env_consistency_check ) {
-                if ( pr->pushed_ws != ct_none ) {
-                    pr->pushed_ws = __kmp_pop_workshare( gtid, pr->pushed_ws, loc );
-                }
-            }
+        KMP_MB(); /* Flush all pending memory write invalidates.  */
 
-            th -> th.th_dispatch -> th_deo_fcn = NULL;
-            th -> th.th_dispatch -> th_dxo_fcn = NULL;
-            th -> th.th_dispatch -> th_dispatch_sh_current = NULL;
-            th -> th.th_dispatch -> th_dispatch_pr_current = NULL;
-        } // if (status == 0)
-#if KMP_OS_WINDOWS
-        else if ( last ) {
-            pr->u.p.last_upper = pr->u.p.ub;
+      } // if
+      if (__kmp_env_consistency_check) {
+        if (pr->pushed_ws != ct_none) {
+          pr->pushed_ws = __kmp_pop_workshare(gtid, pr->pushed_ws, loc);
         }
-#endif /* KMP_OS_WINDOWS */
-        if ( p_last != NULL && status != 0 )
-            *p_last = last;
-    } // if
+      }
 
-    #ifdef KMP_DEBUG
-    {
-        const char * buff;
-        // create format specifiers before the debug output
-        buff = __kmp_str_format(
-            "__kmp_dispatch_next: T#%%d normal case: " \
-            "p_lb:%%%s p_ub:%%%s p_st:%%%s p_last:%%p  returning:%%d\n",
-            traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec );
-        KD_TRACE(10, ( buff, gtid, *p_lb, *p_ub, p_st ? *p_st : 0, p_last, status ) );
-        __kmp_str_free( &buff );
+      th->th.th_dispatch->th_deo_fcn = NULL;
+      th->th.th_dispatch->th_dxo_fcn = NULL;
+      th->th.th_dispatch->th_dispatch_sh_current = NULL;
+      th->th.th_dispatch->th_dispatch_pr_current = NULL;
+    } // if (status == 0)
+#if KMP_OS_WINDOWS
+    else if (last) {
+      pr->u.p.last_upper = pr->u.p.ub;
     }
-    #endif
+#endif /* KMP_OS_WINDOWS */
+    if (p_last != NULL && status != 0)
+      *p_last = last;
+  } // if
+
+#ifdef KMP_DEBUG
+  {
+    const char *buff;
+    // create format specifiers before the debug output
+    buff = __kmp_str_format(
+        "__kmp_dispatch_next: T#%%d normal case: "
+        "p_lb:%%%s p_ub:%%%s p_st:%%%s p_last:%%p  returning:%%d\n",
+        traits_t<T>::spec, traits_t<T>::spec, traits_t<ST>::spec);
+    KD_TRACE(10, (buff, gtid, *p_lb, *p_ub, p_st ? *p_st : 0, p_last, status));
+    __kmp_str_free(&buff);
+  }
+#endif
 #if INCLUDE_SSC_MARKS
-    SSC_MARK_DISPATCH_NEXT();
+  SSC_MARK_DISPATCH_NEXT();
 #endif
-    OMPT_LOOP_END;
-    return status;
+  OMPT_LOOP_END;
+  return status;
 }
 
-template< typename T >
-static void
-__kmp_dist_get_bounds(
-    ident_t                          *loc,
-    kmp_int32                         gtid,
-    kmp_int32                        *plastiter,
-    T                                *plower,
-    T                                *pupper,
-    typename traits_t< T >::signed_t  incr
-) {
-    typedef typename traits_t< T >::unsigned_t  UT;
-    typedef typename traits_t< T >::signed_t    ST;
-    register kmp_uint32  team_id;
-    register kmp_uint32  nteams;
-    register UT          trip_count;
-    register kmp_team_t *team;
-    kmp_info_t * th;
-
-    KMP_DEBUG_ASSERT( plastiter && plower && pupper );
-    KE_TRACE( 10, ("__kmpc_dist_get_bounds called (%d)\n", gtid));
-    #ifdef KMP_DEBUG
-    {
-        const char * buff;
-        // create format specifiers before the debug output
-        buff = __kmp_str_format( "__kmpc_dist_get_bounds: T#%%d liter=%%d "\
-            "iter=(%%%s, %%%s, %%%s) signed?<%s>\n",
-            traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec,
-            traits_t< T >::spec );
-        KD_TRACE(100, ( buff, gtid, *plastiter, *plower, *pupper, incr ) );
-        __kmp_str_free( &buff );
-    }
-    #endif
-
-    if( __kmp_env_consistency_check ) {
-        if( incr == 0 ) {
-            __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrZeroProhibited, ct_pdo, loc );
-        }
-        if( incr > 0 ? (*pupper < *plower) : (*plower < *pupper) ) {
-            // The loop is illegal.
-            // Some zero-trip loops maintained by compiler, e.g.:
-            //   for(i=10;i<0;++i) // lower >= upper - run-time check
-            //   for(i=0;i>10;--i) // lower <= upper - run-time check
-            //   for(i=0;i>10;++i) // incr > 0       - compile-time check
-            //   for(i=10;i<0;--i) // incr < 0       - compile-time check
-            // Compiler does not check the following illegal loops:
-            //   for(i=0;i<10;i+=incr) // where incr<0
-            //   for(i=10;i>0;i-=incr) // where incr<0
-            __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrIllegal, ct_pdo, loc );
-        }
-    }
-    th = __kmp_threads[gtid];
-    team = th->th.th_team;
-    #if OMP_40_ENABLED
-    KMP_DEBUG_ASSERT(th->th.th_teams_microtask);   // we are in the teams construct
-    nteams = th->th.th_teams_size.nteams;
-    #endif
-    team_id = team->t.t_master_tid;
-    KMP_DEBUG_ASSERT(nteams == team->t.t_parent->t.t_nproc);
-
-    // compute global trip count
-    if( incr == 1 ) {
-        trip_count = *pupper - *plower + 1;
-    } else if(incr == -1) {
-        trip_count = *plower - *pupper + 1;
-    } else if ( incr > 0 ) {
-        // upper-lower can exceed the limit of signed type
-        trip_count = (UT)(*pupper - *plower) / incr + 1;
+template <typename T>
+static void __kmp_dist_get_bounds(ident_t *loc, kmp_int32 gtid,
+                                  kmp_int32 *plastiter, T *plower, T *pupper,
+                                  typename traits_t<T>::signed_t incr) {
+  typedef typename traits_t<T>::unsigned_t UT;
+  typedef typename traits_t<T>::signed_t ST;
+  register kmp_uint32 team_id;
+  register kmp_uint32 nteams;
+  register UT trip_count;
+  register kmp_team_t *team;
+  kmp_info_t *th;
+
+  KMP_DEBUG_ASSERT(plastiter && plower && pupper);
+  KE_TRACE(10, ("__kmpc_dist_get_bounds called (%d)\n", gtid));
+#ifdef KMP_DEBUG
+  {
+    const char *buff;
+    // create format specifiers before the debug output
+    buff = __kmp_str_format("__kmpc_dist_get_bounds: T#%%d liter=%%d "
+                            "iter=(%%%s, %%%s, %%%s) signed?<%s>\n",
+                            traits_t<T>::spec, traits_t<T>::spec,
+                            traits_t<ST>::spec, traits_t<T>::spec);
+    KD_TRACE(100, (buff, gtid, *plastiter, *plower, *pupper, incr));
+    __kmp_str_free(&buff);
+  }
+#endif
+
+  if (__kmp_env_consistency_check) {
+    if (incr == 0) {
+      __kmp_error_construct(kmp_i18n_msg_CnsLoopIncrZeroProhibited, ct_pdo,
+                            loc);
+    }
+    if (incr > 0 ? (*pupper < *plower) : (*plower < *pupper)) {
+      // The loop is illegal.
+      // Some zero-trip loops maintained by compiler, e.g.:
+      //   for(i=10;i<0;++i) // lower >= upper - run-time check
+      //   for(i=0;i>10;--i) // lower <= upper - run-time check
+      //   for(i=0;i>10;++i) // incr > 0       - compile-time check
+      //   for(i=10;i<0;--i) // incr < 0       - compile-time check
+      // Compiler does not check the following illegal loops:
+      //   for(i=0;i<10;i+=incr) // where incr<0
+      //   for(i=10;i>0;i-=incr) // where incr<0
+      __kmp_error_construct(kmp_i18n_msg_CnsLoopIncrIllegal, ct_pdo, loc);
+    }
+  }
+  th = __kmp_threads[gtid];
+  team = th->th.th_team;
+#if OMP_40_ENABLED
+  KMP_DEBUG_ASSERT(th->th.th_teams_microtask); // we are in the teams construct
+  nteams = th->th.th_teams_size.nteams;
+#endif
+  team_id = team->t.t_master_tid;
+  KMP_DEBUG_ASSERT(nteams == team->t.t_parent->t.t_nproc);
+
+  // compute global trip count
+  if (incr == 1) {
+    trip_count = *pupper - *plower + 1;
+  } else if (incr == -1) {
+    trip_count = *plower - *pupper + 1;
+  } else if (incr > 0) {
+    // upper-lower can exceed the limit of signed type
+    trip_count = (UT)(*pupper - *plower) / incr + 1;
+  } else {
+    trip_count = (UT)(*plower - *pupper) / (-incr) + 1;
+  }
+
+  if (trip_count <= nteams) {
+    KMP_DEBUG_ASSERT(
+        __kmp_static == kmp_sch_static_greedy ||
+        __kmp_static ==
+            kmp_sch_static_balanced); // Unknown static scheduling type.
+    // only some teams get single iteration, others get nothing
+    if (team_id < trip_count) {
+      *pupper = *plower = *plower + team_id * incr;
     } else {
-        trip_count = (UT)(*plower - *pupper) / ( -incr ) + 1;
+      *plower = *pupper + incr; // zero-trip loop
     }
-
-    if( trip_count <= nteams ) {
-        KMP_DEBUG_ASSERT(
-            __kmp_static == kmp_sch_static_greedy || \
-            __kmp_static == kmp_sch_static_balanced
-        ); // Unknown static scheduling type.
-        // only some teams get single iteration, others get nothing
-        if( team_id < trip_count ) {
-            *pupper = *plower = *plower + team_id * incr;
-        } else {
-            *plower = *pupper + incr; // zero-trip loop
-        }
-        if( plastiter != NULL )
-            *plastiter = ( team_id == trip_count - 1 );
+    if (plastiter != NULL)
+      *plastiter = (team_id == trip_count - 1);
+  } else {
+    if (__kmp_static == kmp_sch_static_balanced) {
+      register UT chunk = trip_count / nteams;
+      register UT extras = trip_count % nteams;
+      *plower +=
+          incr * (team_id * chunk + (team_id < extras ? team_id : extras));
+      *pupper = *plower + chunk * incr - (team_id < extras ? 0 : incr);
+      if (plastiter != NULL)
+        *plastiter = (team_id == nteams - 1);
     } else {
-        if( __kmp_static == kmp_sch_static_balanced ) {
-            register UT chunk = trip_count / nteams;
-            register UT extras = trip_count % nteams;
-            *plower += incr * ( team_id * chunk + ( team_id < extras ? team_id : extras ) );
-            *pupper = *plower + chunk * incr - ( team_id < extras ? 0 : incr );
-            if( plastiter != NULL )
-                *plastiter = ( team_id == nteams - 1 );
-        } else {
-            register T chunk_inc_count =
-                ( trip_count / nteams + ( ( trip_count % nteams ) ? 1 : 0) ) * incr;
-            register T upper = *pupper;
-            KMP_DEBUG_ASSERT( __kmp_static == kmp_sch_static_greedy );
-                // Unknown static scheduling type.
-            *plower += team_id * chunk_inc_count;
-            *pupper = *plower + chunk_inc_count - incr;
-            // Check/correct bounds if needed
-            if( incr > 0 ) {
-                if( *pupper < *plower )
-                    *pupper = traits_t<T>::max_value;
-                if( plastiter != NULL )
-                    *plastiter = *plower <= upper && *pupper > upper - incr;
-                if( *pupper > upper )
-                    *pupper = upper; // tracker C73258
-            } else {
-                if( *pupper > *plower )
-                    *pupper = traits_t<T>::min_value;
-                if( plastiter != NULL )
-                    *plastiter = *plower >= upper && *pupper < upper - incr;
-                if( *pupper < upper )
-                    *pupper = upper; // tracker C73258
-            }
-        }
+      register T chunk_inc_count =
+          (trip_count / nteams + ((trip_count % nteams) ? 1 : 0)) * incr;
+      register T upper = *pupper;
+      KMP_DEBUG_ASSERT(__kmp_static == kmp_sch_static_greedy);
+      // Unknown static scheduling type.
+      *plower += team_id * chunk_inc_count;
+      *pupper = *plower + chunk_inc_count - incr;
+      // Check/correct bounds if needed
+      if (incr > 0) {
+        if (*pupper < *plower)
+          *pupper = traits_t<T>::max_value;
+        if (plastiter != NULL)
+          *plastiter = *plower <= upper && *pupper > upper - incr;
+        if (*pupper > upper)
+          *pupper = upper; // tracker C73258
+      } else {
+        if (*pupper > *plower)
+          *pupper = traits_t<T>::min_value;
+        if (plastiter != NULL)
+          *plastiter = *plower >= upper && *pupper < upper - incr;
+        if (*pupper < upper)
+          *pupper = upper; // tracker C73258
+      }
     }
+  }
 }
 
-//-----------------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 // Dispatch routines
 //    Transfer call to template< type T >
 //    __kmp_dispatch_init( ident_t *loc, int gtid, enum sched_type schedule,
@@ -2408,50 +2392,45 @@ extern "C" {
 @param st  Step (or increment if you prefer)
 @param chunk The chunk size to block with
 
-This function prepares the runtime to start a dynamically scheduled for loop, saving the loop arguments.
+This function prepares the runtime to start a dynamically scheduled for loop,
+saving the loop arguments.
 These functions are all identical apart from the types of the arguments.
 */
 
-void
-__kmpc_dispatch_init_4( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                        kmp_int32 lb, kmp_int32 ub, kmp_int32 st, kmp_int32 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dispatch_init< kmp_int32 >( loc, gtid, schedule, lb, ub, st, chunk, true );
+void __kmpc_dispatch_init_4(ident_t *loc, kmp_int32 gtid,
+                            enum sched_type schedule, kmp_int32 lb,
+                            kmp_int32 ub, kmp_int32 st, kmp_int32 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dispatch_init<kmp_int32>(loc, gtid, schedule, lb, ub, st, chunk, true);
 }
 /*!
 See @ref __kmpc_dispatch_init_4
 */
-void
-__kmpc_dispatch_init_4u( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                        kmp_uint32 lb, kmp_uint32 ub, kmp_int32 st, kmp_int32 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dispatch_init< kmp_uint32 >( loc, gtid, schedule, lb, ub, st, chunk, true );
+void __kmpc_dispatch_init_4u(ident_t *loc, kmp_int32 gtid,
+                             enum sched_type schedule, kmp_uint32 lb,
+                             kmp_uint32 ub, kmp_int32 st, kmp_int32 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dispatch_init<kmp_uint32>(loc, gtid, schedule, lb, ub, st, chunk, true);
 }
 
 /*!
 See @ref __kmpc_dispatch_init_4
 */
-void
-__kmpc_dispatch_init_8( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                        kmp_int64 lb, kmp_int64 ub,
-                        kmp_int64 st, kmp_int64 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dispatch_init< kmp_int64 >( loc, gtid, schedule, lb, ub, st, chunk, true );
+void __kmpc_dispatch_init_8(ident_t *loc, kmp_int32 gtid,
+                            enum sched_type schedule, kmp_int64 lb,
+                            kmp_int64 ub, kmp_int64 st, kmp_int64 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dispatch_init<kmp_int64>(loc, gtid, schedule, lb, ub, st, chunk, true);
 }
 
 /*!
 See @ref __kmpc_dispatch_init_4
 */
-void
-__kmpc_dispatch_init_8u( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                         kmp_uint64 lb, kmp_uint64 ub,
-                         kmp_int64 st, kmp_int64 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dispatch_init< kmp_uint64 >( loc, gtid, schedule, lb, ub, st, chunk, true );
+void __kmpc_dispatch_init_8u(ident_t *loc, kmp_int32 gtid,
+                             enum sched_type schedule, kmp_uint64 lb,
+                             kmp_uint64 ub, kmp_int64 st, kmp_int64 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dispatch_init<kmp_uint64>(loc, gtid, schedule, lb, ub, st, chunk, true);
 }
 
 /*!
@@ -2463,46 +2442,47 @@ regular iterations dispatching we need t
 
 These functions are all identical apart from the types of the arguments.
 */
-void
-__kmpc_dist_dispatch_init_4( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-    kmp_int32 *p_last, kmp_int32 lb, kmp_int32 ub, kmp_int32 st, kmp_int32 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dist_get_bounds< kmp_int32 >( loc, gtid, p_last, &lb, &ub, st );
-    __kmp_dispatch_init< kmp_int32 >( loc, gtid, schedule, lb, ub, st, chunk, true );
-}
-
-void
-__kmpc_dist_dispatch_init_4u( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-    kmp_int32 *p_last, kmp_uint32 lb, kmp_uint32 ub, kmp_int32 st, kmp_int32 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dist_get_bounds< kmp_uint32 >( loc, gtid, p_last, &lb, &ub, st );
-    __kmp_dispatch_init< kmp_uint32 >( loc, gtid, schedule, lb, ub, st, chunk, true );
-}
-
-void
-__kmpc_dist_dispatch_init_8( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-    kmp_int32 *p_last, kmp_int64 lb, kmp_int64 ub, kmp_int64 st, kmp_int64 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dist_get_bounds< kmp_int64 >( loc, gtid, p_last, &lb, &ub, st );
-    __kmp_dispatch_init< kmp_int64 >( loc, gtid, schedule, lb, ub, st, chunk, true );
-}
-
-void
-__kmpc_dist_dispatch_init_8u( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-    kmp_int32 *p_last, kmp_uint64 lb, kmp_uint64 ub, kmp_int64 st, kmp_int64 chunk )
-{
-    KMP_DEBUG_ASSERT( __kmp_init_serial );
-    __kmp_dist_get_bounds< kmp_uint64 >( loc, gtid, p_last, &lb, &ub, st );
-    __kmp_dispatch_init< kmp_uint64 >( loc, gtid, schedule, lb, ub, st, chunk, true );
+void __kmpc_dist_dispatch_init_4(ident_t *loc, kmp_int32 gtid,
+                                 enum sched_type schedule, kmp_int32 *p_last,
+                                 kmp_int32 lb, kmp_int32 ub, kmp_int32 st,
+                                 kmp_int32 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dist_get_bounds<kmp_int32>(loc, gtid, p_last, &lb, &ub, st);
+  __kmp_dispatch_init<kmp_int32>(loc, gtid, schedule, lb, ub, st, chunk, true);
+}
+
+void __kmpc_dist_dispatch_init_4u(ident_t *loc, kmp_int32 gtid,
+                                  enum sched_type schedule, kmp_int32 *p_last,
+                                  kmp_uint32 lb, kmp_uint32 ub, kmp_int32 st,
+                                  kmp_int32 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dist_get_bounds<kmp_uint32>(loc, gtid, p_last, &lb, &ub, st);
+  __kmp_dispatch_init<kmp_uint32>(loc, gtid, schedule, lb, ub, st, chunk, true);
+}
+
+void __kmpc_dist_dispatch_init_8(ident_t *loc, kmp_int32 gtid,
+                                 enum sched_type schedule, kmp_int32 *p_last,
+                                 kmp_int64 lb, kmp_int64 ub, kmp_int64 st,
+                                 kmp_int64 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dist_get_bounds<kmp_int64>(loc, gtid, p_last, &lb, &ub, st);
+  __kmp_dispatch_init<kmp_int64>(loc, gtid, schedule, lb, ub, st, chunk, true);
+}
+
+void __kmpc_dist_dispatch_init_8u(ident_t *loc, kmp_int32 gtid,
+                                  enum sched_type schedule, kmp_int32 *p_last,
+                                  kmp_uint64 lb, kmp_uint64 ub, kmp_int64 st,
+                                  kmp_int64 chunk) {
+  KMP_DEBUG_ASSERT(__kmp_init_serial);
+  __kmp_dist_get_bounds<kmp_uint64>(loc, gtid, p_last, &lb, &ub, st);
+  __kmp_dispatch_init<kmp_uint64>(loc, gtid, schedule, lb, ub, st, chunk, true);
 }
 
 /*!
 @param loc Source code location
 @param gtid Global thread id
- at param p_last Pointer to a flag set to one if this is the last chunk or zero otherwise
+ at param p_last Pointer to a flag set to one if this is the last chunk or zero
+otherwise
 @param p_lb   Pointer to the lower bound for the next chunk of work
 @param p_ub   Pointer to the upper bound for the next chunk of work
 @param p_st   Pointer to the stride for the next chunk of work
@@ -2511,41 +2491,35 @@ __kmpc_dist_dispatch_init_8u( ident_t *l
 Get the next dynamically allocated chunk of work for this thread.
 If there is no more work, then the lb,ub and stride need not be modified.
 */
-int
-__kmpc_dispatch_next_4( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
-                        kmp_int32 *p_lb, kmp_int32 *p_ub, kmp_int32 *p_st )
-{
-    return __kmp_dispatch_next< kmp_int32 >( loc, gtid, p_last, p_lb, p_ub, p_st );
+int __kmpc_dispatch_next_4(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
+                           kmp_int32 *p_lb, kmp_int32 *p_ub, kmp_int32 *p_st) {
+  return __kmp_dispatch_next<kmp_int32>(loc, gtid, p_last, p_lb, p_ub, p_st);
 }
 
 /*!
 See @ref __kmpc_dispatch_next_4
 */
-int
-__kmpc_dispatch_next_4u( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
-                        kmp_uint32 *p_lb, kmp_uint32 *p_ub, kmp_int32 *p_st )
-{
-    return __kmp_dispatch_next< kmp_uint32 >( loc, gtid, p_last, p_lb, p_ub, p_st );
+int __kmpc_dispatch_next_4u(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
+                            kmp_uint32 *p_lb, kmp_uint32 *p_ub,
+                            kmp_int32 *p_st) {
+  return __kmp_dispatch_next<kmp_uint32>(loc, gtid, p_last, p_lb, p_ub, p_st);
 }
 
 /*!
 See @ref __kmpc_dispatch_next_4
 */
-int
-__kmpc_dispatch_next_8( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
-                        kmp_int64 *p_lb, kmp_int64 *p_ub, kmp_int64 *p_st )
-{
-    return __kmp_dispatch_next< kmp_int64 >( loc, gtid, p_last, p_lb, p_ub, p_st );
+int __kmpc_dispatch_next_8(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
+                           kmp_int64 *p_lb, kmp_int64 *p_ub, kmp_int64 *p_st) {
+  return __kmp_dispatch_next<kmp_int64>(loc, gtid, p_last, p_lb, p_ub, p_st);
 }
 
 /*!
 See @ref __kmpc_dispatch_next_4
 */
-int
-__kmpc_dispatch_next_8u( ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
-                        kmp_uint64 *p_lb, kmp_uint64 *p_ub, kmp_int64 *p_st )
-{
-    return __kmp_dispatch_next< kmp_uint64 >( loc, gtid, p_last, p_lb, p_ub, p_st );
+int __kmpc_dispatch_next_8u(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
+                            kmp_uint64 *p_lb, kmp_uint64 *p_ub,
+                            kmp_int64 *p_st) {
+  return __kmp_dispatch_next<kmp_uint64>(loc, gtid, p_last, p_lb, p_ub, p_st);
 }
 
 /*!
@@ -2554,188 +2528,161 @@ __kmpc_dispatch_next_8u( ident_t *loc, k
 
 Mark the end of a dynamic loop.
 */
-void
-__kmpc_dispatch_fini_4( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish< kmp_uint32 >( gtid, loc );
+void __kmpc_dispatch_fini_4(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish<kmp_uint32>(gtid, loc);
 }
 
 /*!
 See @ref __kmpc_dispatch_fini_4
 */
-void
-__kmpc_dispatch_fini_8( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish< kmp_uint64 >( gtid, loc );
+void __kmpc_dispatch_fini_8(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish<kmp_uint64>(gtid, loc);
 }
 
 /*!
 See @ref __kmpc_dispatch_fini_4
 */
-void
-__kmpc_dispatch_fini_4u( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish< kmp_uint32 >( gtid, loc );
+void __kmpc_dispatch_fini_4u(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish<kmp_uint32>(gtid, loc);
 }
 
 /*!
 See @ref __kmpc_dispatch_fini_4
 */
-void
-__kmpc_dispatch_fini_8u( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish< kmp_uint64 >( gtid, loc );
+void __kmpc_dispatch_fini_8u(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish<kmp_uint64>(gtid, loc);
 }
 /*! @} */
 
-//-----------------------------------------------------------------------------------------
-//Non-template routines from kmp_dispatch.cpp used in other sources
+//-----------------------------------------------------------------------------
+// Non-template routines from kmp_dispatch.cpp used in other sources
 
-kmp_uint32 __kmp_eq_4( kmp_uint32 value, kmp_uint32 checker) {
-    return value == checker;
+kmp_uint32 __kmp_eq_4(kmp_uint32 value, kmp_uint32 checker) {
+  return value == checker;
 }
 
-kmp_uint32 __kmp_neq_4( kmp_uint32 value, kmp_uint32 checker) {
-    return value != checker;
+kmp_uint32 __kmp_neq_4(kmp_uint32 value, kmp_uint32 checker) {
+  return value != checker;
 }
 
-kmp_uint32 __kmp_lt_4( kmp_uint32 value, kmp_uint32 checker) {
-    return value < checker;
+kmp_uint32 __kmp_lt_4(kmp_uint32 value, kmp_uint32 checker) {
+  return value < checker;
 }
 
-kmp_uint32 __kmp_ge_4( kmp_uint32 value, kmp_uint32 checker) {
-    return value >= checker;
+kmp_uint32 __kmp_ge_4(kmp_uint32 value, kmp_uint32 checker) {
+  return value >= checker;
 }
 
-kmp_uint32 __kmp_le_4( kmp_uint32 value, kmp_uint32 checker) {
-    return value <= checker;
+kmp_uint32 __kmp_le_4(kmp_uint32 value, kmp_uint32 checker) {
+  return value <= checker;
 }
 
 kmp_uint32
-__kmp_wait_yield_4(volatile kmp_uint32 * spinner,
-                   kmp_uint32            checker,
-                   kmp_uint32 (* pred)( kmp_uint32, kmp_uint32 )
-                   , void        * obj    // Higher-level synchronization object, or NULL.
-                   )
-{
-    // note: we may not belong to a team at this point
-    register volatile kmp_uint32         * spin          = spinner;
-    register          kmp_uint32           check         = checker;
-    register          kmp_uint32   spins;
-    register          kmp_uint32 (*f) ( kmp_uint32, kmp_uint32 ) = pred;
-    register          kmp_uint32           r;
-
-    KMP_FSYNC_SPIN_INIT( obj, (void*) spin );
-    KMP_INIT_YIELD( spins );
-    // main wait spin loop
-    while(!f(r = TCR_4(*spin), check)) {
-        KMP_FSYNC_SPIN_PREPARE( obj );
-        /* GEH - remove this since it was accidentally introduced when kmp_wait was split.
-           It causes problems with infinite recursion because of exit lock */
-        /* if ( TCR_4(__kmp_global.g.g_done) && __kmp_global.g.g_abort)
-            __kmp_abort_thread(); */
-
-        /* if we have waited a bit, or are oversubscribed, yield */
-        /* pause is in the following code */
-        KMP_YIELD( TCR_4(__kmp_nth) > __kmp_avail_proc );
-        KMP_YIELD_SPIN( spins );
-    }
-    KMP_FSYNC_SPIN_ACQUIRED( obj );
-    return r;
-}
-
-void
-__kmp_wait_yield_4_ptr(void *spinner,
-                   kmp_uint32 checker,
-                   kmp_uint32 (*pred)( void *, kmp_uint32 ),
-                   void        *obj    // Higher-level synchronization object, or NULL.
-                   )
-{
-    // note: we may not belong to a team at this point
-    register void                *spin          = spinner;
-    register kmp_uint32           check         = checker;
-    register kmp_uint32           spins;
-    register kmp_uint32 (*f) ( void *, kmp_uint32 ) = pred;
-
-    KMP_FSYNC_SPIN_INIT( obj, spin );
-    KMP_INIT_YIELD( spins );
-    // main wait spin loop
-    while ( !f( spin, check ) ) {
-        KMP_FSYNC_SPIN_PREPARE( obj );
-        /* if we have waited a bit, or are oversubscribed, yield */
-        /* pause is in the following code */
-        KMP_YIELD( TCR_4( __kmp_nth ) > __kmp_avail_proc );
-        KMP_YIELD_SPIN( spins );
-    }
-    KMP_FSYNC_SPIN_ACQUIRED( obj );
+__kmp_wait_yield_4(volatile kmp_uint32 *spinner, kmp_uint32 checker,
+                   kmp_uint32 (*pred)(kmp_uint32, kmp_uint32),
+                   void *obj // Higher-level synchronization object, or NULL.
+                   ) {
+  // note: we may not belong to a team at this point
+  register volatile kmp_uint32 *spin = spinner;
+  register kmp_uint32 check = checker;
+  register kmp_uint32 spins;
+  register kmp_uint32 (*f)(kmp_uint32, kmp_uint32) = pred;
+  register kmp_uint32 r;
+
+  KMP_FSYNC_SPIN_INIT(obj, (void *)spin);
+  KMP_INIT_YIELD(spins);
+  // main wait spin loop
+  while (!f(r = TCR_4(*spin), check)) {
+    KMP_FSYNC_SPIN_PREPARE(obj);
+    /* GEH - remove this since it was accidentally introduced when kmp_wait was
+       split. It causes problems with infinite recursion because of exit lock */
+    /* if ( TCR_4(__kmp_global.g.g_done) && __kmp_global.g.g_abort)
+        __kmp_abort_thread(); */
+
+    /* if we have waited a bit, or are oversubscribed, yield */
+    /* pause is in the following code */
+    KMP_YIELD(TCR_4(__kmp_nth) > __kmp_avail_proc);
+    KMP_YIELD_SPIN(spins);
+  }
+  KMP_FSYNC_SPIN_ACQUIRED(obj);
+  return r;
+}
+
+void __kmp_wait_yield_4_ptr(
+    void *spinner, kmp_uint32 checker, kmp_uint32 (*pred)(void *, kmp_uint32),
+    void *obj // Higher-level synchronization object, or NULL.
+    ) {
+  // note: we may not belong to a team at this point
+  register void *spin = spinner;
+  register kmp_uint32 check = checker;
+  register kmp_uint32 spins;
+  register kmp_uint32 (*f)(void *, kmp_uint32) = pred;
+
+  KMP_FSYNC_SPIN_INIT(obj, spin);
+  KMP_INIT_YIELD(spins);
+  // main wait spin loop
+  while (!f(spin, check)) {
+    KMP_FSYNC_SPIN_PREPARE(obj);
+    /* if we have waited a bit, or are oversubscribed, yield */
+    /* pause is in the following code */
+    KMP_YIELD(TCR_4(__kmp_nth) > __kmp_avail_proc);
+    KMP_YIELD_SPIN(spins);
+  }
+  KMP_FSYNC_SPIN_ACQUIRED(obj);
 }
 
 } // extern "C"
 
 #ifdef KMP_GOMP_COMPAT
 
-void
-__kmp_aux_dispatch_init_4( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                           kmp_int32 lb, kmp_int32 ub, kmp_int32 st,
-                           kmp_int32 chunk, int push_ws )
-{
-    __kmp_dispatch_init< kmp_int32 >( loc, gtid, schedule, lb, ub, st, chunk,
-                                      push_ws );
-}
-
-void
-__kmp_aux_dispatch_init_4u( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                            kmp_uint32 lb, kmp_uint32 ub, kmp_int32 st,
-                            kmp_int32 chunk, int push_ws )
-{
-    __kmp_dispatch_init< kmp_uint32 >( loc, gtid, schedule, lb, ub, st, chunk,
-                                       push_ws );
-}
-
-void
-__kmp_aux_dispatch_init_8( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                           kmp_int64 lb, kmp_int64 ub, kmp_int64 st,
-                           kmp_int64 chunk, int push_ws )
-{
-    __kmp_dispatch_init< kmp_int64 >( loc, gtid, schedule, lb, ub, st, chunk,
-                                      push_ws );
-}
-
-void
-__kmp_aux_dispatch_init_8u( ident_t *loc, kmp_int32 gtid, enum sched_type schedule,
-                            kmp_uint64 lb, kmp_uint64 ub, kmp_int64 st,
-                            kmp_int64 chunk, int push_ws )
-{
-    __kmp_dispatch_init< kmp_uint64 >( loc, gtid, schedule, lb, ub, st, chunk,
-                                       push_ws );
-}
-
-void
-__kmp_aux_dispatch_fini_chunk_4( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish_chunk< kmp_uint32 >( gtid, loc );
-}
-
-void
-__kmp_aux_dispatch_fini_chunk_8( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish_chunk< kmp_uint64 >( gtid, loc );
-}
-
-void
-__kmp_aux_dispatch_fini_chunk_4u( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish_chunk< kmp_uint32 >( gtid, loc );
-}
-
-void
-__kmp_aux_dispatch_fini_chunk_8u( ident_t *loc, kmp_int32 gtid )
-{
-    __kmp_dispatch_finish_chunk< kmp_uint64 >( gtid, loc );
+void __kmp_aux_dispatch_init_4(ident_t *loc, kmp_int32 gtid,
+                               enum sched_type schedule, kmp_int32 lb,
+                               kmp_int32 ub, kmp_int32 st, kmp_int32 chunk,
+                               int push_ws) {
+  __kmp_dispatch_init<kmp_int32>(loc, gtid, schedule, lb, ub, st, chunk,
+                                 push_ws);
+}
+
+void __kmp_aux_dispatch_init_4u(ident_t *loc, kmp_int32 gtid,
+                                enum sched_type schedule, kmp_uint32 lb,
+                                kmp_uint32 ub, kmp_int32 st, kmp_int32 chunk,
+                                int push_ws) {
+  __kmp_dispatch_init<kmp_uint32>(loc, gtid, schedule, lb, ub, st, chunk,
+                                  push_ws);
+}
+
+void __kmp_aux_dispatch_init_8(ident_t *loc, kmp_int32 gtid,
+                               enum sched_type schedule, kmp_int64 lb,
+                               kmp_int64 ub, kmp_int64 st, kmp_int64 chunk,
+                               int push_ws) {
+  __kmp_dispatch_init<kmp_int64>(loc, gtid, schedule, lb, ub, st, chunk,
+                                 push_ws);
+}
+
+void __kmp_aux_dispatch_init_8u(ident_t *loc, kmp_int32 gtid,
+                                enum sched_type schedule, kmp_uint64 lb,
+                                kmp_uint64 ub, kmp_int64 st, kmp_int64 chunk,
+                                int push_ws) {
+  __kmp_dispatch_init<kmp_uint64>(loc, gtid, schedule, lb, ub, st, chunk,
+                                  push_ws);
+}
+
+void __kmp_aux_dispatch_fini_chunk_4(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish_chunk<kmp_uint32>(gtid, loc);
+}
+
+void __kmp_aux_dispatch_fini_chunk_8(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish_chunk<kmp_uint64>(gtid, loc);
+}
+
+void __kmp_aux_dispatch_fini_chunk_4u(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish_chunk<kmp_uint32>(gtid, loc);
+}
+
+void __kmp_aux_dispatch_fini_chunk_8u(ident_t *loc, kmp_int32 gtid) {
+  __kmp_dispatch_finish_chunk<kmp_uint64>(gtid, loc);
 }
 
 #endif /* KMP_GOMP_COMPAT */
 
 /* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
-

Modified: openmp/trunk/runtime/src/kmp_environment.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_environment.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_environment.cpp (original)
+++ openmp/trunk/runtime/src/kmp_environment.cpp Fri May 12 13:01:32 2017
@@ -13,355 +13,297 @@
 //===----------------------------------------------------------------------===//
 
 
-/*
-    ------------------------------------------------------------------------------------------------
-    We use GetEnvironmentVariable for Windows* OS instead of getenv because the act of
-    loading a DLL on Windows* OS makes any user-set environment variables (i.e. with putenv())
-    unavailable.  getenv() apparently gets a clean copy of the env variables as they existed
-    at the start of the run.
-    JH 12/23/2002
-    ------------------------------------------------------------------------------------------------
-    On Windows* OS, there are two environments (at least, see below):
-
-        1. Environment maintained by Windows* OS on IA-32 architecture.
-	   Accessible through GetEnvironmentVariable(),
-           SetEnvironmentVariable(), and GetEnvironmentStrings().
-
-        2. Environment maintained by C RTL. Accessible through getenv(), putenv().
-
-    putenv() function updates both C and Windows* OS on IA-32 architecture. getenv() function
-    search for variables in C RTL environment only. Windows* OS on IA-32 architecture functions work *only*
-    with Windows* OS on IA-32 architecture.
-
-    Windows* OS on IA-32 architecture maintained by OS, so there is always only one Windows* OS on
-    IA-32 architecture per process. Changes in Windows* OS on IA-32 architecture are process-visible.
-
-    C environment maintained by C RTL. Multiple copies of C RTL may be present in the process, and
-    each C RTL maintains its own environment. :-(
-
-    Thus, proper way to work with environment on Windows* OS is:
-
-        1. Set variables with putenv() function -- both C and Windows* OS on
-	   IA-32 architecture are being updated. Windows* OS on
-	   IA-32 architecture may be considered as primary target,
-	   while updating C RTL environment is a free bonus.
-
-        2. Get variables with GetEnvironmentVariable() -- getenv() does not
-	   search Windows* OS on IA-32 architecture, and can not see variables
-	   set with SetEnvironmentVariable().
+/* We use GetEnvironmentVariable for Windows* OS instead of getenv because the
+   act of loading a DLL on Windows* OS makes any user-set environment variables
+   (i.e. with putenv()) unavailable.  getenv() apparently gets a clean copy of
+   the env variables as they existed at the start of the run. JH 12/23/2002
 
-    2007-04-05 -- lev
-    ------------------------------------------------------------------------------------------------
+   On Windows* OS, there are two environments (at least, see below):
+
+   1. Environment maintained by Windows* OS on IA-32 architecture. Accessible
+      through GetEnvironmentVariable(), SetEnvironmentVariable(), and
+      GetEnvironmentStrings().
+
+   2. Environment maintained by C RTL. Accessible through getenv(), putenv().
+
+   putenv() function updates both C and Windows* OS on IA-32 architecture.
+   getenv() function search for variables in C RTL environment only.
+   Windows* OS on IA-32 architecture functions work *only* with Windows* OS on
+   IA-32 architecture.
+
+   Windows* OS on IA-32 architecture maintained by OS, so there is always only
+   one Windows* OS on IA-32 architecture per process. Changes in Windows* OS on
+   IA-32 architecture are process-visible.
+
+   C environment maintained by C RTL. Multiple copies of C RTL may be present
+   in the process, and each C RTL maintains its own environment. :-(
+
+   Thus, proper way to work with environment on Windows* OS is:
+
+   1. Set variables with putenv() function -- both C and Windows* OS on IA-32
+      architecture are being updated. Windows* OS on IA-32 architecture may be
+      considered primary target, while updating C RTL environment is free bonus.
+
+   2. Get variables with GetEnvironmentVariable() -- getenv() does not
+      search Windows* OS on IA-32 architecture, and can not see variables
+      set with SetEnvironmentVariable().
+
+   2007-04-05 -- lev
 */
 
 #include "kmp_environment.h"
 
-#include "kmp_os.h"    // KMP_OS_*.
-#include "kmp.h"       //
-#include "kmp_str.h"   // __kmp_str_*().
+#include "kmp.h" //
 #include "kmp_i18n.h"
+#include "kmp_os.h" // KMP_OS_*.
+#include "kmp_str.h" // __kmp_str_*().
 
 #if KMP_OS_UNIX
-    #include <stdlib.h>    // getenv, setenv, unsetenv.
-    #include <string.h>    // strlen, strcpy.
-    #if KMP_OS_DARWIN
-        #include <crt_externs.h>
-        #define environ (*_NSGetEnviron())
-    #else
-        extern char * * environ;
-    #endif
+#include <stdlib.h> // getenv, setenv, unsetenv.
+#include <string.h> // strlen, strcpy.
+#if KMP_OS_DARWIN
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
+extern char **environ;
+#endif
 #elif KMP_OS_WINDOWS
-    #include <windows.h>   // GetEnvironmentVariable, SetEnvironmentVariable, GetLastError.
+#include <windows.h> // GetEnvironmentVariable, SetEnvironmentVariable,
+// GetLastError.
 #else
-    #error Unknown or unsupported OS.
+#error Unknown or unsupported OS.
 #endif
 
-
 // TODO: Eliminate direct memory allocations, use string operations instead.
 
-static inline
-void *
-allocate(
-    size_t size
-) {
-    void * ptr = KMP_INTERNAL_MALLOC( size );
-    if ( ptr == NULL ) {
-	KMP_FATAL( MemoryAllocFailed );
-    }; // if
-    return ptr;
+static inline void *allocate(size_t size) {
+  void *ptr = KMP_INTERNAL_MALLOC(size);
+  if (ptr == NULL) {
+    KMP_FATAL(MemoryAllocFailed);
+  }; // if
+  return ptr;
 } // allocate
 
+char *__kmp_env_get(char const *name) {
 
-char *
-__kmp_env_get( char const * name ) {
+  char *result = NULL;
 
-    char * result = NULL;
-
-    #if KMP_OS_UNIX
-        char const * value = getenv( name );
-        if ( value != NULL ) {
-            size_t len = KMP_STRLEN( value ) + 1;
-            result = (char *) KMP_INTERNAL_MALLOC( len );
-            if ( result == NULL ) {
-		KMP_FATAL( MemoryAllocFailed );
-            }; // if
-            KMP_STRNCPY_S( result, len, value, len );
-        }; // if
-    #elif KMP_OS_WINDOWS
-        /*
-            We use GetEnvironmentVariable for Windows* OS instead of getenv because the act of
-            loading a DLL on Windows* OS makes any user-set environment variables (i.e. with putenv())
-            unavailable.  getenv() apparently gets a clean copy of the env variables as they existed
-            at the start of the run.
-            JH 12/23/2002
-        */
-        DWORD rc;
-        rc = GetEnvironmentVariable( name, NULL, 0 );
-        if ( ! rc ) {
-            DWORD error = GetLastError();
-            if ( error != ERROR_ENVVAR_NOT_FOUND ) {
-                __kmp_msg(
-                    kmp_ms_fatal,
-                    KMP_MSG( CantGetEnvVar, name ),
-                    KMP_ERR( error ),
-                    __kmp_msg_null
-                );
-            }; // if
-            // Variable is not found, it's ok, just continue.
-        } else {
-            DWORD len = rc;
-            result = (char *) KMP_INTERNAL_MALLOC( len );
-            if ( result == NULL ) {
-		KMP_FATAL( MemoryAllocFailed );
-            }; // if
-            rc = GetEnvironmentVariable( name, result, len );
-            if ( ! rc ) {
-                // GetEnvironmentVariable() may return 0 if variable is empty.
-                // In such a case GetLastError() returns ERROR_SUCCESS.
-                DWORD error = GetLastError();
-                if ( error != ERROR_SUCCESS ) {
-                    // Unexpected error. The variable should be in the environment,
-                    // and buffer should be large enough.
-                    __kmp_msg(
-                        kmp_ms_fatal,
-                        KMP_MSG( CantGetEnvVar, name ),
-                        KMP_ERR( error ),
-                        __kmp_msg_null
-                    );
-                    KMP_INTERNAL_FREE( (void *) result );
-                    result = NULL;
-                }; // if
-            }; // if
-        }; // if
-    #else
-        #error Unknown or unsupported OS.
-    #endif
+#if KMP_OS_UNIX
+  char const *value = getenv(name);
+  if (value != NULL) {
+    size_t len = KMP_STRLEN(value) + 1;
+    result = (char *)KMP_INTERNAL_MALLOC(len);
+    if (result == NULL) {
+      KMP_FATAL(MemoryAllocFailed);
+    }; // if
+    KMP_STRNCPY_S(result, len, value, len);
+  }; // if
+#elif KMP_OS_WINDOWS
+  /* We use GetEnvironmentVariable for Windows* OS instead of getenv because the
+     act of loading a DLL on Windows* OS makes any user-set environment
+     variables (i.e. with putenv()) unavailable. getenv() apparently gets a
+     clean copy of the env variables as they existed at the start of the run.
+     JH 12/23/2002 */
+  DWORD rc;
+  rc = GetEnvironmentVariable(name, NULL, 0);
+  if (!rc) {
+    DWORD error = GetLastError();
+    if (error != ERROR_ENVVAR_NOT_FOUND) {
+      __kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
+                __kmp_msg_null);
+    }; // if
+    // Variable is not found, it's ok, just continue.
+  } else {
+    DWORD len = rc;
+    result = (char *)KMP_INTERNAL_MALLOC(len);
+    if (result == NULL) {
+      KMP_FATAL(MemoryAllocFailed);
+    }; // if
+    rc = GetEnvironmentVariable(name, result, len);
+    if (!rc) {
+      // GetEnvironmentVariable() may return 0 if variable is empty.
+      // In such a case GetLastError() returns ERROR_SUCCESS.
+      DWORD error = GetLastError();
+      if (error != ERROR_SUCCESS) {
+        // Unexpected error. The variable should be in the environment,
+        // and buffer should be large enough.
+        __kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
+                  __kmp_msg_null);
+        KMP_INTERNAL_FREE((void *)result);
+        result = NULL;
+      }; // if
+    }; // if
+  }; // if
+#else
+#error Unknown or unsupported OS.
+#endif
 
-    return result;
+  return result;
 
 } // func __kmp_env_get
 
-
 // TODO: Find and replace all regular free() with __kmp_env_free().
 
-void
-__kmp_env_free( char const * * value ) {
+void __kmp_env_free(char const **value) {
 
-    KMP_DEBUG_ASSERT( value != NULL );
-    KMP_INTERNAL_FREE( (void *) * value );
-    * value = NULL;
+  KMP_DEBUG_ASSERT(value != NULL);
+  KMP_INTERNAL_FREE((void *)*value);
+  *value = NULL;
 
 } // func __kmp_env_free
 
+int __kmp_env_exists(char const *name) {
 
-
-int
-__kmp_env_exists( char const * name ) {
-
-    #if KMP_OS_UNIX
-        char const * value = getenv( name );
-        return ( ( value == NULL ) ? ( 0 ) : ( 1 ) );
-    #elif KMP_OS_WINDOWS
-        DWORD rc;
-        rc = GetEnvironmentVariable( name, NULL, 0 );
-        if ( rc == 0 ) {
-            DWORD error = GetLastError();
-            if ( error != ERROR_ENVVAR_NOT_FOUND ) {
-                __kmp_msg(
-                    kmp_ms_fatal,
-                    KMP_MSG( CantGetEnvVar, name ),
-                    KMP_ERR( error ),
-                    __kmp_msg_null
-                );
-            }; // if
-            return 0;
-        }; // if
-        return 1;
-    #else
-        #error Unknown or unsupported OS.
-    #endif
+#if KMP_OS_UNIX
+  char const *value = getenv(name);
+  return ((value == NULL) ? (0) : (1));
+#elif KMP_OS_WINDOWS
+  DWORD rc;
+  rc = GetEnvironmentVariable(name, NULL, 0);
+  if (rc == 0) {
+    DWORD error = GetLastError();
+    if (error != ERROR_ENVVAR_NOT_FOUND) {
+      __kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
+                __kmp_msg_null);
+    }; // if
+    return 0;
+  }; // if
+  return 1;
+#else
+#error Unknown or unsupported OS.
+#endif
 
 } // func __kmp_env_exists
 
+void __kmp_env_set(char const *name, char const *value, int overwrite) {
 
-
-void
-__kmp_env_set( char const * name, char const * value, int overwrite ) {
-
-    #if KMP_OS_UNIX
-        int rc = setenv( name, value, overwrite );
-        if ( rc != 0 ) {
-            // Dead code. I tried to put too many variables into Linux* OS
-            // environment on IA-32 architecture. When application consumes
-            // more than ~2.5 GB of memory, entire system feels bad. Sometimes
-            // application is killed (by OS?), sometimes system stops
-            // responding... But this error message never appears. --ln
-            __kmp_msg(
-                kmp_ms_fatal,
-                KMP_MSG( CantSetEnvVar, name ),
-                KMP_HNT( NotEnoughMemory ),
-                __kmp_msg_null
-            );
-        }; // if
-    #elif KMP_OS_WINDOWS
-        BOOL rc;
-        if ( ! overwrite ) {
-            rc = GetEnvironmentVariable( name, NULL, 0 );
-            if ( rc ) {
-                // Variable exists, do not overwrite.
-                return;
-            }; // if
-            DWORD error = GetLastError();
-            if ( error != ERROR_ENVVAR_NOT_FOUND ) {
-                __kmp_msg(
-                    kmp_ms_fatal,
-                    KMP_MSG( CantGetEnvVar, name ),
-                    KMP_ERR( error ),
-                    __kmp_msg_null
-                );
-            }; // if
-        }; // if
-        rc = SetEnvironmentVariable( name, value );
-        if ( ! rc ) {
-            DWORD error = GetLastError();
-            __kmp_msg(
-                kmp_ms_fatal,
-                KMP_MSG( CantSetEnvVar, name ),
-                KMP_ERR( error ),
-                __kmp_msg_null
-            );
-        }; // if
-    #else
-        #error Unknown or unsupported OS.
-    #endif
+#if KMP_OS_UNIX
+  int rc = setenv(name, value, overwrite);
+  if (rc != 0) {
+    // Dead code. I tried to put too many variables into Linux* OS
+    // environment on IA-32 architecture. When application consumes
+    // more than ~2.5 GB of memory, entire system feels bad. Sometimes
+    // application is killed (by OS?), sometimes system stops
+    // responding... But this error message never appears. --ln
+    __kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name),
+              KMP_HNT(NotEnoughMemory), __kmp_msg_null);
+  }; // if
+#elif KMP_OS_WINDOWS
+  BOOL rc;
+  if (!overwrite) {
+    rc = GetEnvironmentVariable(name, NULL, 0);
+    if (rc) {
+      // Variable exists, do not overwrite.
+      return;
+    }; // if
+    DWORD error = GetLastError();
+    if (error != ERROR_ENVVAR_NOT_FOUND) {
+      __kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
+                __kmp_msg_null);
+    }; // if
+  }; // if
+  rc = SetEnvironmentVariable(name, value);
+  if (!rc) {
+    DWORD error = GetLastError();
+    __kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name), KMP_ERR(error),
+              __kmp_msg_null);
+  }; // if
+#else
+#error Unknown or unsupported OS.
+#endif
 
 } // func __kmp_env_set
 
+void __kmp_env_unset(char const *name) {
 
-
-void
-__kmp_env_unset( char const * name ) {
-
-    #if KMP_OS_UNIX
-        unsetenv( name );
-    #elif KMP_OS_WINDOWS
-        BOOL rc = SetEnvironmentVariable( name, NULL );
-        if ( ! rc ) {
-            DWORD error = GetLastError();
-            __kmp_msg(
-                kmp_ms_fatal,
-                KMP_MSG( CantSetEnvVar, name ),
-                KMP_ERR( error ),
-                __kmp_msg_null
-            );
-        }; // if
-    #else
-        #error Unknown or unsupported OS.
-    #endif
+#if KMP_OS_UNIX
+  unsetenv(name);
+#elif KMP_OS_WINDOWS
+  BOOL rc = SetEnvironmentVariable(name, NULL);
+  if (!rc) {
+    DWORD error = GetLastError();
+    __kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name), KMP_ERR(error),
+              __kmp_msg_null);
+  }; // if
+#else
+#error Unknown or unsupported OS.
+#endif
 
 } // func __kmp_env_unset
 
-// -------------------------------------------------------------------------------------------------
-
-/*
-    Intel OpenMP RTL string representation of environment: just a string of characters, variables
-    are separated with vertical bars, e. g.:
+/* Intel OpenMP RTL string representation of environment: just a string of
+   characters, variables are separated with vertical bars, e. g.:
 
         "KMP_WARNINGS=0|KMP_AFFINITY=compact|"
 
     Empty variables are allowed and ignored:
 
         "||KMP_WARNINGS=1||"
-
 */
 
-static
-void
-___kmp_env_blk_parse_string(
-    kmp_env_blk_t * block,   // M: Env block to fill.
-    char const *    env      // I: String to parse.
-) {
-
-    char const chr_delimiter   = '|';
-    char const str_delimiter[] = { chr_delimiter, 0 };
-
-    char *          bulk       = NULL;
-    kmp_env_var_t * vars       = NULL;
-    int             count      = 0;  // Number of used elements in vars array.
-    int             delimiters = 0;  // Number of delimiters in input string.
-
-    // Copy original string, we will modify the copy.
-    bulk = __kmp_str_format( "%s", env );
-
-    // Loop thru all the vars in environment block. Count delimiters (maximum number of variables
-    // is number of delimiters plus one).
-    {
-        char const * ptr = bulk;
-        for ( ; ; ) {
-            ptr = strchr( ptr, chr_delimiter );
-            if ( ptr == NULL ) {
-                break;
-            }; // if
-            ++ delimiters;
-            ptr += 1;
-        }; // forever
-    }
-
-    // Allocate vars array.
-    vars = (kmp_env_var_t *) allocate( ( delimiters + 1 ) * sizeof( kmp_env_var_t ) );
-
-    // Loop thru all the variables.
-    {
-        char * var;     // Pointer to variable (both name and value).
-        char * name;    // Pointer to name of variable.
-        char * value;   // Pointer to value.
-        char * buf;     // Buffer for __kmp_str_token() function.
-        var = __kmp_str_token( bulk, str_delimiter, & buf );      // Get the first var.
-        while ( var != NULL ) {
-            // Save found variable in vars array.
-            __kmp_str_split( var, '=', & name, & value );
-            KMP_DEBUG_ASSERT( count < delimiters + 1 );
-            vars[ count ].name  = name;
-            vars[ count ].value = value;
-            ++ count;
-            // Get the next var.
-            var = __kmp_str_token( NULL, str_delimiter, & buf );
-        }; // while
-    }
-
-    // Fill out result.
-    block->bulk  = bulk;
-    block->vars  = vars;
-    block->count = count;
+static void
+___kmp_env_blk_parse_string(kmp_env_blk_t *block, // M: Env block to fill.
+                            char const *env // I: String to parse.
+                            ) {
+
+  char const chr_delimiter = '|';
+  char const str_delimiter[] = {chr_delimiter, 0};
+
+  char *bulk = NULL;
+  kmp_env_var_t *vars = NULL;
+  int count = 0; // Number of used elements in vars array.
+  int delimiters = 0; // Number of delimiters in input string.
+
+  // Copy original string, we will modify the copy.
+  bulk = __kmp_str_format("%s", env);
+
+  // Loop thru all the vars in environment block. Count delimiters (maximum
+  // number of variables is number of delimiters plus one).
+  {
+    char const *ptr = bulk;
+    for (;;) {
+      ptr = strchr(ptr, chr_delimiter);
+      if (ptr == NULL) {
+        break;
+      }; // if
+      ++delimiters;
+      ptr += 1;
+    }; // forever
+  }
+
+  // Allocate vars array.
+  vars = (kmp_env_var_t *)allocate((delimiters + 1) * sizeof(kmp_env_var_t));
+
+  // Loop thru all the variables.
+  {
+    char *var; // Pointer to variable (both name and value).
+    char *name; // Pointer to name of variable.
+    char *value; // Pointer to value.
+    char *buf; // Buffer for __kmp_str_token() function.
+    var = __kmp_str_token(bulk, str_delimiter, &buf); // Get the first var.
+    while (var != NULL) {
+      // Save found variable in vars array.
+      __kmp_str_split(var, '=', &name, &value);
+      KMP_DEBUG_ASSERT(count < delimiters + 1);
+      vars[count].name = name;
+      vars[count].value = value;
+      ++count;
+      // Get the next var.
+      var = __kmp_str_token(NULL, str_delimiter, &buf);
+    }; // while
+  }
+
+  // Fill out result.
+  block->bulk = bulk;
+  block->vars = vars;
+  block->count = count;
 
 }; // ___kmp_env_blk_parse_string
 
-
-
-/*
-    Windows* OS (actually, DOS) environment block is a piece of memory with environment variables. Each
-    variable is terminated with zero byte, entire block is terminated with one extra zero byte, so
-    we have two zero bytes at the end of environment block, e. g.:
+/* Windows* OS (actually, DOS) environment block is a piece of memory with
+   environment variables. Each variable is terminated with zero byte, entire
+   block is terminated with one extra zero byte, so we have two zero bytes at
+   the end of environment block, e. g.:
 
         "HOME=C:\\users\\lev\x00OS=Windows_NT\x00\x00"
 
@@ -369,227 +311,201 @@ ___kmp_env_blk_parse_string(
 */
 
 #if KMP_OS_WINDOWS
-static
-void
-___kmp_env_blk_parse_windows(
-    kmp_env_blk_t * block,   // M: Env block to fill.
-    char const *    env      // I: Pointer to Windows* OS (DOS) environment block.
-) {
-
-    char *          bulk  = NULL;
-    kmp_env_var_t * vars  = NULL;
-    int             count = 0;     // Number of used elements in vars array.
-    int             size  = 0;     // Size of bulk.
-
-    char * name;    // Pointer to name of variable.
-    char * value;   // Pointer to value.
-
-    if ( env != NULL ) {
-
-        // Loop thru all the vars in environment block. Count variables, find size of block.
-        {
-            char const * var;     // Pointer to beginning of var.
-            int          len;     // Length of variable.
-            count = 0;
-            var = env;            // The first variable starts and beginning of environment block.
-            len = KMP_STRLEN( var );
-            while ( len != 0 ) {
-                ++ count;
-                size = size + len + 1;
-                var = var + len + 1; // Move pointer to the beginning of the next variable.
-                len = KMP_STRLEN( var );
-            }; // while
-            size = size + 1;         // Total size of env block, including terminating zero byte.
-        }
-
-        // Copy original block to bulk, we will modify bulk, not original block.
-        bulk = (char *) allocate( size );
-        KMP_MEMCPY_S( bulk, size, env, size );
-        // Allocate vars array.
-        vars = (kmp_env_var_t *) allocate( count * sizeof( kmp_env_var_t ) );
-
-        // Loop thru all the vars, now in bulk.
-        {
-            char * var;     // Pointer to beginning of var.
-            int    len;     // Length of variable.
-            count = 0;
-            var = bulk;
-            len = KMP_STRLEN( var );
-            while ( len != 0 ) {
-                // Save variable in vars array.
-                __kmp_str_split( var, '=', & name, & value );
-                vars[ count ].name  = name;
-                vars[ count ].value = value;
-                ++ count;
-                // Get the next var.
-                var = var + len + 1;
-                len = KMP_STRLEN( var );
-            }; // while
-        }
-
-    }; // if
+static void ___kmp_env_blk_parse_windows(
+    kmp_env_blk_t *block, // M: Env block to fill.
+    char const *env // I: Pointer to Windows* OS (DOS) environment block.
+    ) {
+
+  char *bulk = NULL;
+  kmp_env_var_t *vars = NULL;
+  int count = 0; // Number of used elements in vars array.
+  int size = 0; // Size of bulk.
 
-    // Fill out result.
-    block->bulk  = bulk;
-    block->vars  = vars;
-    block->count = count;
+  char *name; // Pointer to name of variable.
+  char *value; // Pointer to value.
 
-}; // ___kmp_env_blk_parse_windows
-#endif
+  if (env != NULL) {
 
-
-/*
-    Unix environment block is a array of pointers to variables, last pointer in array is NULL:
-
-        { "HOME=/home/lev", "TERM=xterm", NULL }
-*/
-
-static
-void
-___kmp_env_blk_parse_unix(
-    kmp_env_blk_t * block,   // M: Env block to fill.
-    char * *        env      // I: Unix environment to parse.
-) {
-
-    char *          bulk  = NULL;
-    kmp_env_var_t * vars  = NULL;
-    int             count = 0;
-    int             size  = 0;    // Size of bulk.
-
-    // Count number of variables and length of required bulk.
+    // Loop thru all the vars in environment block. Count variables, find size
+    // of block.
     {
-        count = 0;
-        size  = 0;
-        while ( env[ count ] != NULL ) {
-            size += KMP_STRLEN( env[ count ] ) + 1;
-            ++ count;
-        }; // while
+      char const *var; // Pointer to beginning of var.
+      int len; // Length of variable.
+      count = 0;
+      var =
+          env; // The first variable starts and beginning of environment block.
+      len = KMP_STRLEN(var);
+      while (len != 0) {
+        ++count;
+        size = size + len + 1;
+        var = var + len +
+              1; // Move pointer to the beginning of the next variable.
+        len = KMP_STRLEN(var);
+      }; // while
+      size =
+          size + 1; // Total size of env block, including terminating zero byte.
     }
 
-    // Allocate memory.
-    bulk = (char *) allocate( size );
-    vars = (kmp_env_var_t *) allocate( count * sizeof( kmp_env_var_t ) );
+    // Copy original block to bulk, we will modify bulk, not original block.
+    bulk = (char *)allocate(size);
+    KMP_MEMCPY_S(bulk, size, env, size);
+    // Allocate vars array.
+    vars = (kmp_env_var_t *)allocate(count * sizeof(kmp_env_var_t));
 
-    // Loop thru all the vars.
+    // Loop thru all the vars, now in bulk.
     {
-        char * var;     // Pointer to beginning of var.
-        char * name;    // Pointer to name of variable.
-        char * value;   // Pointer to value.
-        int    len;     // Length of variable.
-        int    i;
-        var = bulk;
-        for ( i = 0; i < count; ++ i ) {
-            // Copy variable to bulk.
-            len = KMP_STRLEN( env[ i ] );
-            KMP_MEMCPY_S( var, size, env[ i ], len + 1 );
-            // Save found variable in vars array.
-            __kmp_str_split( var, '=', & name, & value );
-            vars[ i ].name  = name;
-            vars[ i ].value = value;
-            // Move pointer.
-            var += len + 1;
-        }; // for
+      char *var; // Pointer to beginning of var.
+      int len; // Length of variable.
+      count = 0;
+      var = bulk;
+      len = KMP_STRLEN(var);
+      while (len != 0) {
+        // Save variable in vars array.
+        __kmp_str_split(var, '=', &name, &value);
+        vars[count].name = name;
+        vars[count].value = value;
+        ++count;
+        // Get the next var.
+        var = var + len + 1;
+        len = KMP_STRLEN(var);
+      }; // while
     }
 
-    // Fill out result.
-    block->bulk  = bulk;
-    block->vars  = vars;
-    block->count = count;
-
-}; // ___kmp_env_blk_parse_unix
-
+  }; // if
 
+  // Fill out result.
+  block->bulk = bulk;
+  block->vars = vars;
+  block->count = count;
 
-void
-__kmp_env_blk_init(
-    kmp_env_blk_t * block,  // M: Block to initialize.
-    char const *    bulk    // I: Initialization string, or NULL.
-) {
-
-    if ( bulk != NULL ) {
-        ___kmp_env_blk_parse_string( block, bulk );
-    } else {
-        #if KMP_OS_UNIX
-            ___kmp_env_blk_parse_unix( block, environ );
-        #elif KMP_OS_WINDOWS
-            {
-                char * mem = GetEnvironmentStrings();
-                if ( mem == NULL ) {
-                    DWORD error = GetLastError();
-                    __kmp_msg(
-                        kmp_ms_fatal,
-                        KMP_MSG( CantGetEnvironment ),
-                        KMP_ERR( error ),
-                        __kmp_msg_null
-                    );
-                }; // if
-                ___kmp_env_blk_parse_windows( block, mem );
-                FreeEnvironmentStrings( mem );
-            }
-        #else
-            #error Unknown or unsupported OS.
-        #endif
-    }; // if
+}; // ___kmp_env_blk_parse_windows
+#endif
 
-} // __kmp_env_blk_init
+/* Unix environment block is a array of pointers to variables, last pointer in
+   array is NULL:
 
+        { "HOME=/home/lev", "TERM=xterm", NULL }
+*/
 
+static void
+___kmp_env_blk_parse_unix(kmp_env_blk_t *block, // M: Env block to fill.
+                          char **env // I: Unix environment to parse.
+                          ) {
+
+  char *bulk = NULL;
+  kmp_env_var_t *vars = NULL;
+  int count = 0;
+  int size = 0; // Size of bulk.
+
+  // Count number of variables and length of required bulk.
+  {
+    count = 0;
+    size = 0;
+    while (env[count] != NULL) {
+      size += KMP_STRLEN(env[count]) + 1;
+      ++count;
+    }; // while
+  }
+
+  // Allocate memory.
+  bulk = (char *)allocate(size);
+  vars = (kmp_env_var_t *)allocate(count * sizeof(kmp_env_var_t));
+
+  // Loop thru all the vars.
+  {
+    char *var; // Pointer to beginning of var.
+    char *name; // Pointer to name of variable.
+    char *value; // Pointer to value.
+    int len; // Length of variable.
+    int i;
+    var = bulk;
+    for (i = 0; i < count; ++i) {
+      // Copy variable to bulk.
+      len = KMP_STRLEN(env[i]);
+      KMP_MEMCPY_S(var, size, env[i], len + 1);
+      // Save found variable in vars array.
+      __kmp_str_split(var, '=', &name, &value);
+      vars[i].name = name;
+      vars[i].value = value;
+      // Move pointer.
+      var += len + 1;
+    }; // for
+  }
 
-static
-int
-___kmp_env_var_cmp(                              // Comparison function for qsort().
-    kmp_env_var_t const * lhs,
-    kmp_env_var_t const * rhs
-) {
-    return strcmp( lhs->name, rhs->name );
-}
+  // Fill out result.
+  block->bulk = bulk;
+  block->vars = vars;
+  block->count = count;
 
-void
-__kmp_env_blk_sort(
-    kmp_env_blk_t * block  // M: Block of environment variables to sort.
-) {
-
-    qsort(
-        (void *) block->vars,
-        block->count,
-        sizeof( kmp_env_var_t ),
-        ( int ( * )( void const *, void const * ) ) & ___kmp_env_var_cmp
-    );
+}; // ___kmp_env_blk_parse_unix
 
-} // __kmp_env_block_sort
+void __kmp_env_blk_init(kmp_env_blk_t *block, // M: Block to initialize.
+                        char const *bulk // I: Initialization string, or NULL.
+                        ) {
+
+  if (bulk != NULL) {
+    ___kmp_env_blk_parse_string(block, bulk);
+  } else {
+#if KMP_OS_UNIX
+    ___kmp_env_blk_parse_unix(block, environ);
+#elif KMP_OS_WINDOWS
+    {
+      char *mem = GetEnvironmentStrings();
+      if (mem == NULL) {
+        DWORD error = GetLastError();
+        __kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvironment), KMP_ERR(error),
+                  __kmp_msg_null);
+      }; // if
+      ___kmp_env_blk_parse_windows(block, mem);
+      FreeEnvironmentStrings(mem);
+    }
+#else
+#error Unknown or unsupported OS.
+#endif
+  }; // if
 
+} // __kmp_env_blk_init
 
+static int ___kmp_env_var_cmp( // Comparison function for qsort().
+    kmp_env_var_t const *lhs, kmp_env_var_t const *rhs) {
+  return strcmp(lhs->name, rhs->name);
+}
 
-void
-__kmp_env_blk_free(
-    kmp_env_blk_t * block  // M: Block of environment variables to free.
-) {
+void __kmp_env_blk_sort(
+    kmp_env_blk_t *block // M: Block of environment variables to sort.
+    ) {
 
-    KMP_INTERNAL_FREE( (void *) block->vars );
-    __kmp_str_free(&(block->bulk));
+  qsort((void *)block->vars, block->count, sizeof(kmp_env_var_t),
+        (int (*)(void const *, void const *)) & ___kmp_env_var_cmp);
 
-    block->count = 0;
-    block->vars  = NULL;
+} // __kmp_env_block_sort
 
-} // __kmp_env_blk_free
+void __kmp_env_blk_free(
+    kmp_env_blk_t *block // M: Block of environment variables to free.
+    ) {
 
+  KMP_INTERNAL_FREE((void *)block->vars);
+  __kmp_str_free(&(block->bulk));
 
+  block->count = 0;
+  block->vars = NULL;
 
-char const *               // R: Value of variable or NULL if variable does not exist.
-__kmp_env_blk_var(
-    kmp_env_blk_t * block, // I: Block of environment variables.
-    char const *    name   // I: Name of variable to find.
-) {
+} // __kmp_env_blk_free
 
-    int i;
-    for ( i = 0; i < block->count; ++ i ) {
-        if ( strcmp( block->vars[ i ].name, name ) == 0 ) {
-            return block->vars[ i ].value;
-        }; // if
-    }; // for
-    return NULL;
+char const * // R: Value of variable or NULL if variable does not exist.
+    __kmp_env_blk_var(
+        kmp_env_blk_t *block, // I: Block of environment variables.
+        char const *name // I: Name of variable to find.
+        ) {
+
+  int i;
+  for (i = 0; i < block->count; ++i) {
+    if (strcmp(block->vars[i].name, name) == 0) {
+      return block->vars[i].value;
+    }; // if
+  }; // for
+  return NULL;
 
 } // __kmp_env_block_var
 
-
 // end of file //

Modified: openmp/trunk/runtime/src/kmp_environment.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_environment.h?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_environment.h (original)
+++ openmp/trunk/runtime/src/kmp_environment.h Fri May 12 13:01:32 2017
@@ -20,56 +20,56 @@
 extern "C" {
 #endif
 
-// Return a copy of the value of environment variable or NULL if the variable does not exist.
+// Return a copy of the value of environment variable or NULL if the variable
+// does not exist.
 // *Note*: Returned pointed *must* be freed after use with __kmp_env_free().
-char * __kmp_env_get( char const * name );
-void   __kmp_env_free( char const * * value );
+char *__kmp_env_get(char const *name);
+void __kmp_env_free(char const **value);
 
 // Return 1 if the environment variable exists or 0 if does not exist.
-int __kmp_env_exists( char const * name );
+int __kmp_env_exists(char const *name);
 
 // Set the environment variable.
-void __kmp_env_set( char const * name, char const * value, int overwrite );
+void __kmp_env_set(char const *name, char const *value, int overwrite);
 
 // Unset (remove) environment variable.
-void __kmp_env_unset( char const * name );
+void __kmp_env_unset(char const *name);
 
-
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 //  Working with environment blocks.
-// -------------------------------------------------------------------------------------------------
 
-/*
-    kmp_env_blk_t is read-only collection of environment variables (or environment-like). Usage:
+/* kmp_env_blk_t is read-only collection of environment variables (or
+   environment-like). Usage:
 
-        kmp_env_blk_t block;
-        __kmp_env_blk_init( & block, NULL ); // Initialize block from process environment.
-        // or
-        __kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string.
-        __kmp_env_blk_sort( & block ); // Optionally, sort list.
-        for ( i = 0; i < block.count; ++ i ) {
-            // Process block.vars[ i ].name and block.vars[ i ].value...
-        }; // for i
-        __kmp_env_block_free( & block );
+kmp_env_blk_t block;
+__kmp_env_blk_init( & block, NULL ); // Initialize block from process
+                                        // environment.
+// or
+__kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string
+__kmp_env_blk_sort( & block ); // Optionally, sort list.
+for ( i = 0; i < block.count; ++ i ) {
+    // Process block.vars[ i ].name and block.vars[ i ].value...
+}; // for i
+__kmp_env_block_free( & block );
 */
 
 struct __kmp_env_var {
-    char const * name;
-    char const * value;
+  char const *name;
+  char const *value;
 };
 typedef struct __kmp_env_var kmp_env_var_t;
 
 struct __kmp_env_blk {
-    char const *          bulk;
-    kmp_env_var_t const * vars;
-    int                   count;
+  char const *bulk;
+  kmp_env_var_t const *vars;
+  int count;
 };
 typedef struct __kmp_env_blk kmp_env_blk_t;
 
-void         __kmp_env_blk_init( kmp_env_blk_t * block, char const * bulk );
-void         __kmp_env_blk_free( kmp_env_blk_t * block );
-void         __kmp_env_blk_sort( kmp_env_blk_t * block );
-char const * __kmp_env_blk_var(  kmp_env_blk_t * block, char const * name );
+void __kmp_env_blk_init(kmp_env_blk_t *block, char const *bulk);
+void __kmp_env_blk_free(kmp_env_blk_t *block);
+void __kmp_env_blk_sort(kmp_env_blk_t *block);
+char const *__kmp_env_blk_var(kmp_env_blk_t *block, char const *name);
 
 #ifdef __cplusplus
 }
@@ -78,4 +78,3 @@ char const * __kmp_env_blk_var(  kmp_env
 #endif // KMP_ENVIRONMENT_H
 
 // end of file //
-

Modified: openmp/trunk/runtime/src/kmp_error.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_error.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_error.cpp (original)
+++ openmp/trunk/runtime/src/kmp_error.cpp Fri May 12 13:01:32 2017
@@ -14,259 +14,237 @@
 
 
 #include "kmp.h"
+#include "kmp_error.h"
 #include "kmp_i18n.h"
 #include "kmp_str.h"
-#include "kmp_error.h"
 
 /* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
 
-#define MIN_STACK       100
+#define MIN_STACK 100
 
-
-static char const * cons_text_c[] = {
-    "(none)",
-    "\"parallel\"",
-    "work-sharing",             /* this is not called "for" because of lowering of "sections" pragmas */
-    "\"ordered\" work-sharing", /* this is not called "for ordered" because of lowering of "sections" pragmas */
+static char const *cons_text_c[] = {
+    "(none)", "\"parallel\"", "work-sharing", /* this is not called "for"
+                                                 because of lowering of
+                                                 "sections" pragmas */
+    "\"ordered\" work-sharing", /* this is not called "for ordered" because of
+                                   lowering of "sections" pragmas */
     "\"sections\"",
-    "work-sharing",             /* this is not called "single" because of lowering of "sections" pragmas */
-    "\"taskq\"",
-    "\"taskq\"",
-    "\"taskq ordered\"",
-    "\"critical\"",
-    "\"ordered\"",              /* in PARALLEL */
-    "\"ordered\"",              /* in PDO */
-    "\"ordered\"",              /* in TASKQ */
-    "\"master\"",
-    "\"reduce\"",
-    "\"barrier\""
-};
-
-#define get_src( ident )   ( (ident) == NULL ? NULL : (ident)->psource )
-
-#define PUSH_MSG( ct, ident ) \
-    "\tpushing on stack: %s (%s)\n", cons_text_c[ (ct) ], get_src( (ident) )
-#define POP_MSG( p )                                  \
-    "\tpopping off stack: %s (%s)\n",                 \
-    cons_text_c[ (p)->stack_data[ tos ].type ],       \
-    get_src( (p)->stack_data[ tos ].ident )
+    "work-sharing", /* this is not called "single" because of lowering of
+                       "sections" pragmas */
+    "\"taskq\"", "\"taskq\"", "\"taskq ordered\"", "\"critical\"",
+    "\"ordered\"", /* in PARALLEL */
+    "\"ordered\"", /* in PDO */
+    "\"ordered\"", /* in TASKQ */
+    "\"master\"", "\"reduce\"", "\"barrier\""};
+
+#define get_src(ident) ((ident) == NULL ? NULL : (ident)->psource)
+
+#define PUSH_MSG(ct, ident)                                                    \
+  "\tpushing on stack: %s (%s)\n", cons_text_c[(ct)], get_src((ident))
+#define POP_MSG(p)                                                             \
+  "\tpopping off stack: %s (%s)\n", cons_text_c[(p)->stack_data[tos].type],    \
+      get_src((p)->stack_data[tos].ident)
 
-static int const cons_text_c_num    = sizeof( cons_text_c    ) / sizeof( char const * );
+static int const cons_text_c_num = sizeof(cons_text_c) / sizeof(char const *);
 
-/* ------------------------------------------------------------------------ */
 /* --------------- START OF STATIC LOCAL ROUTINES ------------------------- */
-/* ------------------------------------------------------------------------ */
 
-static void
-__kmp_check_null_func( void )
-{
-    /* nothing to do */
+static void __kmp_check_null_func(void) { /* nothing to do */
 }
 
-static void
-__kmp_expand_cons_stack( int gtid, struct cons_header *p )
-{
-    int    i;
-    struct cons_data *d;
+static void __kmp_expand_cons_stack(int gtid, struct cons_header *p) {
+  int i;
+  struct cons_data *d;
 
-    /* TODO for monitor perhaps? */
-    if (gtid < 0)
-        __kmp_check_null_func();
+  /* TODO for monitor perhaps? */
+  if (gtid < 0)
+    __kmp_check_null_func();
 
-    KE_TRACE( 10, ("expand cons_stack (%d %d)\n", gtid, __kmp_get_gtid() ) );
+  KE_TRACE(10, ("expand cons_stack (%d %d)\n", gtid, __kmp_get_gtid()));
 
-    d = p->stack_data;
+  d = p->stack_data;
 
-    p->stack_size = (p->stack_size * 2) + 100;
+  p->stack_size = (p->stack_size * 2) + 100;
 
-    /* TODO free the old data */
-    p->stack_data = (struct cons_data *) __kmp_allocate( sizeof( struct cons_data ) * (p->stack_size+1) );
+  /* TODO free the old data */
+  p->stack_data = (struct cons_data *)__kmp_allocate(sizeof(struct cons_data) *
+                                                     (p->stack_size + 1));
 
-    for (i = p->stack_top; i >= 0; --i)
-        p->stack_data[i] = d[i];
+  for (i = p->stack_top; i >= 0; --i)
+    p->stack_data[i] = d[i];
 
-    /* NOTE: we do not free the old stack_data */
+  /* NOTE: we do not free the old stack_data */
 }
 
 // NOTE: Function returns allocated memory, caller must free it!
-static char const *
-__kmp_pragma(
-    int              ct,
-    ident_t const *  ident
-) {
-    char const * cons = NULL;  // Construct name.
-    char * file = NULL;  // File name.
-    char * func = NULL;  // Function (routine) name.
-    char * line = NULL;  // Line number.
-    kmp_str_buf_t buffer;
-    kmp_msg_t     prgm;
-    __kmp_str_buf_init( & buffer );
-    if ( 0 < ct && ct < cons_text_c_num ) {
-        cons = cons_text_c[ ct ];
-    } else {
-        KMP_DEBUG_ASSERT( 0 );
-    };
-    if ( ident != NULL && ident->psource != NULL ) {
-        char * tail = NULL;
-        __kmp_str_buf_print( & buffer, "%s", ident->psource ); // Copy source to buffer.
-        // Split string in buffer to file, func, and line.
-        tail = buffer.str;
-        __kmp_str_split( tail, ';', NULL,   & tail );
-        __kmp_str_split( tail, ';', & file, & tail );
-        __kmp_str_split( tail, ';', & func, & tail );
-        __kmp_str_split( tail, ';', & line, & tail );
-    }; // if
-    prgm = __kmp_msg_format( kmp_i18n_fmt_Pragma, cons, file, func, line );
-    __kmp_str_buf_free( & buffer );
-    return prgm.str;
+static char const *__kmp_pragma(int ct, ident_t const *ident) {
+  char const *cons = NULL; // Construct name.
+  char *file = NULL; // File name.
+  char *func = NULL; // Function (routine) name.
+  char *line = NULL; // Line number.
+  kmp_str_buf_t buffer;
+  kmp_msg_t prgm;
+  __kmp_str_buf_init(&buffer);
+  if (0 < ct && ct < cons_text_c_num) {
+    cons = cons_text_c[ct];
+  } else {
+    KMP_DEBUG_ASSERT(0);
+  };
+  if (ident != NULL && ident->psource != NULL) {
+    char *tail = NULL;
+    __kmp_str_buf_print(&buffer, "%s",
+                        ident->psource); // Copy source to buffer.
+    // Split string in buffer to file, func, and line.
+    tail = buffer.str;
+    __kmp_str_split(tail, ';', NULL, &tail);
+    __kmp_str_split(tail, ';', &file, &tail);
+    __kmp_str_split(tail, ';', &func, &tail);
+    __kmp_str_split(tail, ';', &line, &tail);
+  }; // if
+  prgm = __kmp_msg_format(kmp_i18n_fmt_Pragma, cons, file, func, line);
+  __kmp_str_buf_free(&buffer);
+  return prgm.str;
 } // __kmp_pragma
 
-/* ------------------------------------------------------------------------ */
 /* ----------------- END OF STATIC LOCAL ROUTINES ------------------------- */
-/* ------------------------------------------------------------------------ */
-
-
-void
-__kmp_error_construct(
-    kmp_i18n_id_t    id,     // Message identifier.
-    enum cons_type   ct,     // Construct type.
-    ident_t const *  ident   // Construct ident.
-) {
-    char const * construct = __kmp_pragma( ct, ident );
-    __kmp_msg( kmp_ms_fatal, __kmp_msg_format( id, construct ), __kmp_msg_null );
-    KMP_INTERNAL_FREE( (void *) construct );
-}
-
-void
-__kmp_error_construct2(
-    kmp_i18n_id_t            id,     // Message identifier.
-    enum cons_type           ct,     // First construct type.
-    ident_t const *          ident,  // First construct ident.
-    struct cons_data const * cons    // Second construct.
-) {
-    char const * construct1 = __kmp_pragma( ct, ident );
-    char const * construct2 = __kmp_pragma( cons->type, cons->ident );
-    __kmp_msg( kmp_ms_fatal, __kmp_msg_format( id, construct1, construct2 ), __kmp_msg_null );
-    KMP_INTERNAL_FREE( (void *) construct1 );
-    KMP_INTERNAL_FREE( (void *) construct2 );
-}
-
-
-struct cons_header *
-__kmp_allocate_cons_stack( int gtid )
-{
-    struct cons_header *p;
 
-    /* TODO for monitor perhaps? */
-    if ( gtid < 0 ) {
-        __kmp_check_null_func();
+void __kmp_error_construct(kmp_i18n_id_t id, // Message identifier.
+                           enum cons_type ct, // Construct type.
+                           ident_t const *ident // Construct ident.
+                           ) {
+  char const *construct = __kmp_pragma(ct, ident);
+  __kmp_msg(kmp_ms_fatal, __kmp_msg_format(id, construct), __kmp_msg_null);
+  KMP_INTERNAL_FREE((void *)construct);
+}
+
+void __kmp_error_construct2(kmp_i18n_id_t id, // Message identifier.
+                            enum cons_type ct, // First construct type.
+                            ident_t const *ident, // First construct ident.
+                            struct cons_data const *cons // Second construct.
+                            ) {
+  char const *construct1 = __kmp_pragma(ct, ident);
+  char const *construct2 = __kmp_pragma(cons->type, cons->ident);
+  __kmp_msg(kmp_ms_fatal, __kmp_msg_format(id, construct1, construct2),
+            __kmp_msg_null);
+  KMP_INTERNAL_FREE((void *)construct1);
+  KMP_INTERNAL_FREE((void *)construct2);
+}
+
+struct cons_header *__kmp_allocate_cons_stack(int gtid) {
+  struct cons_header *p;
+
+  /* TODO for monitor perhaps? */
+  if (gtid < 0) {
+    __kmp_check_null_func();
+  }; // if
+  KE_TRACE(10, ("allocate cons_stack (%d)\n", gtid));
+  p = (struct cons_header *)__kmp_allocate(sizeof(struct cons_header));
+  p->p_top = p->w_top = p->s_top = 0;
+  p->stack_data = (struct cons_data *)__kmp_allocate(sizeof(struct cons_data) *
+                                                     (MIN_STACK + 1));
+  p->stack_size = MIN_STACK;
+  p->stack_top = 0;
+  p->stack_data[0].type = ct_none;
+  p->stack_data[0].prev = 0;
+  p->stack_data[0].ident = NULL;
+  return p;
+}
+
+void __kmp_free_cons_stack(void *ptr) {
+  struct cons_header *p = (struct cons_header *)ptr;
+  if (p != NULL) {
+    if (p->stack_data != NULL) {
+      __kmp_free(p->stack_data);
+      p->stack_data = NULL;
     }; // if
-    KE_TRACE( 10, ("allocate cons_stack (%d)\n", gtid ) );
-    p = (struct cons_header *) __kmp_allocate( sizeof( struct cons_header ) );
-    p->p_top = p->w_top = p->s_top = 0;
-    p->stack_data = (struct cons_data *) __kmp_allocate( sizeof( struct cons_data ) * (MIN_STACK+1) );
-    p->stack_size = MIN_STACK;
-    p->stack_top  = 0;
-    p->stack_data[ 0 ].type = ct_none;
-    p->stack_data[ 0 ].prev = 0;
-    p->stack_data[ 0 ].ident = NULL;
-    return p;
+    __kmp_free(p);
+  }; // if
 }
 
-void
-__kmp_free_cons_stack( void * ptr ) {
-    struct cons_header * p = (struct cons_header *) ptr;
-    if ( p != NULL ) {
-        if ( p->stack_data != NULL ) {
-            __kmp_free( p->stack_data );
-            p->stack_data = NULL;
-        }; // if
-        __kmp_free( p );
-    }; // if
-}
-
-
 #if KMP_DEBUG
-static void
-dump_cons_stack( int gtid, struct cons_header * p ) {
-    int i;
-    int tos = p->stack_top;
-    kmp_str_buf_t buffer;
-    __kmp_str_buf_init( & buffer );
-    __kmp_str_buf_print( & buffer, "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n" );
-    __kmp_str_buf_print( & buffer, "Begin construct stack with %d items for thread %d\n", tos, gtid );
-    __kmp_str_buf_print( & buffer, "     stack_top=%d { P=%d, W=%d, S=%d }\n", tos, p->p_top, p->w_top, p->s_top );
-    for ( i = tos; i > 0; i-- ) {
-        struct cons_data * c = & ( p->stack_data[ i ] );
-        __kmp_str_buf_print( & buffer, "        stack_data[%2d] = { %s (%s) %d %p }\n", i, cons_text_c[ c->type ], get_src( c->ident ), c->prev, c->name );
-    }; // for i
-    __kmp_str_buf_print( & buffer, "End construct stack for thread %d\n", gtid );
-    __kmp_str_buf_print( & buffer, "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n" );
-    __kmp_debug_printf( "%s", buffer.str );
-    __kmp_str_buf_free( & buffer );
+static void dump_cons_stack(int gtid, struct cons_header *p) {
+  int i;
+  int tos = p->stack_top;
+  kmp_str_buf_t buffer;
+  __kmp_str_buf_init(&buffer);
+  __kmp_str_buf_print(
+      &buffer,
+      "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n");
+  __kmp_str_buf_print(&buffer,
+                      "Begin construct stack with %d items for thread %d\n",
+                      tos, gtid);
+  __kmp_str_buf_print(&buffer, "     stack_top=%d { P=%d, W=%d, S=%d }\n", tos,
+                      p->p_top, p->w_top, p->s_top);
+  for (i = tos; i > 0; i--) {
+    struct cons_data *c = &(p->stack_data[i]);
+    __kmp_str_buf_print(
+        &buffer, "        stack_data[%2d] = { %s (%s) %d %p }\n", i,
+        cons_text_c[c->type], get_src(c->ident), c->prev, c->name);
+  }; // for i
+  __kmp_str_buf_print(&buffer, "End construct stack for thread %d\n", gtid);
+  __kmp_str_buf_print(
+      &buffer,
+      "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n");
+  __kmp_debug_printf("%s", buffer.str);
+  __kmp_str_buf_free(&buffer);
 }
 #endif
 
-void
-__kmp_push_parallel( int gtid, ident_t const * ident )
-{
-    int tos;
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-
-    KMP_DEBUG_ASSERT( __kmp_threads[ gtid ]-> th.th_cons );
-    KE_TRACE( 10, ("__kmp_push_parallel (%d %d)\n", gtid, __kmp_get_gtid() ) );
-    KE_TRACE( 100, ( PUSH_MSG( ct_parallel, ident ) ) );
-    if ( p->stack_top >= p->stack_size ) {
-        __kmp_expand_cons_stack( gtid, p );
-    }; // if
-    tos = ++p->stack_top;
-    p->stack_data[ tos ].type = ct_parallel;
-    p->stack_data[ tos ].prev = p->p_top;
-    p->stack_data[ tos ].ident = ident;
-    p->stack_data[ tos ].name = NULL;
-    p->p_top = tos;
-    KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
-}
-
-void
-__kmp_check_workshare( int gtid, enum cons_type ct, ident_t const * ident )
-{
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-
-    KMP_DEBUG_ASSERT( __kmp_threads[ gtid ]-> th.th_cons );
-    KE_TRACE( 10, ("__kmp_check_workshare (%d %d)\n", gtid, __kmp_get_gtid() ) );
-
-
-    if ( p->stack_top >= p->stack_size ) {
-        __kmp_expand_cons_stack( gtid, p );
-    }; // if
-    if ( p->w_top > p->p_top &&
-        !(IS_CONS_TYPE_TASKQ(p->stack_data[ p->w_top ].type) && IS_CONS_TYPE_TASKQ(ct))) {
-        // We are already in a WORKSHARE construct for this PARALLEL region.
-        __kmp_error_construct2( kmp_i18n_msg_CnsInvalidNesting, ct, ident, & p->stack_data[ p->w_top ] );
-    }; // if
-    if ( p->s_top > p->p_top ) {
-        // We are already in a SYNC construct for this PARALLEL region.
-        __kmp_error_construct2( kmp_i18n_msg_CnsInvalidNesting, ct, ident, & p->stack_data[ p->s_top ] );
-    }; // if
-}
-
-void
-__kmp_push_workshare( int gtid, enum cons_type ct, ident_t const * ident )
-{
-    int         tos;
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-    KE_TRACE( 10, ("__kmp_push_workshare (%d %d)\n", gtid, __kmp_get_gtid() ) );
-    __kmp_check_workshare( gtid, ct, ident );
-    KE_TRACE( 100, ( PUSH_MSG( ct, ident ) ) );
-    tos = ++p->stack_top;
-    p->stack_data[ tos ].type = ct;
-    p->stack_data[ tos ].prev = p->w_top;
-    p->stack_data[ tos ].ident = ident;
-    p->stack_data[ tos ].name = NULL;
-    p->w_top = tos;
-    KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
+void __kmp_push_parallel(int gtid, ident_t const *ident) {
+  int tos;
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+
+  KMP_DEBUG_ASSERT(__kmp_threads[gtid]->th.th_cons);
+  KE_TRACE(10, ("__kmp_push_parallel (%d %d)\n", gtid, __kmp_get_gtid()));
+  KE_TRACE(100, (PUSH_MSG(ct_parallel, ident)));
+  if (p->stack_top >= p->stack_size) {
+    __kmp_expand_cons_stack(gtid, p);
+  }; // if
+  tos = ++p->stack_top;
+  p->stack_data[tos].type = ct_parallel;
+  p->stack_data[tos].prev = p->p_top;
+  p->stack_data[tos].ident = ident;
+  p->stack_data[tos].name = NULL;
+  p->p_top = tos;
+  KE_DUMP(1000, dump_cons_stack(gtid, p));
+}
+
+void __kmp_check_workshare(int gtid, enum cons_type ct, ident_t const *ident) {
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+
+  KMP_DEBUG_ASSERT(__kmp_threads[gtid]->th.th_cons);
+  KE_TRACE(10, ("__kmp_check_workshare (%d %d)\n", gtid, __kmp_get_gtid()));
+
+  if (p->stack_top >= p->stack_size) {
+    __kmp_expand_cons_stack(gtid, p);
+  }; // if
+  if (p->w_top > p->p_top &&
+      !(IS_CONS_TYPE_TASKQ(p->stack_data[p->w_top].type) &&
+        IS_CONS_TYPE_TASKQ(ct))) {
+    // We are already in a WORKSHARE construct for this PARALLEL region.
+    __kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
+                           &p->stack_data[p->w_top]);
+  }; // if
+  if (p->s_top > p->p_top) {
+    // We are already in a SYNC construct for this PARALLEL region.
+    __kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
+                           &p->stack_data[p->s_top]);
+  }; // if
+}
+
+void __kmp_push_workshare(int gtid, enum cons_type ct, ident_t const *ident) {
+  int tos;
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+  KE_TRACE(10, ("__kmp_push_workshare (%d %d)\n", gtid, __kmp_get_gtid()));
+  __kmp_check_workshare(gtid, ct, ident);
+  KE_TRACE(100, (PUSH_MSG(ct, ident)));
+  tos = ++p->stack_top;
+  p->stack_data[tos].type = ct;
+  p->stack_data[tos].prev = p->w_top;
+  p->stack_data[tos].ident = ident;
+  p->stack_data[tos].name = NULL;
+  p->w_top = tos;
+  KE_DUMP(1000, dump_cons_stack(gtid, p));
 }
 
 void
@@ -276,98 +254,91 @@ __kmp_check_sync( int gtid, enum cons_ty
 __kmp_check_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p lck )
 #endif
 {
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
 
-    KE_TRACE( 10, ("__kmp_check_sync (gtid=%d)\n", __kmp_get_gtid() ) );
+  KE_TRACE(10, ("__kmp_check_sync (gtid=%d)\n", __kmp_get_gtid()));
 
-    if (p->stack_top >= p->stack_size)
-       __kmp_expand_cons_stack( gtid, p );
+  if (p->stack_top >= p->stack_size)
+    __kmp_expand_cons_stack(gtid, p);
 
-    if (ct == ct_ordered_in_parallel || ct == ct_ordered_in_pdo || ct == ct_ordered_in_taskq ) {
-        if (p->w_top <= p->p_top) {
-            /* we are not in a worksharing construct */
-            #ifdef BUILD_PARALLEL_ORDERED
-                /* do not report error messages for PARALLEL ORDERED */
-                KMP_ASSERT( ct == ct_ordered_in_parallel );
-            #else
-                __kmp_error_construct( kmp_i18n_msg_CnsBoundToWorksharing, ct, ident );
-            #endif /* BUILD_PARALLEL_ORDERED */
+  if (ct == ct_ordered_in_parallel || ct == ct_ordered_in_pdo ||
+      ct == ct_ordered_in_taskq) {
+    if (p->w_top <= p->p_top) {
+/* we are not in a worksharing construct */
+#ifdef BUILD_PARALLEL_ORDERED
+      /* do not report error messages for PARALLEL ORDERED */
+      KMP_ASSERT(ct == ct_ordered_in_parallel);
+#else
+      __kmp_error_construct(kmp_i18n_msg_CnsBoundToWorksharing, ct, ident);
+#endif /* BUILD_PARALLEL_ORDERED */
+    } else {
+      /* inside a WORKSHARING construct for this PARALLEL region */
+      if (!IS_CONS_TYPE_ORDERED(p->stack_data[p->w_top].type)) {
+        if (p->stack_data[p->w_top].type == ct_taskq) {
+          __kmp_error_construct2(kmp_i18n_msg_CnsNotInTaskConstruct, ct, ident,
+                                 &p->stack_data[p->w_top]);
         } else {
-            /* inside a WORKSHARING construct for this PARALLEL region */
-            if (!IS_CONS_TYPE_ORDERED(p->stack_data[ p->w_top ].type)) {
-                if (p->stack_data[ p->w_top ].type == ct_taskq) {
-                    __kmp_error_construct2(
-                        kmp_i18n_msg_CnsNotInTaskConstruct,
-                        ct, ident,
-                        & p->stack_data[ p->w_top ]
-                    );
-                } else {
-                    __kmp_error_construct2(
-                        kmp_i18n_msg_CnsNoOrderedClause,
-                        ct, ident,
-                        & p->stack_data[ p->w_top ]
-                    );
-               }
-            }
+          __kmp_error_construct2(kmp_i18n_msg_CnsNoOrderedClause, ct, ident,
+                                 &p->stack_data[p->w_top]);
         }
-        if (p->s_top > p->p_top && p->s_top > p->w_top) {
-            /* inside a sync construct which is inside a worksharing construct */
-            int index = p->s_top;
-            enum cons_type stack_type;
-
-            stack_type = p->stack_data[ index ].type;
-
-            if (stack_type == ct_critical ||
-                ( ( stack_type == ct_ordered_in_parallel ||
-                    stack_type == ct_ordered_in_pdo      ||
-                    stack_type == ct_ordered_in_taskq  ) &&     /* C doesn't allow named ordered; ordered in ordered gets error */
-                 p->stack_data[ index ].ident != NULL &&
-                 (p->stack_data[ index ].ident->flags & KMP_IDENT_KMPC ))) {
-                /* we are in ORDERED which is inside an ORDERED or CRITICAL construct */
-                __kmp_error_construct2(
-                    kmp_i18n_msg_CnsInvalidNesting,
-                    ct, ident,
-                    & p->stack_data[ index ]
-                );
-            }
-        }
-    } else if ( ct == ct_critical ) {
+      }
+    }
+    if (p->s_top > p->p_top && p->s_top > p->w_top) {
+      /* inside a sync construct which is inside a worksharing construct */
+      int index = p->s_top;
+      enum cons_type stack_type;
+
+      stack_type = p->stack_data[index].type;
+
+      if (stack_type == ct_critical ||
+          ((stack_type == ct_ordered_in_parallel ||
+            stack_type == ct_ordered_in_pdo ||
+            stack_type ==
+                ct_ordered_in_taskq) && /* C doesn't allow named ordered;
+                                           ordered in ordered gets error */
+           p->stack_data[index].ident != NULL &&
+           (p->stack_data[index].ident->flags & KMP_IDENT_KMPC))) {
+        /* we are in ORDERED which is inside an ORDERED or CRITICAL construct */
+        __kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
+                               &p->stack_data[index]);
+      }
+    }
+  } else if (ct == ct_critical) {
 #if KMP_USE_DYNAMIC_LOCK
-        if ( lck != NULL && __kmp_get_user_lock_owner( lck, seq ) == gtid ) {    /* this same thread already has lock for this critical section */
+    if (lck != NULL &&
+        __kmp_get_user_lock_owner(lck, seq) ==
+            gtid) { /* this thread already has lock for this critical section */
 #else
-        if ( lck != NULL && __kmp_get_user_lock_owner( lck ) == gtid ) {    /* this same thread already has lock for this critical section */
+    if (lck != NULL &&
+        __kmp_get_user_lock_owner(lck) ==
+            gtid) { /* this thread already has lock for this critical section */
 #endif
-            int index = p->s_top;
-            struct cons_data cons = { NULL, ct_critical, 0, NULL };
-            /* walk up construct stack and try to find critical with matching name */
-            while ( index != 0 && p->stack_data[ index ].name != lck ) {
-                index = p->stack_data[ index ].prev;
-            }
-            if ( index != 0 ) {
-                /* found match on the stack (may not always because of interleaved critical for Fortran) */
-                cons = p->stack_data[ index ];
-            }
-            /* we are in CRITICAL which is inside a CRITICAL construct of the same name */
-            __kmp_error_construct2( kmp_i18n_msg_CnsNestingSameName, ct, ident, & cons );
-        }
-    } else if ( ct == ct_master || ct == ct_reduce ) {
-        if (p->w_top > p->p_top) {
-            /* inside a WORKSHARING construct for this PARALLEL region */
-           __kmp_error_construct2(
-               kmp_i18n_msg_CnsInvalidNesting,
-               ct, ident,
-               & p->stack_data[ p->w_top ]
-           );
-        }
-        if (ct == ct_reduce && p->s_top > p->p_top) {
-            /* inside a another SYNC construct for this PARALLEL region */
-            __kmp_error_construct2(
-                kmp_i18n_msg_CnsInvalidNesting,
-                ct, ident,
-                & p->stack_data[ p->s_top ]
-            );
-        }; // if
+      int index = p->s_top;
+      struct cons_data cons = {NULL, ct_critical, 0, NULL};
+      /* walk up construct stack and try to find critical with matching name */
+      while (index != 0 && p->stack_data[index].name != lck) {
+        index = p->stack_data[index].prev;
+      }
+      if (index != 0) {
+        /* found match on the stack (may not always because of interleaved
+         * critical for Fortran) */
+        cons = p->stack_data[index];
+      }
+      /* we are in CRITICAL which is inside a CRITICAL construct of same name */
+      __kmp_error_construct2(kmp_i18n_msg_CnsNestingSameName, ct, ident, &cons);
+    }
+  } else if (ct == ct_master || ct == ct_reduce) {
+    if (p->w_top > p->p_top) {
+      /* inside a WORKSHARING construct for this PARALLEL region */
+      __kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
+                             &p->stack_data[p->w_top]);
+    }
+    if (ct == ct_reduce && p->s_top > p->p_top) {
+      /* inside a another SYNC construct for this PARALLEL region */
+      __kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
+                             &p->stack_data[p->s_top]);
     }; // if
+  }; // if
 }
 
 void
@@ -377,147 +348,118 @@ __kmp_push_sync( int gtid, enum cons_typ
 __kmp_push_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p lck )
 #endif
 {
-    int         tos;
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
+  int tos;
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
 
-    KMP_ASSERT( gtid == __kmp_get_gtid() );
-    KE_TRACE( 10, ("__kmp_push_sync (gtid=%d)\n", gtid ) );
+  KMP_ASSERT(gtid == __kmp_get_gtid());
+  KE_TRACE(10, ("__kmp_push_sync (gtid=%d)\n", gtid));
 #if KMP_USE_DYNAMIC_LOCK
-    __kmp_check_sync( gtid, ct, ident, lck, seq );
+  __kmp_check_sync(gtid, ct, ident, lck, seq);
 #else
-    __kmp_check_sync( gtid, ct, ident, lck );
+  __kmp_check_sync(gtid, ct, ident, lck);
 #endif
-    KE_TRACE( 100, ( PUSH_MSG( ct, ident ) ) );
-    tos = ++ p->stack_top;
-    p->stack_data[ tos ].type  = ct;
-    p->stack_data[ tos ].prev  = p->s_top;
-    p->stack_data[ tos ].ident = ident;
-    p->stack_data[ tos ].name  = lck;
-    p->s_top = tos;
-    KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
-}
-
-/* ------------------------------------------------------------------------ */
-
-void
-__kmp_pop_parallel( int gtid, ident_t const * ident )
-{
-    int tos;
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-    tos = p->stack_top;
-    KE_TRACE( 10, ("__kmp_pop_parallel (%d %d)\n", gtid, __kmp_get_gtid() ) );
-    if ( tos == 0 || p->p_top == 0 ) {
-        __kmp_error_construct( kmp_i18n_msg_CnsDetectedEnd, ct_parallel, ident );
-    }
-    if ( tos != p->p_top || p->stack_data[ tos ].type != ct_parallel ) {
-        __kmp_error_construct2(
-            kmp_i18n_msg_CnsExpectedEnd,
-            ct_parallel, ident,
-            & p->stack_data[ tos ]
-        );
-    }
-    KE_TRACE( 100, ( POP_MSG( p ) ) );
-    p->p_top = p->stack_data[ tos ].prev;
-    p->stack_data[ tos ].type = ct_none;
-    p->stack_data[ tos ].ident = NULL;
-    p->stack_top = tos - 1;
-    KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
-}
-
-enum cons_type
-__kmp_pop_workshare( int gtid, enum cons_type ct, ident_t const * ident )
-{
-    int tos;
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-
-    tos = p->stack_top;
-    KE_TRACE( 10, ("__kmp_pop_workshare (%d %d)\n", gtid, __kmp_get_gtid() ) );
-    if ( tos == 0 || p->w_top == 0 ) {
-        __kmp_error_construct( kmp_i18n_msg_CnsDetectedEnd, ct, ident );
-    }
-
-    if ( tos != p->w_top ||
-         ( p->stack_data[ tos ].type != ct &&
-          /* below are two exceptions to the rule that construct types must match */
-          ! ( p->stack_data[ tos ].type == ct_pdo_ordered && ct == ct_pdo ) &&
-          ! ( p->stack_data[ tos ].type == ct_task_ordered && ct == ct_task )
-         )
-       ) {
-        __kmp_check_null_func();
-        __kmp_error_construct2(
-            kmp_i18n_msg_CnsExpectedEnd,
-            ct, ident,
-            & p->stack_data[ tos ]
-        );
-    }
-    KE_TRACE( 100, ( POP_MSG( p ) ) );
-    p->w_top = p->stack_data[ tos ].prev;
-    p->stack_data[ tos ].type = ct_none;
-    p->stack_data[ tos ].ident = NULL;
-    p->stack_top = tos - 1;
-    KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
-    return p->stack_data[ p->w_top ].type;
-}
-
-void
-__kmp_pop_sync( int gtid, enum cons_type ct, ident_t const * ident )
-{
-    int tos;
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-    tos = p->stack_top;
-    KE_TRACE( 10, ("__kmp_pop_sync (%d %d)\n", gtid, __kmp_get_gtid() ) );
-    if ( tos == 0 || p->s_top == 0 ) {
-        __kmp_error_construct( kmp_i18n_msg_CnsDetectedEnd, ct, ident );
-    };
-    if ( tos != p->s_top || p->stack_data[ tos ].type != ct ) {
-        __kmp_check_null_func();
-        __kmp_error_construct2(
-            kmp_i18n_msg_CnsExpectedEnd,
-            ct, ident,
-            & p->stack_data[ tos ]
-        );
-    };
-    if ( gtid < 0 ) {
-        __kmp_check_null_func();
-    };
-    KE_TRACE( 100, ( POP_MSG( p ) ) );
-    p->s_top = p->stack_data[ tos ].prev;
-    p->stack_data[ tos ].type = ct_none;
-    p->stack_data[ tos ].ident = NULL;
-    p->stack_top = tos - 1;
-    KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
-}
-
-/* ------------------------------------------------------------------------ */
-
-void
-__kmp_check_barrier( int gtid, enum cons_type ct, ident_t const * ident )
-{
-    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;
-    KE_TRACE( 10, ("__kmp_check_barrier (loc: %p, gtid: %d %d)\n", ident, gtid, __kmp_get_gtid() ) );
-    if ( ident != 0 ) {
-        __kmp_check_null_func();
-    }
-    if ( p->w_top > p->p_top ) {
-        /* we are already in a WORKSHARING construct for this PARALLEL region */
-        __kmp_error_construct2(
-            kmp_i18n_msg_CnsInvalidNesting,
-            ct, ident,
-            & p->stack_data[ p->w_top ]
-        );
-    }
-    if (p->s_top > p->p_top) {
-        /* we are already in a SYNC construct for this PARALLEL region */
-        __kmp_error_construct2(
-            kmp_i18n_msg_CnsInvalidNesting,
-            ct, ident,
-            & p->stack_data[ p->s_top ]
-        );
-    }
+  KE_TRACE(100, (PUSH_MSG(ct, ident)));
+  tos = ++p->stack_top;
+  p->stack_data[tos].type = ct;
+  p->stack_data[tos].prev = p->s_top;
+  p->stack_data[tos].ident = ident;
+  p->stack_data[tos].name = lck;
+  p->s_top = tos;
+  KE_DUMP(1000, dump_cons_stack(gtid, p));
+}
+
+/* ------------------------------------------------------------------------ */
+
+void __kmp_pop_parallel(int gtid, ident_t const *ident) {
+  int tos;
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+  tos = p->stack_top;
+  KE_TRACE(10, ("__kmp_pop_parallel (%d %d)\n", gtid, __kmp_get_gtid()));
+  if (tos == 0 || p->p_top == 0) {
+    __kmp_error_construct(kmp_i18n_msg_CnsDetectedEnd, ct_parallel, ident);
+  }
+  if (tos != p->p_top || p->stack_data[tos].type != ct_parallel) {
+    __kmp_error_construct2(kmp_i18n_msg_CnsExpectedEnd, ct_parallel, ident,
+                           &p->stack_data[tos]);
+  }
+  KE_TRACE(100, (POP_MSG(p)));
+  p->p_top = p->stack_data[tos].prev;
+  p->stack_data[tos].type = ct_none;
+  p->stack_data[tos].ident = NULL;
+  p->stack_top = tos - 1;
+  KE_DUMP(1000, dump_cons_stack(gtid, p));
+}
+
+enum cons_type __kmp_pop_workshare(int gtid, enum cons_type ct,
+                                   ident_t const *ident) {
+  int tos;
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+
+  tos = p->stack_top;
+  KE_TRACE(10, ("__kmp_pop_workshare (%d %d)\n", gtid, __kmp_get_gtid()));
+  if (tos == 0 || p->w_top == 0) {
+    __kmp_error_construct(kmp_i18n_msg_CnsDetectedEnd, ct, ident);
+  }
+
+  if (tos != p->w_top ||
+      (p->stack_data[tos].type != ct &&
+       // below are two exceptions to the rule that construct types must match
+       !(p->stack_data[tos].type == ct_pdo_ordered && ct == ct_pdo) &&
+       !(p->stack_data[tos].type == ct_task_ordered && ct == ct_task))) {
+    __kmp_check_null_func();
+    __kmp_error_construct2(kmp_i18n_msg_CnsExpectedEnd, ct, ident,
+                           &p->stack_data[tos]);
+  }
+  KE_TRACE(100, (POP_MSG(p)));
+  p->w_top = p->stack_data[tos].prev;
+  p->stack_data[tos].type = ct_none;
+  p->stack_data[tos].ident = NULL;
+  p->stack_top = tos - 1;
+  KE_DUMP(1000, dump_cons_stack(gtid, p));
+  return p->stack_data[p->w_top].type;
+}
+
+void __kmp_pop_sync(int gtid, enum cons_type ct, ident_t const *ident) {
+  int tos;
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+  tos = p->stack_top;
+  KE_TRACE(10, ("__kmp_pop_sync (%d %d)\n", gtid, __kmp_get_gtid()));
+  if (tos == 0 || p->s_top == 0) {
+    __kmp_error_construct(kmp_i18n_msg_CnsDetectedEnd, ct, ident);
+  };
+  if (tos != p->s_top || p->stack_data[tos].type != ct) {
+    __kmp_check_null_func();
+    __kmp_error_construct2(kmp_i18n_msg_CnsExpectedEnd, ct, ident,
+                           &p->stack_data[tos]);
+  };
+  if (gtid < 0) {
+    __kmp_check_null_func();
+  };
+  KE_TRACE(100, (POP_MSG(p)));
+  p->s_top = p->stack_data[tos].prev;
+  p->stack_data[tos].type = ct_none;
+  p->stack_data[tos].ident = NULL;
+  p->stack_top = tos - 1;
+  KE_DUMP(1000, dump_cons_stack(gtid, p));
+}
+
+/* ------------------------------------------------------------------------ */
+
+void __kmp_check_barrier(int gtid, enum cons_type ct, ident_t const *ident) {
+  struct cons_header *p = __kmp_threads[gtid]->th.th_cons;
+  KE_TRACE(10, ("__kmp_check_barrier (loc: %p, gtid: %d %d)\n", ident, gtid,
+                __kmp_get_gtid()));
+  if (ident != 0) {
+    __kmp_check_null_func();
+  }
+  if (p->w_top > p->p_top) {
+    /* we are already in a WORKSHARING construct for this PARALLEL region */
+    __kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
+                           &p->stack_data[p->w_top]);
+  }
+  if (p->s_top > p->p_top) {
+    /* we are already in a SYNC construct for this PARALLEL region */
+    __kmp_error_construct2(kmp_i18n_msg_CnsInvalidNesting, ct, ident,
+                           &p->stack_data[p->s_top]);
+  }
 }
-
-/* ------------------------------------------------------------------------ */
-
-
-/* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */

Modified: openmp/trunk/runtime/src/kmp_error.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_error.h?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_error.h (original)
+++ openmp/trunk/runtime/src/kmp_error.h Fri May 12 13:01:32 2017
@@ -20,38 +20,44 @@
 
 /* ------------------------------------------------------------------------ */
 #ifdef __cplusplus
-    extern "C" {
+extern "C" {
 #endif
 
-void __kmp_error_construct(  kmp_i18n_id_t id, enum cons_type ct, ident_t const * ident );
-void __kmp_error_construct2( kmp_i18n_id_t id, enum cons_type ct, ident_t const * ident, struct cons_data const * cons );
+void __kmp_error_construct(kmp_i18n_id_t id, enum cons_type ct,
+                           ident_t const *ident);
+void __kmp_error_construct2(kmp_i18n_id_t id, enum cons_type ct,
+                            ident_t const *ident, struct cons_data const *cons);
 
-struct cons_header * __kmp_allocate_cons_stack( int gtid );
-void                 __kmp_free_cons_stack( void * ptr );
+struct cons_header *__kmp_allocate_cons_stack(int gtid);
+void __kmp_free_cons_stack(void *ptr);
 
-void __kmp_push_parallel( int gtid, ident_t const * ident );
-void __kmp_push_workshare( int gtid, enum cons_type ct, ident_t const * ident );
+void __kmp_push_parallel(int gtid, ident_t const *ident);
+void __kmp_push_workshare(int gtid, enum cons_type ct, ident_t const *ident);
 #if KMP_USE_DYNAMIC_LOCK
-void __kmp_push_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name, kmp_uint32 );
+void __kmp_push_sync(int gtid, enum cons_type ct, ident_t const *ident,
+                     kmp_user_lock_p name, kmp_uint32);
 #else
-void __kmp_push_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name );
+void __kmp_push_sync(int gtid, enum cons_type ct, ident_t const *ident,
+                     kmp_user_lock_p name);
 #endif
 
-void __kmp_check_workshare( int gtid, enum cons_type ct, ident_t const * ident );
+void __kmp_check_workshare(int gtid, enum cons_type ct, ident_t const *ident);
 #if KMP_USE_DYNAMIC_LOCK
-void __kmp_check_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name, kmp_uint32 );
+void __kmp_check_sync(int gtid, enum cons_type ct, ident_t const *ident,
+                      kmp_user_lock_p name, kmp_uint32);
 #else
-void __kmp_check_sync( int gtid, enum cons_type ct, ident_t const * ident, kmp_user_lock_p name );
+void __kmp_check_sync(int gtid, enum cons_type ct, ident_t const *ident,
+                      kmp_user_lock_p name);
 #endif
 
-void __kmp_pop_parallel( int gtid, ident_t const * ident );
-enum cons_type __kmp_pop_workshare( int gtid, enum cons_type ct, ident_t const * ident );
-void __kmp_pop_sync( int gtid, enum cons_type ct, ident_t const * ident );
-void __kmp_check_barrier( int gtid, enum cons_type ct, ident_t const * ident );
+void __kmp_pop_parallel(int gtid, ident_t const *ident);
+enum cons_type __kmp_pop_workshare(int gtid, enum cons_type ct,
+                                   ident_t const *ident);
+void __kmp_pop_sync(int gtid, enum cons_type ct, ident_t const *ident);
+void __kmp_check_barrier(int gtid, enum cons_type ct, ident_t const *ident);
 
 #ifdef __cplusplus
-    } // extern "C"
+} // extern "C"
 #endif
 
 #endif // KMP_ERROR_H
-

Modified: openmp/trunk/runtime/src/kmp_ftn_cdecl.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_ftn_cdecl.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_ftn_cdecl.cpp (original)
+++ openmp/trunk/runtime/src/kmp_ftn_cdecl.cpp Fri May 12 13:01:32 2017
@@ -17,20 +17,21 @@
 #include "kmp_affinity.h"
 
 #if KMP_OS_WINDOWS
-#   if defined  KMP_WIN_CDECL ||  !defined KMP_DYNAMIC_LIB
-#       define KMP_FTN_ENTRIES      KMP_FTN_UPPER
-#   endif
+#if defined KMP_WIN_CDECL || !defined KMP_DYNAMIC_LIB
+#define KMP_FTN_ENTRIES KMP_FTN_UPPER
+#endif
 #elif KMP_OS_UNIX
-#   define KMP_FTN_ENTRIES  KMP_FTN_PLAIN
+#define KMP_FTN_ENTRIES KMP_FTN_PLAIN
 #endif
 
 // Note: This string is not printed when KMP_VERSION=1.
-char const __kmp_version_ftncdecl[] = KMP_VERSION_PREFIX "Fortran __cdecl OMP support: "
+char const __kmp_version_ftncdecl[] =
+    KMP_VERSION_PREFIX "Fortran __cdecl OMP support: "
 #ifdef KMP_FTN_ENTRIES
-    "yes";
-#   define FTN_STDCALL 	/* no stdcall */
-#   include "kmp_ftn_os.h"
-#   include "kmp_ftn_entry.h"
+                       "yes";
+#define FTN_STDCALL /* no stdcall */
+#include "kmp_ftn_os.h"
+#include "kmp_ftn_entry.h"
 #else
-    "no";
+                       "no";
 #endif /* KMP_FTN_ENTRIES */

Modified: openmp/trunk/runtime/src/kmp_ftn_entry.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_ftn_entry.h?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_ftn_entry.h (original)
+++ openmp/trunk/runtime/src/kmp_ftn_entry.h Fri May 12 13:01:32 2017
@@ -14,947 +14,815 @@
 
 
 #ifndef FTN_STDCALL
-# error The support file kmp_ftn_entry.h should not be compiled by itself.
+#error The support file kmp_ftn_entry.h should not be compiled by itself.
 #endif
 
 #ifdef KMP_STUB
-    #include "kmp_stub.h"
+#include "kmp_stub.h"
 #endif
 
 #include "kmp_i18n.h"
 
 #ifdef __cplusplus
-    extern "C" {
+extern "C" {
 #endif // __cplusplus
 
-/*
- * For compatibility with the Gnu/MS Open MP codegen, omp_set_num_threads(),
+/* For compatibility with the Gnu/MS Open MP codegen, omp_set_num_threads(),
  * omp_set_nested(), and omp_set_dynamic() [in lowercase on MS, and w/o
  * a trailing underscore on Linux* OS] take call by value integer arguments.
  * + omp_set_max_active_levels()
  * + omp_set_schedule()
  *
  * For backward compatibility with 9.1 and previous Intel compiler, these
- * entry points take call by reference integer arguments.
- */
+ * entry points take call by reference integer arguments. */
 #ifdef KMP_GOMP_COMPAT
-# if (KMP_FTN_ENTRIES == KMP_FTN_PLAIN) || (KMP_FTN_ENTRIES == KMP_FTN_UPPER)
-#  define PASS_ARGS_BY_VALUE 1
-# endif
+#if (KMP_FTN_ENTRIES == KMP_FTN_PLAIN) || (KMP_FTN_ENTRIES == KMP_FTN_UPPER)
+#define PASS_ARGS_BY_VALUE 1
+#endif
 #endif
 #if KMP_OS_WINDOWS
-# if (KMP_FTN_ENTRIES == KMP_FTN_PLAIN) || (KMP_FTN_ENTRIES == KMP_FTN_APPEND)
-#  define PASS_ARGS_BY_VALUE 1
-# endif
+#if (KMP_FTN_ENTRIES == KMP_FTN_PLAIN) || (KMP_FTN_ENTRIES == KMP_FTN_APPEND)
+#define PASS_ARGS_BY_VALUE 1
+#endif
 #endif
 
 // This macro helps to reduce code duplication.
 #ifdef PASS_ARGS_BY_VALUE
-    #define KMP_DEREF
+#define KMP_DEREF
+#else
+#define KMP_DEREF *
+#endif
+
+void FTN_STDCALL FTN_SET_STACKSIZE(int KMP_DEREF arg) {
+#ifdef KMP_STUB
+  __kmps_set_stacksize(KMP_DEREF arg);
+#else
+  // __kmp_aux_set_stacksize initializes the library if needed
+  __kmp_aux_set_stacksize((size_t)KMP_DEREF arg);
+#endif
+}
+
+void FTN_STDCALL FTN_SET_STACKSIZE_S(size_t KMP_DEREF arg) {
+#ifdef KMP_STUB
+  __kmps_set_stacksize(KMP_DEREF arg);
+#else
+  // __kmp_aux_set_stacksize initializes the library if needed
+  __kmp_aux_set_stacksize(KMP_DEREF arg);
+#endif
+}
+
+int FTN_STDCALL FTN_GET_STACKSIZE(void) {
+#ifdef KMP_STUB
+  return __kmps_get_stacksize();
+#else
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  };
+  return (int)__kmp_stksize;
+#endif
+}
+
+size_t FTN_STDCALL FTN_GET_STACKSIZE_S(void) {
+#ifdef KMP_STUB
+  return __kmps_get_stacksize();
 #else
-    #define KMP_DEREF *
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  };
+  return __kmp_stksize;
 #endif
+}
 
-void  FTN_STDCALL
-FTN_SET_STACKSIZE( int KMP_DEREF arg )
-{
-    #ifdef KMP_STUB
-        __kmps_set_stacksize( KMP_DEREF arg );
-    #else
-        // __kmp_aux_set_stacksize initializes the library if needed
-        __kmp_aux_set_stacksize( (size_t) KMP_DEREF arg );
-    #endif
-}
-
-void  FTN_STDCALL
-FTN_SET_STACKSIZE_S( size_t KMP_DEREF arg )
-{
-    #ifdef KMP_STUB
-        __kmps_set_stacksize( KMP_DEREF arg );
-    #else
-        // __kmp_aux_set_stacksize initializes the library if needed
-        __kmp_aux_set_stacksize( KMP_DEREF arg );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_STACKSIZE( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_stacksize();
-    #else
-        if ( ! __kmp_init_serial ) {
-            __kmp_serial_initialize();
-        };
-        return (int)__kmp_stksize;
-    #endif
-}
-
-size_t FTN_STDCALL
-FTN_GET_STACKSIZE_S( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_stacksize();
-    #else
-        if ( ! __kmp_init_serial ) {
-            __kmp_serial_initialize();
-        };
-        return __kmp_stksize;
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_BLOCKTIME( int KMP_DEREF arg )
-{
-    #ifdef KMP_STUB
-        __kmps_set_blocktime( KMP_DEREF arg );
-    #else
-	int gtid, tid;
-	kmp_info_t *thread;
-
-	gtid = __kmp_entry_gtid();
-	tid = __kmp_tid_from_gtid(gtid);
-	thread = __kmp_thread_from_gtid(gtid);
-
-        __kmp_aux_set_blocktime( KMP_DEREF arg, thread, tid );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_BLOCKTIME( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_blocktime();
-    #else
-	int gtid, tid;
-	kmp_info_t *thread;
-        kmp_team_p *team;
-
-	gtid = __kmp_entry_gtid();
-	tid = __kmp_tid_from_gtid(gtid);
-	thread = __kmp_thread_from_gtid(gtid);
-        team = __kmp_threads[ gtid ] -> th.th_team;
-
-        /* These must match the settings used in __kmp_wait_sleep() */
-        if ( __kmp_dflt_blocktime == KMP_MAX_BLOCKTIME ) {
-	    KF_TRACE(10, ( "kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n",
-			  gtid, team->t.t_id, tid, KMP_MAX_BLOCKTIME) );
-            return KMP_MAX_BLOCKTIME;
-        }
+void FTN_STDCALL FTN_SET_BLOCKTIME(int KMP_DEREF arg) {
+#ifdef KMP_STUB
+  __kmps_set_blocktime(KMP_DEREF arg);
+#else
+  int gtid, tid;
+  kmp_info_t *thread;
+
+  gtid = __kmp_entry_gtid();
+  tid = __kmp_tid_from_gtid(gtid);
+  thread = __kmp_thread_from_gtid(gtid);
+
+  __kmp_aux_set_blocktime(KMP_DEREF arg, thread, tid);
+#endif
+}
+
+int FTN_STDCALL FTN_GET_BLOCKTIME(void) {
+#ifdef KMP_STUB
+  return __kmps_get_blocktime();
+#else
+  int gtid, tid;
+  kmp_info_t *thread;
+  kmp_team_p *team;
+
+  gtid = __kmp_entry_gtid();
+  tid = __kmp_tid_from_gtid(gtid);
+  thread = __kmp_thread_from_gtid(gtid);
+  team = __kmp_threads[gtid]->th.th_team;
+
+  /* These must match the settings used in __kmp_wait_sleep() */
+  if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME) {
+    KF_TRACE(10, ("kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n", gtid,
+                  team->t.t_id, tid, KMP_MAX_BLOCKTIME));
+    return KMP_MAX_BLOCKTIME;
+  }
 #ifdef KMP_ADJUST_BLOCKTIME
-        else if ( __kmp_zero_bt && !get__bt_set( team, tid ) ) {
-	    KF_TRACE(10, ( "kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n",
-			  gtid, team->t.t_id, tid, 0) );
-            return 0;
-        }
+  else if (__kmp_zero_bt && !get__bt_set(team, tid)) {
+    KF_TRACE(10, ("kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n", gtid,
+                  team->t.t_id, tid, 0));
+    return 0;
+  }
 #endif /* KMP_ADJUST_BLOCKTIME */
-        else {
-	    KF_TRACE(10, ( "kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n",
-              gtid, team->t.t_id, tid, get__blocktime( team, tid ) ) );
-            return get__blocktime( team, tid );
-        };
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_LIBRARY_SERIAL( void )
-{
-    #ifdef KMP_STUB
-        __kmps_set_library( library_serial );
-    #else
-        // __kmp_user_set_library initializes the library if needed
-        __kmp_user_set_library( library_serial );
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_LIBRARY_TURNAROUND( void )
-{
-    #ifdef KMP_STUB
-        __kmps_set_library( library_turnaround );
-    #else
-        // __kmp_user_set_library initializes the library if needed
-        __kmp_user_set_library( library_turnaround );
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_LIBRARY_THROUGHPUT( void )
-{
-    #ifdef KMP_STUB
-        __kmps_set_library( library_throughput );
-    #else
-        // __kmp_user_set_library initializes the library if needed
-        __kmp_user_set_library( library_throughput );
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_LIBRARY( int KMP_DEREF arg )
-{
-    #ifdef KMP_STUB
-        __kmps_set_library( KMP_DEREF arg );
-    #else
-        enum library_type lib;
-        lib = (enum library_type) KMP_DEREF arg;
-        // __kmp_user_set_library initializes the library if needed
-        __kmp_user_set_library( lib );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_LIBRARY (void)
-{
-    #ifdef KMP_STUB
-        return __kmps_get_library();
-    #else
-        if ( ! __kmp_init_serial ) {
-            __kmp_serial_initialize();
-        }
-        return ((int) __kmp_library);
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_DISP_NUM_BUFFERS( int KMP_DEREF arg )
-{
-    #ifdef KMP_STUB
-        ; // empty routine
-    #else
-        // ignore after initialization because some teams have already
-        // allocated dispatch buffers
-        if( __kmp_init_serial == 0 && (KMP_DEREF arg) > 0 )
-            __kmp_dispatch_num_buffers = KMP_DEREF arg;
-    #endif
-}
-
-int FTN_STDCALL
-FTN_SET_AFFINITY( void **mask )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return -1;
-    #else
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        return __kmp_aux_set_affinity( mask );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_AFFINITY( void **mask )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return -1;
-    #else
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        return __kmp_aux_get_affinity( mask );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_AFFINITY_MAX_PROC( void )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return 0;
-    #else
-        //
-        // We really only NEED serial initialization here.
-        //
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        return __kmp_aux_get_affinity_max_proc();
-    #endif
-}
-
-void FTN_STDCALL
-FTN_CREATE_AFFINITY_MASK( void **mask )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        *mask = NULL;
-    #else
-        //
-        // We really only NEED serial initialization here.
-        //
-        kmp_affin_mask_t* mask_internals;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        mask_internals = __kmp_affinity_dispatch->allocate_mask();
-        KMP_CPU_ZERO( mask_internals );
-        *mask = mask_internals;
-    #endif
-}
-
-void FTN_STDCALL
-FTN_DESTROY_AFFINITY_MASK( void **mask )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        // Nothing
-    #else
-        //
-        // We really only NEED serial initialization here.
-        //
-        kmp_affin_mask_t* mask_internals;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        if ( __kmp_env_consistency_check ) {
-            if ( *mask == NULL ) {
-	        KMP_FATAL( AffinityInvalidMask, "kmp_destroy_affinity_mask" );
-	    }
-        }
-        mask_internals = (kmp_affin_mask_t*)(*mask);
-        __kmp_affinity_dispatch->deallocate_mask(mask_internals);
-        *mask = NULL;
-    #endif
-}
-
-int FTN_STDCALL
-FTN_SET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return -1;
-    #else
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        return __kmp_aux_set_affinity_mask_proc( KMP_DEREF proc, mask );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_UNSET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return -1;
-    #else
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        return __kmp_aux_unset_affinity_mask_proc( KMP_DEREF proc, mask );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return -1;
-    #else
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        return __kmp_aux_get_affinity_mask_proc( KMP_DEREF proc, mask );
-    #endif
+  else {
+    KF_TRACE(10, ("kmp_get_blocktime: T#%d(%d:%d), blocktime=%d\n", gtid,
+                  team->t.t_id, tid, get__blocktime(team, tid)));
+    return get__blocktime(team, tid);
+  };
+#endif
 }
 
+void FTN_STDCALL FTN_SET_LIBRARY_SERIAL(void) {
+#ifdef KMP_STUB
+  __kmps_set_library(library_serial);
+#else
+  // __kmp_user_set_library initializes the library if needed
+  __kmp_user_set_library(library_serial);
+#endif
+}
+
+void FTN_STDCALL FTN_SET_LIBRARY_TURNAROUND(void) {
+#ifdef KMP_STUB
+  __kmps_set_library(library_turnaround);
+#else
+  // __kmp_user_set_library initializes the library if needed
+  __kmp_user_set_library(library_turnaround);
+#endif
+}
+
+void FTN_STDCALL FTN_SET_LIBRARY_THROUGHPUT(void) {
+#ifdef KMP_STUB
+  __kmps_set_library(library_throughput);
+#else
+  // __kmp_user_set_library initializes the library if needed
+  __kmp_user_set_library(library_throughput);
+#endif
+}
+
+void FTN_STDCALL FTN_SET_LIBRARY(int KMP_DEREF arg) {
+#ifdef KMP_STUB
+  __kmps_set_library(KMP_DEREF arg);
+#else
+  enum library_type lib;
+  lib = (enum library_type)KMP_DEREF arg;
+  // __kmp_user_set_library initializes the library if needed
+  __kmp_user_set_library(lib);
+#endif
+}
+
+int FTN_STDCALL FTN_GET_LIBRARY(void) {
+#ifdef KMP_STUB
+  return __kmps_get_library();
+#else
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  }
+  return ((int)__kmp_library);
+#endif
+}
+
+void FTN_STDCALL FTN_SET_DISP_NUM_BUFFERS(int KMP_DEREF arg) {
+#ifdef KMP_STUB
+  ; // empty routine
+#else
+  // ignore after initialization because some teams have already
+  // allocated dispatch buffers
+  if (__kmp_init_serial == 0 && (KMP_DEREF arg) > 0)
+    __kmp_dispatch_num_buffers = KMP_DEREF arg;
+#endif
+}
+
+int FTN_STDCALL FTN_SET_AFFINITY(void **mask) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return -1;
+#else
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  return __kmp_aux_set_affinity(mask);
+#endif
+}
+
+int FTN_STDCALL FTN_GET_AFFINITY(void **mask) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return -1;
+#else
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  return __kmp_aux_get_affinity(mask);
+#endif
+}
+
+int FTN_STDCALL FTN_GET_AFFINITY_MAX_PROC(void) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return 0;
+#else
+  // We really only NEED serial initialization here.
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  return __kmp_aux_get_affinity_max_proc();
+#endif
+}
+
+void FTN_STDCALL FTN_CREATE_AFFINITY_MASK(void **mask) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  *mask = NULL;
+#else
+  // We really only NEED serial initialization here.
+  kmp_affin_mask_t *mask_internals;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  mask_internals = __kmp_affinity_dispatch->allocate_mask();
+  KMP_CPU_ZERO(mask_internals);
+  *mask = mask_internals;
+#endif
+}
+
+void FTN_STDCALL FTN_DESTROY_AFFINITY_MASK(void **mask) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+// Nothing
+#else
+  // We really only NEED serial initialization here.
+  kmp_affin_mask_t *mask_internals;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  if (__kmp_env_consistency_check) {
+    if (*mask == NULL) {
+      KMP_FATAL(AffinityInvalidMask, "kmp_destroy_affinity_mask");
+    }
+  }
+  mask_internals = (kmp_affin_mask_t *)(*mask);
+  __kmp_affinity_dispatch->deallocate_mask(mask_internals);
+  *mask = NULL;
+#endif
+}
+
+int FTN_STDCALL FTN_SET_AFFINITY_MASK_PROC(int KMP_DEREF proc, void **mask) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return -1;
+#else
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  return __kmp_aux_set_affinity_mask_proc(KMP_DEREF proc, mask);
+#endif
+}
+
+int FTN_STDCALL FTN_UNSET_AFFINITY_MASK_PROC(int KMP_DEREF proc, void **mask) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return -1;
+#else
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  return __kmp_aux_unset_affinity_mask_proc(KMP_DEREF proc, mask);
+#endif
+}
+
+int FTN_STDCALL FTN_GET_AFFINITY_MASK_PROC(int KMP_DEREF proc, void **mask) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return -1;
+#else
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  return __kmp_aux_get_affinity_mask_proc(KMP_DEREF proc, mask);
+#endif
+}
 
 /* ------------------------------------------------------------------------ */
 
 /* sets the requested number of threads for the next parallel region */
+void FTN_STDCALL xexpand(FTN_SET_NUM_THREADS)(int KMP_DEREF arg) {
+#ifdef KMP_STUB
+// Nothing.
+#else
+  __kmp_set_num_threads(KMP_DEREF arg, __kmp_entry_gtid());
+#endif
+}
 
-void FTN_STDCALL
-xexpand(FTN_SET_NUM_THREADS)( int KMP_DEREF arg )
-{
-    #ifdef KMP_STUB
-        // Nothing.
-    #else
-        __kmp_set_num_threads( KMP_DEREF arg, __kmp_entry_gtid() );
-    #endif
+/* returns the number of threads in current team */
+int FTN_STDCALL xexpand(FTN_GET_NUM_THREADS)(void) {
+#ifdef KMP_STUB
+  return 1;
+#else
+  // __kmpc_bound_num_threads initializes the library if needed
+  return __kmpc_bound_num_threads(NULL);
+#endif
 }
 
+int FTN_STDCALL xexpand(FTN_GET_MAX_THREADS)(void) {
+#ifdef KMP_STUB
+  return 1;
+#else
+  int gtid;
+  kmp_info_t *thread;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  gtid = __kmp_entry_gtid();
+  thread = __kmp_threads[gtid];
+  // return thread -> th.th_team -> t.t_current_task[
+  // thread->th.th_info.ds.ds_tid ] -> icvs.nproc;
+  return thread->th.th_current_task->td_icvs.nproc;
+#endif
+}
 
-/* returns the number of threads in current team */
-int FTN_STDCALL
-xexpand(FTN_GET_NUM_THREADS)( void )
-{
-    #ifdef KMP_STUB
-        return 1;
-    #else
-        // __kmpc_bound_num_threads initializes the library if needed
-        return __kmpc_bound_num_threads(NULL);
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_MAX_THREADS)( void )
-{
-    #ifdef KMP_STUB
-        return 1;
-    #else
-        int         gtid;
-        kmp_info_t *thread;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        gtid   = __kmp_entry_gtid();
-        thread = __kmp_threads[ gtid ];
-        //return thread -> th.th_team -> t.t_current_task[ thread->th.th_info.ds.ds_tid ] -> icvs.nproc;
-	return thread -> th.th_current_task -> td_icvs.nproc;
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_THREAD_NUM)( void )
-{
-    #ifdef KMP_STUB
-        return 0;
-    #else
-        int gtid;
-
-        #if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD
-            gtid = __kmp_entry_gtid();
-        #elif KMP_OS_WINDOWS
-            if (!__kmp_init_parallel ||
-                (gtid = (int)((kmp_intptr_t)TlsGetValue( __kmp_gtid_threadprivate_key ))) == 0) {
-                // Either library isn't initialized or thread is not registered
-                // 0 is the correct TID in this case
-                return 0;
-            }
-            --gtid; // We keep (gtid+1) in TLS
-        #elif KMP_OS_LINUX
-            #ifdef KMP_TDATA_GTID
-            if ( __kmp_gtid_mode >= 3 ) {
-                if ((gtid = __kmp_gtid) == KMP_GTID_DNE) {
-                    return 0;
-                }
-            } else {
-            #endif
-                if (!__kmp_init_parallel ||
-                    (gtid = (kmp_intptr_t)(pthread_getspecific( __kmp_gtid_threadprivate_key ))) == 0) {
-                    return 0;
-                }
-                --gtid;
-            #ifdef KMP_TDATA_GTID
-            }
-            #endif
-        #else
-            #error Unknown or unsupported OS
-        #endif
-
-        return __kmp_tid_from_gtid( gtid );
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_NUM_KNOWN_THREADS( void )
-{
-    #ifdef KMP_STUB
-        return 1;
-    #else
-        if ( ! __kmp_init_serial ) {
-            __kmp_serial_initialize();
-        }
-        /* NOTE: this is not syncronized, so it can change at any moment */
-        /* NOTE: this number also includes threads preallocated in hot-teams */
-        return TCR_4(__kmp_nth);
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_NUM_PROCS)( void )
-{
-    #ifdef KMP_STUB
-        return 1;
-    #else
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        return __kmp_avail_proc;
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_SET_NESTED)( int KMP_DEREF flag )
-{
-    #ifdef KMP_STUB
-        __kmps_set_nested( KMP_DEREF flag );
-    #else
-        kmp_info_t *thread;
-        /* For the thread-private internal controls implementation */
-        thread = __kmp_entry_thread();
-        __kmp_save_internal_controls( thread );
-        set__nested( thread, ( (KMP_DEREF flag) ? TRUE : FALSE ) );
-    #endif
-}
-
-
-int FTN_STDCALL
-xexpand(FTN_GET_NESTED)( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_nested();
-    #else
-        kmp_info_t *thread;
-        thread = __kmp_entry_thread();
-        return get__nested( thread );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_SET_DYNAMIC)( int KMP_DEREF flag )
-{
-    #ifdef KMP_STUB
-        __kmps_set_dynamic( KMP_DEREF flag ? TRUE : FALSE );
-    #else
-        kmp_info_t *thread;
-        /* For the thread-private implementation of the internal controls */
-        thread = __kmp_entry_thread();
-        // !!! What if foreign thread calls it?
-        __kmp_save_internal_controls( thread );
-        set__dynamic( thread, KMP_DEREF flag ? TRUE : FALSE );
-    #endif
-}
-
-
-int FTN_STDCALL
-xexpand(FTN_GET_DYNAMIC)( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_dynamic();
-    #else
-        kmp_info_t *thread;
-        thread = __kmp_entry_thread();
-        return get__dynamic( thread );
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_IN_PARALLEL)( void )
-{
-    #ifdef KMP_STUB
-        return 0;
-    #else
-        kmp_info_t *th = __kmp_entry_thread();
+int FTN_STDCALL xexpand(FTN_GET_THREAD_NUM)(void) {
+#ifdef KMP_STUB
+  return 0;
+#else
+  int gtid;
+
+#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD
+  gtid = __kmp_entry_gtid();
+#elif KMP_OS_WINDOWS
+  if (!__kmp_init_parallel ||
+      (gtid = (int)((kmp_intptr_t)TlsGetValue(__kmp_gtid_threadprivate_key))) ==
+          0) {
+    // Either library isn't initialized or thread is not registered
+    // 0 is the correct TID in this case
+    return 0;
+  }
+  --gtid; // We keep (gtid+1) in TLS
+#elif KMP_OS_LINUX
+#ifdef KMP_TDATA_GTID
+  if (__kmp_gtid_mode >= 3) {
+    if ((gtid = __kmp_gtid) == KMP_GTID_DNE) {
+      return 0;
+    }
+  } else {
+#endif
+    if (!__kmp_init_parallel ||
+        (gtid = (kmp_intptr_t)(
+             pthread_getspecific(__kmp_gtid_threadprivate_key))) == 0) {
+      return 0;
+    }
+    --gtid;
+#ifdef KMP_TDATA_GTID
+  }
+#endif
+#else
+#error Unknown or unsupported OS
+#endif
+
+  return __kmp_tid_from_gtid(gtid);
+#endif
+}
+
+int FTN_STDCALL FTN_GET_NUM_KNOWN_THREADS(void) {
+#ifdef KMP_STUB
+  return 1;
+#else
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  }
+  /* NOTE: this is not syncronized, so it can change at any moment */
+  /* NOTE: this number also includes threads preallocated in hot-teams */
+  return TCR_4(__kmp_nth);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_NUM_PROCS)(void) {
+#ifdef KMP_STUB
+  return 1;
+#else
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  return __kmp_avail_proc;
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_SET_NESTED)(int KMP_DEREF flag) {
+#ifdef KMP_STUB
+  __kmps_set_nested(KMP_DEREF flag);
+#else
+  kmp_info_t *thread;
+  /* For the thread-private internal controls implementation */
+  thread = __kmp_entry_thread();
+  __kmp_save_internal_controls(thread);
+  set__nested(thread, ((KMP_DEREF flag) ? TRUE : FALSE));
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_NESTED)(void) {
+#ifdef KMP_STUB
+  return __kmps_get_nested();
+#else
+  kmp_info_t *thread;
+  thread = __kmp_entry_thread();
+  return get__nested(thread);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_SET_DYNAMIC)(int KMP_DEREF flag) {
+#ifdef KMP_STUB
+  __kmps_set_dynamic(KMP_DEREF flag ? TRUE : FALSE);
+#else
+  kmp_info_t *thread;
+  /* For the thread-private implementation of the internal controls */
+  thread = __kmp_entry_thread();
+  // !!! What if foreign thread calls it?
+  __kmp_save_internal_controls(thread);
+  set__dynamic(thread, KMP_DEREF flag ? TRUE : FALSE);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_DYNAMIC)(void) {
+#ifdef KMP_STUB
+  return __kmps_get_dynamic();
+#else
+  kmp_info_t *thread;
+  thread = __kmp_entry_thread();
+  return get__dynamic(thread);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_IN_PARALLEL)(void) {
+#ifdef KMP_STUB
+  return 0;
+#else
+  kmp_info_t *th = __kmp_entry_thread();
 #if OMP_40_ENABLED
-        if ( th->th.th_teams_microtask ) {
-            // AC: r_in_parallel does not work inside teams construct
-            //     where real parallel is inactive, but all threads have same root,
-            //     so setting it in one team affects other teams.
-            //     The solution is to use per-team nesting level
-            return ( th->th.th_team->t.t_active_level ? 1 : 0 );
-        }
-        else
+  if (th->th.th_teams_microtask) {
+    // AC: r_in_parallel does not work inside teams construct where real
+    // parallel is inactive, but all threads have same root, so setting it in
+    // one team affects other teams.
+    // The solution is to use per-team nesting level
+    return (th->th.th_team->t.t_active_level ? 1 : 0);
+  } else
 #endif /* OMP_40_ENABLED */
-            return ( th->th.th_root->r.r_in_parallel ? FTN_TRUE : FTN_FALSE );
-    #endif
+    return (th->th.th_root->r.r_in_parallel ? FTN_TRUE : FTN_FALSE);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_SET_SCHEDULE)(kmp_sched_t KMP_DEREF kind,
+                                           int KMP_DEREF modifier) {
+#ifdef KMP_STUB
+  __kmps_set_schedule(KMP_DEREF kind, KMP_DEREF modifier);
+#else
+  /* TO DO: For the per-task implementation of the internal controls */
+  __kmp_set_schedule(__kmp_entry_gtid(), KMP_DEREF kind, KMP_DEREF modifier);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_GET_SCHEDULE)(kmp_sched_t *kind, int *modifier) {
+#ifdef KMP_STUB
+  __kmps_get_schedule(kind, modifier);
+#else
+  /* TO DO: For the per-task implementation of the internal controls */
+  __kmp_get_schedule(__kmp_entry_gtid(), kind, modifier);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_SET_MAX_ACTIVE_LEVELS)(int KMP_DEREF arg) {
+#ifdef KMP_STUB
+// Nothing.
+#else
+  /* TO DO: We want per-task implementation of this internal control */
+  __kmp_set_max_active_levels(__kmp_entry_gtid(), KMP_DEREF arg);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_MAX_ACTIVE_LEVELS)(void) {
+#ifdef KMP_STUB
+  return 0;
+#else
+  /* TO DO: We want per-task implementation of this internal control */
+  return __kmp_get_max_active_levels(__kmp_entry_gtid());
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_ACTIVE_LEVEL)(void) {
+#ifdef KMP_STUB
+  return 0; // returns 0 if it is called from the sequential part of the program
+#else
+  /* TO DO: For the per-task implementation of the internal controls */
+  return __kmp_entry_thread()->th.th_team->t.t_active_level;
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_LEVEL)(void) {
+#ifdef KMP_STUB
+  return 0; // returns 0 if it is called from the sequential part of the program
+#else
+  /* TO DO: For the per-task implementation of the internal controls */
+  return __kmp_entry_thread()->th.th_team->t.t_level;
+#endif
 }
 
-void FTN_STDCALL
-xexpand(FTN_SET_SCHEDULE)( kmp_sched_t KMP_DEREF kind, int KMP_DEREF modifier )
-{
-    #ifdef KMP_STUB
-        __kmps_set_schedule( KMP_DEREF kind, KMP_DEREF modifier );
-    #else
-	/*  TO DO  */
-        /* For the per-task implementation of the internal controls */
-        __kmp_set_schedule( __kmp_entry_gtid(), KMP_DEREF kind, KMP_DEREF modifier );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_GET_SCHEDULE)( kmp_sched_t * kind, int * modifier )
-{
-    #ifdef KMP_STUB
-        __kmps_get_schedule( kind, modifier );
-    #else
-	/*  TO DO  */
-	/* For the per-task implementation of the internal controls */
-        __kmp_get_schedule( __kmp_entry_gtid(), kind, modifier );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_SET_MAX_ACTIVE_LEVELS)( int KMP_DEREF arg )
-{
-    #ifdef KMP_STUB
-	// Nothing.
-    #else
-	/*  TO DO  */
-        /* We want per-task implementation of this internal control */
-        __kmp_set_max_active_levels( __kmp_entry_gtid(), KMP_DEREF arg );
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_MAX_ACTIVE_LEVELS)( void )
-{
-    #ifdef KMP_STUB
-	return 0;
-    #else
-	/*  TO DO  */
-	/* We want per-task implementation of this internal control */
-	return __kmp_get_max_active_levels( __kmp_entry_gtid() );
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_ACTIVE_LEVEL)( void )
-{
-    #ifdef KMP_STUB
-	return 0; // returns 0 if it is called from the sequential part of the program
-    #else
-	/*  TO DO  */
-	/* For the per-task implementation of the internal controls */
-        return __kmp_entry_thread() -> th.th_team -> t.t_active_level;
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_LEVEL)( void )
-{
-    #ifdef KMP_STUB
-	return 0; // returns 0 if it is called from the sequential part of the program
-    #else
-	/*  TO DO  */
-	/* For the per-task implementation of the internal controls */
-        return __kmp_entry_thread() -> th.th_team -> t.t_level;
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_ANCESTOR_THREAD_NUM)( int KMP_DEREF level )
-{
-    #ifdef KMP_STUB
-	return ( KMP_DEREF level ) ? ( -1 ) : ( 0 );
-    #else
-	return __kmp_get_ancestor_thread_num( __kmp_entry_gtid(), KMP_DEREF level );
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_TEAM_SIZE)( int KMP_DEREF level )
-{
-    #ifdef KMP_STUB
-        return ( KMP_DEREF level ) ? ( -1 ) : ( 1 );
-    #else
-        return __kmp_get_team_size( __kmp_entry_gtid(), KMP_DEREF level );
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_THREAD_LIMIT)( void )
-{
-    #ifdef KMP_STUB
-	return 1;   // TO DO: clarify whether it returns 1 or 0?
-    #else
-        if ( ! __kmp_init_serial ) {
-            __kmp_serial_initialize();
-        };
-        /* global ICV */
-	return __kmp_max_nth;
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_IN_FINAL)( void )
-{
-    #ifdef KMP_STUB
-	return 0;   // TO DO: clarify whether it returns 1 or 0?
-    #else
-        if ( ! TCR_4(__kmp_init_parallel) ) {
-            return 0;
-        }
-	return __kmp_entry_thread() -> th.th_current_task -> td_flags.final;
-    #endif
+int FTN_STDCALL xexpand(FTN_GET_ANCESTOR_THREAD_NUM)(int KMP_DEREF level) {
+#ifdef KMP_STUB
+  return (KMP_DEREF level) ? (-1) : (0);
+#else
+  return __kmp_get_ancestor_thread_num(__kmp_entry_gtid(), KMP_DEREF level);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_TEAM_SIZE)(int KMP_DEREF level) {
+#ifdef KMP_STUB
+  return (KMP_DEREF level) ? (-1) : (1);
+#else
+  return __kmp_get_team_size(__kmp_entry_gtid(), KMP_DEREF level);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_THREAD_LIMIT)(void) {
+#ifdef KMP_STUB
+  return 1; // TO DO: clarify whether it returns 1 or 0?
+#else
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  };
+  /* global ICV */
+  return __kmp_max_nth;
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_IN_FINAL)(void) {
+#ifdef KMP_STUB
+  return 0; // TO DO: clarify whether it returns 1 or 0?
+#else
+  if (!TCR_4(__kmp_init_parallel)) {
+    return 0;
+  }
+  return __kmp_entry_thread()->th.th_current_task->td_flags.final;
+#endif
 }
 
 #if OMP_40_ENABLED
 
 
-kmp_proc_bind_t FTN_STDCALL
-xexpand(FTN_GET_PROC_BIND)( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_proc_bind();
-    #else
-        return get__proc_bind( __kmp_entry_thread() );
-    #endif
+kmp_proc_bind_t FTN_STDCALL xexpand(FTN_GET_PROC_BIND)(void) {
+#ifdef KMP_STUB
+  return __kmps_get_proc_bind();
+#else
+  return get__proc_bind(__kmp_entry_thread());
+#endif
 }
 
 #if OMP_45_ENABLED
-int FTN_STDCALL
-FTN_GET_NUM_PLACES( void )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return 0;
-    #else
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        if (!KMP_AFFINITY_CAPABLE())
-            return 0;
-        return __kmp_affinity_num_masks;
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_PLACE_NUM_PROCS( int place_num )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return 0;
-    #else
-        int i;
-        int retval = 0;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        if (!KMP_AFFINITY_CAPABLE())
-            return 0;
-        if ( place_num < 0 || place_num >= (int)__kmp_affinity_num_masks )
-            return 0;
-        kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num);
-        KMP_CPU_SET_ITERATE(i, mask) {
-            if ((! KMP_CPU_ISSET(i, __kmp_affin_fullMask)) ||
-              (!KMP_CPU_ISSET(i, mask))) {
-                continue;
-            }
-            ++retval;
-        }
-        return retval;
-    #endif
-}
-
-void FTN_STDCALL
-FTN_GET_PLACE_PROC_IDS( int place_num, int *ids )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-    // Nothing.
-    #else
-        int i,j;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        if (!KMP_AFFINITY_CAPABLE())
-            return;
-        if ( place_num < 0 || place_num >= (int)__kmp_affinity_num_masks )
-            return;
-        kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num);
-        j = 0;
-        KMP_CPU_SET_ITERATE(i, mask) {
-            if ((! KMP_CPU_ISSET(i, __kmp_affin_fullMask)) ||
-              (!KMP_CPU_ISSET(i, mask))) {
-                continue;
-            }
-            ids[j++] = i;
-        }
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_PLACE_NUM( void )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return -1;
-    #else
-        int gtid;
-        kmp_info_t *thread;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        if (!KMP_AFFINITY_CAPABLE())
-            return -1;
-        gtid = __kmp_entry_gtid();
-        thread = __kmp_thread_from_gtid(gtid);
-        if ( thread->th.th_current_place < 0 )
-            return -1;
-        return thread->th.th_current_place;
-    #endif
-}
-
-int FTN_STDCALL
-FTN_GET_PARTITION_NUM_PLACES( void )
-{
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-        return 0;
-    #else
-        int gtid, num_places, first_place, last_place;
-        kmp_info_t *thread;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        if (!KMP_AFFINITY_CAPABLE())
-            return 0;
-        gtid = __kmp_entry_gtid();
-        thread = __kmp_thread_from_gtid(gtid);
-        first_place = thread->th.th_first_place;
-        last_place = thread->th.th_last_place;
-        if ( first_place < 0 || last_place < 0 )
-            return 0;
-        if ( first_place <= last_place )
-            num_places = last_place - first_place + 1;
-        else
-            num_places = __kmp_affinity_num_masks - first_place + last_place + 1;
-        return num_places;
-    #endif
-}
-
-void FTN_STDCALL
-FTN_GET_PARTITION_PLACE_NUMS( int *place_nums ) {
-    #if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
-    // Nothing.
-    #else
-        int i, gtid, place_num, first_place, last_place, start, end;
-        kmp_info_t *thread;
-        if ( ! TCR_4(__kmp_init_middle) ) {
-            __kmp_middle_initialize();
-        }
-        if (!KMP_AFFINITY_CAPABLE())
-            return;
-        gtid = __kmp_entry_gtid();
-        thread = __kmp_thread_from_gtid(gtid);
-        first_place = thread->th.th_first_place;
-        last_place = thread->th.th_last_place;
-        if ( first_place < 0 || last_place < 0 )
-            return;
-        if ( first_place <= last_place ) {
-            start = first_place;
-            end = last_place;
-        } else {
-            start = last_place;
-            end = first_place;
-        }
-        for (i = 0, place_num = start; place_num <= end; ++place_num, ++i) {
-            place_nums[i] = place_num;
-        }
-    #endif
-}
-#endif
-
-int FTN_STDCALL
-xexpand(FTN_GET_NUM_TEAMS)( void )
-{
-    #ifdef KMP_STUB
-        return 1;
-    #else
-        kmp_info_t *thr = __kmp_entry_thread();
-        if ( thr->th.th_teams_microtask ) {
-            kmp_team_t *team = thr->th.th_team;
-            int tlevel = thr->th.th_teams_level;
-            int ii = team->t.t_level;            // the level of the teams construct
-            int dd = team -> t.t_serialized;
-            int level = tlevel + 1;
-            KMP_DEBUG_ASSERT( ii >= tlevel );
-            while( ii > level )
-            {
-                for( dd = team -> t.t_serialized; ( dd > 0 ) && ( ii > level ); dd--, ii-- )
-                {
-                }
-                if( team -> t.t_serialized && ( !dd ) ) {
-                    team = team->t.t_parent;
-                    continue;
-                }
-                if( ii > level ) {
-                    team = team->t.t_parent;
-                    ii--;
-                }
-            }
-            if ( dd > 1 ) {
-                return 1;  // teams region is serialized ( 1 team of 1 thread ).
-            } else {
-                return team->t.t_parent->t.t_nproc;
-            }
-        } else {
-            return 1;
-        }
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_TEAM_NUM)( void )
-{
-    #ifdef KMP_STUB
-        return 0;
-    #else
-        kmp_info_t *thr = __kmp_entry_thread();
-        if ( thr->th.th_teams_microtask ) {
-            kmp_team_t *team = thr->th.th_team;
-            int tlevel = thr->th.th_teams_level; // the level of the teams construct
-            int ii = team->t.t_level;
-            int dd = team -> t.t_serialized;
-            int level = tlevel + 1;
-            KMP_DEBUG_ASSERT( ii >= tlevel );
-            while( ii > level )
-            {
-                for( dd = team -> t.t_serialized; ( dd > 0 ) && ( ii > level ); dd--, ii-- )
-                {
-                }
-                if( team -> t.t_serialized && ( !dd ) ) {
-                    team = team->t.t_parent;
-                    continue;
-                }
-                if( ii > level ) {
-                    team = team->t.t_parent;
-                    ii--;
-                }
-            }
-            if ( dd > 1 ) {
-                return 0;  // teams region is serialized ( 1 team of 1 thread ).
-            } else {
-                return team->t.t_master_tid;
-            }
-        } else {
-            return 0;
-        }
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_GET_DEFAULT_DEVICE)( void )
-{
-    #if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
-        return 0;
-    #else
-        return __kmp_entry_thread() -> th.th_current_task -> td_icvs.default_device;
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_SET_DEFAULT_DEVICE)( int KMP_DEREF arg )
-{
-    #if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
-    // Nothing.
-    #else
-        __kmp_entry_thread() -> th.th_current_task -> td_icvs.default_device = KMP_DEREF arg;
-    #endif
+int FTN_STDCALL FTN_GET_NUM_PLACES(void) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return 0;
+#else
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  if (!KMP_AFFINITY_CAPABLE())
+    return 0;
+  return __kmp_affinity_num_masks;
+#endif
 }
 
-#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
-
-int FTN_STDCALL
-FTN_GET_NUM_DEVICES( void )
-{
+int FTN_STDCALL FTN_GET_PLACE_NUM_PROCS(int place_num) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return 0;
+#else
+  int i;
+  int retval = 0;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  if (!KMP_AFFINITY_CAPABLE())
+    return 0;
+  if (place_num < 0 || place_num >= (int)__kmp_affinity_num_masks)
     return 0;
+  kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num);
+  KMP_CPU_SET_ITERATE(i, mask) {
+    if ((!KMP_CPU_ISSET(i, __kmp_affin_fullMask)) ||
+        (!KMP_CPU_ISSET(i, mask))) {
+      continue;
+    }
+    ++retval;
+  }
+  return retval;
+#endif
 }
 
-#endif // KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+void FTN_STDCALL FTN_GET_PLACE_PROC_IDS(int place_num, int *ids) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+// Nothing.
+#else
+  int i, j;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  if (!KMP_AFFINITY_CAPABLE())
+    return;
+  if (place_num < 0 || place_num >= (int)__kmp_affinity_num_masks)
+    return;
+  kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num);
+  j = 0;
+  KMP_CPU_SET_ITERATE(i, mask) {
+    if ((!KMP_CPU_ISSET(i, __kmp_affin_fullMask)) ||
+        (!KMP_CPU_ISSET(i, mask))) {
+      continue;
+    }
+    ids[j++] = i;
+  }
+#endif
+}
 
-#if ! KMP_OS_LINUX
+int FTN_STDCALL FTN_GET_PLACE_NUM(void) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return -1;
+#else
+  int gtid;
+  kmp_info_t *thread;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  if (!KMP_AFFINITY_CAPABLE())
+    return -1;
+  gtid = __kmp_entry_gtid();
+  thread = __kmp_thread_from_gtid(gtid);
+  if (thread->th.th_current_place < 0)
+    return -1;
+  return thread->th.th_current_place;
+#endif
+}
+
+int FTN_STDCALL FTN_GET_PARTITION_NUM_PLACES(void) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+  return 0;
+#else
+  int gtid, num_places, first_place, last_place;
+  kmp_info_t *thread;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  if (!KMP_AFFINITY_CAPABLE())
+    return 0;
+  gtid = __kmp_entry_gtid();
+  thread = __kmp_thread_from_gtid(gtid);
+  first_place = thread->th.th_first_place;
+  last_place = thread->th.th_last_place;
+  if (first_place < 0 || last_place < 0)
+    return 0;
+  if (first_place <= last_place)
+    num_places = last_place - first_place + 1;
+  else
+    num_places = __kmp_affinity_num_masks - first_place + last_place + 1;
+  return num_places;
+#endif
+}
 
-int FTN_STDCALL
-xexpand(FTN_IS_INITIAL_DEVICE)( void )
-{
+void FTN_STDCALL FTN_GET_PARTITION_PLACE_NUMS(int *place_nums) {
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
+// Nothing.
+#else
+  int i, gtid, place_num, first_place, last_place, start, end;
+  kmp_info_t *thread;
+  if (!TCR_4(__kmp_init_middle)) {
+    __kmp_middle_initialize();
+  }
+  if (!KMP_AFFINITY_CAPABLE())
+    return;
+  gtid = __kmp_entry_gtid();
+  thread = __kmp_thread_from_gtid(gtid);
+  first_place = thread->th.th_first_place;
+  last_place = thread->th.th_last_place;
+  if (first_place < 0 || last_place < 0)
+    return;
+  if (first_place <= last_place) {
+    start = first_place;
+    end = last_place;
+  } else {
+    start = last_place;
+    end = first_place;
+  }
+  for (i = 0, place_num = start; place_num <= end; ++place_num, ++i) {
+    place_nums[i] = place_num;
+  }
+#endif
+}
+#endif
+
+int FTN_STDCALL xexpand(FTN_GET_NUM_TEAMS)(void) {
+#ifdef KMP_STUB
+  return 1;
+#else
+  kmp_info_t *thr = __kmp_entry_thread();
+  if (thr->th.th_teams_microtask) {
+    kmp_team_t *team = thr->th.th_team;
+    int tlevel = thr->th.th_teams_level;
+    int ii = team->t.t_level; // the level of the teams construct
+    int dd = team->t.t_serialized;
+    int level = tlevel + 1;
+    KMP_DEBUG_ASSERT(ii >= tlevel);
+    while (ii > level) {
+      for (dd = team->t.t_serialized; (dd > 0) && (ii > level); dd--, ii--) {
+      }
+      if (team->t.t_serialized && (!dd)) {
+        team = team->t.t_parent;
+        continue;
+      }
+      if (ii > level) {
+        team = team->t.t_parent;
+        ii--;
+      }
+    }
+    if (dd > 1) {
+      return 1; // teams region is serialized ( 1 team of 1 thread ).
+    } else {
+      return team->t.t_parent->t.t_nproc;
+    }
+  } else {
     return 1;
+  }
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_TEAM_NUM)(void) {
+#ifdef KMP_STUB
+  return 0;
+#else
+  kmp_info_t *thr = __kmp_entry_thread();
+  if (thr->th.th_teams_microtask) {
+    kmp_team_t *team = thr->th.th_team;
+    int tlevel = thr->th.th_teams_level; // the level of the teams construct
+    int ii = team->t.t_level;
+    int dd = team->t.t_serialized;
+    int level = tlevel + 1;
+    KMP_DEBUG_ASSERT(ii >= tlevel);
+    while (ii > level) {
+      for (dd = team->t.t_serialized; (dd > 0) && (ii > level); dd--, ii--) {
+      }
+      if (team->t.t_serialized && (!dd)) {
+        team = team->t.t_parent;
+        continue;
+      }
+      if (ii > level) {
+        team = team->t.t_parent;
+        ii--;
+      }
+    }
+    if (dd > 1) {
+      return 0; // teams region is serialized ( 1 team of 1 thread ).
+    } else {
+      return team->t.t_master_tid;
+    }
+  } else {
+    return 0;
+  }
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_GET_DEFAULT_DEVICE)(void) {
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+  return 0;
+#else
+  return __kmp_entry_thread()->th.th_current_task->td_icvs.default_device;
+#endif
 }
 
+void FTN_STDCALL xexpand(FTN_SET_DEFAULT_DEVICE)(int KMP_DEREF arg) {
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+// Nothing.
+#else
+  __kmp_entry_thread()->th.th_current_task->td_icvs.default_device =
+      KMP_DEREF arg;
+#endif
+}
+
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+
+int FTN_STDCALL FTN_GET_NUM_DEVICES(void) { return 0; }
+
+#endif // KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+
+#if !KMP_OS_LINUX
+
+int FTN_STDCALL xexpand(FTN_IS_INITIAL_DEVICE)(void) { return 1; }
+
 #else
 
 // This internal function is used when the entry from the offload library
 // is not found.
-int _Offload_get_device_number( void )  __attribute__((weak));
+int _Offload_get_device_number(void) __attribute__((weak));
 
-int FTN_STDCALL
-xexpand(FTN_IS_INITIAL_DEVICE)( void )
-{
-    if( _Offload_get_device_number ) {
-        return _Offload_get_device_number() == -1;
-    } else {
-        return 1;
-    }
+int FTN_STDCALL xexpand(FTN_IS_INITIAL_DEVICE)(void) {
+  if (_Offload_get_device_number) {
+    return _Offload_get_device_number() == -1;
+  } else {
+    return 1;
+  }
 }
 
 #endif // ! KMP_OS_LINUX
@@ -964,57 +832,37 @@ xexpand(FTN_IS_INITIAL_DEVICE)( void )
 #if OMP_45_ENABLED && defined(KMP_STUB)
 // OpenMP 4.5 entries for stubs library
 
-int FTN_STDCALL
-FTN_GET_INITIAL_DEVICE(void)
-{
-   return -1;
-}
+int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) { return -1; }
 
 // As all *target* functions are C-only parameters always passed by value
-void * FTN_STDCALL
-FTN_TARGET_ALLOC(size_t size, int device_num)
-{
-    return 0;
-}
+void *FTN_STDCALL FTN_TARGET_ALLOC(size_t size, int device_num) { return 0; }
 
-void FTN_STDCALL
-FTN_TARGET_FREE(void * device_ptr, int device_num)
-{
-}
+void FTN_STDCALL FTN_TARGET_FREE(void *device_ptr, int device_num) {}
 
-int FTN_STDCALL
-FTN_TARGET_IS_PRESENT(void * ptr, int device_num)
-{
-   return 0;
-}
+int FTN_STDCALL FTN_TARGET_IS_PRESENT(void *ptr, int device_num) { return 0; }
 
-int FTN_STDCALL
-FTN_TARGET_MEMCPY(void *dst, void *src, size_t length, size_t  dst_offset,
-                  size_t src_offset, int dst_device, int src_device)
-{
-    return -1;
+int FTN_STDCALL FTN_TARGET_MEMCPY(void *dst, void *src, size_t length,
+                                  size_t dst_offset, size_t src_offset,
+                                  int dst_device, int src_device) {
+  return -1;
 }
 
-int FTN_STDCALL
-FTN_TARGET_MEMCPY_RECT(void *dst, void *src, size_t element_size, int num_dims,
-                       const size_t *volume, const size_t *dst_offsets,
-                       const size_t *src_offsets, const size_t *dst_dimensions,
-                       const size_t *src_dimensions, int dst_device, int src_device)
-{
-    return -1;
+int FTN_STDCALL FTN_TARGET_MEMCPY_RECT(
+    void *dst, void *src, size_t element_size, int num_dims,
+    const size_t *volume, const size_t *dst_offsets, const size_t *src_offsets,
+    const size_t *dst_dimensions, const size_t *src_dimensions, int dst_device,
+    int src_device) {
+  return -1;
 }
 
-int FTN_STDCALL
-FTN_TARGET_ASSOCIATE_PTR(void *host_ptr, void *device_ptr, size_t  size,
-                         size_t  device_offset, int device_num)
-{
-    return -1;
+int FTN_STDCALL FTN_TARGET_ASSOCIATE_PTR(void *host_ptr, void *device_ptr,
+                                         size_t size, size_t device_offset,
+                                         int device_num) {
+  return -1;
 }
 
-int FTN_STDCALL
-FTN_TARGET_DISASSOCIATE_PTR(void *host_ptr, int device_num)
-{
-    return -1;
+int FTN_STDCALL FTN_TARGET_DISASSOCIATE_PTR(void *host_ptr, int device_num) {
+  return -1;
 }
 #endif // OMP_45_ENABLED && defined(KMP_STUB)
 
@@ -1023,260 +871,222 @@ typedef enum { UNINIT = -1, UNLOCKED, LO
 #endif /* KMP_STUB */
 
 #if KMP_USE_DYNAMIC_LOCK
-void FTN_STDCALL
-FTN_INIT_LOCK_WITH_HINT( void **user_lock, uintptr_t KMP_DEREF hint )
-{
-    #ifdef KMP_STUB
-        *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
-    #else
-        __kmpc_init_lock_with_hint( NULL, __kmp_entry_gtid(), user_lock, KMP_DEREF hint );
-    #endif
-}
-
-void FTN_STDCALL
-FTN_INIT_NEST_LOCK_WITH_HINT( void **user_lock, uintptr_t KMP_DEREF hint )
-{
-    #ifdef KMP_STUB
-        *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
-    #else
-        __kmpc_init_nest_lock_with_hint( NULL, __kmp_entry_gtid(), user_lock, KMP_DEREF hint );
-    #endif
+void FTN_STDCALL FTN_INIT_LOCK_WITH_HINT(void **user_lock,
+                                         uintptr_t KMP_DEREF hint) {
+#ifdef KMP_STUB
+  *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
+#else
+  __kmpc_init_lock_with_hint(NULL, __kmp_entry_gtid(), user_lock,
+                             KMP_DEREF hint);
+#endif
+}
+
+void FTN_STDCALL FTN_INIT_NEST_LOCK_WITH_HINT(void **user_lock,
+                                              uintptr_t KMP_DEREF hint) {
+#ifdef KMP_STUB
+  *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
+#else
+  __kmpc_init_nest_lock_with_hint(NULL, __kmp_entry_gtid(), user_lock,
+                                  KMP_DEREF hint);
+#endif
 }
 #endif
 
 /* initialize the lock */
-void FTN_STDCALL
-xexpand(FTN_INIT_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
-    #else
-        __kmpc_init_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
+void FTN_STDCALL xexpand(FTN_INIT_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
+#else
+  __kmpc_init_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
 }
 
 /* initialize the lock */
-void FTN_STDCALL
-xexpand(FTN_INIT_NEST_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
-    #else
-        __kmpc_init_nest_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_DESTROY_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        *((kmp_stub_lock_t *)user_lock) = UNINIT;
-    #else
-        __kmpc_destroy_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_DESTROY_NEST_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        *((kmp_stub_lock_t *)user_lock) = UNINIT;
-    #else
-        __kmpc_destroy_nest_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_SET_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        if ( *((kmp_stub_lock_t *)user_lock) == UNINIT ) {
-            // TODO: Issue an error.
-        }; // if
-        if ( *((kmp_stub_lock_t *)user_lock) != UNLOCKED ) {
-            // TODO: Issue an error.
-        }; // if
-        *((kmp_stub_lock_t *)user_lock) = LOCKED;
-    #else
-        __kmpc_set_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_SET_NEST_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        if ( *((kmp_stub_lock_t *)user_lock) == UNINIT ) {
-            // TODO: Issue an error.
-        }; // if
-        (*((int *)user_lock))++;
-    #else
-        __kmpc_set_nest_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_UNSET_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        if ( *((kmp_stub_lock_t *)user_lock) == UNINIT ) {
-            // TODO: Issue an error.
-        }; // if
-        if ( *((kmp_stub_lock_t *)user_lock) == UNLOCKED ) {
-            // TODO: Issue an error.
-        }; // if
-        *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
-    #else
-        __kmpc_unset_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-void FTN_STDCALL
-xexpand(FTN_UNSET_NEST_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        if ( *((kmp_stub_lock_t *)user_lock) == UNINIT ) {
-            // TODO: Issue an error.
-        }; // if
-        if ( *((kmp_stub_lock_t *)user_lock) == UNLOCKED ) {
-            // TODO: Issue an error.
-        }; // if
-        (*((int *)user_lock))--;
-    #else
-        __kmpc_unset_nest_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_TEST_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        if ( *((kmp_stub_lock_t *)user_lock) == UNINIT ) {
-            // TODO: Issue an error.
-        }; // if
-        if ( *((kmp_stub_lock_t *)user_lock) == LOCKED ) {
-            return 0;
-        }; // if
-        *((kmp_stub_lock_t *)user_lock) = LOCKED;
-        return 1;
-    #else
-        return __kmpc_test_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-int FTN_STDCALL
-xexpand(FTN_TEST_NEST_LOCK)( void **user_lock )
-{
-    #ifdef KMP_STUB
-        if ( *((kmp_stub_lock_t *)user_lock) == UNINIT ) {
-            // TODO: Issue an error.
-        }; // if
-        return ++(*((int *)user_lock));
-    #else
-        return __kmpc_test_nest_lock( NULL, __kmp_entry_gtid(), user_lock );
-    #endif
-}
-
-double FTN_STDCALL
-xexpand(FTN_GET_WTIME)( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_wtime();
-    #else
-        double data;
-        #if ! KMP_OS_LINUX
-        // We don't need library initialization to get the time on Linux* OS.
-        // The routine can be used to measure library initialization time on Linux* OS now.
-        if ( ! __kmp_init_serial ) {
-            __kmp_serial_initialize();
-        };
-        #endif
-        __kmp_elapsed( & data );
-        return data;
-    #endif
-}
-
-double FTN_STDCALL
-xexpand(FTN_GET_WTICK)( void )
-{
-    #ifdef KMP_STUB
-        return __kmps_get_wtick();
-    #else
-        double data;
-        if ( ! __kmp_init_serial ) {
-            __kmp_serial_initialize();
-        };
-        __kmp_elapsed_tick( & data );
-        return data;
-    #endif
+void FTN_STDCALL xexpand(FTN_INIT_NEST_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
+#else
+  __kmpc_init_nest_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_DESTROY_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  *((kmp_stub_lock_t *)user_lock) = UNINIT;
+#else
+  __kmpc_destroy_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_DESTROY_NEST_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  *((kmp_stub_lock_t *)user_lock) = UNINIT;
+#else
+  __kmpc_destroy_nest_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_SET_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
+    // TODO: Issue an error.
+  }; // if
+  if (*((kmp_stub_lock_t *)user_lock) != UNLOCKED) {
+    // TODO: Issue an error.
+  }; // if
+  *((kmp_stub_lock_t *)user_lock) = LOCKED;
+#else
+  __kmpc_set_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_SET_NEST_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
+    // TODO: Issue an error.
+  }; // if
+  (*((int *)user_lock))++;
+#else
+  __kmpc_set_nest_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_UNSET_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
+    // TODO: Issue an error.
+  }; // if
+  if (*((kmp_stub_lock_t *)user_lock) == UNLOCKED) {
+    // TODO: Issue an error.
+  }; // if
+  *((kmp_stub_lock_t *)user_lock) = UNLOCKED;
+#else
+  __kmpc_unset_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+void FTN_STDCALL xexpand(FTN_UNSET_NEST_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
+    // TODO: Issue an error.
+  }; // if
+  if (*((kmp_stub_lock_t *)user_lock) == UNLOCKED) {
+    // TODO: Issue an error.
+  }; // if
+  (*((int *)user_lock))--;
+#else
+  __kmpc_unset_nest_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_TEST_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
+    // TODO: Issue an error.
+  }; // if
+  if (*((kmp_stub_lock_t *)user_lock) == LOCKED) {
+    return 0;
+  }; // if
+  *((kmp_stub_lock_t *)user_lock) = LOCKED;
+  return 1;
+#else
+  return __kmpc_test_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+int FTN_STDCALL xexpand(FTN_TEST_NEST_LOCK)(void **user_lock) {
+#ifdef KMP_STUB
+  if (*((kmp_stub_lock_t *)user_lock) == UNINIT) {
+    // TODO: Issue an error.
+  }; // if
+  return ++(*((int *)user_lock));
+#else
+  return __kmpc_test_nest_lock(NULL, __kmp_entry_gtid(), user_lock);
+#endif
+}
+
+double FTN_STDCALL xexpand(FTN_GET_WTIME)(void) {
+#ifdef KMP_STUB
+  return __kmps_get_wtime();
+#else
+  double data;
+#if !KMP_OS_LINUX
+  // We don't need library initialization to get the time on Linux* OS. The
+  // routine can be used to measure library initialization time on Linux* OS now
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  };
+#endif
+  __kmp_elapsed(&data);
+  return data;
+#endif
+}
+
+double FTN_STDCALL xexpand(FTN_GET_WTICK)(void) {
+#ifdef KMP_STUB
+  return __kmps_get_wtick();
+#else
+  double data;
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  };
+  __kmp_elapsed_tick(&data);
+  return data;
+#endif
 }
 
 /* ------------------------------------------------------------------------ */
 
-void * FTN_STDCALL
-FTN_MALLOC( size_t KMP_DEREF size )
-{
-    // kmpc_malloc initializes the library if needed
-    return kmpc_malloc( KMP_DEREF size );
-}
-
-void * FTN_STDCALL
-FTN_ALIGNED_MALLOC( size_t KMP_DEREF size, size_t KMP_DEREF alignment )
-{
-    // kmpc_aligned_malloc initializes the library if needed
-    return kmpc_aligned_malloc( KMP_DEREF size, KMP_DEREF alignment );
-}
-
-void * FTN_STDCALL
-FTN_CALLOC( size_t KMP_DEREF nelem, size_t KMP_DEREF elsize )
-{
-    // kmpc_calloc initializes the library if needed
-    return kmpc_calloc( KMP_DEREF nelem, KMP_DEREF elsize );
-}
-
-void * FTN_STDCALL
-FTN_REALLOC( void * KMP_DEREF ptr, size_t KMP_DEREF size )
-{
-    // kmpc_realloc initializes the library if needed
-    return kmpc_realloc( KMP_DEREF ptr, KMP_DEREF size );
-}
-
-void FTN_STDCALL
-FTN_FREE( void * KMP_DEREF ptr )
-{
-    // does nothing if the library is not initialized
-    kmpc_free( KMP_DEREF ptr );
-}
-
-void FTN_STDCALL
-FTN_SET_WARNINGS_ON( void )
-{
-    #ifndef KMP_STUB
-        __kmp_generate_warnings = kmp_warnings_explicit;
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_WARNINGS_OFF( void )
-{
-    #ifndef KMP_STUB
-        __kmp_generate_warnings = FALSE;
-    #endif
-}
-
-void FTN_STDCALL
-FTN_SET_DEFAULTS( char const * str
-    #ifndef PASS_ARGS_BY_VALUE
-        , int len
-    #endif
-)
-{
-    #ifndef KMP_STUB
-        #ifdef PASS_ARGS_BY_VALUE
-            int len = (int)KMP_STRLEN( str );
-        #endif
-        __kmp_aux_set_defaults( str, len );
-    #endif
+void *FTN_STDCALL FTN_MALLOC(size_t KMP_DEREF size) {
+  // kmpc_malloc initializes the library if needed
+  return kmpc_malloc(KMP_DEREF size);
+}
+
+void *FTN_STDCALL FTN_ALIGNED_MALLOC(size_t KMP_DEREF size,
+                                     size_t KMP_DEREF alignment) {
+  // kmpc_aligned_malloc initializes the library if needed
+  return kmpc_aligned_malloc(KMP_DEREF size, KMP_DEREF alignment);
+}
+
+void *FTN_STDCALL FTN_CALLOC(size_t KMP_DEREF nelem, size_t KMP_DEREF elsize) {
+  // kmpc_calloc initializes the library if needed
+  return kmpc_calloc(KMP_DEREF nelem, KMP_DEREF elsize);
+}
+
+void *FTN_STDCALL FTN_REALLOC(void *KMP_DEREF ptr, size_t KMP_DEREF size) {
+  // kmpc_realloc initializes the library if needed
+  return kmpc_realloc(KMP_DEREF ptr, KMP_DEREF size);
+}
+
+void FTN_STDCALL FTN_FREE(void *KMP_DEREF ptr) {
+  // does nothing if the library is not initialized
+  kmpc_free(KMP_DEREF ptr);
+}
+
+void FTN_STDCALL FTN_SET_WARNINGS_ON(void) {
+#ifndef KMP_STUB
+  __kmp_generate_warnings = kmp_warnings_explicit;
+#endif
+}
+
+void FTN_STDCALL FTN_SET_WARNINGS_OFF(void) {
+#ifndef KMP_STUB
+  __kmp_generate_warnings = FALSE;
+#endif
+}
+
+void FTN_STDCALL FTN_SET_DEFAULTS(char const *str
+#ifndef PASS_ARGS_BY_VALUE
+                                  ,
+                                  int len
+#endif
+                                  ) {
+#ifndef KMP_STUB
+#ifdef PASS_ARGS_BY_VALUE
+  int len = (int)KMP_STRLEN(str);
+#endif
+  __kmp_aux_set_defaults(str, len);
+#endif
 }
 
 /* ------------------------------------------------------------------------ */
@@ -1284,25 +1094,23 @@ FTN_SET_DEFAULTS( char const * str
 
 #if OMP_40_ENABLED
 /* returns the status of cancellation */
-int FTN_STDCALL
-xexpand(FTN_GET_CANCELLATION)(void) {
+int FTN_STDCALL xexpand(FTN_GET_CANCELLATION)(void) {
 #ifdef KMP_STUB
-    return 0 /* false */;
+  return 0 /* false */;
 #else
-    // initialize the library if needed
-    if ( ! __kmp_init_serial ) {
-        __kmp_serial_initialize();
-    }
-    return __kmp_omp_cancellation;
+  // initialize the library if needed
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  }
+  return __kmp_omp_cancellation;
 #endif
 }
 
-int FTN_STDCALL
-FTN_GET_CANCELLATION_STATUS(int cancel_kind) {
+int FTN_STDCALL FTN_GET_CANCELLATION_STATUS(int cancel_kind) {
 #ifdef KMP_STUB
-    return 0 /* false */;
+  return 0 /* false */;
 #else
-    return __kmp_get_cancellation_status(cancel_kind);
+  return __kmp_get_cancellation_status(cancel_kind);
 #endif
 }
 
@@ -1310,16 +1118,14 @@ FTN_GET_CANCELLATION_STATUS(int cancel_k
 
 #if OMP_45_ENABLED
 /* returns the maximum allowed task priority */
-int FTN_STDCALL
-FTN_GET_MAX_TASK_PRIORITY( void )
-{
+int FTN_STDCALL FTN_GET_MAX_TASK_PRIORITY(void) {
 #ifdef KMP_STUB
-    return 0;
+  return 0;
 #else
-    if ( ! __kmp_init_serial ) {
-        __kmp_serial_initialize();
-    }
-    return __kmp_max_task_priority;
+  if (!__kmp_init_serial) {
+    __kmp_serial_initialize();
+  }
+  return __kmp_max_task_priority;
 #endif
 }
 #endif
@@ -1327,68 +1133,70 @@ FTN_GET_MAX_TASK_PRIORITY( void )
 // GCC compatibility (versioned symbols)
 #ifdef KMP_USE_VERSION_SYMBOLS
 
-/*
-    These following sections create function aliases (dummy symbols) for the omp_* routines.
-    These aliases will then be versioned according to how libgomp ``versions'' its
-    symbols (OMP_1.0, OMP_2.0, OMP_3.0, ...) while also retaining the
-    default version which libomp uses: VERSION (defined in exports_so.txt)
-    If you want to see the versioned symbols for libgomp.so.1 then just type:
-
-    objdump -T /path/to/libgomp.so.1 | grep omp_
-
-    Example:
-    Step 1)  Create __kmp_api_omp_set_num_threads_10_alias
-             which is alias of __kmp_api_omp_set_num_threads
-    Step 2)  Set __kmp_api_omp_set_num_threads_10_alias to version: omp_set_num_threads at OMP_1.0
-    Step 2B) Set __kmp_api_omp_set_num_threads to default version : omp_set_num_threads@@VERSION
+/* These following sections create function aliases (dummy symbols) for the
+   omp_* routines. These aliases will then be versioned according to how
+   libgomp ``versions'' its symbols (OMP_1.0, OMP_2.0, OMP_3.0, ...) while also
+   retaining the default version which libomp uses: VERSION (defined in
+   exports_so.txt). If you want to see the versioned symbols for libgomp.so.1
+   then just type:
+
+   objdump -T /path/to/libgomp.so.1 | grep omp_
+
+   Example:
+   Step 1) Create __kmp_api_omp_set_num_threads_10_alias which is alias of
+     __kmp_api_omp_set_num_threads
+   Step 2) Set __kmp_api_omp_set_num_threads_10_alias to version:
+     omp_set_num_threads at OMP_1.0
+   Step 2B) Set __kmp_api_omp_set_num_threads to default version:
+     omp_set_num_threads@@VERSION
 */
 
 // OMP_1.0 aliases
-xaliasify(FTN_SET_NUM_THREADS,   10);
-xaliasify(FTN_GET_NUM_THREADS,   10);
-xaliasify(FTN_GET_MAX_THREADS,   10);
-xaliasify(FTN_GET_THREAD_NUM,    10);
-xaliasify(FTN_GET_NUM_PROCS,     10);
-xaliasify(FTN_IN_PARALLEL,       10);
-xaliasify(FTN_SET_DYNAMIC,       10);
-xaliasify(FTN_GET_DYNAMIC,       10);
-xaliasify(FTN_SET_NESTED,        10);
-xaliasify(FTN_GET_NESTED,        10);
-xaliasify(FTN_INIT_LOCK,         10);
-xaliasify(FTN_INIT_NEST_LOCK,    10);
-xaliasify(FTN_DESTROY_LOCK,      10);
+xaliasify(FTN_SET_NUM_THREADS, 10);
+xaliasify(FTN_GET_NUM_THREADS, 10);
+xaliasify(FTN_GET_MAX_THREADS, 10);
+xaliasify(FTN_GET_THREAD_NUM, 10);
+xaliasify(FTN_GET_NUM_PROCS, 10);
+xaliasify(FTN_IN_PARALLEL, 10);
+xaliasify(FTN_SET_DYNAMIC, 10);
+xaliasify(FTN_GET_DYNAMIC, 10);
+xaliasify(FTN_SET_NESTED, 10);
+xaliasify(FTN_GET_NESTED, 10);
+xaliasify(FTN_INIT_LOCK, 10);
+xaliasify(FTN_INIT_NEST_LOCK, 10);
+xaliasify(FTN_DESTROY_LOCK, 10);
 xaliasify(FTN_DESTROY_NEST_LOCK, 10);
-xaliasify(FTN_SET_LOCK,          10);
-xaliasify(FTN_SET_NEST_LOCK,     10);
-xaliasify(FTN_UNSET_LOCK,        10);
-xaliasify(FTN_UNSET_NEST_LOCK,   10);
-xaliasify(FTN_TEST_LOCK,         10);
-xaliasify(FTN_TEST_NEST_LOCK,    10);
+xaliasify(FTN_SET_LOCK, 10);
+xaliasify(FTN_SET_NEST_LOCK, 10);
+xaliasify(FTN_UNSET_LOCK, 10);
+xaliasify(FTN_UNSET_NEST_LOCK, 10);
+xaliasify(FTN_TEST_LOCK, 10);
+xaliasify(FTN_TEST_NEST_LOCK, 10);
 
 // OMP_2.0 aliases
 xaliasify(FTN_GET_WTICK, 20);
 xaliasify(FTN_GET_WTIME, 20);
 
 // OMP_3.0 aliases
-xaliasify(FTN_SET_SCHEDULE,            30);
-xaliasify(FTN_GET_SCHEDULE,            30);
-xaliasify(FTN_GET_THREAD_LIMIT,        30);
-xaliasify(FTN_SET_MAX_ACTIVE_LEVELS,   30);
-xaliasify(FTN_GET_MAX_ACTIVE_LEVELS,   30);
-xaliasify(FTN_GET_LEVEL,               30);
+xaliasify(FTN_SET_SCHEDULE, 30);
+xaliasify(FTN_GET_SCHEDULE, 30);
+xaliasify(FTN_GET_THREAD_LIMIT, 30);
+xaliasify(FTN_SET_MAX_ACTIVE_LEVELS, 30);
+xaliasify(FTN_GET_MAX_ACTIVE_LEVELS, 30);
+xaliasify(FTN_GET_LEVEL, 30);
 xaliasify(FTN_GET_ANCESTOR_THREAD_NUM, 30);
-xaliasify(FTN_GET_TEAM_SIZE,           30);
-xaliasify(FTN_GET_ACTIVE_LEVEL,        30);
-xaliasify(FTN_INIT_LOCK,               30);
-xaliasify(FTN_INIT_NEST_LOCK,          30);
-xaliasify(FTN_DESTROY_LOCK,            30);
-xaliasify(FTN_DESTROY_NEST_LOCK,       30);
-xaliasify(FTN_SET_LOCK,                30);
-xaliasify(FTN_SET_NEST_LOCK,           30);
-xaliasify(FTN_UNSET_LOCK,              30);
-xaliasify(FTN_UNSET_NEST_LOCK,         30);
-xaliasify(FTN_TEST_LOCK,               30);
-xaliasify(FTN_TEST_NEST_LOCK,          30);
+xaliasify(FTN_GET_TEAM_SIZE, 30);
+xaliasify(FTN_GET_ACTIVE_LEVEL, 30);
+xaliasify(FTN_INIT_LOCK, 30);
+xaliasify(FTN_INIT_NEST_LOCK, 30);
+xaliasify(FTN_DESTROY_LOCK, 30);
+xaliasify(FTN_DESTROY_NEST_LOCK, 30);
+xaliasify(FTN_SET_LOCK, 30);
+xaliasify(FTN_SET_NEST_LOCK, 30);
+xaliasify(FTN_UNSET_LOCK, 30);
+xaliasify(FTN_UNSET_NEST_LOCK, 30);
+xaliasify(FTN_TEST_LOCK, 30);
+xaliasify(FTN_TEST_NEST_LOCK, 30);
 
 // OMP_3.1 aliases
 xaliasify(FTN_IN_FINAL, 31);
@@ -1413,66 +1221,66 @@ xaliasify(FTN_IS_INITIAL_DEVICE, 40);
 #endif
 
 // OMP_1.0 versioned symbols
-xversionify(FTN_SET_NUM_THREADS,   10, "OMP_1.0");
-xversionify(FTN_GET_NUM_THREADS,   10, "OMP_1.0");
-xversionify(FTN_GET_MAX_THREADS,   10, "OMP_1.0");
-xversionify(FTN_GET_THREAD_NUM,    10, "OMP_1.0");
-xversionify(FTN_GET_NUM_PROCS,     10, "OMP_1.0");
-xversionify(FTN_IN_PARALLEL,       10, "OMP_1.0");
-xversionify(FTN_SET_DYNAMIC,       10, "OMP_1.0");
-xversionify(FTN_GET_DYNAMIC,       10, "OMP_1.0");
-xversionify(FTN_SET_NESTED,        10, "OMP_1.0");
-xversionify(FTN_GET_NESTED,        10, "OMP_1.0");
-xversionify(FTN_INIT_LOCK,         10, "OMP_1.0");
-xversionify(FTN_INIT_NEST_LOCK,    10, "OMP_1.0");
-xversionify(FTN_DESTROY_LOCK,      10, "OMP_1.0");
+xversionify(FTN_SET_NUM_THREADS, 10, "OMP_1.0");
+xversionify(FTN_GET_NUM_THREADS, 10, "OMP_1.0");
+xversionify(FTN_GET_MAX_THREADS, 10, "OMP_1.0");
+xversionify(FTN_GET_THREAD_NUM, 10, "OMP_1.0");
+xversionify(FTN_GET_NUM_PROCS, 10, "OMP_1.0");
+xversionify(FTN_IN_PARALLEL, 10, "OMP_1.0");
+xversionify(FTN_SET_DYNAMIC, 10, "OMP_1.0");
+xversionify(FTN_GET_DYNAMIC, 10, "OMP_1.0");
+xversionify(FTN_SET_NESTED, 10, "OMP_1.0");
+xversionify(FTN_GET_NESTED, 10, "OMP_1.0");
+xversionify(FTN_INIT_LOCK, 10, "OMP_1.0");
+xversionify(FTN_INIT_NEST_LOCK, 10, "OMP_1.0");
+xversionify(FTN_DESTROY_LOCK, 10, "OMP_1.0");
 xversionify(FTN_DESTROY_NEST_LOCK, 10, "OMP_1.0");
-xversionify(FTN_SET_LOCK,          10, "OMP_1.0");
-xversionify(FTN_SET_NEST_LOCK,     10, "OMP_1.0");
-xversionify(FTN_UNSET_LOCK,        10, "OMP_1.0");
-xversionify(FTN_UNSET_NEST_LOCK,   10, "OMP_1.0");
-xversionify(FTN_TEST_LOCK,         10, "OMP_1.0");
-xversionify(FTN_TEST_NEST_LOCK,    10, "OMP_1.0");
+xversionify(FTN_SET_LOCK, 10, "OMP_1.0");
+xversionify(FTN_SET_NEST_LOCK, 10, "OMP_1.0");
+xversionify(FTN_UNSET_LOCK, 10, "OMP_1.0");
+xversionify(FTN_UNSET_NEST_LOCK, 10, "OMP_1.0");
+xversionify(FTN_TEST_LOCK, 10, "OMP_1.0");
+xversionify(FTN_TEST_NEST_LOCK, 10, "OMP_1.0");
 
 // OMP_2.0 versioned symbols
-xversionify(FTN_GET_WTICK,         20, "OMP_2.0");
-xversionify(FTN_GET_WTIME,         20, "OMP_2.0");
+xversionify(FTN_GET_WTICK, 20, "OMP_2.0");
+xversionify(FTN_GET_WTIME, 20, "OMP_2.0");
 
 // OMP_3.0 versioned symbols
-xversionify(FTN_SET_SCHEDULE,      30, "OMP_3.0");
-xversionify(FTN_GET_SCHEDULE,      30, "OMP_3.0");
-xversionify(FTN_GET_THREAD_LIMIT,        30, "OMP_3.0");
-xversionify(FTN_SET_MAX_ACTIVE_LEVELS,   30, "OMP_3.0");
-xversionify(FTN_GET_MAX_ACTIVE_LEVELS,   30, "OMP_3.0");
+xversionify(FTN_SET_SCHEDULE, 30, "OMP_3.0");
+xversionify(FTN_GET_SCHEDULE, 30, "OMP_3.0");
+xversionify(FTN_GET_THREAD_LIMIT, 30, "OMP_3.0");
+xversionify(FTN_SET_MAX_ACTIVE_LEVELS, 30, "OMP_3.0");
+xversionify(FTN_GET_MAX_ACTIVE_LEVELS, 30, "OMP_3.0");
 xversionify(FTN_GET_ANCESTOR_THREAD_NUM, 30, "OMP_3.0");
-xversionify(FTN_GET_LEVEL,               30, "OMP_3.0");
-xversionify(FTN_GET_TEAM_SIZE,     30, "OMP_3.0");
-xversionify(FTN_GET_ACTIVE_LEVEL,  30, "OMP_3.0");
+xversionify(FTN_GET_LEVEL, 30, "OMP_3.0");
+xversionify(FTN_GET_TEAM_SIZE, 30, "OMP_3.0");
+xversionify(FTN_GET_ACTIVE_LEVEL, 30, "OMP_3.0");
 
 // the lock routines have a 1.0 and 3.0 version
-xversionify(FTN_INIT_LOCK,         30, "OMP_3.0");
-xversionify(FTN_INIT_NEST_LOCK,    30, "OMP_3.0");
-xversionify(FTN_DESTROY_LOCK,      30, "OMP_3.0");
+xversionify(FTN_INIT_LOCK, 30, "OMP_3.0");
+xversionify(FTN_INIT_NEST_LOCK, 30, "OMP_3.0");
+xversionify(FTN_DESTROY_LOCK, 30, "OMP_3.0");
 xversionify(FTN_DESTROY_NEST_LOCK, 30, "OMP_3.0");
-xversionify(FTN_SET_LOCK,          30, "OMP_3.0");
-xversionify(FTN_SET_NEST_LOCK,     30, "OMP_3.0");
-xversionify(FTN_UNSET_LOCK,        30, "OMP_3.0");
-xversionify(FTN_UNSET_NEST_LOCK,   30, "OMP_3.0");
-xversionify(FTN_TEST_LOCK,         30, "OMP_3.0");
-xversionify(FTN_TEST_NEST_LOCK,    30, "OMP_3.0");
+xversionify(FTN_SET_LOCK, 30, "OMP_3.0");
+xversionify(FTN_SET_NEST_LOCK, 30, "OMP_3.0");
+xversionify(FTN_UNSET_LOCK, 30, "OMP_3.0");
+xversionify(FTN_UNSET_NEST_LOCK, 30, "OMP_3.0");
+xversionify(FTN_TEST_LOCK, 30, "OMP_3.0");
+xversionify(FTN_TEST_NEST_LOCK, 30, "OMP_3.0");
 
 // OMP_3.1 versioned symbol
-xversionify(FTN_IN_FINAL,          31, "OMP_3.1");
+xversionify(FTN_IN_FINAL, 31, "OMP_3.1");
 
 #if OMP_40_ENABLED
 // OMP_4.0 versioned symbols
-xversionify(FTN_GET_PROC_BIND,      40, "OMP_4.0");
-xversionify(FTN_GET_NUM_TEAMS,      40, "OMP_4.0");
-xversionify(FTN_GET_TEAM_NUM,       40, "OMP_4.0");
-xversionify(FTN_GET_CANCELLATION,   40, "OMP_4.0");
+xversionify(FTN_GET_PROC_BIND, 40, "OMP_4.0");
+xversionify(FTN_GET_NUM_TEAMS, 40, "OMP_4.0");
+xversionify(FTN_GET_TEAM_NUM, 40, "OMP_4.0");
+xversionify(FTN_GET_CANCELLATION, 40, "OMP_4.0");
 xversionify(FTN_GET_DEFAULT_DEVICE, 40, "OMP_4.0");
 xversionify(FTN_SET_DEFAULT_DEVICE, 40, "OMP_4.0");
-xversionify(FTN_IS_INITIAL_DEVICE,  40, "OMP_4.0");
+xversionify(FTN_IS_INITIAL_DEVICE, 40, "OMP_4.0");
 #endif /* OMP_40_ENABLED */
 
 #if OMP_45_ENABLED
@@ -1486,7 +1294,7 @@ xversionify(FTN_IS_INITIAL_DEVICE,  40,
 #endif // KMP_USE_VERSION_SYMBOLS
 
 #ifdef __cplusplus
-    } //extern "C"
+} // extern "C"
 #endif // __cplusplus
 
 // end of file //

Modified: openmp/trunk/runtime/src/kmp_ftn_extra.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_ftn_extra.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_ftn_extra.cpp (original)
+++ openmp/trunk/runtime/src/kmp_ftn_extra.cpp Fri May 12 13:01:32 2017
@@ -17,18 +17,19 @@
 #include "kmp_affinity.h"
 
 #if KMP_OS_WINDOWS
-#   define KMP_FTN_ENTRIES KMP_FTN_PLAIN
+#define KMP_FTN_ENTRIES KMP_FTN_PLAIN
 #elif KMP_OS_UNIX
-#   define KMP_FTN_ENTRIES KMP_FTN_APPEND
+#define KMP_FTN_ENTRIES KMP_FTN_APPEND
 #endif
 
 // Note: This string is not printed when KMP_VERSION=1.
-char const __kmp_version_ftnextra[] = KMP_VERSION_PREFIX "Fortran \"extra\" OMP support: "
+char const __kmp_version_ftnextra[] =
+    KMP_VERSION_PREFIX "Fortran \"extra\" OMP support: "
 #ifdef KMP_FTN_ENTRIES
-    "yes";
-#   define FTN_STDCALL /* nothing to do */
-#   include "kmp_ftn_os.h"
-#   include "kmp_ftn_entry.h"
+                       "yes";
+#define FTN_STDCALL /* nothing to do */
+#include "kmp_ftn_os.h"
+#include "kmp_ftn_entry.h"
 #else
-    "no";
+                       "no";
 #endif /* KMP_FTN_ENTRIES */

Modified: openmp/trunk/runtime/src/kmp_ftn_os.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_ftn_os.h?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_ftn_os.h (original)
+++ openmp/trunk/runtime/src/kmp_ftn_os.h Fri May 12 13:01:32 2017
@@ -16,123 +16,123 @@
 #ifndef KMP_FTN_OS_H
 #define KMP_FTN_OS_H
 
-// KMP_FNT_ENTRIES may be one of: KMP_FTN_PLAIN, KMP_FTN_UPPER, KMP_FTN_APPEND, KMP_FTN_UAPPEND.
-
+// KMP_FNT_ENTRIES may be one of: KMP_FTN_PLAIN, KMP_FTN_UPPER, KMP_FTN_APPEND,
+// KMP_FTN_UAPPEND.
 
 /* -------------------------- External definitions ------------------------ */
 
 #if KMP_FTN_ENTRIES == KMP_FTN_PLAIN
 
-    #define FTN_SET_STACKSIZE                    kmp_set_stacksize
-    #define FTN_SET_STACKSIZE_S                  kmp_set_stacksize_s
-    #define FTN_GET_STACKSIZE                    kmp_get_stacksize
-    #define FTN_GET_STACKSIZE_S                  kmp_get_stacksize_s
-    #define FTN_SET_BLOCKTIME                    kmp_set_blocktime
-    #define FTN_GET_BLOCKTIME                    kmp_get_blocktime
-    #define FTN_SET_LIBRARY_SERIAL               kmp_set_library_serial
-    #define FTN_SET_LIBRARY_TURNAROUND           kmp_set_library_turnaround
-    #define FTN_SET_LIBRARY_THROUGHPUT           kmp_set_library_throughput
-    #define FTN_SET_LIBRARY                      kmp_set_library
-    #define FTN_GET_LIBRARY                      kmp_get_library
-    #define FTN_SET_DEFAULTS                     kmp_set_defaults
-    #define FTN_SET_DISP_NUM_BUFFERS             kmp_set_disp_num_buffers
-    #define FTN_SET_AFFINITY                     kmp_set_affinity
-    #define FTN_GET_AFFINITY                     kmp_get_affinity
-    #define FTN_GET_AFFINITY_MAX_PROC            kmp_get_affinity_max_proc
-    #define FTN_CREATE_AFFINITY_MASK             kmp_create_affinity_mask
-    #define FTN_DESTROY_AFFINITY_MASK            kmp_destroy_affinity_mask
-    #define FTN_SET_AFFINITY_MASK_PROC           kmp_set_affinity_mask_proc
-    #define FTN_UNSET_AFFINITY_MASK_PROC         kmp_unset_affinity_mask_proc
-    #define FTN_GET_AFFINITY_MASK_PROC           kmp_get_affinity_mask_proc
-
-    #define FTN_MALLOC                           kmp_malloc
-    #define FTN_ALIGNED_MALLOC                   kmp_aligned_malloc
-    #define FTN_CALLOC                           kmp_calloc
-    #define FTN_REALLOC                          kmp_realloc
-    #define FTN_FREE                             kmp_free
-
-    #define FTN_GET_NUM_KNOWN_THREADS            kmp_get_num_known_threads
-
-    #define FTN_SET_NUM_THREADS                  omp_set_num_threads
-    #define FTN_GET_NUM_THREADS                  omp_get_num_threads
-    #define FTN_GET_MAX_THREADS                  omp_get_max_threads
-    #define FTN_GET_THREAD_NUM                   omp_get_thread_num
-    #define FTN_GET_NUM_PROCS                    omp_get_num_procs
-    #define FTN_SET_DYNAMIC                      omp_set_dynamic
-    #define FTN_GET_DYNAMIC                      omp_get_dynamic
-    #define FTN_SET_NESTED                       omp_set_nested
-    #define FTN_GET_NESTED                       omp_get_nested
-    #define FTN_IN_PARALLEL                      omp_in_parallel
-    #define FTN_GET_THREAD_LIMIT                 omp_get_thread_limit
-    #define FTN_SET_SCHEDULE                     omp_set_schedule
-    #define FTN_GET_SCHEDULE                     omp_get_schedule
-    #define FTN_SET_MAX_ACTIVE_LEVELS            omp_set_max_active_levels
-    #define FTN_GET_MAX_ACTIVE_LEVELS            omp_get_max_active_levels
-    #define FTN_GET_ACTIVE_LEVEL                 omp_get_active_level
-    #define FTN_GET_LEVEL                        omp_get_level
-    #define FTN_GET_ANCESTOR_THREAD_NUM          omp_get_ancestor_thread_num
-    #define FTN_GET_TEAM_SIZE                    omp_get_team_size
-    #define FTN_IN_FINAL                         omp_in_final
+#define FTN_SET_STACKSIZE kmp_set_stacksize
+#define FTN_SET_STACKSIZE_S kmp_set_stacksize_s
+#define FTN_GET_STACKSIZE kmp_get_stacksize
+#define FTN_GET_STACKSIZE_S kmp_get_stacksize_s
+#define FTN_SET_BLOCKTIME kmp_set_blocktime
+#define FTN_GET_BLOCKTIME kmp_get_blocktime
+#define FTN_SET_LIBRARY_SERIAL kmp_set_library_serial
+#define FTN_SET_LIBRARY_TURNAROUND kmp_set_library_turnaround
+#define FTN_SET_LIBRARY_THROUGHPUT kmp_set_library_throughput
+#define FTN_SET_LIBRARY kmp_set_library
+#define FTN_GET_LIBRARY kmp_get_library
+#define FTN_SET_DEFAULTS kmp_set_defaults
+#define FTN_SET_DISP_NUM_BUFFERS kmp_set_disp_num_buffers
+#define FTN_SET_AFFINITY kmp_set_affinity
+#define FTN_GET_AFFINITY kmp_get_affinity
+#define FTN_GET_AFFINITY_MAX_PROC kmp_get_affinity_max_proc
+#define FTN_CREATE_AFFINITY_MASK kmp_create_affinity_mask
+#define FTN_DESTROY_AFFINITY_MASK kmp_destroy_affinity_mask
+#define FTN_SET_AFFINITY_MASK_PROC kmp_set_affinity_mask_proc
+#define FTN_UNSET_AFFINITY_MASK_PROC kmp_unset_affinity_mask_proc
+#define FTN_GET_AFFINITY_MASK_PROC kmp_get_affinity_mask_proc
+
+#define FTN_MALLOC kmp_malloc
+#define FTN_ALIGNED_MALLOC kmp_aligned_malloc
+#define FTN_CALLOC kmp_calloc
+#define FTN_REALLOC kmp_realloc
+#define FTN_FREE kmp_free
+
+#define FTN_GET_NUM_KNOWN_THREADS kmp_get_num_known_threads
+
+#define FTN_SET_NUM_THREADS omp_set_num_threads
+#define FTN_GET_NUM_THREADS omp_get_num_threads
+#define FTN_GET_MAX_THREADS omp_get_max_threads
+#define FTN_GET_THREAD_NUM omp_get_thread_num
+#define FTN_GET_NUM_PROCS omp_get_num_procs
+#define FTN_SET_DYNAMIC omp_set_dynamic
+#define FTN_GET_DYNAMIC omp_get_dynamic
+#define FTN_SET_NESTED omp_set_nested
+#define FTN_GET_NESTED omp_get_nested
+#define FTN_IN_PARALLEL omp_in_parallel
+#define FTN_GET_THREAD_LIMIT omp_get_thread_limit
+#define FTN_SET_SCHEDULE omp_set_schedule
+#define FTN_GET_SCHEDULE omp_get_schedule
+#define FTN_SET_MAX_ACTIVE_LEVELS omp_set_max_active_levels
+#define FTN_GET_MAX_ACTIVE_LEVELS omp_get_max_active_levels
+#define FTN_GET_ACTIVE_LEVEL omp_get_active_level
+#define FTN_GET_LEVEL omp_get_level
+#define FTN_GET_ANCESTOR_THREAD_NUM omp_get_ancestor_thread_num
+#define FTN_GET_TEAM_SIZE omp_get_team_size
+#define FTN_IN_FINAL omp_in_final
 //  #define FTN_SET_PROC_BIND                    omp_set_proc_bind
-    #define FTN_GET_PROC_BIND                    omp_get_proc_bind
+#define FTN_GET_PROC_BIND omp_get_proc_bind
 //  #define FTN_CURR_PROC_BIND                   omp_curr_proc_bind
 #if OMP_40_ENABLED
-    #define FTN_GET_NUM_TEAMS                    omp_get_num_teams
-    #define FTN_GET_TEAM_NUM                     omp_get_team_num
+#define FTN_GET_NUM_TEAMS omp_get_num_teams
+#define FTN_GET_TEAM_NUM omp_get_team_num
 #endif
-    #define FTN_INIT_LOCK                        omp_init_lock
+#define FTN_INIT_LOCK omp_init_lock
 #if KMP_USE_DYNAMIC_LOCK
-    #define FTN_INIT_LOCK_WITH_HINT              omp_init_lock_with_hint
-    #define FTN_INIT_NEST_LOCK_WITH_HINT         omp_init_nest_lock_with_hint
+#define FTN_INIT_LOCK_WITH_HINT omp_init_lock_with_hint
+#define FTN_INIT_NEST_LOCK_WITH_HINT omp_init_nest_lock_with_hint
 #endif
-    #define FTN_DESTROY_LOCK                     omp_destroy_lock
-    #define FTN_SET_LOCK                         omp_set_lock
-    #define FTN_UNSET_LOCK                       omp_unset_lock
-    #define FTN_TEST_LOCK                        omp_test_lock
-    #define FTN_INIT_NEST_LOCK                   omp_init_nest_lock
-    #define FTN_DESTROY_NEST_LOCK                omp_destroy_nest_lock
-    #define FTN_SET_NEST_LOCK                    omp_set_nest_lock
-    #define FTN_UNSET_NEST_LOCK                  omp_unset_nest_lock
-    #define FTN_TEST_NEST_LOCK                   omp_test_nest_lock
+#define FTN_DESTROY_LOCK omp_destroy_lock
+#define FTN_SET_LOCK omp_set_lock
+#define FTN_UNSET_LOCK omp_unset_lock
+#define FTN_TEST_LOCK omp_test_lock
+#define FTN_INIT_NEST_LOCK omp_init_nest_lock
+#define FTN_DESTROY_NEST_LOCK omp_destroy_nest_lock
+#define FTN_SET_NEST_LOCK omp_set_nest_lock
+#define FTN_UNSET_NEST_LOCK omp_unset_nest_lock
+#define FTN_TEST_NEST_LOCK omp_test_nest_lock
 
-    #define FTN_SET_WARNINGS_ON                  kmp_set_warnings_on
-    #define FTN_SET_WARNINGS_OFF                 kmp_set_warnings_off
+#define FTN_SET_WARNINGS_ON kmp_set_warnings_on
+#define FTN_SET_WARNINGS_OFF kmp_set_warnings_off
 
-    #define FTN_GET_WTIME                        omp_get_wtime
-    #define FTN_GET_WTICK                        omp_get_wtick
+#define FTN_GET_WTIME omp_get_wtime
+#define FTN_GET_WTICK omp_get_wtick
 
 #if OMP_40_ENABLED
 #if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
-    #define FTN_GET_NUM_DEVICES                  omp_get_num_devices
+#define FTN_GET_NUM_DEVICES omp_get_num_devices
 #endif
-    #define FTN_GET_DEFAULT_DEVICE               omp_get_default_device
-    #define FTN_SET_DEFAULT_DEVICE               omp_set_default_device
-    #define FTN_IS_INITIAL_DEVICE                omp_is_initial_device
+#define FTN_GET_DEFAULT_DEVICE omp_get_default_device
+#define FTN_SET_DEFAULT_DEVICE omp_set_default_device
+#define FTN_IS_INITIAL_DEVICE omp_is_initial_device
 #endif
 
 #if OMP_40_ENABLED
-    #define FTN_GET_CANCELLATION                 omp_get_cancellation
-    #define FTN_GET_CANCELLATION_STATUS          kmp_get_cancellation_status
+#define FTN_GET_CANCELLATION omp_get_cancellation
+#define FTN_GET_CANCELLATION_STATUS kmp_get_cancellation_status
 #endif
 
 #if OMP_45_ENABLED
-    #define FTN_GET_MAX_TASK_PRIORITY            omp_get_max_task_priority
-    #define FTN_GET_NUM_PLACES                   omp_get_num_places
-    #define FTN_GET_PLACE_NUM_PROCS              omp_get_place_num_procs
-    #define FTN_GET_PLACE_PROC_IDS               omp_get_place_proc_ids
-    #define FTN_GET_PLACE_NUM                    omp_get_place_num
-    #define FTN_GET_PARTITION_NUM_PLACES         omp_get_partition_num_places
-    #define FTN_GET_PARTITION_PLACE_NUMS         omp_get_partition_place_nums
-# ifdef KMP_STUB
-    #define FTN_GET_INITIAL_DEVICE               omp_get_initial_device
-    #define FTN_TARGET_ALLOC                     omp_target_alloc
-    #define FTN_TARGET_FREE                      omp_target_free
-    #define FTN_TARGET_IS_PRESENT                omp_target_is_present
-    #define FTN_TARGET_MEMCPY                    omp_target_memcpy
-    #define FTN_TARGET_MEMCPY_RECT               omp_target_memcpy_rect
-    #define FTN_TARGET_ASSOCIATE_PTR             omp_target_associate_ptr
-    #define FTN_TARGET_DISASSOCIATE_PTR          omp_target_disassociate_ptr
-# endif
+#define FTN_GET_MAX_TASK_PRIORITY omp_get_max_task_priority
+#define FTN_GET_NUM_PLACES omp_get_num_places
+#define FTN_GET_PLACE_NUM_PROCS omp_get_place_num_procs
+#define FTN_GET_PLACE_PROC_IDS omp_get_place_proc_ids
+#define FTN_GET_PLACE_NUM omp_get_place_num
+#define FTN_GET_PARTITION_NUM_PLACES omp_get_partition_num_places
+#define FTN_GET_PARTITION_PLACE_NUMS omp_get_partition_place_nums
+#ifdef KMP_STUB
+#define FTN_GET_INITIAL_DEVICE omp_get_initial_device
+#define FTN_TARGET_ALLOC omp_target_alloc
+#define FTN_TARGET_FREE omp_target_free
+#define FTN_TARGET_IS_PRESENT omp_target_is_present
+#define FTN_TARGET_MEMCPY omp_target_memcpy
+#define FTN_TARGET_MEMCPY_RECT omp_target_memcpy_rect
+#define FTN_TARGET_ASSOCIATE_PTR omp_target_associate_ptr
+#define FTN_TARGET_DISASSOCIATE_PTR omp_target_disassociate_ptr
+#endif
 #endif
 
 #endif /* KMP_FTN_PLAIN */
@@ -141,117 +141,117 @@
 
 #if KMP_FTN_ENTRIES == KMP_FTN_APPEND
 
-    #define FTN_SET_STACKSIZE                    kmp_set_stacksize_
-    #define FTN_SET_STACKSIZE_S                  kmp_set_stacksize_s_
-    #define FTN_GET_STACKSIZE                    kmp_get_stacksize_
-    #define FTN_GET_STACKSIZE_S                  kmp_get_stacksize_s_
-    #define FTN_SET_BLOCKTIME                    kmp_set_blocktime_
-    #define FTN_GET_BLOCKTIME                    kmp_get_blocktime_
-    #define FTN_SET_LIBRARY_SERIAL               kmp_set_library_serial_
-    #define FTN_SET_LIBRARY_TURNAROUND           kmp_set_library_turnaround_
-    #define FTN_SET_LIBRARY_THROUGHPUT           kmp_set_library_throughput_
-    #define FTN_SET_LIBRARY                      kmp_set_library_
-    #define FTN_GET_LIBRARY                      kmp_get_library_
-    #define FTN_SET_DEFAULTS                     kmp_set_defaults_
-    #define FTN_SET_DISP_NUM_BUFFERS             kmp_set_disp_num_buffers_
-    #define FTN_SET_AFFINITY                     kmp_set_affinity_
-    #define FTN_GET_AFFINITY                     kmp_get_affinity_
-    #define FTN_GET_AFFINITY_MAX_PROC            kmp_get_affinity_max_proc_
-    #define FTN_CREATE_AFFINITY_MASK             kmp_create_affinity_mask_
-    #define FTN_DESTROY_AFFINITY_MASK            kmp_destroy_affinity_mask_
-    #define FTN_SET_AFFINITY_MASK_PROC           kmp_set_affinity_mask_proc_
-    #define FTN_UNSET_AFFINITY_MASK_PROC         kmp_unset_affinity_mask_proc_
-    #define FTN_GET_AFFINITY_MASK_PROC           kmp_get_affinity_mask_proc_
-
-    #define FTN_MALLOC                           kmp_malloc_
-    #define FTN_ALIGNED_MALLOC                   kmp_aligned_malloc_
-    #define FTN_CALLOC                           kmp_calloc_
-    #define FTN_REALLOC                          kmp_realloc_
-    #define FTN_FREE                             kmp_free_
-
-    #define FTN_GET_NUM_KNOWN_THREADS            kmp_get_num_known_threads_
-
-    #define FTN_SET_NUM_THREADS                  omp_set_num_threads_
-    #define FTN_GET_NUM_THREADS                  omp_get_num_threads_
-    #define FTN_GET_MAX_THREADS                  omp_get_max_threads_
-    #define FTN_GET_THREAD_NUM                   omp_get_thread_num_
-    #define FTN_GET_NUM_PROCS                    omp_get_num_procs_
-    #define FTN_SET_DYNAMIC                      omp_set_dynamic_
-    #define FTN_GET_DYNAMIC                      omp_get_dynamic_
-    #define FTN_SET_NESTED                       omp_set_nested_
-    #define FTN_GET_NESTED                       omp_get_nested_
-    #define FTN_IN_PARALLEL                      omp_in_parallel_
-    #define FTN_GET_THREAD_LIMIT                 omp_get_thread_limit_
-    #define FTN_SET_SCHEDULE                     omp_set_schedule_
-    #define FTN_GET_SCHEDULE                     omp_get_schedule_
-    #define FTN_SET_MAX_ACTIVE_LEVELS            omp_set_max_active_levels_
-    #define FTN_GET_MAX_ACTIVE_LEVELS            omp_get_max_active_levels_
-    #define FTN_GET_ACTIVE_LEVEL                 omp_get_active_level_
-    #define FTN_GET_LEVEL                        omp_get_level_
-    #define FTN_GET_ANCESTOR_THREAD_NUM          omp_get_ancestor_thread_num_
-    #define FTN_GET_TEAM_SIZE                    omp_get_team_size_
-    #define FTN_IN_FINAL                         omp_in_final_
+#define FTN_SET_STACKSIZE kmp_set_stacksize_
+#define FTN_SET_STACKSIZE_S kmp_set_stacksize_s_
+#define FTN_GET_STACKSIZE kmp_get_stacksize_
+#define FTN_GET_STACKSIZE_S kmp_get_stacksize_s_
+#define FTN_SET_BLOCKTIME kmp_set_blocktime_
+#define FTN_GET_BLOCKTIME kmp_get_blocktime_
+#define FTN_SET_LIBRARY_SERIAL kmp_set_library_serial_
+#define FTN_SET_LIBRARY_TURNAROUND kmp_set_library_turnaround_
+#define FTN_SET_LIBRARY_THROUGHPUT kmp_set_library_throughput_
+#define FTN_SET_LIBRARY kmp_set_library_
+#define FTN_GET_LIBRARY kmp_get_library_
+#define FTN_SET_DEFAULTS kmp_set_defaults_
+#define FTN_SET_DISP_NUM_BUFFERS kmp_set_disp_num_buffers_
+#define FTN_SET_AFFINITY kmp_set_affinity_
+#define FTN_GET_AFFINITY kmp_get_affinity_
+#define FTN_GET_AFFINITY_MAX_PROC kmp_get_affinity_max_proc_
+#define FTN_CREATE_AFFINITY_MASK kmp_create_affinity_mask_
+#define FTN_DESTROY_AFFINITY_MASK kmp_destroy_affinity_mask_
+#define FTN_SET_AFFINITY_MASK_PROC kmp_set_affinity_mask_proc_
+#define FTN_UNSET_AFFINITY_MASK_PROC kmp_unset_affinity_mask_proc_
+#define FTN_GET_AFFINITY_MASK_PROC kmp_get_affinity_mask_proc_
+
+#define FTN_MALLOC kmp_malloc_
+#define FTN_ALIGNED_MALLOC kmp_aligned_malloc_
+#define FTN_CALLOC kmp_calloc_
+#define FTN_REALLOC kmp_realloc_
+#define FTN_FREE kmp_free_
+
+#define FTN_GET_NUM_KNOWN_THREADS kmp_get_num_known_threads_
+
+#define FTN_SET_NUM_THREADS omp_set_num_threads_
+#define FTN_GET_NUM_THREADS omp_get_num_threads_
+#define FTN_GET_MAX_THREADS omp_get_max_threads_
+#define FTN_GET_THREAD_NUM omp_get_thread_num_
+#define FTN_GET_NUM_PROCS omp_get_num_procs_
+#define FTN_SET_DYNAMIC omp_set_dynamic_
+#define FTN_GET_DYNAMIC omp_get_dynamic_
+#define FTN_SET_NESTED omp_set_nested_
+#define FTN_GET_NESTED omp_get_nested_
+#define FTN_IN_PARALLEL omp_in_parallel_
+#define FTN_GET_THREAD_LIMIT omp_get_thread_limit_
+#define FTN_SET_SCHEDULE omp_set_schedule_
+#define FTN_GET_SCHEDULE omp_get_schedule_
+#define FTN_SET_MAX_ACTIVE_LEVELS omp_set_max_active_levels_
+#define FTN_GET_MAX_ACTIVE_LEVELS omp_get_max_active_levels_
+#define FTN_GET_ACTIVE_LEVEL omp_get_active_level_
+#define FTN_GET_LEVEL omp_get_level_
+#define FTN_GET_ANCESTOR_THREAD_NUM omp_get_ancestor_thread_num_
+#define FTN_GET_TEAM_SIZE omp_get_team_size_
+#define FTN_IN_FINAL omp_in_final_
 //  #define FTN_SET_PROC_BIND                    omp_set_proc_bind_
-    #define FTN_GET_PROC_BIND                    omp_get_proc_bind_
+#define FTN_GET_PROC_BIND omp_get_proc_bind_
 //  #define FTN_CURR_PROC_BIND                   omp_curr_proc_bind_
 #if OMP_40_ENABLED
-    #define FTN_GET_NUM_TEAMS                    omp_get_num_teams_
-    #define FTN_GET_TEAM_NUM                     omp_get_team_num_
+#define FTN_GET_NUM_TEAMS omp_get_num_teams_
+#define FTN_GET_TEAM_NUM omp_get_team_num_
 #endif
-    #define FTN_INIT_LOCK                        omp_init_lock_
+#define FTN_INIT_LOCK omp_init_lock_
 #if KMP_USE_DYNAMIC_LOCK
-    #define FTN_INIT_LOCK_WITH_HINT              omp_init_lock_with_hint_
-    #define FTN_INIT_NEST_LOCK_WITH_HINT         omp_init_nest_lock_with_hint_
+#define FTN_INIT_LOCK_WITH_HINT omp_init_lock_with_hint_
+#define FTN_INIT_NEST_LOCK_WITH_HINT omp_init_nest_lock_with_hint_
 #endif
-    #define FTN_DESTROY_LOCK                     omp_destroy_lock_
-    #define FTN_SET_LOCK                         omp_set_lock_
-    #define FTN_UNSET_LOCK                       omp_unset_lock_
-    #define FTN_TEST_LOCK                        omp_test_lock_
-    #define FTN_INIT_NEST_LOCK                   omp_init_nest_lock_
-    #define FTN_DESTROY_NEST_LOCK                omp_destroy_nest_lock_
-    #define FTN_SET_NEST_LOCK                    omp_set_nest_lock_
-    #define FTN_UNSET_NEST_LOCK                  omp_unset_nest_lock_
-    #define FTN_TEST_NEST_LOCK                   omp_test_nest_lock_
+#define FTN_DESTROY_LOCK omp_destroy_lock_
+#define FTN_SET_LOCK omp_set_lock_
+#define FTN_UNSET_LOCK omp_unset_lock_
+#define FTN_TEST_LOCK omp_test_lock_
+#define FTN_INIT_NEST_LOCK omp_init_nest_lock_
+#define FTN_DESTROY_NEST_LOCK omp_destroy_nest_lock_
+#define FTN_SET_NEST_LOCK omp_set_nest_lock_
+#define FTN_UNSET_NEST_LOCK omp_unset_nest_lock_
+#define FTN_TEST_NEST_LOCK omp_test_nest_lock_
 
-    #define FTN_SET_WARNINGS_ON                  kmp_set_warnings_on_
-    #define FTN_SET_WARNINGS_OFF                 kmp_set_warnings_off_
+#define FTN_SET_WARNINGS_ON kmp_set_warnings_on_
+#define FTN_SET_WARNINGS_OFF kmp_set_warnings_off_
 
-    #define FTN_GET_WTIME                        omp_get_wtime_
-    #define FTN_GET_WTICK                        omp_get_wtick_
+#define FTN_GET_WTIME omp_get_wtime_
+#define FTN_GET_WTICK omp_get_wtick_
 
 #if OMP_40_ENABLED
 #if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
-    #define FTN_GET_NUM_DEVICES                  omp_get_num_devices_
+#define FTN_GET_NUM_DEVICES omp_get_num_devices_
 #endif
-    #define FTN_GET_DEFAULT_DEVICE               omp_get_default_device_
-    #define FTN_SET_DEFAULT_DEVICE               omp_set_default_device_
-    #define FTN_IS_INITIAL_DEVICE                omp_is_initial_device_
+#define FTN_GET_DEFAULT_DEVICE omp_get_default_device_
+#define FTN_SET_DEFAULT_DEVICE omp_set_default_device_
+#define FTN_IS_INITIAL_DEVICE omp_is_initial_device_
 #endif
 
 
 #if OMP_40_ENABLED
-    #define FTN_GET_CANCELLATION                 omp_get_cancellation_
-    #define FTN_GET_CANCELLATION_STATUS          kmp_get_cancellation_status_
+#define FTN_GET_CANCELLATION omp_get_cancellation_
+#define FTN_GET_CANCELLATION_STATUS kmp_get_cancellation_status_
 #endif
 
 #if OMP_45_ENABLED
-    #define FTN_GET_MAX_TASK_PRIORITY            omp_get_max_task_priority_
-    #define FTN_GET_NUM_PLACES                   omp_get_num_places_
-    #define FTN_GET_PLACE_NUM_PROCS              omp_get_place_num_procs_
-    #define FTN_GET_PLACE_PROC_IDS               omp_get_place_proc_ids_
-    #define FTN_GET_PLACE_NUM                    omp_get_place_num_
-    #define FTN_GET_PARTITION_NUM_PLACES         omp_get_partition_num_places_
-    #define FTN_GET_PARTITION_PLACE_NUMS         omp_get_partition_place_nums_
-# ifdef KMP_STUB
-    #define FTN_GET_INITIAL_DEVICE               omp_get_initial_device_
-    #define FTN_TARGET_ALLOC                     omp_target_alloc_
-    #define FTN_TARGET_FREE                      omp_target_free_
-    #define FTN_TARGET_IS_PRESENT                omp_target_is_present_
-    #define FTN_TARGET_MEMCPY                    omp_target_memcpy_
-    #define FTN_TARGET_MEMCPY_RECT               omp_target_memcpy_rect_
-    #define FTN_TARGET_ASSOCIATE_PTR             omp_target_associate_ptr_
-    #define FTN_TARGET_DISASSOCIATE_PTR          omp_target_disassociate_ptr_
-# endif
+#define FTN_GET_MAX_TASK_PRIORITY omp_get_max_task_priority_
+#define FTN_GET_NUM_PLACES omp_get_num_places_
+#define FTN_GET_PLACE_NUM_PROCS omp_get_place_num_procs_
+#define FTN_GET_PLACE_PROC_IDS omp_get_place_proc_ids_
+#define FTN_GET_PLACE_NUM omp_get_place_num_
+#define FTN_GET_PARTITION_NUM_PLACES omp_get_partition_num_places_
+#define FTN_GET_PARTITION_PLACE_NUMS omp_get_partition_place_nums_
+#ifdef KMP_STUB
+#define FTN_GET_INITIAL_DEVICE omp_get_initial_device_
+#define FTN_TARGET_ALLOC omp_target_alloc_
+#define FTN_TARGET_FREE omp_target_free_
+#define FTN_TARGET_IS_PRESENT omp_target_is_present_
+#define FTN_TARGET_MEMCPY omp_target_memcpy_
+#define FTN_TARGET_MEMCPY_RECT omp_target_memcpy_rect_
+#define FTN_TARGET_ASSOCIATE_PTR omp_target_associate_ptr_
+#define FTN_TARGET_DISASSOCIATE_PTR omp_target_disassociate_ptr_
+#endif
 #endif
 
 #endif /* KMP_FTN_APPEND */
@@ -260,117 +260,117 @@
 
 #if KMP_FTN_ENTRIES == KMP_FTN_UPPER
 
-    #define FTN_SET_STACKSIZE                    KMP_SET_STACKSIZE
-    #define FTN_SET_STACKSIZE_S                  KMP_SET_STACKSIZE_S
-    #define FTN_GET_STACKSIZE                    KMP_GET_STACKSIZE
-    #define FTN_GET_STACKSIZE_S                  KMP_GET_STACKSIZE_S
-    #define FTN_SET_BLOCKTIME                    KMP_SET_BLOCKTIME
-    #define FTN_GET_BLOCKTIME                    KMP_GET_BLOCKTIME
-    #define FTN_SET_LIBRARY_SERIAL               KMP_SET_LIBRARY_SERIAL
-    #define FTN_SET_LIBRARY_TURNAROUND           KMP_SET_LIBRARY_TURNAROUND
-    #define FTN_SET_LIBRARY_THROUGHPUT           KMP_SET_LIBRARY_THROUGHPUT
-    #define FTN_SET_LIBRARY                      KMP_SET_LIBRARY
-    #define FTN_GET_LIBRARY                      KMP_GET_LIBRARY
-    #define FTN_SET_DEFAULTS                     KMP_SET_DEFAULTS
-    #define FTN_SET_DISP_NUM_BUFFERS             KMP_SET_DISP_NUM_BUFFERS
-    #define FTN_SET_AFFINITY                     KMP_SET_AFFINITY
-    #define FTN_GET_AFFINITY                     KMP_GET_AFFINITY
-    #define FTN_GET_AFFINITY_MAX_PROC            KMP_GET_AFFINITY_MAX_PROC
-    #define FTN_CREATE_AFFINITY_MASK             KMP_CREATE_AFFINITY_MASK
-    #define FTN_DESTROY_AFFINITY_MASK            KMP_DESTROY_AFFINITY_MASK
-    #define FTN_SET_AFFINITY_MASK_PROC           KMP_SET_AFFINITY_MASK_PROC
-    #define FTN_UNSET_AFFINITY_MASK_PROC         KMP_UNSET_AFFINITY_MASK_PROC
-    #define FTN_GET_AFFINITY_MASK_PROC           KMP_GET_AFFINITY_MASK_PROC
-
-    #define FTN_MALLOC                           KMP_MALLOC
-    #define FTN_ALIGNED_MALLOC                   KMP_ALIGNED_MALLOC
-    #define FTN_CALLOC                           KMP_CALLOC
-    #define FTN_REALLOC                          KMP_REALLOC
-    #define FTN_FREE                             KMP_FREE
-
-    #define FTN_GET_NUM_KNOWN_THREADS            KMP_GET_NUM_KNOWN_THREADS
-
-    #define FTN_SET_NUM_THREADS                  OMP_SET_NUM_THREADS
-    #define FTN_GET_NUM_THREADS                  OMP_GET_NUM_THREADS
-    #define FTN_GET_MAX_THREADS                  OMP_GET_MAX_THREADS
-    #define FTN_GET_THREAD_NUM                   OMP_GET_THREAD_NUM
-    #define FTN_GET_NUM_PROCS                    OMP_GET_NUM_PROCS
-    #define FTN_SET_DYNAMIC                      OMP_SET_DYNAMIC
-    #define FTN_GET_DYNAMIC                      OMP_GET_DYNAMIC
-    #define FTN_SET_NESTED                       OMP_SET_NESTED
-    #define FTN_GET_NESTED                       OMP_GET_NESTED
-    #define FTN_IN_PARALLEL                      OMP_IN_PARALLEL
-    #define FTN_GET_THREAD_LIMIT                 OMP_GET_THREAD_LIMIT
-    #define FTN_SET_SCHEDULE                     OMP_SET_SCHEDULE
-    #define FTN_GET_SCHEDULE                     OMP_GET_SCHEDULE
-    #define FTN_SET_MAX_ACTIVE_LEVELS            OMP_SET_MAX_ACTIVE_LEVELS
-    #define FTN_GET_MAX_ACTIVE_LEVELS            OMP_GET_MAX_ACTIVE_LEVELS
-    #define FTN_GET_ACTIVE_LEVEL                 OMP_GET_ACTIVE_LEVEL
-    #define FTN_GET_LEVEL                        OMP_GET_LEVEL
-    #define FTN_GET_ANCESTOR_THREAD_NUM          OMP_GET_ANCESTOR_THREAD_NUM
-    #define FTN_GET_TEAM_SIZE                    OMP_GET_TEAM_SIZE
-    #define FTN_IN_FINAL                         OMP_IN_FINAL
+#define FTN_SET_STACKSIZE KMP_SET_STACKSIZE
+#define FTN_SET_STACKSIZE_S KMP_SET_STACKSIZE_S
+#define FTN_GET_STACKSIZE KMP_GET_STACKSIZE
+#define FTN_GET_STACKSIZE_S KMP_GET_STACKSIZE_S
+#define FTN_SET_BLOCKTIME KMP_SET_BLOCKTIME
+#define FTN_GET_BLOCKTIME KMP_GET_BLOCKTIME
+#define FTN_SET_LIBRARY_SERIAL KMP_SET_LIBRARY_SERIAL
+#define FTN_SET_LIBRARY_TURNAROUND KMP_SET_LIBRARY_TURNAROUND
+#define FTN_SET_LIBRARY_THROUGHPUT KMP_SET_LIBRARY_THROUGHPUT
+#define FTN_SET_LIBRARY KMP_SET_LIBRARY
+#define FTN_GET_LIBRARY KMP_GET_LIBRARY
+#define FTN_SET_DEFAULTS KMP_SET_DEFAULTS
+#define FTN_SET_DISP_NUM_BUFFERS KMP_SET_DISP_NUM_BUFFERS
+#define FTN_SET_AFFINITY KMP_SET_AFFINITY
+#define FTN_GET_AFFINITY KMP_GET_AFFINITY
+#define FTN_GET_AFFINITY_MAX_PROC KMP_GET_AFFINITY_MAX_PROC
+#define FTN_CREATE_AFFINITY_MASK KMP_CREATE_AFFINITY_MASK
+#define FTN_DESTROY_AFFINITY_MASK KMP_DESTROY_AFFINITY_MASK
+#define FTN_SET_AFFINITY_MASK_PROC KMP_SET_AFFINITY_MASK_PROC
+#define FTN_UNSET_AFFINITY_MASK_PROC KMP_UNSET_AFFINITY_MASK_PROC
+#define FTN_GET_AFFINITY_MASK_PROC KMP_GET_AFFINITY_MASK_PROC
+
+#define FTN_MALLOC KMP_MALLOC
+#define FTN_ALIGNED_MALLOC KMP_ALIGNED_MALLOC
+#define FTN_CALLOC KMP_CALLOC
+#define FTN_REALLOC KMP_REALLOC
+#define FTN_FREE KMP_FREE
+
+#define FTN_GET_NUM_KNOWN_THREADS KMP_GET_NUM_KNOWN_THREADS
+
+#define FTN_SET_NUM_THREADS OMP_SET_NUM_THREADS
+#define FTN_GET_NUM_THREADS OMP_GET_NUM_THREADS
+#define FTN_GET_MAX_THREADS OMP_GET_MAX_THREADS
+#define FTN_GET_THREAD_NUM OMP_GET_THREAD_NUM
+#define FTN_GET_NUM_PROCS OMP_GET_NUM_PROCS
+#define FTN_SET_DYNAMIC OMP_SET_DYNAMIC
+#define FTN_GET_DYNAMIC OMP_GET_DYNAMIC
+#define FTN_SET_NESTED OMP_SET_NESTED
+#define FTN_GET_NESTED OMP_GET_NESTED
+#define FTN_IN_PARALLEL OMP_IN_PARALLEL
+#define FTN_GET_THREAD_LIMIT OMP_GET_THREAD_LIMIT
+#define FTN_SET_SCHEDULE OMP_SET_SCHEDULE
+#define FTN_GET_SCHEDULE OMP_GET_SCHEDULE
+#define FTN_SET_MAX_ACTIVE_LEVELS OMP_SET_MAX_ACTIVE_LEVELS
+#define FTN_GET_MAX_ACTIVE_LEVELS OMP_GET_MAX_ACTIVE_LEVELS
+#define FTN_GET_ACTIVE_LEVEL OMP_GET_ACTIVE_LEVEL
+#define FTN_GET_LEVEL OMP_GET_LEVEL
+#define FTN_GET_ANCESTOR_THREAD_NUM OMP_GET_ANCESTOR_THREAD_NUM
+#define FTN_GET_TEAM_SIZE OMP_GET_TEAM_SIZE
+#define FTN_IN_FINAL OMP_IN_FINAL
 //  #define FTN_SET_PROC_BIND                    OMP_SET_PROC_BIND
-    #define FTN_GET_PROC_BIND                    OMP_GET_PROC_BIND
+#define FTN_GET_PROC_BIND OMP_GET_PROC_BIND
 //  #define FTN_CURR_PROC_BIND                   OMP_CURR_PROC_BIND
 #if OMP_40_ENABLED
-    #define FTN_GET_NUM_TEAMS                    OMP_GET_NUM_TEAMS
-    #define FTN_GET_TEAM_NUM                     OMP_GET_TEAM_NUM
+#define FTN_GET_NUM_TEAMS OMP_GET_NUM_TEAMS
+#define FTN_GET_TEAM_NUM OMP_GET_TEAM_NUM
 #endif
-    #define FTN_INIT_LOCK                        OMP_INIT_LOCK
+#define FTN_INIT_LOCK OMP_INIT_LOCK
 #if KMP_USE_DYNAMIC_LOCK
-    #define FTN_INIT_LOCK_WITH_HINT              OMP_INIT_LOCK_WITH_HINT
-    #define FTN_INIT_NEST_LOCK_WITH_HINT         OMP_INIT_NEST_LOCK_WITH_HINT
+#define FTN_INIT_LOCK_WITH_HINT OMP_INIT_LOCK_WITH_HINT
+#define FTN_INIT_NEST_LOCK_WITH_HINT OMP_INIT_NEST_LOCK_WITH_HINT
 #endif
-    #define FTN_DESTROY_LOCK                     OMP_DESTROY_LOCK
-    #define FTN_SET_LOCK                         OMP_SET_LOCK
-    #define FTN_UNSET_LOCK                       OMP_UNSET_LOCK
-    #define FTN_TEST_LOCK                        OMP_TEST_LOCK
-    #define FTN_INIT_NEST_LOCK                   OMP_INIT_NEST_LOCK
-    #define FTN_DESTROY_NEST_LOCK                OMP_DESTROY_NEST_LOCK
-    #define FTN_SET_NEST_LOCK                    OMP_SET_NEST_LOCK
-    #define FTN_UNSET_NEST_LOCK                  OMP_UNSET_NEST_LOCK
-    #define FTN_TEST_NEST_LOCK                   OMP_TEST_NEST_LOCK
+#define FTN_DESTROY_LOCK OMP_DESTROY_LOCK
+#define FTN_SET_LOCK OMP_SET_LOCK
+#define FTN_UNSET_LOCK OMP_UNSET_LOCK
+#define FTN_TEST_LOCK OMP_TEST_LOCK
+#define FTN_INIT_NEST_LOCK OMP_INIT_NEST_LOCK
+#define FTN_DESTROY_NEST_LOCK OMP_DESTROY_NEST_LOCK
+#define FTN_SET_NEST_LOCK OMP_SET_NEST_LOCK
+#define FTN_UNSET_NEST_LOCK OMP_UNSET_NEST_LOCK
+#define FTN_TEST_NEST_LOCK OMP_TEST_NEST_LOCK
 
-    #define FTN_SET_WARNINGS_ON                  KMP_SET_WARNINGS_ON
-    #define FTN_SET_WARNINGS_OFF                 KMP_SET_WARNINGS_OFF
+#define FTN_SET_WARNINGS_ON KMP_SET_WARNINGS_ON
+#define FTN_SET_WARNINGS_OFF KMP_SET_WARNINGS_OFF
 
-    #define FTN_GET_WTIME                        OMP_GET_WTIME
-    #define FTN_GET_WTICK                        OMP_GET_WTICK
+#define FTN_GET_WTIME OMP_GET_WTIME
+#define FTN_GET_WTICK OMP_GET_WTICK
 
 #if OMP_40_ENABLED
 #if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
-    #define FTN_GET_NUM_DEVICES                  OMP_GET_NUM_DEVICES
+#define FTN_GET_NUM_DEVICES OMP_GET_NUM_DEVICES
 #endif
-    #define FTN_GET_DEFAULT_DEVICE               OMP_GET_DEFAULT_DEVICE
-    #define FTN_SET_DEFAULT_DEVICE               OMP_SET_DEFAULT_DEVICE
-    #define FTN_IS_INITIAL_DEVICE                OMP_IS_INITIAL_DEVICE
+#define FTN_GET_DEFAULT_DEVICE OMP_GET_DEFAULT_DEVICE
+#define FTN_SET_DEFAULT_DEVICE OMP_SET_DEFAULT_DEVICE
+#define FTN_IS_INITIAL_DEVICE OMP_IS_INITIAL_DEVICE
 #endif
 
 
 #if OMP_40_ENABLED
-    #define FTN_GET_CANCELLATION                 OMP_GET_CANCELLATION
-    #define FTN_GET_CANCELLATION_STATUS          KMP_GET_CANCELLATION_STATUS
+#define FTN_GET_CANCELLATION OMP_GET_CANCELLATION
+#define FTN_GET_CANCELLATION_STATUS KMP_GET_CANCELLATION_STATUS
 #endif
 
 #if OMP_45_ENABLED
-    #define FTN_GET_MAX_TASK_PRIORITY            OMP_GET_MAX_TASK_PRIORITY
-    #define FTN_GET_NUM_PLACES                   OMP_GET_NUM_PLACES
-    #define FTN_GET_PLACE_NUM_PROCS              OMP_GET_PLACE_NUM_PROCS
-    #define FTN_GET_PLACE_PROC_IDS               OMP_GET_PLACE_PROC_IDS
-    #define FTN_GET_PLACE_NUM                    OMP_GET_PLACE_NUM
-    #define FTN_GET_PARTITION_NUM_PLACES         OMP_GET_PARTITION_NUM_PLACES
-    #define FTN_GET_PARTITION_PLACE_NUMS         OMP_GET_PARTITION_PLACE_NUMS
-# ifdef KMP_STUB
-    #define FTN_GET_INITIAL_DEVICE               OMP_GET_INITIAL_DEVICE
-    #define FTN_TARGET_ALLOC                     OMP_TARGET_ALLOC
-    #define FTN_TARGET_FREE                      OMP_TARGET_FREE
-    #define FTN_TARGET_IS_PRESENT                OMP_TARGET_IS_PRESENT
-    #define FTN_TARGET_MEMCPY                    OMP_TARGET_MEMCPY
-    #define FTN_TARGET_MEMCPY_RECT               OMP_TARGET_MEMCPY_RECT
-    #define FTN_TARGET_ASSOCIATE_PTR             OMP_TARGET_ASSOCIATE_PTR
-    #define FTN_TARGET_DISASSOCIATE_PTR          OMP_TARGET_DISASSOCIATE_PTR
-# endif
+#define FTN_GET_MAX_TASK_PRIORITY OMP_GET_MAX_TASK_PRIORITY
+#define FTN_GET_NUM_PLACES OMP_GET_NUM_PLACES
+#define FTN_GET_PLACE_NUM_PROCS OMP_GET_PLACE_NUM_PROCS
+#define FTN_GET_PLACE_PROC_IDS OMP_GET_PLACE_PROC_IDS
+#define FTN_GET_PLACE_NUM OMP_GET_PLACE_NUM
+#define FTN_GET_PARTITION_NUM_PLACES OMP_GET_PARTITION_NUM_PLACES
+#define FTN_GET_PARTITION_PLACE_NUMS OMP_GET_PARTITION_PLACE_NUMS
+#ifdef KMP_STUB
+#define FTN_GET_INITIAL_DEVICE OMP_GET_INITIAL_DEVICE
+#define FTN_TARGET_ALLOC OMP_TARGET_ALLOC
+#define FTN_TARGET_FREE OMP_TARGET_FREE
+#define FTN_TARGET_IS_PRESENT OMP_TARGET_IS_PRESENT
+#define FTN_TARGET_MEMCPY OMP_TARGET_MEMCPY
+#define FTN_TARGET_MEMCPY_RECT OMP_TARGET_MEMCPY_RECT
+#define FTN_TARGET_ASSOCIATE_PTR OMP_TARGET_ASSOCIATE_PTR
+#define FTN_TARGET_DISASSOCIATE_PTR OMP_TARGET_DISASSOCIATE_PTR
+#endif
 #endif
 
 #endif /* KMP_FTN_UPPER */
@@ -379,242 +379,266 @@
 
 #if KMP_FTN_ENTRIES == KMP_FTN_UAPPEND
 
-    #define FTN_SET_STACKSIZE                    KMP_SET_STACKSIZE_
-    #define FTN_SET_STACKSIZE_S                  KMP_SET_STACKSIZE_S_
-    #define FTN_GET_STACKSIZE                    KMP_GET_STACKSIZE_
-    #define FTN_GET_STACKSIZE_S                  KMP_GET_STACKSIZE_S_
-    #define FTN_SET_BLOCKTIME                    KMP_SET_BLOCKTIME_
-    #define FTN_GET_BLOCKTIME                    KMP_GET_BLOCKTIME_
-    #define FTN_SET_LIBRARY_SERIAL               KMP_SET_LIBRARY_SERIAL_
-    #define FTN_SET_LIBRARY_TURNAROUND           KMP_SET_LIBRARY_TURNAROUND_
-    #define FTN_SET_LIBRARY_THROUGHPUT           KMP_SET_LIBRARY_THROUGHPUT_
-    #define FTN_SET_LIBRARY                      KMP_SET_LIBRARY_
-    #define FTN_GET_LIBRARY                      KMP_GET_LIBRARY_
-    #define FTN_SET_DEFAULTS                     KMP_SET_DEFAULTS_
-    #define FTN_SET_DISP_NUM_BUFFERS             KMP_SET_DISP_NUM_BUFFERS_
-    #define FTN_SET_AFFINITY                     KMP_SET_AFFINITY_
-    #define FTN_GET_AFFINITY                     KMP_GET_AFFINITY_
-    #define FTN_GET_AFFINITY_MAX_PROC            KMP_GET_AFFINITY_MAX_PROC_
-    #define FTN_CREATE_AFFINITY_MASK             KMP_CREATE_AFFINITY_MASK_
-    #define FTN_DESTROY_AFFINITY_MASK            KMP_DESTROY_AFFINITY_MASK_
-    #define FTN_SET_AFFINITY_MASK_PROC           KMP_SET_AFFINITY_MASK_PROC_
-    #define FTN_UNSET_AFFINITY_MASK_PROC         KMP_UNSET_AFFINITY_MASK_PROC_
-    #define FTN_GET_AFFINITY_MASK_PROC           KMP_GET_AFFINITY_MASK_PROC_
-
-    #define FTN_MALLOC                           KMP_MALLOC_
-    #define FTN_ALIGNED_MALLOC                   KMP_ALIGNED_MALLOC_
-    #define FTN_CALLOC                           KMP_CALLOC_
-    #define FTN_REALLOC                          KMP_REALLOC_
-    #define FTN_FREE                             KMP_FREE_
-
-    #define FTN_GET_NUM_KNOWN_THREADS            KMP_GET_NUM_KNOWN_THREADS_
-
-    #define FTN_SET_NUM_THREADS                  OMP_SET_NUM_THREADS_
-    #define FTN_GET_NUM_THREADS                  OMP_GET_NUM_THREADS_
-    #define FTN_GET_MAX_THREADS                  OMP_GET_MAX_THREADS_
-    #define FTN_GET_THREAD_NUM                   OMP_GET_THREAD_NUM_
-    #define FTN_GET_NUM_PROCS                    OMP_GET_NUM_PROCS_
-    #define FTN_SET_DYNAMIC                      OMP_SET_DYNAMIC_
-    #define FTN_GET_DYNAMIC                      OMP_GET_DYNAMIC_
-    #define FTN_SET_NESTED                       OMP_SET_NESTED_
-    #define FTN_GET_NESTED                       OMP_GET_NESTED_
-    #define FTN_IN_PARALLEL                      OMP_IN_PARALLEL_
-    #define FTN_GET_THREAD_LIMIT                 OMP_GET_THREAD_LIMIT_
-    #define FTN_SET_SCHEDULE                     OMP_SET_SCHEDULE_
-    #define FTN_GET_SCHEDULE                     OMP_GET_SCHEDULE_
-    #define FTN_SET_MAX_ACTIVE_LEVELS            OMP_SET_MAX_ACTIVE_LEVELS_
-    #define FTN_GET_MAX_ACTIVE_LEVELS            OMP_GET_MAX_ACTIVE_LEVELS_
-    #define FTN_GET_ACTIVE_LEVEL                 OMP_GET_ACTIVE_LEVEL_
-    #define FTN_GET_LEVEL                        OMP_GET_LEVEL_
-    #define FTN_GET_ANCESTOR_THREAD_NUM          OMP_GET_ANCESTOR_THREAD_NUM_
-    #define FTN_GET_TEAM_SIZE                    OMP_GET_TEAM_SIZE_
-    #define FTN_IN_FINAL                         OMP_IN_FINAL_
+#define FTN_SET_STACKSIZE KMP_SET_STACKSIZE_
+#define FTN_SET_STACKSIZE_S KMP_SET_STACKSIZE_S_
+#define FTN_GET_STACKSIZE KMP_GET_STACKSIZE_
+#define FTN_GET_STACKSIZE_S KMP_GET_STACKSIZE_S_
+#define FTN_SET_BLOCKTIME KMP_SET_BLOCKTIME_
+#define FTN_GET_BLOCKTIME KMP_GET_BLOCKTIME_
+#define FTN_SET_LIBRARY_SERIAL KMP_SET_LIBRARY_SERIAL_
+#define FTN_SET_LIBRARY_TURNAROUND KMP_SET_LIBRARY_TURNAROUND_
+#define FTN_SET_LIBRARY_THROUGHPUT KMP_SET_LIBRARY_THROUGHPUT_
+#define FTN_SET_LIBRARY KMP_SET_LIBRARY_
+#define FTN_GET_LIBRARY KMP_GET_LIBRARY_
+#define FTN_SET_DEFAULTS KMP_SET_DEFAULTS_
+#define FTN_SET_DISP_NUM_BUFFERS KMP_SET_DISP_NUM_BUFFERS_
+#define FTN_SET_AFFINITY KMP_SET_AFFINITY_
+#define FTN_GET_AFFINITY KMP_GET_AFFINITY_
+#define FTN_GET_AFFINITY_MAX_PROC KMP_GET_AFFINITY_MAX_PROC_
+#define FTN_CREATE_AFFINITY_MASK KMP_CREATE_AFFINITY_MASK_
+#define FTN_DESTROY_AFFINITY_MASK KMP_DESTROY_AFFINITY_MASK_
+#define FTN_SET_AFFINITY_MASK_PROC KMP_SET_AFFINITY_MASK_PROC_
+#define FTN_UNSET_AFFINITY_MASK_PROC KMP_UNSET_AFFINITY_MASK_PROC_
+#define FTN_GET_AFFINITY_MASK_PROC KMP_GET_AFFINITY_MASK_PROC_
+
+#define FTN_MALLOC KMP_MALLOC_
+#define FTN_ALIGNED_MALLOC KMP_ALIGNED_MALLOC_
+#define FTN_CALLOC KMP_CALLOC_
+#define FTN_REALLOC KMP_REALLOC_
+#define FTN_FREE KMP_FREE_
+
+#define FTN_GET_NUM_KNOWN_THREADS KMP_GET_NUM_KNOWN_THREADS_
+
+#define FTN_SET_NUM_THREADS OMP_SET_NUM_THREADS_
+#define FTN_GET_NUM_THREADS OMP_GET_NUM_THREADS_
+#define FTN_GET_MAX_THREADS OMP_GET_MAX_THREADS_
+#define FTN_GET_THREAD_NUM OMP_GET_THREAD_NUM_
+#define FTN_GET_NUM_PROCS OMP_GET_NUM_PROCS_
+#define FTN_SET_DYNAMIC OMP_SET_DYNAMIC_
+#define FTN_GET_DYNAMIC OMP_GET_DYNAMIC_
+#define FTN_SET_NESTED OMP_SET_NESTED_
+#define FTN_GET_NESTED OMP_GET_NESTED_
+#define FTN_IN_PARALLEL OMP_IN_PARALLEL_
+#define FTN_GET_THREAD_LIMIT OMP_GET_THREAD_LIMIT_
+#define FTN_SET_SCHEDULE OMP_SET_SCHEDULE_
+#define FTN_GET_SCHEDULE OMP_GET_SCHEDULE_
+#define FTN_SET_MAX_ACTIVE_LEVELS OMP_SET_MAX_ACTIVE_LEVELS_
+#define FTN_GET_MAX_ACTIVE_LEVELS OMP_GET_MAX_ACTIVE_LEVELS_
+#define FTN_GET_ACTIVE_LEVEL OMP_GET_ACTIVE_LEVEL_
+#define FTN_GET_LEVEL OMP_GET_LEVEL_
+#define FTN_GET_ANCESTOR_THREAD_NUM OMP_GET_ANCESTOR_THREAD_NUM_
+#define FTN_GET_TEAM_SIZE OMP_GET_TEAM_SIZE_
+#define FTN_IN_FINAL OMP_IN_FINAL_
 //  #define FTN_SET_PROC_BIND                    OMP_SET_PROC_BIND_
-    #define FTN_GET_PROC_BIND                    OMP_GET_PROC_BIND_
+#define FTN_GET_PROC_BIND OMP_GET_PROC_BIND_
 //  #define FTN_CURR_PROC_BIND                   OMP_CURR_PROC_BIND_
 #if OMP_40_ENABLED
-    #define FTN_GET_NUM_TEAMS                    OMP_GET_NUM_TEAMS_
-    #define FTN_GET_TEAM_NUM                     OMP_GET_TEAM_NUM_
+#define FTN_GET_NUM_TEAMS OMP_GET_NUM_TEAMS_
+#define FTN_GET_TEAM_NUM OMP_GET_TEAM_NUM_
 #endif
-    #define FTN_INIT_LOCK                        OMP_INIT_LOCK_
+#define FTN_INIT_LOCK OMP_INIT_LOCK_
 #if KMP_USE_DYNAMIC_LOCK
-    #define FTN_INIT_LOCK_WITH_HINT              OMP_INIT_LOCK_WITH_HINT_
-    #define FTN_INIT_NEST_LOCK_WITH_HINT         OMP_INIT_NEST_LOCK_WITH_HINT_
+#define FTN_INIT_LOCK_WITH_HINT OMP_INIT_LOCK_WITH_HINT_
+#define FTN_INIT_NEST_LOCK_WITH_HINT OMP_INIT_NEST_LOCK_WITH_HINT_
 #endif
-    #define FTN_DESTROY_LOCK                     OMP_DESTROY_LOCK_
-    #define FTN_SET_LOCK                         OMP_SET_LOCK_
-    #define FTN_UNSET_LOCK                       OMP_UNSET_LOCK_
-    #define FTN_TEST_LOCK                        OMP_TEST_LOCK_
-    #define FTN_INIT_NEST_LOCK                   OMP_INIT_NEST_LOCK_
-    #define FTN_DESTROY_NEST_LOCK                OMP_DESTROY_NEST_LOCK_
-    #define FTN_SET_NEST_LOCK                    OMP_SET_NEST_LOCK_
-    #define FTN_UNSET_NEST_LOCK                  OMP_UNSET_NEST_LOCK_
-    #define FTN_TEST_NEST_LOCK                   OMP_TEST_NEST_LOCK_
+#define FTN_DESTROY_LOCK OMP_DESTROY_LOCK_
+#define FTN_SET_LOCK OMP_SET_LOCK_
+#define FTN_UNSET_LOCK OMP_UNSET_LOCK_
+#define FTN_TEST_LOCK OMP_TEST_LOCK_
+#define FTN_INIT_NEST_LOCK OMP_INIT_NEST_LOCK_
+#define FTN_DESTROY_NEST_LOCK OMP_DESTROY_NEST_LOCK_
+#define FTN_SET_NEST_LOCK OMP_SET_NEST_LOCK_
+#define FTN_UNSET_NEST_LOCK OMP_UNSET_NEST_LOCK_
+#define FTN_TEST_NEST_LOCK OMP_TEST_NEST_LOCK_
 
-    #define FTN_SET_WARNINGS_ON                  KMP_SET_WARNINGS_ON_
-    #define FTN_SET_WARNINGS_OFF                 KMP_SET_WARNINGS_OFF_
+#define FTN_SET_WARNINGS_ON KMP_SET_WARNINGS_ON_
+#define FTN_SET_WARNINGS_OFF KMP_SET_WARNINGS_OFF_
 
-    #define FTN_GET_WTIME                        OMP_GET_WTIME_
-    #define FTN_GET_WTICK                        OMP_GET_WTICK_
+#define FTN_GET_WTIME OMP_GET_WTIME_
+#define FTN_GET_WTICK OMP_GET_WTICK_
 
 #if OMP_40_ENABLED
 #if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
-    #define FTN_GET_NUM_DEVICES                  OMP_GET_NUM_DEVICES_
+#define FTN_GET_NUM_DEVICES OMP_GET_NUM_DEVICES_
 #endif
-    #define FTN_GET_DEFAULT_DEVICE               OMP_GET_DEFAULT_DEVICE_
-    #define FTN_SET_DEFAULT_DEVICE               OMP_SET_DEFAULT_DEVICE_
-    #define FTN_IS_INITIAL_DEVICE                OMP_IS_INITIAL_DEVICE_
+#define FTN_GET_DEFAULT_DEVICE OMP_GET_DEFAULT_DEVICE_
+#define FTN_SET_DEFAULT_DEVICE OMP_SET_DEFAULT_DEVICE_
+#define FTN_IS_INITIAL_DEVICE OMP_IS_INITIAL_DEVICE_
 #endif
 
 
 #if OMP_40_ENABLED
-    #define FTN_GET_CANCELLATION                 OMP_GET_CANCELLATION_
-    #define FTN_GET_CANCELLATION_STATUS          KMP_GET_CANCELLATION_STATUS_
+#define FTN_GET_CANCELLATION OMP_GET_CANCELLATION_
+#define FTN_GET_CANCELLATION_STATUS KMP_GET_CANCELLATION_STATUS_
 #endif
 
 #if OMP_45_ENABLED
-    #define FTN_GET_MAX_TASK_PRIORITY            OMP_GET_MAX_TASK_PRIORITY_
-    #define FTN_GET_NUM_PLACES                   OMP_GET_NUM_PLACES_
-    #define FTN_GET_PLACE_NUM_PROCS              OMP_GET_PLACE_NUM_PROCS_
-    #define FTN_GET_PLACE_PROC_IDS               OMP_GET_PLACE_PROC_IDS_
-    #define FTN_GET_PLACE_NUM                    OMP_GET_PLACE_NUM_
-    #define FTN_GET_PARTITION_NUM_PLACES         OMP_GET_PARTITION_NUM_PLACES_
-    #define FTN_GET_PARTITION_PLACE_NUMS         OMP_GET_PARTITION_PLACE_NUMS_
-# ifdef KMP_STUB
-    #define FTN_GET_INITIAL_DEVICE               OMP_GET_INITIAL_DEVICE_
-    #define FTN_TARGET_ALLOC                     OMP_TARGET_ALLOC_
-    #define FTN_TARGET_FREE                      OMP_TARGET_FREE_
-    #define FTN_TARGET_IS_PRESENT                OMP_TARGET_IS_PRESENT_
-    #define FTN_TARGET_MEMCPY                    OMP_TARGET_MEMCPY_
-    #define FTN_TARGET_MEMCPY_RECT               OMP_TARGET_MEMCPY_RECT_
-    #define FTN_TARGET_ASSOCIATE_PTR             OMP_TARGET_ASSOCIATE_PTR_
-    #define FTN_TARGET_DISASSOCIATE_PTR          OMP_TARGET_DISASSOCIATE_PTR_
-# endif
+#define FTN_GET_MAX_TASK_PRIORITY OMP_GET_MAX_TASK_PRIORITY_
+#define FTN_GET_NUM_PLACES OMP_GET_NUM_PLACES_
+#define FTN_GET_PLACE_NUM_PROCS OMP_GET_PLACE_NUM_PROCS_
+#define FTN_GET_PLACE_PROC_IDS OMP_GET_PLACE_PROC_IDS_
+#define FTN_GET_PLACE_NUM OMP_GET_PLACE_NUM_
+#define FTN_GET_PARTITION_NUM_PLACES OMP_GET_PARTITION_NUM_PLACES_
+#define FTN_GET_PARTITION_PLACE_NUMS OMP_GET_PARTITION_PLACE_NUMS_
+#ifdef KMP_STUB
+#define FTN_GET_INITIAL_DEVICE OMP_GET_INITIAL_DEVICE_
+#define FTN_TARGET_ALLOC OMP_TARGET_ALLOC_
+#define FTN_TARGET_FREE OMP_TARGET_FREE_
+#define FTN_TARGET_IS_PRESENT OMP_TARGET_IS_PRESENT_
+#define FTN_TARGET_MEMCPY OMP_TARGET_MEMCPY_
+#define FTN_TARGET_MEMCPY_RECT OMP_TARGET_MEMCPY_RECT_
+#define FTN_TARGET_ASSOCIATE_PTR OMP_TARGET_ASSOCIATE_PTR_
+#define FTN_TARGET_DISASSOCIATE_PTR OMP_TARGET_DISASSOCIATE_PTR_
+#endif
 #endif
 
 #endif /* KMP_FTN_UAPPEND */
 
-/* ------------------------------------------------------------------ */
 /* -------------------------- GOMP API NAMES ------------------------ */
 // All GOMP_1.0 symbols
-#define KMP_API_NAME_GOMP_ATOMIC_END                   GOMP_atomic_end
-#define KMP_API_NAME_GOMP_ATOMIC_START                 GOMP_atomic_start
-#define KMP_API_NAME_GOMP_BARRIER                      GOMP_barrier
-#define KMP_API_NAME_GOMP_CRITICAL_END                 GOMP_critical_end
-#define KMP_API_NAME_GOMP_CRITICAL_NAME_END            GOMP_critical_name_end
-#define KMP_API_NAME_GOMP_CRITICAL_NAME_START          GOMP_critical_name_start
-#define KMP_API_NAME_GOMP_CRITICAL_START               GOMP_critical_start
-#define KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT            GOMP_loop_dynamic_next
-#define KMP_API_NAME_GOMP_LOOP_DYNAMIC_START           GOMP_loop_dynamic_start
-#define KMP_API_NAME_GOMP_LOOP_END                     GOMP_loop_end
-#define KMP_API_NAME_GOMP_LOOP_END_NOWAIT              GOMP_loop_end_nowait
-#define KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT             GOMP_loop_guided_next
-#define KMP_API_NAME_GOMP_LOOP_GUIDED_START            GOMP_loop_guided_start
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT    GOMP_loop_ordered_dynamic_next
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START   GOMP_loop_ordered_dynamic_start
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT     GOMP_loop_ordered_guided_next
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START    GOMP_loop_ordered_guided_start
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT    GOMP_loop_ordered_runtime_next
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START   GOMP_loop_ordered_runtime_start
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT     GOMP_loop_ordered_static_next
-#define KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START    GOMP_loop_ordered_static_start
-#define KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT            GOMP_loop_runtime_next
-#define KMP_API_NAME_GOMP_LOOP_RUNTIME_START           GOMP_loop_runtime_start
-#define KMP_API_NAME_GOMP_LOOP_STATIC_NEXT             GOMP_loop_static_next
-#define KMP_API_NAME_GOMP_LOOP_STATIC_START            GOMP_loop_static_start
-#define KMP_API_NAME_GOMP_ORDERED_END                  GOMP_ordered_end
-#define KMP_API_NAME_GOMP_ORDERED_START                GOMP_ordered_start
-#define KMP_API_NAME_GOMP_PARALLEL_END                 GOMP_parallel_end
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START  GOMP_parallel_loop_dynamic_start
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START   GOMP_parallel_loop_guided_start
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START  GOMP_parallel_loop_runtime_start
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START   GOMP_parallel_loop_static_start
-#define KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START      GOMP_parallel_sections_start
-#define KMP_API_NAME_GOMP_PARALLEL_START               GOMP_parallel_start
-#define KMP_API_NAME_GOMP_SECTIONS_END                 GOMP_sections_end
-#define KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT          GOMP_sections_end_nowait
-#define KMP_API_NAME_GOMP_SECTIONS_NEXT                GOMP_sections_next
-#define KMP_API_NAME_GOMP_SECTIONS_START               GOMP_sections_start
-#define KMP_API_NAME_GOMP_SINGLE_COPY_END              GOMP_single_copy_end
-#define KMP_API_NAME_GOMP_SINGLE_COPY_START            GOMP_single_copy_start
-#define KMP_API_NAME_GOMP_SINGLE_START                 GOMP_single_start
+#define KMP_API_NAME_GOMP_ATOMIC_END GOMP_atomic_end
+#define KMP_API_NAME_GOMP_ATOMIC_START GOMP_atomic_start
+#define KMP_API_NAME_GOMP_BARRIER GOMP_barrier
+#define KMP_API_NAME_GOMP_CRITICAL_END GOMP_critical_end
+#define KMP_API_NAME_GOMP_CRITICAL_NAME_END GOMP_critical_name_end
+#define KMP_API_NAME_GOMP_CRITICAL_NAME_START GOMP_critical_name_start
+#define KMP_API_NAME_GOMP_CRITICAL_START GOMP_critical_start
+#define KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT GOMP_loop_dynamic_next
+#define KMP_API_NAME_GOMP_LOOP_DYNAMIC_START GOMP_loop_dynamic_start
+#define KMP_API_NAME_GOMP_LOOP_END GOMP_loop_end
+#define KMP_API_NAME_GOMP_LOOP_END_NOWAIT GOMP_loop_end_nowait
+#define KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT GOMP_loop_guided_next
+#define KMP_API_NAME_GOMP_LOOP_GUIDED_START GOMP_loop_guided_start
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT                            \
+  GOMP_loop_ordered_dynamic_next
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START                           \
+  GOMP_loop_ordered_dynamic_start
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT GOMP_loop_ordered_guided_next
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START                            \
+  GOMP_loop_ordered_guided_start
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT                            \
+  GOMP_loop_ordered_runtime_next
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START                           \
+  GOMP_loop_ordered_runtime_start
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT GOMP_loop_ordered_static_next
+#define KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START                            \
+  GOMP_loop_ordered_static_start
+#define KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT GOMP_loop_runtime_next
+#define KMP_API_NAME_GOMP_LOOP_RUNTIME_START GOMP_loop_runtime_start
+#define KMP_API_NAME_GOMP_LOOP_STATIC_NEXT GOMP_loop_static_next
+#define KMP_API_NAME_GOMP_LOOP_STATIC_START GOMP_loop_static_start
+#define KMP_API_NAME_GOMP_ORDERED_END GOMP_ordered_end
+#define KMP_API_NAME_GOMP_ORDERED_START GOMP_ordered_start
+#define KMP_API_NAME_GOMP_PARALLEL_END GOMP_parallel_end
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START                          \
+  GOMP_parallel_loop_dynamic_start
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED_START                           \
+  GOMP_parallel_loop_guided_start
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START                          \
+  GOMP_parallel_loop_runtime_start
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START                           \
+  GOMP_parallel_loop_static_start
+#define KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START GOMP_parallel_sections_start
+#define KMP_API_NAME_GOMP_PARALLEL_START GOMP_parallel_start
+#define KMP_API_NAME_GOMP_SECTIONS_END GOMP_sections_end
+#define KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT GOMP_sections_end_nowait
+#define KMP_API_NAME_GOMP_SECTIONS_NEXT GOMP_sections_next
+#define KMP_API_NAME_GOMP_SECTIONS_START GOMP_sections_start
+#define KMP_API_NAME_GOMP_SINGLE_COPY_END GOMP_single_copy_end
+#define KMP_API_NAME_GOMP_SINGLE_COPY_START GOMP_single_copy_start
+#define KMP_API_NAME_GOMP_SINGLE_START GOMP_single_start
 
 // All GOMP_2.0 symbols
-#define KMP_API_NAME_GOMP_TASK                           GOMP_task
-#define KMP_API_NAME_GOMP_TASKWAIT                       GOMP_taskwait
-#define KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT          GOMP_loop_ull_dynamic_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START         GOMP_loop_ull_dynamic_start
-#define KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT           GOMP_loop_ull_guided_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START          GOMP_loop_ull_guided_start
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT  GOMP_loop_ull_ordered_dynamic_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START GOMP_loop_ull_ordered_dynamic_start
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT   GOMP_loop_ull_ordered_guided_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START  GOMP_loop_ull_ordered_guided_start
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT  GOMP_loop_ull_ordered_runtime_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START GOMP_loop_ull_ordered_runtime_start
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT   GOMP_loop_ull_ordered_static_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START  GOMP_loop_ull_ordered_static_start
-#define KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT          GOMP_loop_ull_runtime_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START         GOMP_loop_ull_runtime_start
-#define KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT           GOMP_loop_ull_static_next
-#define KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START          GOMP_loop_ull_static_start
+#define KMP_API_NAME_GOMP_TASK GOMP_task
+#define KMP_API_NAME_GOMP_TASKWAIT GOMP_taskwait
+#define KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT GOMP_loop_ull_dynamic_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START GOMP_loop_ull_dynamic_start
+#define KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT GOMP_loop_ull_guided_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START GOMP_loop_ull_guided_start
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT                        \
+  GOMP_loop_ull_ordered_dynamic_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START                       \
+  GOMP_loop_ull_ordered_dynamic_start
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT                         \
+  GOMP_loop_ull_ordered_guided_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START                        \
+  GOMP_loop_ull_ordered_guided_start
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT                        \
+  GOMP_loop_ull_ordered_runtime_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START                       \
+  GOMP_loop_ull_ordered_runtime_start
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT                         \
+  GOMP_loop_ull_ordered_static_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START                        \
+  GOMP_loop_ull_ordered_static_start
+#define KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT GOMP_loop_ull_runtime_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START GOMP_loop_ull_runtime_start
+#define KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT GOMP_loop_ull_static_next
+#define KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START GOMP_loop_ull_static_start
 
 // All GOMP_3.0 symbols
-#define KMP_API_NAME_GOMP_TASKYIELD                      GOMP_taskyield
+#define KMP_API_NAME_GOMP_TASKYIELD GOMP_taskyield
 
 // All GOMP_4.0 symbols
-// TODO: As of 2013-10-14, none of the GOMP_4.0 functions are implemented in libomp
-#define KMP_API_NAME_GOMP_BARRIER_CANCEL                 GOMP_barrier_cancel
-#define KMP_API_NAME_GOMP_CANCEL                         GOMP_cancel
-#define KMP_API_NAME_GOMP_CANCELLATION_POINT             GOMP_cancellation_point
-#define KMP_API_NAME_GOMP_LOOP_END_CANCEL                GOMP_loop_end_cancel
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC          GOMP_parallel_loop_dynamic
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED           GOMP_parallel_loop_guided
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME          GOMP_parallel_loop_runtime
-#define KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC           GOMP_parallel_loop_static
-#define KMP_API_NAME_GOMP_PARALLEL_SECTIONS              GOMP_parallel_sections
-#define KMP_API_NAME_GOMP_PARALLEL                       GOMP_parallel
-#define KMP_API_NAME_GOMP_SECTIONS_END_CANCEL            GOMP_sections_end_cancel
-#define KMP_API_NAME_GOMP_TASKGROUP_START                GOMP_taskgroup_start
-#define KMP_API_NAME_GOMP_TASKGROUP_END                  GOMP_taskgroup_end
+// TODO: As of 2013-10-14, none of the GOMP_4.0 functions are implemented in
+// libomp
+#define KMP_API_NAME_GOMP_BARRIER_CANCEL GOMP_barrier_cancel
+#define KMP_API_NAME_GOMP_CANCEL GOMP_cancel
+#define KMP_API_NAME_GOMP_CANCELLATION_POINT GOMP_cancellation_point
+#define KMP_API_NAME_GOMP_LOOP_END_CANCEL GOMP_loop_end_cancel
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC GOMP_parallel_loop_dynamic
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED GOMP_parallel_loop_guided
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME GOMP_parallel_loop_runtime
+#define KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC GOMP_parallel_loop_static
+#define KMP_API_NAME_GOMP_PARALLEL_SECTIONS GOMP_parallel_sections
+#define KMP_API_NAME_GOMP_PARALLEL GOMP_parallel
+#define KMP_API_NAME_GOMP_SECTIONS_END_CANCEL GOMP_sections_end_cancel
+#define KMP_API_NAME_GOMP_TASKGROUP_START GOMP_taskgroup_start
+#define KMP_API_NAME_GOMP_TASKGROUP_END GOMP_taskgroup_end
 /* Target functions should be taken care of by liboffload */
-#define KMP_API_NAME_GOMP_TARGET                         GOMP_target
-#define KMP_API_NAME_GOMP_TARGET_DATA                    GOMP_target_data
-#define KMP_API_NAME_GOMP_TARGET_END_DATA                GOMP_target_end_data
-#define KMP_API_NAME_GOMP_TARGET_UPDATE                  GOMP_target_update
-#define KMP_API_NAME_GOMP_TEAMS                          GOMP_teams
+#define KMP_API_NAME_GOMP_TARGET GOMP_target
+#define KMP_API_NAME_GOMP_TARGET_DATA GOMP_target_data
+#define KMP_API_NAME_GOMP_TARGET_END_DATA GOMP_target_end_data
+#define KMP_API_NAME_GOMP_TARGET_UPDATE GOMP_target_update
+#define KMP_API_NAME_GOMP_TEAMS GOMP_teams
 
 #ifdef KMP_USE_VERSION_SYMBOLS
-    #define xstr(x) str(x)
-    #define str(x) #x
+#define xstr(x) str(x)
+#define str(x) #x
 
-    // If Linux, xexpand prepends __kmp_api_ to the real API name
-    #define xexpand(api_name) expand(api_name)
-    #define expand(api_name) __kmp_api_##api_name
-
-    #define xaliasify(api_name,ver) aliasify(api_name,ver)
-    #define aliasify(api_name,ver) __typeof__(__kmp_api_##api_name) __kmp_api_##api_name##_##ver##_alias __attribute__((alias(xstr(__kmp_api_##api_name))))
-
-    #define xversionify(api_name, version_num, version_str) versionify(api_name, version_num, version_str, "VERSION")
-    #define versionify(api_name, version_num, version_str, default_ver) \
-    __asm__(".symver " xstr(__kmp_api_##api_name##_##version_num##_alias) "," xstr(api_name) "@" version_str "\n\t"); \
-    __asm__(".symver " xstr(__kmp_api_##api_name) "," xstr(api_name) "@@" default_ver "\n\t")
+// If Linux, xexpand prepends __kmp_api_ to the real API name
+#define xexpand(api_name) expand(api_name)
+#define expand(api_name) __kmp_api_##api_name
+
+#define xaliasify(api_name, ver) aliasify(api_name, ver)
+#define aliasify(api_name, ver)                                                \
+  __typeof__(__kmp_api_##api_name) __kmp_api_##api_name##_##ver##_alias        \
+      __attribute__((alias(xstr(__kmp_api_##api_name))))
+
+#define xversionify(api_name, version_num, version_str)                        \
+  versionify(api_name, version_num, version_str, "VERSION")
+#define versionify(api_name, version_num, version_str, default_ver)            \
+  __asm__(                                                                     \
+      ".symver " xstr(__kmp_api_##api_name##_##version_num##_alias) "," xstr(  \
+          api_name) "@" version_str "\n\t");                                   \
+  __asm__(".symver " xstr(__kmp_api_##api_name) "," xstr(                      \
+      api_name) "@@" default_ver "\n\t")
 
 #else // KMP_USE_VERSION_SYMBOLS
-    #define xstr(x) /* Nothing */
-    #define str(x)  /* Nothing */
-
-    // if Windows or Mac, xexpand does no name transformation
-    #define xexpand(api_name) expand(api_name)
-    #define expand(api_name) api_name
+#define xstr(x) /* Nothing */
+#define str(x) /* Nothing */
 
-    #define xaliasify(api_name,ver) /* Nothing */
-    #define aliasify(api_name,ver)  /* Nothing */
-
-    #define xversionify(api_name, version_num, version_str) /* Nothing */
-    #define versionify(api_name, version_num, version_str, default_ver) /* Nothing */
+// if Windows or Mac, xexpand does no name transformation
+#define xexpand(api_name) expand(api_name)
+#define expand(api_name) api_name
+
+#define xaliasify(api_name, ver) /* Nothing */
+#define aliasify(api_name, ver) /* Nothing */
+
+#define xversionify(api_name, version_num, version_str) /* Nothing */
+#define versionify(api_name, version_num, version_str,                         \
+                   default_ver) /* Nothing */
 
 #endif // KMP_USE_VERSION_SYMBOLS
 
 #endif /* KMP_FTN_OS_H */
-

Modified: openmp/trunk/runtime/src/kmp_ftn_stdcall.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_ftn_stdcall.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_ftn_stdcall.cpp (original)
+++ openmp/trunk/runtime/src/kmp_ftn_stdcall.cpp Fri May 12 13:01:32 2017
@@ -16,20 +16,20 @@
 #include "kmp.h"
 
 // Note: This string is not printed when KMP_VERSION=1.
-char const __kmp_version_ftnstdcall[] = KMP_VERSION_PREFIX "Fortran __stdcall OMP support: "
+char const __kmp_version_ftnstdcall[] =
+    KMP_VERSION_PREFIX "Fortran __stdcall OMP support: "
 #ifdef USE_FTN_STDCALL
-    "yes";
+                       "yes";
 #else
-    "no";
+                       "no";
 #endif
 
 #ifdef USE_FTN_STDCALL
 
-#define FTN_STDCALL 	KMP_STDCALL
-#define KMP_FTN_ENTRIES	USE_FTN_STDCALL
+#define FTN_STDCALL KMP_STDCALL
+#define KMP_FTN_ENTRIES USE_FTN_STDCALL
 
-#include "kmp_ftn_os.h"
 #include "kmp_ftn_entry.h"
+#include "kmp_ftn_os.h"
 
 #endif /* USE_FTN_STDCALL */
-

Modified: openmp/trunk/runtime/src/kmp_global.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_global.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_global.cpp (original)
+++ openmp/trunk/runtime/src/kmp_global.cpp Fri May 12 13:01:32 2017
@@ -19,7 +19,7 @@
 kmp_key_t __kmp_gtid_threadprivate_key;
 
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
-kmp_cpuinfo_t   __kmp_cpuinfo = { 0 }; // Not initialized
+kmp_cpuinfo_t __kmp_cpuinfo = {0}; // Not initialized
 #endif
 
 #if KMP_STATS_ENABLED
@@ -27,11 +27,12 @@ kmp_cpuinfo_t   __kmp_cpuinfo = { 0 }; /
 // lock for modifying the global __kmp_stats_list
 kmp_tas_lock_t __kmp_stats_lock;
 
-// global list of per thread stats, the head is a sentinel node which accumulates all stats produced before __kmp_create_worker is called.
-kmp_stats_list* __kmp_stats_list;
+// global list of per thread stats, the head is a sentinel node which
+// accumulates all stats produced before __kmp_create_worker is called.
+kmp_stats_list *__kmp_stats_list;
 
 // thread local pointer to stats node within list
-__thread kmp_stats_list* __kmp_stats_thread_ptr = NULL;
+__thread kmp_stats_list *__kmp_stats_thread_ptr = NULL;
 
 // gives reference tick for all events (considered the 0 tick)
 tsc_tick_count __kmp_stats_start_time;
@@ -40,176 +41,196 @@ tsc_tick_count __kmp_stats_start_time;
 /* ----------------------------------------------------- */
 /* INITIALIZATION VARIABLES */
 /* they are syncronized to write during init, but read anytime */
-volatile int        __kmp_init_serial     = FALSE;
-volatile int        __kmp_init_gtid       = FALSE;
-volatile int        __kmp_init_common     = FALSE;
-volatile int        __kmp_init_middle     = FALSE;
-volatile int        __kmp_init_parallel   = FALSE;
+volatile int __kmp_init_serial = FALSE;
+volatile int __kmp_init_gtid = FALSE;
+volatile int __kmp_init_common = FALSE;
+volatile int __kmp_init_middle = FALSE;
+volatile int __kmp_init_parallel = FALSE;
 #if KMP_USE_MONITOR
-volatile int        __kmp_init_monitor    = 0;  /* 1 - launched, 2 - actually started (Windows* OS only) */
+volatile int __kmp_init_monitor =
+    0; /* 1 - launched, 2 - actually started (Windows* OS only) */
 #endif
-volatile int        __kmp_init_user_locks = FALSE;
+volatile int __kmp_init_user_locks = FALSE;
 
 /* list of address of allocated caches for commons */
-kmp_cached_addr_t  *__kmp_threadpriv_cache_list = NULL;
+kmp_cached_addr_t *__kmp_threadpriv_cache_list = NULL;
 
-int                 __kmp_init_counter  = 0;
-int                 __kmp_root_counter  = 0;
-int                 __kmp_version       = 0;
+int __kmp_init_counter = 0;
+int __kmp_root_counter = 0;
+int __kmp_version = 0;
 
-volatile kmp_uint32 __kmp_team_counter  = 0;
-volatile kmp_uint32 __kmp_task_counter  = 0;
+volatile kmp_uint32 __kmp_team_counter = 0;
+volatile kmp_uint32 __kmp_task_counter = 0;
 
-unsigned int __kmp_init_wait = KMP_DEFAULT_INIT_WAIT;   /* initial number of spin-tests   */
-unsigned int __kmp_next_wait = KMP_DEFAULT_NEXT_WAIT;   /* susequent number of spin-tests */
+unsigned int __kmp_init_wait =
+    KMP_DEFAULT_INIT_WAIT; /* initial number of spin-tests   */
+unsigned int __kmp_next_wait =
+    KMP_DEFAULT_NEXT_WAIT; /* susequent number of spin-tests */
 
-size_t      __kmp_stksize         = KMP_DEFAULT_STKSIZE;
+size_t __kmp_stksize = KMP_DEFAULT_STKSIZE;
 #if KMP_USE_MONITOR
-size_t      __kmp_monitor_stksize = 0;  // auto adjust
+size_t __kmp_monitor_stksize = 0; // auto adjust
 #endif
-size_t      __kmp_stkoffset       = KMP_DEFAULT_STKOFFSET;
-int         __kmp_stkpadding      = KMP_MIN_STKPADDING;
+size_t __kmp_stkoffset = KMP_DEFAULT_STKOFFSET;
+int __kmp_stkpadding = KMP_MIN_STKPADDING;
 
-size_t    __kmp_malloc_pool_incr  = KMP_DEFAULT_MALLOC_POOL_INCR;
+size_t __kmp_malloc_pool_incr = KMP_DEFAULT_MALLOC_POOL_INCR;
 
-/* Barrier method defaults, settings, and strings */
-/* branch factor = 2^branch_bits (only relevant for tree and hyper barrier types) */
+// Barrier method defaults, settings, and strings.
+// branch factor = 2^branch_bits (only relevant for tree & hyper barrier types)
 #if KMP_ARCH_X86_64
-kmp_uint32 __kmp_barrier_gather_bb_dflt      = 2;  /* branch_factor = 4 */ /* hyper2: C78980 */
-kmp_uint32 __kmp_barrier_release_bb_dflt     = 2;  /* branch_factor = 4 */ /* hyper2: C78980 */
+kmp_uint32 __kmp_barrier_gather_bb_dflt = 2;
+/* branch_factor = 4 */ /* hyper2: C78980 */
+kmp_uint32 __kmp_barrier_release_bb_dflt = 2;
+/* branch_factor = 4 */ /* hyper2: C78980 */
 #else
-kmp_uint32 __kmp_barrier_gather_bb_dflt      = 2;  /* branch_factor = 4 */ /* communication in core for MIC */
-kmp_uint32 __kmp_barrier_release_bb_dflt     = 2;  /* branch_factor = 4 */ /* communication in core for MIC */
+kmp_uint32 __kmp_barrier_gather_bb_dflt = 2;
+/* branch_factor = 4 */ /* communication in core for MIC */
+kmp_uint32 __kmp_barrier_release_bb_dflt = 2;
+/* branch_factor = 4 */ /* communication in core for MIC */
 #endif // KMP_ARCH_X86_64
 #if KMP_ARCH_X86_64
-kmp_bar_pat_e __kmp_barrier_gather_pat_dflt  = bp_hyper_bar;  /* hyper2: C78980 */
-kmp_bar_pat_e __kmp_barrier_release_pat_dflt = bp_hyper_bar;  /* hyper2: C78980 */
+kmp_bar_pat_e __kmp_barrier_gather_pat_dflt = bp_hyper_bar; /* hyper2: C78980 */
+kmp_bar_pat_e __kmp_barrier_release_pat_dflt =
+    bp_hyper_bar; /* hyper2: C78980 */
 #else
-kmp_bar_pat_e __kmp_barrier_gather_pat_dflt  = bp_linear_bar;
+kmp_bar_pat_e __kmp_barrier_gather_pat_dflt = bp_linear_bar;
 kmp_bar_pat_e __kmp_barrier_release_pat_dflt = bp_linear_bar;
 #endif
-kmp_uint32 __kmp_barrier_gather_branch_bits  [ bs_last_barrier ] = { 0 };
-kmp_uint32 __kmp_barrier_release_branch_bits [ bs_last_barrier ] = { 0 };
-kmp_bar_pat_e __kmp_barrier_gather_pattern   [ bs_last_barrier ] = { bp_linear_bar };
-kmp_bar_pat_e __kmp_barrier_release_pattern  [ bs_last_barrier ] = { bp_linear_bar };
-char const *__kmp_barrier_branch_bit_env_name [ bs_last_barrier ] =
-                            { "KMP_PLAIN_BARRIER", "KMP_FORKJOIN_BARRIER"
-                                #if KMP_FAST_REDUCTION_BARRIER
-                                    , "KMP_REDUCTION_BARRIER"
-                                #endif // KMP_FAST_REDUCTION_BARRIER
-                            };
-char const *__kmp_barrier_pattern_env_name    [ bs_last_barrier ] =
-                            { "KMP_PLAIN_BARRIER_PATTERN", "KMP_FORKJOIN_BARRIER_PATTERN"
-                                #if KMP_FAST_REDUCTION_BARRIER
-                                    , "KMP_REDUCTION_BARRIER_PATTERN"
-                                #endif // KMP_FAST_REDUCTION_BARRIER
-                            };
-char const *__kmp_barrier_type_name           [ bs_last_barrier ] =
-                            { "plain", "forkjoin"
-                                #if KMP_FAST_REDUCTION_BARRIER
-                                    , "reduction"
-                                #endif // KMP_FAST_REDUCTION_BARRIER
-                            };
-char const *__kmp_barrier_pattern_name[bp_last_bar] = {"linear","tree","hyper","hierarchical"};
-
-int       __kmp_allThreadsSpecified = 0;
-size_t    __kmp_align_alloc = CACHE_LINE;
-
-
-int     __kmp_generate_warnings = kmp_warnings_low;
-int          __kmp_reserve_warn = 0;
-int                 __kmp_xproc = 0;
-int            __kmp_avail_proc = 0;
-size_t    __kmp_sys_min_stksize = KMP_MIN_STKSIZE;
-int           __kmp_sys_max_nth = KMP_MAX_NTH;
-int               __kmp_max_nth = 0;
-int      __kmp_threads_capacity = 0;
-int         __kmp_dflt_team_nth = 0;
-int      __kmp_dflt_team_nth_ub = 0;
-int           __kmp_tp_capacity = 0;
-int             __kmp_tp_cached = 0;
-int           __kmp_dflt_nested = FALSE;
-int  __kmp_dispatch_num_buffers = KMP_DFLT_DISP_NUM_BUFF;
-int __kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT; /* max_active_levels limit */
+kmp_uint32 __kmp_barrier_gather_branch_bits[bs_last_barrier] = {0};
+kmp_uint32 __kmp_barrier_release_branch_bits[bs_last_barrier] = {0};
+kmp_bar_pat_e __kmp_barrier_gather_pattern[bs_last_barrier] = {bp_linear_bar};
+kmp_bar_pat_e __kmp_barrier_release_pattern[bs_last_barrier] = {bp_linear_bar};
+char const *__kmp_barrier_branch_bit_env_name[bs_last_barrier] = {
+    "KMP_PLAIN_BARRIER", "KMP_FORKJOIN_BARRIER"
+#if KMP_FAST_REDUCTION_BARRIER
+    ,
+    "KMP_REDUCTION_BARRIER"
+#endif // KMP_FAST_REDUCTION_BARRIER
+};
+char const *__kmp_barrier_pattern_env_name[bs_last_barrier] = {
+    "KMP_PLAIN_BARRIER_PATTERN", "KMP_FORKJOIN_BARRIER_PATTERN"
+#if KMP_FAST_REDUCTION_BARRIER
+    ,
+    "KMP_REDUCTION_BARRIER_PATTERN"
+#endif // KMP_FAST_REDUCTION_BARRIER
+};
+char const *__kmp_barrier_type_name[bs_last_barrier] = {"plain", "forkjoin"
+#if KMP_FAST_REDUCTION_BARRIER
+                                                        ,
+                                                        "reduction"
+#endif // KMP_FAST_REDUCTION_BARRIER
+};
+char const *__kmp_barrier_pattern_name[bp_last_bar] = {"linear", "tree",
+                                                       "hyper", "hierarchical"};
+
+int __kmp_allThreadsSpecified = 0;
+size_t __kmp_align_alloc = CACHE_LINE;
+
+
+int __kmp_generate_warnings = kmp_warnings_low;
+int __kmp_reserve_warn = 0;
+int __kmp_xproc = 0;
+int __kmp_avail_proc = 0;
+size_t __kmp_sys_min_stksize = KMP_MIN_STKSIZE;
+int __kmp_sys_max_nth = KMP_MAX_NTH;
+int __kmp_max_nth = 0;
+int __kmp_threads_capacity = 0;
+int __kmp_dflt_team_nth = 0;
+int __kmp_dflt_team_nth_ub = 0;
+int __kmp_tp_capacity = 0;
+int __kmp_tp_cached = 0;
+int __kmp_dflt_nested = FALSE;
+int __kmp_dispatch_num_buffers = KMP_DFLT_DISP_NUM_BUFF;
+int __kmp_dflt_max_active_levels =
+    KMP_MAX_ACTIVE_LEVELS_LIMIT; /* max_active_levels limit */
 #if KMP_NESTED_HOT_TEAMS
-int __kmp_hot_teams_mode         = 0; /* 0 - free extra threads when reduced */
-                                      /* 1 - keep extra threads when reduced */
-int __kmp_hot_teams_max_level    = 1; /* nesting level of hot teams */
+int __kmp_hot_teams_mode = 0; /* 0 - free extra threads when reduced */
+/* 1 - keep extra threads when reduced */
+int __kmp_hot_teams_max_level = 1; /* nesting level of hot teams */
 #endif
 enum library_type __kmp_library = library_none;
-enum sched_type     __kmp_sched = kmp_sch_default;  /* scheduling method for runtime scheduling */
-enum sched_type    __kmp_static = kmp_sch_static_greedy; /* default static scheduling method */
-enum sched_type    __kmp_guided = kmp_sch_guided_iterative_chunked; /* default guided scheduling method */
-enum sched_type      __kmp_auto = kmp_sch_guided_analytical_chunked; /* default auto scheduling method */
-int        __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
+enum sched_type __kmp_sched =
+    kmp_sch_default; /* scheduling method for runtime scheduling */
+enum sched_type __kmp_static =
+    kmp_sch_static_greedy; /* default static scheduling method */
+enum sched_type __kmp_guided =
+    kmp_sch_guided_iterative_chunked; /* default guided scheduling method */
+enum sched_type __kmp_auto =
+    kmp_sch_guided_analytical_chunked; /* default auto scheduling method */
+int __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME;
 #if KMP_USE_MONITOR
-int       __kmp_monitor_wakeups = KMP_MIN_MONITOR_WAKEUPS;
-int          __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME( KMP_DEFAULT_BLOCKTIME, KMP_MIN_MONITOR_WAKEUPS );
+int __kmp_monitor_wakeups = KMP_MIN_MONITOR_WAKEUPS;
+int __kmp_bt_intervals = KMP_INTERVALS_FROM_BLOCKTIME(KMP_DEFAULT_BLOCKTIME,
+                                                      KMP_MIN_MONITOR_WAKEUPS);
 #endif
 #ifdef KMP_ADJUST_BLOCKTIME
-int               __kmp_zero_bt = FALSE;
+int __kmp_zero_bt = FALSE;
 #endif /* KMP_ADJUST_BLOCKTIME */
 #ifdef KMP_DFLT_NTH_CORES
-int                __kmp_ncores = 0;
+int __kmp_ncores = 0;
 #endif
-int                 __kmp_chunk = 0;
-int           __kmp_abort_delay = 0;
+int __kmp_chunk = 0;
+int __kmp_abort_delay = 0;
 #if KMP_OS_LINUX && defined(KMP_TDATA_GTID)
-int             __kmp_gtid_mode = 3; /* use __declspec(thread) TLS to store gtid */
-int      __kmp_adjust_gtid_mode = FALSE;
+int __kmp_gtid_mode = 3; /* use __declspec(thread) TLS to store gtid */
+int __kmp_adjust_gtid_mode = FALSE;
 #elif KMP_OS_WINDOWS
-int             __kmp_gtid_mode = 2; /* use TLS functions to store gtid */
-int      __kmp_adjust_gtid_mode = FALSE;
+int __kmp_gtid_mode = 2; /* use TLS functions to store gtid */
+int __kmp_adjust_gtid_mode = FALSE;
 #else
-int             __kmp_gtid_mode = 0; /* select method to get gtid based on #threads */
-int      __kmp_adjust_gtid_mode = TRUE;
+int __kmp_gtid_mode = 0; /* select method to get gtid based on #threads */
+int __kmp_adjust_gtid_mode = TRUE;
 #endif /* KMP_OS_LINUX && defined(KMP_TDATA_GTID) */
 #ifdef KMP_TDATA_GTID
 #if KMP_OS_WINDOWS
 __declspec(thread) int __kmp_gtid = KMP_GTID_DNE;
 #else
 __thread int __kmp_gtid = KMP_GTID_DNE;
-#endif /* KMP_OS_WINDOWS - workaround because Intel(R) Many Integrated Core compiler 20110316 doesn't accept __declspec */
+#endif /* KMP_OS_WINDOWS - workaround because Intel(R) Many Integrated Core    \
+          compiler 20110316 doesn't accept __declspec */
 #endif /* KMP_TDATA_GTID */
-int          __kmp_tls_gtid_min = INT_MAX;
-int            __kmp_foreign_tp = TRUE;
+int __kmp_tls_gtid_min = INT_MAX;
+int __kmp_foreign_tp = TRUE;
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
-int    __kmp_inherit_fp_control = TRUE;
-kmp_int16  __kmp_init_x87_fpu_control_word = 0;
-kmp_uint32     __kmp_init_mxcsr = 0;
+int __kmp_inherit_fp_control = TRUE;
+kmp_int16 __kmp_init_x87_fpu_control_word = 0;
+kmp_uint32 __kmp_init_mxcsr = 0;
 #endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
 
 #ifdef USE_LOAD_BALANCE
-double  __kmp_load_balance_interval   = 1.0;
+double __kmp_load_balance_interval = 1.0;
 #endif /* USE_LOAD_BALANCE */
 
-kmp_nested_nthreads_t __kmp_nested_nth  = { NULL, 0, 0 };
+kmp_nested_nthreads_t __kmp_nested_nth = {NULL, 0, 0};
 
 #if KMP_USE_ADAPTIVE_LOCKS
 
-kmp_adaptive_backoff_params_t __kmp_adaptive_backoff_params = { 1, 1024 }; // TODO: tune it!
+kmp_adaptive_backoff_params_t __kmp_adaptive_backoff_params = {
+    1, 1024}; // TODO: tune it!
 
 #if KMP_DEBUG_ADAPTIVE_LOCKS
-char * __kmp_speculative_statsfile = "-";
+char *__kmp_speculative_statsfile = "-";
 #endif
 
 #endif // KMP_USE_ADAPTIVE_LOCKS
 
 #if OMP_40_ENABLED
-int __kmp_display_env           = FALSE;
-int __kmp_display_env_verbose   = FALSE;
-int __kmp_omp_cancellation      = FALSE;
+int __kmp_display_env = FALSE;
+int __kmp_display_env_verbose = FALSE;
+int __kmp_omp_cancellation = FALSE;
 #endif
 
 /* map OMP 3.0 schedule types with our internal schedule types */
-enum sched_type __kmp_sch_map[ kmp_sched_upper - kmp_sched_lower_ext + kmp_sched_upper_std - kmp_sched_lower - 2 ] = {
-    kmp_sch_static_chunked,     // ==> kmp_sched_static            = 1
-    kmp_sch_dynamic_chunked,    // ==> kmp_sched_dynamic           = 2
-    kmp_sch_guided_chunked,     // ==> kmp_sched_guided            = 3
-    kmp_sch_auto,               // ==> kmp_sched_auto              = 4
-    kmp_sch_trapezoidal         // ==> kmp_sched_trapezoidal       = 101
-                                // will likely not used, introduced here just to debug the code
-                                // of public intel extension schedules
+enum sched_type __kmp_sch_map[kmp_sched_upper - kmp_sched_lower_ext +
+                              kmp_sched_upper_std - kmp_sched_lower - 2] = {
+    kmp_sch_static_chunked, // ==> kmp_sched_static            = 1
+    kmp_sch_dynamic_chunked, // ==> kmp_sched_dynamic           = 2
+    kmp_sch_guided_chunked, // ==> kmp_sched_guided            = 3
+    kmp_sch_auto, // ==> kmp_sched_auto              = 4
+    kmp_sch_trapezoidal // ==> kmp_sched_trapezoidal       = 101
+    // will likely not be used, introduced here just to debug the code
+    // of public intel extension schedules
 };
 
 #if KMP_OS_LINUX
@@ -223,44 +244,45 @@ enum mic_type __kmp_mic_type = non_mic;
 
 #if KMP_AFFINITY_SUPPORTED
 
-KMPAffinity* __kmp_affinity_dispatch = NULL;
+KMPAffinity *__kmp_affinity_dispatch = NULL;
 
-# if KMP_USE_HWLOC
+#if KMP_USE_HWLOC
 int __kmp_hwloc_error = FALSE;
 hwloc_topology_t __kmp_hwloc_topology = NULL;
-# endif
+#endif
 
-# if KMP_OS_WINDOWS
-#  if KMP_GROUP_AFFINITY
+#if KMP_OS_WINDOWS
+#if KMP_GROUP_AFFINITY
 int __kmp_num_proc_groups = 1;
-#  endif /* KMP_GROUP_AFFINITY */
+#endif /* KMP_GROUP_AFFINITY */
 kmp_GetActiveProcessorCount_t __kmp_GetActiveProcessorCount = NULL;
 kmp_GetActiveProcessorGroupCount_t __kmp_GetActiveProcessorGroupCount = NULL;
 kmp_GetThreadGroupAffinity_t __kmp_GetThreadGroupAffinity = NULL;
 kmp_SetThreadGroupAffinity_t __kmp_SetThreadGroupAffinity = NULL;
-# endif /* KMP_OS_WINDOWS */
+#endif /* KMP_OS_WINDOWS */
 
-size_t   __kmp_affin_mask_size = 0;
+size_t __kmp_affin_mask_size = 0;
 enum affinity_type __kmp_affinity_type = affinity_default;
 enum affinity_gran __kmp_affinity_gran = affinity_gran_default;
-int __kmp_affinity_gran_levels  = -1;
+int __kmp_affinity_gran_levels = -1;
 int __kmp_affinity_dups = TRUE;
-enum affinity_top_method __kmp_affinity_top_method = affinity_top_method_default;
-int      __kmp_affinity_compact      = 0;
-int      __kmp_affinity_offset       = 0;
-int      __kmp_affinity_verbose      = FALSE;
-int      __kmp_affinity_warnings     = TRUE;
-int      __kmp_affinity_respect_mask = affinity_respect_mask_default;
-char *   __kmp_affinity_proclist     = NULL;
+enum affinity_top_method __kmp_affinity_top_method =
+    affinity_top_method_default;
+int __kmp_affinity_compact = 0;
+int __kmp_affinity_offset = 0;
+int __kmp_affinity_verbose = FALSE;
+int __kmp_affinity_warnings = TRUE;
+int __kmp_affinity_respect_mask = affinity_respect_mask_default;
+char *__kmp_affinity_proclist = NULL;
 kmp_affin_mask_t *__kmp_affinity_masks = NULL;
-unsigned __kmp_affinity_num_masks    = 0;
+unsigned __kmp_affinity_num_masks = 0;
 
-char const *  __kmp_cpuinfo_file     = NULL;
+char const *__kmp_cpuinfo_file = NULL;
 
 #endif /* KMP_AFFINITY_SUPPORTED */
 
 #if OMP_40_ENABLED
-kmp_nested_proc_bind_t __kmp_nested_proc_bind = { NULL, 0, 0 };
+kmp_nested_proc_bind_t __kmp_nested_proc_bind = {NULL, 0, 0};
 int __kmp_affinity_num_places = 0;
 #endif
 
@@ -281,75 +303,87 @@ kmp_tasking_mode_t __kmp_tasking_mode =
 kmp_int32 __kmp_max_task_priority = 0;
 #endif
 
-/* This check ensures that the compiler is passing the correct data type
- * for the flags formal parameter of the function kmpc_omp_task_alloc().
- * If the type is not a 4-byte type, then give an error message about
- * a non-positive length array pointing here.  If that happens, the
- * kmp_tasking_flags_t structure must be redefined to have exactly 32 bits.
- */
-KMP_BUILD_ASSERT( sizeof(kmp_tasking_flags_t) == 4 );
+/* This check ensures that the compiler is passing the correct data type for the
+   flags formal parameter of the function kmpc_omp_task_alloc(). If the type is
+   not a 4-byte type, then give an error message about a non-positive length
+   array pointing here.  If that happens, the kmp_tasking_flags_t structure must
+   be redefined to have exactly 32 bits. */
+KMP_BUILD_ASSERT(sizeof(kmp_tasking_flags_t) == 4);
 
-kmp_int32 __kmp_task_stealing_constraint = 1;   /* Constrain task stealing by default */
+kmp_int32 __kmp_task_stealing_constraint =
+    1; /* Constrain task stealing by default */
 
 #ifdef DEBUG_SUSPEND
-int         __kmp_suspend_count = 0;
+int __kmp_suspend_count = 0;
 #endif
 
-int     __kmp_settings = FALSE;
-int     __kmp_duplicate_library_ok = 0;
+int __kmp_settings = FALSE;
+int __kmp_duplicate_library_ok = 0;
 #if USE_ITT_BUILD
-int     __kmp_forkjoin_frames = 1;
-int     __kmp_forkjoin_frames_mode = 3;
+int __kmp_forkjoin_frames = 1;
+int __kmp_forkjoin_frames_mode = 3;
 #endif
-PACKED_REDUCTION_METHOD_T __kmp_force_reduction_method = reduction_method_not_defined;
-int     __kmp_determ_red = FALSE;
+PACKED_REDUCTION_METHOD_T __kmp_force_reduction_method =
+    reduction_method_not_defined;
+int __kmp_determ_red = FALSE;
 
 #ifdef KMP_DEBUG
-int     kmp_a_debug = 0;
-int     kmp_b_debug = 0;
-int     kmp_c_debug = 0;
-int     kmp_d_debug = 0;
-int     kmp_e_debug = 0;
-int     kmp_f_debug = 0;
-int     kmp_diag    = 0;
+int kmp_a_debug = 0;
+int kmp_b_debug = 0;
+int kmp_c_debug = 0;
+int kmp_d_debug = 0;
+int kmp_e_debug = 0;
+int kmp_f_debug = 0;
+int kmp_diag = 0;
 #endif
 
 /* For debug information logging using rotating buffer */
-int     __kmp_debug_buf = FALSE;        /* TRUE means use buffer, FALSE means print to stderr */
-int     __kmp_debug_buf_lines = KMP_DEBUG_BUF_LINES_INIT; /* Lines of debug stored in buffer */
-int     __kmp_debug_buf_chars = KMP_DEBUG_BUF_CHARS_INIT; /* Characters allowed per line in buffer */
-int     __kmp_debug_buf_atomic = FALSE; /* TRUE means use atomic update of buffer entry pointer */
-
-char   *__kmp_debug_buffer = NULL;      /* Debug buffer itself */
-int     __kmp_debug_count = 0;          /* Counter for number of lines printed in buffer so far */
-int     __kmp_debug_buf_warn_chars = 0; /* Keep track of char increase recommended in warnings */
+int __kmp_debug_buf =
+    FALSE; /* TRUE means use buffer, FALSE means print to stderr */
+int __kmp_debug_buf_lines =
+    KMP_DEBUG_BUF_LINES_INIT; /* Lines of debug stored in buffer */
+int __kmp_debug_buf_chars =
+    KMP_DEBUG_BUF_CHARS_INIT; /* Characters allowed per line in buffer */
+int __kmp_debug_buf_atomic =
+    FALSE; /* TRUE means use atomic update of buffer entry pointer */
+
+char *__kmp_debug_buffer = NULL; /* Debug buffer itself */
+int __kmp_debug_count =
+    0; /* Counter for number of lines printed in buffer so far */
+int __kmp_debug_buf_warn_chars =
+    0; /* Keep track of char increase recommended in warnings */
 /* end rotating debug buffer */
 
 #ifdef KMP_DEBUG
-int     __kmp_par_range;           /* +1 => only go par for constructs in range */
-                                           /* -1 => only go par for constructs outside range */
-char    __kmp_par_range_routine[KMP_PAR_RANGE_ROUTINE_LEN] = { '\0' };
-char    __kmp_par_range_filename[KMP_PAR_RANGE_FILENAME_LEN] = { '\0' };
-int     __kmp_par_range_lb = 0;
-int     __kmp_par_range_ub = INT_MAX;
+int __kmp_par_range; /* +1 => only go par for constructs in range */
+/* -1 => only go par for constructs outside range */
+char __kmp_par_range_routine[KMP_PAR_RANGE_ROUTINE_LEN] = {'\0'};
+char __kmp_par_range_filename[KMP_PAR_RANGE_FILENAME_LEN] = {'\0'};
+int __kmp_par_range_lb = 0;
+int __kmp_par_range_ub = INT_MAX;
 #endif /* KMP_DEBUG */
 
 /* For printing out dynamic storage map for threads and teams */
-int     __kmp_storage_map = FALSE;         /* True means print storage map for threads and teams */
-int     __kmp_storage_map_verbose = FALSE; /* True means storage map includes placement info */
-int     __kmp_storage_map_verbose_specified = FALSE;
-/* Initialize the library data structures when we fork a child process, defaults to TRUE */
-int     __kmp_need_register_atfork = TRUE; /* At initialization, call pthread_atfork to install fork handler */
-int     __kmp_need_register_atfork_specified = TRUE;
-
-int        __kmp_env_chunk       = FALSE;  /* KMP_CHUNK specified?     */
-int        __kmp_env_stksize     = FALSE;  /* KMP_STACKSIZE specified? */
-int        __kmp_env_omp_stksize = FALSE;  /* OMP_STACKSIZE specified? */
-int        __kmp_env_all_threads     = FALSE;/* KMP_ALL_THREADS or KMP_MAX_THREADS specified? */
-int        __kmp_env_omp_all_threads = FALSE;/* OMP_THREAD_LIMIT specified? */
-int        __kmp_env_blocktime   = FALSE;  /* KMP_BLOCKTIME specified? */
-int        __kmp_env_checks      = FALSE;  /* KMP_CHECKS specified?    */
-int        __kmp_env_consistency_check  = FALSE;  /* KMP_CONSISTENCY_CHECK specified? */
+int __kmp_storage_map =
+    FALSE; /* True means print storage map for threads and teams */
+int __kmp_storage_map_verbose =
+    FALSE; /* True means storage map includes placement info */
+int __kmp_storage_map_verbose_specified = FALSE;
+/* Initialize the library data structures when we fork a child process, defaults
+ * to TRUE */
+int __kmp_need_register_atfork =
+    TRUE; /* At initialization, call pthread_atfork to install fork handler */
+int __kmp_need_register_atfork_specified = TRUE;
+
+int __kmp_env_chunk = FALSE; /* KMP_CHUNK specified?     */
+int __kmp_env_stksize = FALSE; /* KMP_STACKSIZE specified? */
+int __kmp_env_omp_stksize = FALSE; /* OMP_STACKSIZE specified? */
+int __kmp_env_all_threads =
+    FALSE; /* KMP_ALL_THREADS or KMP_MAX_THREADS specified? */
+int __kmp_env_omp_all_threads = FALSE; /* OMP_THREAD_LIMIT specified? */
+int __kmp_env_blocktime = FALSE; /* KMP_BLOCKTIME specified? */
+int __kmp_env_checks = FALSE; /* KMP_CHECKS specified?    */
+int __kmp_env_consistency_check = FALSE; /* KMP_CONSISTENCY_CHECK specified? */
 
 kmp_uint32 __kmp_yield_init = KMP_INIT_WAIT;
 kmp_uint32 __kmp_yield_next = KMP_NEXT_WAIT;
@@ -360,42 +394,38 @@ kmp_uint32 __kmp_yielding_on = 1;
 #if KMP_OS_CNK
 kmp_uint32 __kmp_yield_cycle = 0;
 #else
-kmp_uint32 __kmp_yield_cycle = 1;     /* Yield-cycle is on by default */
+kmp_uint32 __kmp_yield_cycle = 1; /* Yield-cycle is on by default */
 #endif
-kmp_int32  __kmp_yield_on_count = 10; /* By default, yielding is on for 10 monitor periods. */
-kmp_int32  __kmp_yield_off_count = 1; /* By default, yielding is off for 1 monitor periods. */
-/* ----------------------------------------------------- */
-
+kmp_int32 __kmp_yield_on_count =
+    10; /* By default, yielding is on for 10 monitor periods. */
+kmp_int32 __kmp_yield_off_count =
+    1; /* By default, yielding is off for 1 monitor periods. */
 
 /* ------------------------------------------------------ */
 /* STATE mostly syncronized with global lock */
 /* data written to rarely by masters, read often by workers */
-/*
- * SHALL WE EDIT THE COMMENT BELOW IN SOME WAY?
- * TODO:  None of this global padding stuff works consistently because
- * the order of declaration is not necessarily correlated to storage order.
- * To fix this, all the important globals must be put in a big structure
- * instead.
- */
+/* TODO: None of this global padding stuff works consistently because the order
+   of declaration is not necessarily correlated to storage order. To fix this,
+   all the important globals must be put in a big structure instead. */
 KMP_ALIGN_CACHE
-         kmp_info_t **__kmp_threads     = NULL;
-         kmp_root_t **__kmp_root        = NULL;
+kmp_info_t **__kmp_threads = NULL;
+kmp_root_t **__kmp_root = NULL;
 
 /* data read/written to often by masters */
 KMP_ALIGN_CACHE
-volatile int          __kmp_nth                    = 0;
-volatile int          __kmp_all_nth                = 0;
-int                   __kmp_thread_pool_nth        = 0;
-volatile kmp_info_t  *__kmp_thread_pool            = NULL;
-volatile kmp_team_t  *__kmp_team_pool              = NULL;
+volatile int __kmp_nth = 0;
+volatile int __kmp_all_nth = 0;
+int __kmp_thread_pool_nth = 0;
+volatile kmp_info_t *__kmp_thread_pool = NULL;
+volatile kmp_team_t *__kmp_team_pool = NULL;
 
 KMP_ALIGN_CACHE
-volatile int          __kmp_thread_pool_active_nth = 0;
+volatile int __kmp_thread_pool_active_nth = 0;
 
 /* -------------------------------------------------
  * GLOBAL/ROOT STATE */
 KMP_ALIGN_CACHE
-kmp_global_t __kmp_global = {{ 0 }};
+kmp_global_t __kmp_global = {{0}};
 
 /* ----------------------------------------------- */
 /* GLOBAL SYNCHRONIZATION LOCKS */
@@ -406,66 +436,72 @@ kmp_global_t __kmp_global = {{ 0 }};
  * false sharing if the alignment is not large enough for these locks */
 KMP_ALIGN_CACHE_INTERNODE
 
-kmp_bootstrap_lock_t __kmp_initz_lock   = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_initz_lock   ); /* Control initializations */
+kmp_bootstrap_lock_t __kmp_initz_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
+    __kmp_initz_lock); /* Control initializations */
 KMP_ALIGN_CACHE_INTERNODE
 kmp_bootstrap_lock_t __kmp_forkjoin_lock; /* control fork/join access */
 KMP_ALIGN_CACHE_INTERNODE
-kmp_bootstrap_lock_t __kmp_exit_lock;   /* exit() is not always thread-safe */
+kmp_bootstrap_lock_t __kmp_exit_lock; /* exit() is not always thread-safe */
 #if KMP_USE_MONITOR
 KMP_ALIGN_CACHE_INTERNODE
 kmp_bootstrap_lock_t __kmp_monitor_lock; /* control monitor thread creation */
 #endif
+/* used for the hack to allow threadprivate cache and __kmp_threads expansion
+   to co-exist */
 KMP_ALIGN_CACHE_INTERNODE
-kmp_bootstrap_lock_t __kmp_tp_cached_lock; /* used for the hack to allow threadprivate cache and __kmp_threads expansion to co-exist */
+kmp_bootstrap_lock_t __kmp_tp_cached_lock;
 
 KMP_ALIGN_CACHE_INTERNODE
-kmp_lock_t __kmp_global_lock;           /* Control OS/global access */
+kmp_lock_t __kmp_global_lock; /* Control OS/global access */
 KMP_ALIGN_CACHE_INTERNODE
-kmp_queuing_lock_t __kmp_dispatch_lock;         /* Control dispatch access  */
+kmp_queuing_lock_t __kmp_dispatch_lock; /* Control dispatch access  */
 KMP_ALIGN_CACHE_INTERNODE
-kmp_lock_t __kmp_debug_lock;            /* Control I/O access for KMP_DEBUG */
+kmp_lock_t __kmp_debug_lock; /* Control I/O access for KMP_DEBUG */
 #else
 KMP_ALIGN_CACHE
 
-kmp_bootstrap_lock_t __kmp_initz_lock   = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_initz_lock   ); /* Control initializations */
+kmp_bootstrap_lock_t __kmp_initz_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
+    __kmp_initz_lock); /* Control initializations */
 kmp_bootstrap_lock_t __kmp_forkjoin_lock; /* control fork/join access */
-kmp_bootstrap_lock_t __kmp_exit_lock;   /* exit() is not always thread-safe */
+kmp_bootstrap_lock_t __kmp_exit_lock; /* exit() is not always thread-safe */
 #if KMP_USE_MONITOR
 kmp_bootstrap_lock_t __kmp_monitor_lock; /* control monitor thread creation */
 #endif
-kmp_bootstrap_lock_t __kmp_tp_cached_lock; /* used for the hack to allow threadprivate cache and __kmp_threads expansion to co-exist */
+/* used for the hack to allow threadprivate cache and __kmp_threads expansion
+   to co-exist */
+kmp_bootstrap_lock_t __kmp_tp_cached_lock;
 
 KMP_ALIGN(128)
-kmp_lock_t __kmp_global_lock;           /* Control OS/global access */
+kmp_lock_t __kmp_global_lock; /* Control OS/global access */
 KMP_ALIGN(128)
-kmp_queuing_lock_t __kmp_dispatch_lock;         /* Control dispatch access  */
+kmp_queuing_lock_t __kmp_dispatch_lock; /* Control dispatch access  */
 KMP_ALIGN(128)
-kmp_lock_t __kmp_debug_lock;            /* Control I/O access for KMP_DEBUG */
+kmp_lock_t __kmp_debug_lock; /* Control I/O access for KMP_DEBUG */
 #endif
 
 /* ----------------------------------------------- */
 
 #if KMP_HANDLE_SIGNALS
-    /*
-        Signal handling is disabled by default, because it confuses users: In case of sigsegv
-        (or other trouble) in user code signal handler catches the signal, which then "appears" in
-        the monitor thread (when the monitor executes raise() function). Users see signal in the
-        monitor thread and blame OpenMP RTL.
-
-        Grant said signal handling required on some older OSes (Irix?) supported by KAI, because
-        bad applications hung but not aborted. Currently it is not a problem for Linux* OS, OS X* and
-        Windows* OS.
-
-        Grant: Found new hangs for EL4, EL5, and a Fedora Core machine.  So I'm putting
-        the default back for now to see if that fixes hangs on those machines.
-
-        2010-04013 Lev: It was a bug in Fortran RTL. Fortran RTL prints a kind of stack backtrace
-        when program is aborting, but the code is not signal-safe. When multiple signals raised at
-        the same time (which occurs in dynamic negative tests because all the worker threads detects
-        the same error), Fortran RTL may hang. The bug finally fixed in Fortran RTL library provided
-        by Steve R., and will be available soon.
-    */
-    int __kmp_handle_signals = FALSE;
+/* Signal handling is disabled by default, because it confuses users: In case of
+   sigsegv (or other trouble) in user code signal handler catches the signal,
+   which then "appears" in the monitor thread (when the monitor executes raise()
+   function). Users see signal in the monitor thread and blame OpenMP RTL.
+
+   Grant said signal handling required on some older OSes (Irix?) supported by
+   KAI, because bad applications hung but not aborted. Currently it is not a
+   problem for Linux* OS, OS X* and Windows* OS.
+
+   Grant: Found new hangs for EL4, EL5, and a Fedora Core machine.  So I'm
+   putting the default back for now to see if that fixes hangs on those
+   machines.
+
+   2010-04013 Lev: It was a bug in Fortran RTL. Fortran RTL prints a kind of
+   stack backtrace when program is aborting, but the code is not signal-safe.
+   When multiple signals raised at the same time (which occurs in dynamic
+   negative tests because all the worker threads detects the same error),
+   Fortran RTL may hang. The bug finally fixed in Fortran RTL library provided
+   by Steve R., and will be available soon. */
+int __kmp_handle_signals = FALSE;
 #endif
 
 /* ----------------------------------------------- */
@@ -474,26 +510,21 @@ kmp_key_t __kmp_tv_key = 0;
 #endif
 
 /* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
 
 #ifdef DEBUG_SUSPEND
-int
-get_suspend_count_( void ) {
-    int count = __kmp_suspend_count;
-    __kmp_suspend_count = 0;
-    return count;
-}
-void
-set_suspend_count_( int * value ) {
-    __kmp_suspend_count = *value;
+int get_suspend_count_(void) {
+  int count = __kmp_suspend_count;
+  __kmp_suspend_count = 0;
+  return count;
 }
+void set_suspend_count_(int *value) { __kmp_suspend_count = *value; }
 #endif
 
 // Symbols for MS mutual detection.
 int _You_must_link_with_exactly_one_OpenMP_library = 1;
-int _You_must_link_with_Intel_OpenMP_library       = 1;
-#if KMP_OS_WINDOWS && ( KMP_VERSION_MAJOR > 4 )
-    int _You_must_link_with_Microsoft_OpenMP_library = 1;
+int _You_must_link_with_Intel_OpenMP_library = 1;
+#if KMP_OS_WINDOWS && (KMP_VERSION_MAJOR > 4)
+int _You_must_link_with_Microsoft_OpenMP_library = 1;
 #endif
 
 // end of file //

Modified: openmp/trunk/runtime/src/kmp_gsupport.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_gsupport.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_gsupport.cpp (original)
+++ openmp/trunk/runtime/src/kmp_gsupport.cpp Fri May 12 13:01:32 2017
@@ -21,551 +21,473 @@
 #endif
 
 #ifdef __cplusplus
-    extern "C" {
+extern "C" {
 #endif // __cplusplus
 
-#define MKLOC(loc,routine) \
-    static ident_t (loc) = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;" };
+#define MKLOC(loc, routine)                                                    \
+  static ident_t(loc) = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;"};
 
 #include "kmp_ftn_os.h"
 
-void
-xexpand(KMP_API_NAME_GOMP_BARRIER)(void)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_barrier");
-    KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
+void xexpand(KMP_API_NAME_GOMP_BARRIER)(void) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_barrier");
+  KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
 #if OMPT_SUPPORT && OMPT_TRACE
-    ompt_frame_t * ompt_frame;
-    if (ompt_enabled ) {
-        ompt_frame = __ompt_get_task_frame_internal(0);
-        ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
-    } 
+  ompt_frame_t *ompt_frame;
+  if (ompt_enabled) {
+    ompt_frame = __ompt_get_task_frame_internal(0);
+    ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
+  }
 #endif
-    __kmpc_barrier(&loc, gtid);
+  __kmpc_barrier(&loc, gtid);
 }
 
-
-//
 // Mutual exclusion
-//
 
-//
-// The symbol that icc/ifort generates for unnamed for unnamed critical
-// sections - .gomp_critical_user_ - is defined using .comm in any objects
-// reference it.  We can't reference it directly here in C code, as the
-// symbol contains a ".".
+// The symbol that icc/ifort generates for unnamed for unnamed critical sections
+// - .gomp_critical_user_ - is defined using .comm in any objects reference it.
+// We can't reference it directly here in C code, as the symbol contains a ".".
 //
 // The RTL contains an assembly language definition of .gomp_critical_user_
 // with another symbol __kmp_unnamed_critical_addr initialized with it's
 // address.
-//
 extern kmp_critical_name *__kmp_unnamed_critical_addr;
 
-
-void
-xexpand(KMP_API_NAME_GOMP_CRITICAL_START)(void)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_critical_start");
-    KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
-    __kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
+void xexpand(KMP_API_NAME_GOMP_CRITICAL_START)(void) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_critical_start");
+  KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
+  __kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
+}
+
+void xexpand(KMP_API_NAME_GOMP_CRITICAL_END)(void) {
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_critical_end");
+  KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
+  __kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
+}
+
+void xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_critical_name_start");
+  KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid));
+  __kmpc_critical(&loc, gtid, (kmp_critical_name *)pptr);
+}
+
+void xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr) {
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_critical_name_end");
+  KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
+  __kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
 }
 
-
-void
-xexpand(KMP_API_NAME_GOMP_CRITICAL_END)(void)
-{
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_critical_end");
-    KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
-    __kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
-}
-
-
-void
-xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_critical_name_start");
-    KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid));
-    __kmpc_critical(&loc, gtid, (kmp_critical_name *)pptr);
-}
-
-
-void
-xexpand(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr)
-{
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_critical_name_end");
-    KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
-    __kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
-}
-
-
-//
 // The Gnu codegen tries to use locked operations to perform atomic updates
 // inline.  If it can't, then it calls GOMP_atomic_start() before performing
 // the update and GOMP_atomic_end() afterward, regardless of the data type.
-//
-
-void
-xexpand(KMP_API_NAME_GOMP_ATOMIC_START)(void)
-{
-    int gtid = __kmp_entry_gtid();
-    KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
+void xexpand(KMP_API_NAME_GOMP_ATOMIC_START)(void) {
+  int gtid = __kmp_entry_gtid();
+  KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
 
 #if OMPT_SUPPORT
-    __ompt_thread_assign_wait_id(0);
+  __ompt_thread_assign_wait_id(0);
 #endif
 
-    __kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
+  __kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
 }
 
-
-void
-xexpand(KMP_API_NAME_GOMP_ATOMIC_END)(void)
-{
-    int gtid = __kmp_get_gtid();
-    KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
-    __kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
+void xexpand(KMP_API_NAME_GOMP_ATOMIC_END)(void) {
+  int gtid = __kmp_get_gtid();
+  KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
+  __kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
 }
 
+int xexpand(KMP_API_NAME_GOMP_SINGLE_START)(void) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_single_start");
+  KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
 
-int
-xexpand(KMP_API_NAME_GOMP_SINGLE_START)(void)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_single_start");
-    KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
-
-    if (! TCR_4(__kmp_init_parallel))
-        __kmp_parallel_initialize();
+  if (!TCR_4(__kmp_init_parallel))
+    __kmp_parallel_initialize();
 
-    //
-    // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
-    // workshare when USE_CHECKS is defined.  We need to avoid the push,
-    // as there is no corresponding GOMP_single_end() call.
-    //
-    return __kmp_enter_single(gtid, &loc, FALSE);
+  // 3rd parameter == FALSE prevents kmp_enter_single from pushing a
+  // workshare when USE_CHECKS is defined.  We need to avoid the push,
+  // as there is no corresponding GOMP_single_end() call.
+  return __kmp_enter_single(gtid, &loc, FALSE);
 }
 
+void *xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void) {
+  void *retval;
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_single_copy_start");
+  KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
 
-void *
-xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void)
-{
-    void *retval;
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_single_copy_start");
-    KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
-
-    if (! TCR_4(__kmp_init_parallel))
-        __kmp_parallel_initialize();
+  if (!TCR_4(__kmp_init_parallel))
+    __kmp_parallel_initialize();
 
-    //
-    // If this is the first thread to enter, return NULL.  The generated
-    // code will then call GOMP_single_copy_end() for this thread only,
-    // with the copyprivate data pointer as an argument.
-    //
-    if (__kmp_enter_single(gtid, &loc, FALSE))
-        return NULL;
+  // If this is the first thread to enter, return NULL.  The generated code will
+  // then call GOMP_single_copy_end() for this thread only, with the
+  // copyprivate data pointer as an argument.
+  if (__kmp_enter_single(gtid, &loc, FALSE))
+    return NULL;
 
-    //
-    // Wait for the first thread to set the copyprivate data pointer,
-    // and for all other threads to reach this point.
-    //
-    __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  // Wait for the first thread to set the copyprivate data pointer,
+  // and for all other threads to reach this point.
+  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
 
-    //
-    // Retrieve the value of the copyprivate data point, and wait for all
-    // threads to do likewise, then return.
-    //
-    retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
-    __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
-    return retval;
+  // Retrieve the value of the copyprivate data point, and wait for all
+  // threads to do likewise, then return.
+  retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
+  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  return retval;
 }
 
+void xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data) {
+  int gtid = __kmp_get_gtid();
+  KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
 
-void
-xexpand(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data)
-{
-    int gtid = __kmp_get_gtid();
-    KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
-
-    //
-    // Set the copyprivate data pointer fo the team, then hit the barrier
-    // so that the other threads will continue on and read it.  Hit another
-    // barrier before continuing, so that the know that the copyprivate
-    // data pointer has been propagated to all threads before trying to
-    // reuse the t_copypriv_data field.
-    //
-    __kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
-    __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
-    __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  // Set the copyprivate data pointer fo the team, then hit the barrier so that
+  // the other threads will continue on and read it.  Hit another barrier before
+  // continuing, so that the know that the copyprivate data pointer has been
+  // propagated to all threads before trying to reuse the t_copypriv_data field.
+  __kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
+  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
 }
 
-
-void
-xexpand(KMP_API_NAME_GOMP_ORDERED_START)(void)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_ordered_start");
-    KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
-    __kmpc_ordered(&loc, gtid);
+void xexpand(KMP_API_NAME_GOMP_ORDERED_START)(void) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_ordered_start");
+  KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
+  __kmpc_ordered(&loc, gtid);
 }
 
-
-void
-xexpand(KMP_API_NAME_GOMP_ORDERED_END)(void)
-{
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_ordered_end");
-    KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
-    __kmpc_end_ordered(&loc, gtid);
+void xexpand(KMP_API_NAME_GOMP_ORDERED_END)(void) {
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_ordered_end");
+  KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
+  __kmpc_end_ordered(&loc, gtid);
 }
 
-
-//
 // Dispatch macro defs
 //
 // They come in two flavors: 64-bit unsigned, and either 32-bit signed
 // (IA-32 architecture) or 64-bit signed (Intel(R) 64).
-//
 
 #if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS
-# define KMP_DISPATCH_INIT              __kmp_aux_dispatch_init_4
-# define KMP_DISPATCH_FINI_CHUNK        __kmp_aux_dispatch_fini_chunk_4
-# define KMP_DISPATCH_NEXT              __kmpc_dispatch_next_4
+#define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
+#define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
+#define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4
 #else
-# define KMP_DISPATCH_INIT              __kmp_aux_dispatch_init_8
-# define KMP_DISPATCH_FINI_CHUNK        __kmp_aux_dispatch_fini_chunk_8
-# define KMP_DISPATCH_NEXT              __kmpc_dispatch_next_8
+#define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_8
+#define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_8
+#define KMP_DISPATCH_NEXT __kmpc_dispatch_next_8
 #endif /* KMP_ARCH_X86 */
 
-# define KMP_DISPATCH_INIT_ULL          __kmp_aux_dispatch_init_8u
-# define KMP_DISPATCH_FINI_CHUNK_ULL    __kmp_aux_dispatch_fini_chunk_8u
-# define KMP_DISPATCH_NEXT_ULL          __kmpc_dispatch_next_8u
-
+#define KMP_DISPATCH_INIT_ULL __kmp_aux_dispatch_init_8u
+#define KMP_DISPATCH_FINI_CHUNK_ULL __kmp_aux_dispatch_fini_chunk_8u
+#define KMP_DISPATCH_NEXT_ULL __kmpc_dispatch_next_8u
 
-//
 // The parallel contruct
-//
 
 #ifndef KMP_DEBUG
 static
 #endif /* KMP_DEBUG */
-void
-__kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
-  void *data)
-{
-#if OMPT_SUPPORT
-    kmp_info_t *thr;
-    ompt_frame_t *ompt_frame;
-    ompt_state_t enclosing_state;
+    void
+    __kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
+                                 void *data) {
+#if OMPT_SUPPORT
+  kmp_info_t *thr;
+  ompt_frame_t *ompt_frame;
+  ompt_state_t enclosing_state;
 
-    if (ompt_enabled) {
-        // get pointer to thread data structure
-        thr = __kmp_threads[*gtid];
+  if (ompt_enabled) {
+    // get pointer to thread data structure
+    thr = __kmp_threads[*gtid];
 
-        // save enclosing task state; set current state for task
-        enclosing_state = thr->th.ompt_thread_info.state;
-        thr->th.ompt_thread_info.state = ompt_state_work_parallel;
-
-        // set task frame
-        ompt_frame = __ompt_get_task_frame_internal(0);
-        ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
-    }
+    // save enclosing task state; set current state for task
+    enclosing_state = thr->th.ompt_thread_info.state;
+    thr->th.ompt_thread_info.state = ompt_state_work_parallel;
+
+    // set task frame
+    ompt_frame = __ompt_get_task_frame_internal(0);
+    ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
+  }
 #endif
 
-    task(data);
+  task(data);
 
 #if OMPT_SUPPORT
-    if (ompt_enabled) {
-        // clear task frame
-        ompt_frame->exit_runtime_frame = NULL;
+  if (ompt_enabled) {
+    // clear task frame
+    ompt_frame->exit_runtime_frame = NULL;
 
-        // restore enclosing state
-        thr->th.ompt_thread_info.state = enclosing_state;
-    }
+    // restore enclosing state
+    thr->th.ompt_thread_info.state = enclosing_state;
+  }
 #endif
 }
 
-
 #ifndef KMP_DEBUG
 static
 #endif /* KMP_DEBUG */
-void
-__kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
-  void (*task)(void *), void *data, unsigned num_threads, ident_t *loc,
-  enum sched_type schedule, long start, long end, long incr, long chunk_size)
-{
-    //
-    // Intialize the loop worksharing construct.
-    //
-    KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
-      schedule != kmp_sch_static);
-
-#if OMPT_SUPPORT
-    kmp_info_t *thr;
-    ompt_frame_t *ompt_frame;
-    ompt_state_t enclosing_state;
-
-    if (ompt_enabled) {
-        thr = __kmp_threads[*gtid];
-        // save enclosing task state; set current state for task
-        enclosing_state = thr->th.ompt_thread_info.state;
-        thr->th.ompt_thread_info.state = ompt_state_work_parallel;
-
-        // set task frame
-        ompt_frame = __ompt_get_task_frame_internal(0);
-        ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
-    }
-#endif
-
-    //
-    // Now invoke the microtask.
-    //
-    task(data);
-
-#if OMPT_SUPPORT
-    if (ompt_enabled) {
-        // clear task frame
-        ompt_frame->exit_runtime_frame = NULL;
-
-        // reset enclosing state
-        thr->th.ompt_thread_info.state = enclosing_state;
-    }
+    void
+    __kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
+                                          void (*task)(void *), void *data,
+                                          unsigned num_threads, ident_t *loc,
+                                          enum sched_type schedule, long start,
+                                          long end, long incr,
+                                          long chunk_size) {
+  // Intialize the loop worksharing construct.
+  KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
+                    schedule != kmp_sch_static);
+
+#if OMPT_SUPPORT
+  kmp_info_t *thr;
+  ompt_frame_t *ompt_frame;
+  ompt_state_t enclosing_state;
+
+  if (ompt_enabled) {
+    thr = __kmp_threads[*gtid];
+    // save enclosing task state; set current state for task
+    enclosing_state = thr->th.ompt_thread_info.state;
+    thr->th.ompt_thread_info.state = ompt_state_work_parallel;
+
+    // set task frame
+    ompt_frame = __ompt_get_task_frame_internal(0);
+    ompt_frame->exit_runtime_frame = __builtin_frame_address(0);
+  }
+#endif
+
+  // Now invoke the microtask.
+  task(data);
+
+#if OMPT_SUPPORT
+  if (ompt_enabled) {
+    // clear task frame
+    ompt_frame->exit_runtime_frame = NULL;
+
+    // reset enclosing state
+    thr->th.ompt_thread_info.state = enclosing_state;
+  }
 #endif
 }
 
-
 #ifndef KMP_DEBUG
 static
 #endif /* KMP_DEBUG */
-void
-__kmp_GOMP_fork_call(ident_t *loc, int gtid, void (*unwrapped_task)(void *), microtask_t wrapper, int argc,...)
-{
-    int rc;
-    kmp_info_t *thr = __kmp_threads[gtid];
-    kmp_team_t *team = thr->th.th_team;
-    int tid = __kmp_tid_from_gtid(gtid);
+    void
+    __kmp_GOMP_fork_call(ident_t *loc, int gtid, void (*unwrapped_task)(void *),
+                         microtask_t wrapper, int argc, ...) {
+  int rc;
+  kmp_info_t *thr = __kmp_threads[gtid];
+  kmp_team_t *team = thr->th.th_team;
+  int tid = __kmp_tid_from_gtid(gtid);
 
-    va_list ap;
-    va_start(ap, argc);
+  va_list ap;
+  va_start(ap, argc);
 
-    rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc,
+  rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc,
 #if OMPT_SUPPORT
-      VOLATILE_CAST(void *) unwrapped_task,
+                       VOLATILE_CAST(void *) unwrapped_task,
 #endif
-      wrapper, __kmp_invoke_task_func,
+                       wrapper, __kmp_invoke_task_func,
 #if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
-      &ap
+                       &ap
 #else
-      ap
+                       ap
 #endif
-      );
+                       );
 
-    va_end(ap);
+  va_end(ap);
 
-    if (rc) {
-        __kmp_run_before_invoked_task(gtid, tid, thr, team);
-    }
+  if (rc) {
+    __kmp_run_before_invoked_task(gtid, tid, thr, team);
+  }
 
 #if OMPT_SUPPORT
-    if (ompt_enabled) {
+  if (ompt_enabled) {
 #if OMPT_TRACE
-        ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
-        ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
+    ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
+    ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
 
-        // implicit task callback
-        if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
-            ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
-                team_info->parallel_id, task_info->task_id);
-        }
-#endif
-        thr->th.ompt_thread_info.state = ompt_state_work_parallel;
+    // implicit task callback
+    if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
+      ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
+          team_info->parallel_id, task_info->task_id);
     }
 #endif
+    thr->th.ompt_thread_info.state = ompt_state_work_parallel;
+  }
+#endif
 }
 
-static void
-__kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid, void (*task)(void *))
-{
+static void __kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid,
+                                           void (*task)(void *)) {
 #if OMPT_SUPPORT
-    ompt_parallel_id_t ompt_parallel_id;
-    if (ompt_enabled) {
-        ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
+  ompt_parallel_id_t ompt_parallel_id;
+  if (ompt_enabled) {
+    ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
 
-        ompt_parallel_id = __ompt_parallel_id_new(gtid);
+    ompt_parallel_id = __ompt_parallel_id_new(gtid);
 
-        // parallel region callback
-        if (ompt_callbacks.ompt_callback(ompt_event_parallel_begin)) {
-            int team_size = 1;
-            ompt_callbacks.ompt_callback(ompt_event_parallel_begin)(
-                task_info->task_id, &task_info->frame, ompt_parallel_id,
-                team_size, (void *) task,
-                OMPT_INVOKER(fork_context_gnu));
-        }
+    // parallel region callback
+    if (ompt_callbacks.ompt_callback(ompt_event_parallel_begin)) {
+      int team_size = 1;
+      ompt_callbacks.ompt_callback(ompt_event_parallel_begin)(
+          task_info->task_id, &task_info->frame, ompt_parallel_id, team_size,
+          (void *)task, OMPT_INVOKER(fork_context_gnu));
     }
+  }
 #endif
 
-    __kmp_serialized_parallel(loc, gtid);
+  __kmp_serialized_parallel(loc, gtid);
 
 #if OMPT_SUPPORT
-    if (ompt_enabled) {
-        kmp_info_t *thr = __kmp_threads[gtid];
+  if (ompt_enabled) {
+    kmp_info_t *thr = __kmp_threads[gtid];
 
-        ompt_task_id_t my_ompt_task_id = __ompt_task_id_new(gtid);
+    ompt_task_id_t my_ompt_task_id = __ompt_task_id_new(gtid);
 
-        // set up lightweight task
-        ompt_lw_taskteam_t *lwt = (ompt_lw_taskteam_t *)
-            __kmp_allocate(sizeof(ompt_lw_taskteam_t));
-        __ompt_lw_taskteam_init(lwt, thr, gtid, (void *) task, ompt_parallel_id);
-        lwt->ompt_task_info.task_id = my_ompt_task_id;
-        __ompt_lw_taskteam_link(lwt, thr);
+    // set up lightweight task
+    ompt_lw_taskteam_t *lwt =
+        (ompt_lw_taskteam_t *)__kmp_allocate(sizeof(ompt_lw_taskteam_t));
+    __ompt_lw_taskteam_init(lwt, thr, gtid, (void *)task, ompt_parallel_id);
+    lwt->ompt_task_info.task_id = my_ompt_task_id;
+    __ompt_lw_taskteam_link(lwt, thr);
 
 #if OMPT_TRACE
-        // implicit task callback
-        if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
-            ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
-                ompt_parallel_id, my_ompt_task_id);
-        }
-        thr->th.ompt_thread_info.state = ompt_state_work_parallel;
-#endif
+    // implicit task callback
+    if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)) {
+      ompt_callbacks.ompt_callback(ompt_event_implicit_task_begin)(
+          ompt_parallel_id, my_ompt_task_id);
     }
+    thr->th.ompt_thread_info.state = ompt_state_work_parallel;
+#endif
+  }
 #endif
 }
 
-
-void
-xexpand(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *), void *data, unsigned num_threads)
-{
-    int gtid = __kmp_entry_gtid();
+void xexpand(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *), void *data,
+                                               unsigned num_threads) {
+  int gtid = __kmp_entry_gtid();
 
 #if OMPT_SUPPORT
-    ompt_frame_t *parent_frame, *frame;
+  ompt_frame_t *parent_frame, *frame;
 
-    if (ompt_enabled) {
-        parent_frame = __ompt_get_task_frame_internal(0);
-        parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
-    }
+  if (ompt_enabled) {
+    parent_frame = __ompt_get_task_frame_internal(0);
+    parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
+  }
 #endif
 
-    MKLOC(loc, "GOMP_parallel_start");
-    KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
+  MKLOC(loc, "GOMP_parallel_start");
+  KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
 
-    if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
-        if (num_threads != 0) {
-            __kmp_push_num_threads(&loc, gtid, num_threads);
-        }
-        __kmp_GOMP_fork_call(&loc, gtid, task,
-          (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
-    }
-    else {
-        __kmp_GOMP_serialized_parallel(&loc, gtid, task);
+  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
+    if (num_threads != 0) {
+      __kmp_push_num_threads(&loc, gtid, num_threads);
     }
+    __kmp_GOMP_fork_call(&loc, gtid, task,
+                         (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task,
+                         data);
+  } else {
+    __kmp_GOMP_serialized_parallel(&loc, gtid, task);
+  }
 
 #if OMPT_SUPPORT
-    if (ompt_enabled) {
-        frame = __ompt_get_task_frame_internal(0);
-        frame->exit_runtime_frame = __builtin_frame_address(1);
-    }
+  if (ompt_enabled) {
+    frame = __ompt_get_task_frame_internal(0);
+    frame->exit_runtime_frame = __builtin_frame_address(1);
+  }
 #endif
 }
 
+void xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(void) {
+  int gtid = __kmp_get_gtid();
+  kmp_info_t *thr;
 
-void
-xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(void)
-{
-    int gtid = __kmp_get_gtid();
-    kmp_info_t *thr;
-
-    thr = __kmp_threads[gtid];
-
-    MKLOC(loc, "GOMP_parallel_end");
-    KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
+  thr = __kmp_threads[gtid];
 
+  MKLOC(loc, "GOMP_parallel_end");
+  KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
 
 #if OMPT_SUPPORT
-    ompt_parallel_id_t parallel_id;
-    ompt_task_id_t serialized_task_id;
-    ompt_frame_t *ompt_frame = NULL;
+  ompt_parallel_id_t parallel_id;
+  ompt_task_id_t serialized_task_id;
+  ompt_frame_t *ompt_frame = NULL;
 
-    if (ompt_enabled) {
-        ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
-        parallel_id = team_info->parallel_id;
-
-        ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
-        serialized_task_id = task_info->task_id;
+  if (ompt_enabled) {
+    ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
+    parallel_id = team_info->parallel_id;
 
-        // unlink if necessary. no-op if there is not a lightweight task.
-        ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
-        // GOMP allocates/frees lwt since it can't be kept on the stack
-        if (lwt) {
-           __kmp_free(lwt);
+    ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
+    serialized_task_id = task_info->task_id;
 
-        }
+    // unlink if necessary. no-op if there is not a lightweight task.
+    ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
+    // GOMP allocates/frees lwt since it can't be kept on the stack
+    if (lwt) {
+      __kmp_free(lwt);
     }
+  }
 #endif
 
-    if (! thr->th.th_team->t.t_serialized) {
-        __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
-          thr->th.th_team);
+  if (!thr->th.th_team->t.t_serialized) {
+    __kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
+                                 thr->th.th_team);
 
 #if OMPT_SUPPORT
-        if (ompt_enabled) {
-          // Implicit task is finished here, in the barrier we might schedule deferred tasks, 
-          // these don't see the implicit task on the stack
-          ompt_frame = __ompt_get_task_frame_internal(0);
-          ompt_frame->exit_runtime_frame = NULL;
-        }
+    if (ompt_enabled) {
+      // Implicit task is finished here, in the barrier we might schedule
+      // deferred tasks,
+      // these don't see the implicit task on the stack
+      ompt_frame = __ompt_get_task_frame_internal(0);
+      ompt_frame->exit_runtime_frame = NULL;
+    }
 #endif
 
-        __kmp_join_call(&loc, gtid
+    __kmp_join_call(&loc, gtid
 #if OMPT_SUPPORT
-            , fork_context_gnu
+                    ,
+                    fork_context_gnu
 #endif
-        );
-    }
-    else {
+                    );
+  } else {
 #if OMPT_SUPPORT && OMPT_TRACE
-        if (ompt_enabled &&
-            ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
-            ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
-                parallel_id, serialized_task_id);
-        }
+    if (ompt_enabled &&
+        ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
+      ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
+          parallel_id, serialized_task_id);
+    }
 #endif
 
-        __kmpc_end_serialized_parallel(&loc, gtid);
+    __kmpc_end_serialized_parallel(&loc, gtid);
 
 #if OMPT_SUPPORT
-        if (ompt_enabled) {
-            // Record that we re-entered the runtime system in the frame that
-            // created the parallel region.
-            ompt_task_info_t *parent_task_info = __ompt_get_taskinfo(0);
+    if (ompt_enabled) {
+      // Record that we re-entered the runtime system in the frame that
+      // created the parallel region.
+      ompt_task_info_t *parent_task_info = __ompt_get_taskinfo(0);
 
-            if (ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
-                ompt_callbacks.ompt_callback(ompt_event_parallel_end)(
-                    parallel_id, parent_task_info->task_id,
-                    OMPT_INVOKER(fork_context_gnu));
-            }
+      if (ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
+        ompt_callbacks.ompt_callback(ompt_event_parallel_end)(
+            parallel_id, parent_task_info->task_id,
+            OMPT_INVOKER(fork_context_gnu));
+      }
 
-            parent_task_info->frame.reenter_runtime_frame = NULL;
+      parent_task_info->frame.reenter_runtime_frame = NULL;
 
-            thr->th.ompt_thread_info.state =
-                (((thr->th.th_team)->t.t_serialized) ?
-                ompt_state_work_serial : ompt_state_work_parallel);
-        }
-#endif
+      thr->th.ompt_thread_info.state =
+          (((thr->th.th_team)->t.t_serialized) ? ompt_state_work_serial
+                                               : ompt_state_work_parallel);
     }
+#endif
+  }
 }
 
-
-//
 // Loop worksharing constructs
-//
 
-//
 // The Gnu codegen passes in an exclusive upper bound for the overall range,
 // but the libguide dispatch code expects an inclusive upper bound, hence the
 // "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
@@ -587,311 +509,308 @@ xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(
 // next iteration.  Instead, it emits inline code to call omp_get_thread_num()
 // num and calculate the iteration space using the result.  It doesn't do this
 // with ordered static loop, so they can be checked.
-//
-
-#define LOOP_START(func,schedule) \
-    int func (long lb, long ub, long str, long chunk_sz, long *p_lb,         \
-      long *p_ub)                                                            \
-    {                                                                        \
-        int status;                                                          \
-        long stride;                                                         \
-        int gtid = __kmp_entry_gtid();                                       \
-        MKLOC(loc, #func);                                                   \
-        KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n",  \
-          gtid, lb, ub, str, chunk_sz ));                                    \
-                                                                             \
-        if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
-            KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                    \
-              (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,                \
-              (schedule) != kmp_sch_static);                                 \
-            status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,    \
-              (kmp_int *)p_ub, (kmp_int *)&stride);                          \
-            if (status) {                                                    \
-                KMP_DEBUG_ASSERT(stride == str);                             \
-                *p_ub += (str > 0) ? 1 : -1;                                 \
-            }                                                                \
-        }                                                                    \
-        else {                                                               \
-            status = 0;                                                      \
-        }                                                                    \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
-          gtid, *p_lb, *p_ub, status));                                      \
-        return status;                                                       \
-    }
-
-
-#define LOOP_RUNTIME_START(func,schedule) \
-    int func (long lb, long ub, long str, long *p_lb, long *p_ub)            \
-    {                                                                        \
-        int status;                                                          \
-        long stride;                                                         \
-        long chunk_sz = 0;                                                   \
-        int gtid = __kmp_entry_gtid();                                       \
-        MKLOC(loc, #func);                                                   \
-        KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n",  \
-          gtid, lb, ub, str, chunk_sz ));                                    \
-                                                                             \
-        if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
-            KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                    \
-              (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE);         \
-            status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,    \
-              (kmp_int *)p_ub, (kmp_int *)&stride);                          \
-            if (status) {                                                    \
-                KMP_DEBUG_ASSERT(stride == str);                             \
-                *p_ub += (str > 0) ? 1 : -1;                                 \
-            }                                                                \
-        }                                                                    \
-        else {                                                               \
-            status = 0;                                                      \
-        }                                                                    \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
-          gtid, *p_lb, *p_ub, status));                                      \
-        return status;                                                       \
-    }
-
-
-#define LOOP_NEXT(func,fini_code) \
-    int func(long *p_lb, long *p_ub)                                         \
-    {                                                                        \
-        int status;                                                          \
-        long stride;                                                         \
-        int gtid = __kmp_get_gtid();                                         \
-        MKLOC(loc, #func);                                                   \
-        KA_TRACE(20, ( #func ": T#%d\n", gtid));                             \
-                                                                             \
-        fini_code                                                            \
-        status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,        \
-          (kmp_int *)p_ub, (kmp_int *)&stride);                              \
-        if (status) {                                                        \
-            *p_ub += (stride > 0) ? 1 : -1;                                  \
-        }                                                                    \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, "  \
-          "returning %d\n", gtid, *p_lb, *p_ub, stride, status));            \
-        return status;                                                       \
-    }
 
+#define LOOP_START(func, schedule)                                             \
+  int func(long lb, long ub, long str, long chunk_sz, long *p_lb,              \
+           long *p_ub) {                                                       \
+    int status;                                                                \
+    long stride;                                                               \
+    int gtid = __kmp_entry_gtid();                                             \
+    MKLOC(loc, #func);                                                         \
+    KA_TRACE(20,                                                               \
+             (#func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
+              gtid, lb, ub, str, chunk_sz));                                   \
+                                                                               \
+    if ((str > 0) ? (lb < ub) : (lb > ub)) {                                   \
+      KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                            \
+                        (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,        \
+                        (schedule) != kmp_sch_static);                         \
+      status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,            \
+                                 (kmp_int *)p_ub, (kmp_int *)&stride);         \
+      if (status) {                                                            \
+        KMP_DEBUG_ASSERT(stride == str);                                       \
+        *p_ub += (str > 0) ? 1 : -1;                                           \
+      }                                                                        \
+    } else {                                                                   \
+      status = 0;                                                              \
+    }                                                                          \
+                                                                               \
+    KA_TRACE(20,                                                               \
+             (#func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n",   \
+              gtid, *p_lb, *p_ub, status));                                    \
+    return status;                                                             \
+  }
+
+#define LOOP_RUNTIME_START(func, schedule)                                     \
+  int func(long lb, long ub, long str, long *p_lb, long *p_ub) {               \
+    int status;                                                                \
+    long stride;                                                               \
+    long chunk_sz = 0;                                                         \
+    int gtid = __kmp_entry_gtid();                                             \
+    MKLOC(loc, #func);                                                         \
+    KA_TRACE(20,                                                               \
+             (#func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n",    \
+              gtid, lb, ub, str, chunk_sz));                                   \
+                                                                               \
+    if ((str > 0) ? (lb < ub) : (lb > ub)) {                                   \
+      KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                            \
+                        (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
+      status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,            \
+                                 (kmp_int *)p_ub, (kmp_int *)&stride);         \
+      if (status) {                                                            \
+        KMP_DEBUG_ASSERT(stride == str);                                       \
+        *p_ub += (str > 0) ? 1 : -1;                                           \
+      }                                                                        \
+    } else {                                                                   \
+      status = 0;                                                              \
+    }                                                                          \
+                                                                               \
+    KA_TRACE(20,                                                               \
+             (#func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n",   \
+              gtid, *p_lb, *p_ub, status));                                    \
+    return status;                                                             \
+  }
+
+#define LOOP_NEXT(func, fini_code)                                             \
+  int func(long *p_lb, long *p_ub) {                                           \
+    int status;                                                                \
+    long stride;                                                               \
+    int gtid = __kmp_get_gtid();                                               \
+    MKLOC(loc, #func);                                                         \
+    KA_TRACE(20, (#func ": T#%d\n", gtid));                                    \
+                                                                               \
+    fini_code status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb,    \
+                                         (kmp_int *)p_ub, (kmp_int *)&stride); \
+    if (status) {                                                              \
+      *p_ub += (stride > 0) ? 1 : -1;                                          \
+    }                                                                          \
+                                                                               \
+    KA_TRACE(20,                                                               \
+             (#func " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, "    \
+                    "returning %d\n",                                          \
+              gtid, *p_lb, *p_ub, stride, status));                            \
+    return status;                                                             \
+  }
 
 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
-LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START), kmp_sch_dynamic_chunked)
+LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START),
+           kmp_sch_dynamic_chunked)
 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_START), kmp_sch_guided_chunked)
 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
-LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_START), kmp_sch_runtime)
+LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_START),
+                   kmp_sch_runtime)
 LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
 
 LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START), kmp_ord_static)
-LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
-LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
-LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
-LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
-LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
-LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START), kmp_ord_runtime)
-LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
-
-
-void
-xexpand(KMP_API_NAME_GOMP_LOOP_END)(void)
-{
-    int gtid = __kmp_get_gtid();
-    KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
-
-    __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
-
-    KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
-}
+LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT),
+          { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
+LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START),
+           kmp_ord_dynamic_chunked)
+LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT),
+          { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
+LOOP_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START),
+           kmp_ord_guided_chunked)
+LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT),
+          { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
+LOOP_RUNTIME_START(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START),
+                   kmp_ord_runtime)
+LOOP_NEXT(xexpand(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT),
+          { KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
+
+void xexpand(KMP_API_NAME_GOMP_LOOP_END)(void) {
+  int gtid = __kmp_get_gtid();
+  KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
 
+  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
 
-void
-xexpand(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void)
-{
-    KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
+  KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
 }
 
+void xexpand(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void) {
+  KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
+}
 
-//
 // Unsigned long long loop worksharing constructs
 //
 // These are new with gcc 4.4
-//
-
-#define LOOP_START_ULL(func,schedule) \
-    int func (int up, unsigned long long lb, unsigned long long ub,          \
-      unsigned long long str, unsigned long long chunk_sz,                   \
-      unsigned long long *p_lb, unsigned long long *p_ub)                    \
-    {                                                                        \
-        int status;                                                          \
-        long long str2 = up ? ((long long)str) : -((long long)str);          \
-        long long stride;                                                    \
-        int gtid = __kmp_entry_gtid();                                       \
-        MKLOC(loc, #func);                                                   \
-                                                                             \
-        KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
-          gtid, up, lb, ub, str, chunk_sz ));                                \
-                                                                             \
-        if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
-            KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb,                \
-              (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz,              \
-              (schedule) != kmp_sch_static);                                 \
-            status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL,                 \
-              (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
-            if (status) {                                                    \
-                KMP_DEBUG_ASSERT(stride == str2);                            \
-                *p_ub += (str > 0) ? 1 : -1;                                 \
-            }                                                                \
-        }                                                                    \
-        else {                                                               \
-            status = 0;                                                      \
-        }                                                                    \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
-          gtid, *p_lb, *p_ub, status));                                      \
-        return status;                                                       \
-    }
-
-
-#define LOOP_RUNTIME_START_ULL(func,schedule) \
-    int func (int up, unsigned long long lb, unsigned long long ub,          \
-      unsigned long long str, unsigned long long *p_lb,                      \
-      unsigned long long *p_ub)                                              \
-    {                                                                        \
-        int status;                                                          \
-        long long str2 = up ? ((long long)str) : -((long long)str);          \
-        unsigned long long stride;                                           \
-        unsigned long long chunk_sz = 0;                                     \
-        int gtid = __kmp_entry_gtid();                                       \
-        MKLOC(loc, #func);                                                   \
-                                                                             \
-        KA_TRACE(20, ( #func ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
-          gtid, up, lb, ub, str, chunk_sz ));                                \
-                                                                             \
-        if ((str > 0) ? (lb < ub) : (lb > ub)) {                             \
-            KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb,                \
-              (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, TRUE);       \
-            status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL,                 \
-              (kmp_uint64 *)p_lb, (kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
-            if (status) {                                                    \
-                KMP_DEBUG_ASSERT((long long)stride == str2);                 \
-                *p_ub += (str > 0) ? 1 : -1;                                 \
-            }                                                                \
-        }                                                                    \
-        else {                                                               \
-            status = 0;                                                      \
-        }                                                                    \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
-          gtid, *p_lb, *p_ub, status));                                      \
-        return status;                                                       \
-    }
-
-
-#define LOOP_NEXT_ULL(func,fini_code) \
-    int func(unsigned long long *p_lb, unsigned long long *p_ub)             \
-    {                                                                        \
-        int status;                                                          \
-        long long stride;                                                    \
-        int gtid = __kmp_get_gtid();                                         \
-        MKLOC(loc, #func);                                                   \
-        KA_TRACE(20, ( #func ": T#%d\n", gtid));                             \
-                                                                             \
-        fini_code                                                            \
-        status = KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
-          (kmp_uint64 *)p_ub, (kmp_int64 *)&stride);                         \
-        if (status) {                                                        \
-            *p_ub += (stride > 0) ? 1 : -1;                                  \
-        }                                                                    \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
-          "returning %d\n", gtid, *p_lb, *p_ub, stride, status));            \
-        return status;                                                       \
-    }
 
+#define LOOP_START_ULL(func, schedule)                                         \
+  int func(int up, unsigned long long lb, unsigned long long ub,               \
+           unsigned long long str, unsigned long long chunk_sz,                \
+           unsigned long long *p_lb, unsigned long long *p_ub) {               \
+    int status;                                                                \
+    long long str2 = up ? ((long long)str) : -((long long)str);                \
+    long long stride;                                                          \
+    int gtid = __kmp_entry_gtid();                                             \
+    MKLOC(loc, #func);                                                         \
+                                                                               \
+    KA_TRACE(                                                                  \
+        20,                                                                    \
+        (#func                                                                 \
+         ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
+         gtid, up, lb, ub, str, chunk_sz));                                    \
+                                                                               \
+    if ((str > 0) ? (lb < ub) : (lb > ub)) {                                   \
+      KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb,                        \
+                            (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz,  \
+                            (schedule) != kmp_sch_static);                     \
+      status =                                                                 \
+          KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb,          \
+                                (kmp_uint64 *)p_ub, (kmp_int64 *)&stride);     \
+      if (status) {                                                            \
+        KMP_DEBUG_ASSERT(stride == str2);                                      \
+        *p_ub += (str > 0) ? 1 : -1;                                           \
+      }                                                                        \
+    } else {                                                                   \
+      status = 0;                                                              \
+    }                                                                          \
+                                                                               \
+    KA_TRACE(20,                                                               \
+             (#func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
+              gtid, *p_lb, *p_ub, status));                                    \
+    return status;                                                             \
+  }
+
+#define LOOP_RUNTIME_START_ULL(func, schedule)                                 \
+  int func(int up, unsigned long long lb, unsigned long long ub,               \
+           unsigned long long str, unsigned long long *p_lb,                   \
+           unsigned long long *p_ub) {                                         \
+    int status;                                                                \
+    long long str2 = up ? ((long long)str) : -((long long)str);                \
+    unsigned long long stride;                                                 \
+    unsigned long long chunk_sz = 0;                                           \
+    int gtid = __kmp_entry_gtid();                                             \
+    MKLOC(loc, #func);                                                         \
+                                                                               \
+    KA_TRACE(                                                                  \
+        20,                                                                    \
+        (#func                                                                 \
+         ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str 0x%llx, chunk_sz 0x%llx\n", \
+         gtid, up, lb, ub, str, chunk_sz));                                    \
+                                                                               \
+    if ((str > 0) ? (lb < ub) : (lb > ub)) {                                   \
+      KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb,                        \
+                            (str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz,  \
+                            TRUE);                                             \
+      status =                                                                 \
+          KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb,          \
+                                (kmp_uint64 *)p_ub, (kmp_int64 *)&stride);     \
+      if (status) {                                                            \
+        KMP_DEBUG_ASSERT((long long)stride == str2);                           \
+        *p_ub += (str > 0) ? 1 : -1;                                           \
+      }                                                                        \
+    } else {                                                                   \
+      status = 0;                                                              \
+    }                                                                          \
+                                                                               \
+    KA_TRACE(20,                                                               \
+             (#func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
+              gtid, *p_lb, *p_ub, status));                                    \
+    return status;                                                             \
+  }
+
+#define LOOP_NEXT_ULL(func, fini_code)                                         \
+  int func(unsigned long long *p_lb, unsigned long long *p_ub) {               \
+    int status;                                                                \
+    long long stride;                                                          \
+    int gtid = __kmp_get_gtid();                                               \
+    MKLOC(loc, #func);                                                         \
+    KA_TRACE(20, (#func ": T#%d\n", gtid));                                    \
+                                                                               \
+    fini_code status =                                                         \
+        KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb,            \
+                              (kmp_uint64 *)p_ub, (kmp_int64 *)&stride);       \
+    if (status) {                                                              \
+      *p_ub += (stride > 0) ? 1 : -1;                                          \
+    }                                                                          \
+                                                                               \
+    KA_TRACE(20,                                                               \
+             (#func " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
+                    "returning %d\n",                                          \
+              gtid, *p_lb, *p_ub, stride, status));                            \
+    return status;                                                             \
+  }
 
 LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START), kmp_sch_static)
 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
-LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START), kmp_sch_dynamic_chunked)
+LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START),
+               kmp_sch_dynamic_chunked)
 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
-LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START), kmp_sch_guided_chunked)
+LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START),
+               kmp_sch_guided_chunked)
 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
-LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
+LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START),
+                       kmp_sch_runtime)
 LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
 
-LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START), kmp_ord_static)
-LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
-LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START), kmp_ord_dynamic_chunked)
-LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
-LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START), kmp_ord_guided_chunked)
-LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
-LOOP_RUNTIME_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START), kmp_ord_runtime)
-LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT), \
-    { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
+LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START),
+               kmp_ord_static)
+LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT),
+              { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
+LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START),
+               kmp_ord_dynamic_chunked)
+LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT),
+              { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
+LOOP_START_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START),
+               kmp_ord_guided_chunked)
+LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT),
+              { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
+LOOP_RUNTIME_START_ULL(
+    xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START), kmp_ord_runtime)
+LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT),
+              { KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
 
-
-//
 // Combined parallel / loop worksharing constructs
 //
 // There are no ull versions (yet).
-//
-
-#define PARALLEL_LOOP_START(func, schedule, ompt_pre, ompt_post) \
-    void func (void (*task) (void *), void *data, unsigned num_threads,      \
-      long lb, long ub, long str, long chunk_sz)                             \
-    {                                                                        \
-        int gtid = __kmp_entry_gtid();                                       \
-        MKLOC(loc, #func);                                                   \
-        KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n",        \
-          gtid, lb, ub, str, chunk_sz ));                                    \
-                                                                             \
-        ompt_pre();                                                          \
-                                                                             \
-        if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {                 \
-            if (num_threads != 0) {                                          \
-                __kmp_push_num_threads(&loc, gtid, num_threads);             \
-            }                                                                \
-            __kmp_GOMP_fork_call(&loc, gtid, task,                           \
-              (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,         \
-              task, data, num_threads, &loc, (schedule), lb,                 \
-              (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz);               \
-        }                                                                    \
-        else {                                                               \
-            __kmp_GOMP_serialized_parallel(&loc, gtid, task);                \
-        }                                                                    \
-                                                                             \
-        KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                        \
-          (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,                    \
-          (schedule) != kmp_sch_static);                                     \
-                                                                             \
-        ompt_post();                                                         \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d\n", gtid));                        \
-    }
-
 
+#define PARALLEL_LOOP_START(func, schedule, ompt_pre, ompt_post)               \
+  void func(void (*task)(void *), void *data, unsigned num_threads, long lb,   \
+            long ub, long str, long chunk_sz) {                                \
+    int gtid = __kmp_entry_gtid();                                             \
+    MKLOC(loc, #func);                                                         \
+    KA_TRACE(20,                                                               \
+             (#func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
+              gtid, lb, ub, str, chunk_sz));                                   \
+                                                                               \
+    ompt_pre();                                                                \
+                                                                               \
+    if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {                       \
+      if (num_threads != 0) {                                                  \
+        __kmp_push_num_threads(&loc, gtid, num_threads);                       \
+      }                                                                        \
+      __kmp_GOMP_fork_call(&loc, gtid, task,                                   \
+                           (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, \
+                           9, task, data, num_threads, &loc, (schedule), lb,   \
+                           (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz);    \
+    } else {                                                                   \
+      __kmp_GOMP_serialized_parallel(&loc, gtid, task);                        \
+    }                                                                          \
+                                                                               \
+    KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                              \
+                      (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,          \
+                      (schedule) != kmp_sch_static);                           \
+                                                                               \
+    ompt_post();                                                               \
+                                                                               \
+    KA_TRACE(20, (#func " exit: T#%d\n", gtid));                               \
+  }
 
 #if OMPT_SUPPORT
 
-#define OMPT_LOOP_PRE() \
-    ompt_frame_t *parent_frame; \
-    if (ompt_enabled) { \
-        parent_frame = __ompt_get_task_frame_internal(0); \
-        parent_frame->reenter_runtime_frame = __builtin_frame_address(1); \
-    }
-
-
-#define OMPT_LOOP_POST() \
-    if (ompt_enabled) { \
-        parent_frame->reenter_runtime_frame = NULL; \
-    }
+#define OMPT_LOOP_PRE()                                                        \
+  ompt_frame_t *parent_frame;                                                  \
+  if (ompt_enabled) {                                                          \
+    parent_frame = __ompt_get_task_frame_internal(0);                          \
+    parent_frame->reenter_runtime_frame = __builtin_frame_address(1);          \
+  }
+
+#define OMPT_LOOP_POST()                                                       \
+  if (ompt_enabled) {                                                          \
+    parent_frame->reenter_runtime_frame = NULL;                                \
+  }
 
 #else
 
@@ -901,7 +820,6 @@ LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_
 
 #endif
 
-
 PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC_START),
                     kmp_sch_static, OMPT_LOOP_PRE, OMPT_LOOP_POST)
 PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC_START),
@@ -911,548 +829,497 @@ PARALLEL_LOOP_START(xexpand(KMP_API_NAME
 PARALLEL_LOOP_START(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME_START),
                     kmp_sch_runtime, OMPT_LOOP_PRE, OMPT_LOOP_POST)
 
-
-//
 // Tasking constructs
-//
 
-void
-xexpand(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data, void (*copy_func)(void *, void *),
-  long arg_size, long arg_align, bool if_cond, unsigned gomp_flags
+void xexpand(KMP_API_NAME_GOMP_TASK)(void (*func)(void *), void *data,
+                                     void (*copy_func)(void *, void *),
+                                     long arg_size, long arg_align,
+                                     bool if_cond, unsigned gomp_flags
 #if OMP_40_ENABLED
-  , void **depend
+                                     ,
+                                     void **depend
 #endif
-)
-{
-    MKLOC(loc, "GOMP_task");
-    int gtid = __kmp_entry_gtid();
-    kmp_int32 flags = 0;
-    kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *) & flags;
-
-    KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
-
-    // The low-order bit is the "tied" flag
-    if (gomp_flags & 1) {
-        input_flags->tiedness = 1;
-    }
-    // The second low-order bit is the "final" flag
-    if (gomp_flags & 2) {
-        input_flags->final = 1;
+                                     ) {
+  MKLOC(loc, "GOMP_task");
+  int gtid = __kmp_entry_gtid();
+  kmp_int32 flags = 0;
+  kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *)&flags;
+
+  KA_TRACE(20, ("GOMP_task: T#%d\n", gtid));
+
+  // The low-order bit is the "tied" flag
+  if (gomp_flags & 1) {
+    input_flags->tiedness = 1;
+  }
+  // The second low-order bit is the "final" flag
+  if (gomp_flags & 2) {
+    input_flags->final = 1;
+  }
+  input_flags->native = 1;
+  // __kmp_task_alloc() sets up all other flags
+
+  if (!if_cond) {
+    arg_size = 0;
+  }
+
+  kmp_task_t *task = __kmp_task_alloc(
+      &loc, gtid, input_flags, sizeof(kmp_task_t),
+      arg_size ? arg_size + arg_align - 1 : 0, (kmp_routine_entry_t)func);
+
+  if (arg_size > 0) {
+    if (arg_align > 0) {
+      task->shareds = (void *)((((size_t)task->shareds) + arg_align - 1) /
+                               arg_align * arg_align);
     }
-    input_flags->native = 1;
-    // __kmp_task_alloc() sets up all other flags
+    // else error??
 
-    if (! if_cond) {
-        arg_size = 0;
-    }
-
-    kmp_task_t *task = __kmp_task_alloc(&loc, gtid, input_flags,
-      sizeof(kmp_task_t), arg_size ? arg_size + arg_align - 1 : 0,
-      (kmp_routine_entry_t)func);
-
-    if (arg_size > 0) {
-        if (arg_align > 0) {
-            task->shareds = (void *)((((size_t)task->shareds)
-              + arg_align - 1) / arg_align * arg_align);
-        }
-        //else error??
-
-        if (copy_func) {
-            (*copy_func)(task->shareds, data);
-        }
-        else {
-            KMP_MEMCPY(task->shareds, data, arg_size);
-        }
+    if (copy_func) {
+      (*copy_func)(task->shareds, data);
+    } else {
+      KMP_MEMCPY(task->shareds, data, arg_size);
     }
+  }
 
-    if (if_cond) {
+  if (if_cond) {
 #if OMP_40_ENABLED
-        if (gomp_flags & 8) {
-            KMP_ASSERT(depend);
-            const size_t ndeps = (kmp_intptr_t)depend[0];
-            const size_t nout = (kmp_intptr_t)depend[1];
-            kmp_depend_info_t dep_list[ndeps];
-
-            for (size_t i = 0U; i < ndeps; i++) {
-                dep_list[i].base_addr = (kmp_intptr_t)depend[2U + i];
-                dep_list[i].len = 0U;
-                dep_list[i].flags.in = 1;
-                dep_list[i].flags.out = (i < nout);
-            }
-            __kmpc_omp_task_with_deps(&loc, gtid, task, ndeps, dep_list, 0, NULL);
-        }
-        else
-#endif
-        __kmpc_omp_task(&loc, gtid, task);
+    if (gomp_flags & 8) {
+      KMP_ASSERT(depend);
+      const size_t ndeps = (kmp_intptr_t)depend[0];
+      const size_t nout = (kmp_intptr_t)depend[1];
+      kmp_depend_info_t dep_list[ndeps];
+
+      for (size_t i = 0U; i < ndeps; i++) {
+        dep_list[i].base_addr = (kmp_intptr_t)depend[2U + i];
+        dep_list[i].len = 0U;
+        dep_list[i].flags.in = 1;
+        dep_list[i].flags.out = (i < nout);
+      }
+      __kmpc_omp_task_with_deps(&loc, gtid, task, ndeps, dep_list, 0, NULL);
+    } else
+#endif
+      __kmpc_omp_task(&loc, gtid, task);
+  } else {
+#if OMPT_SUPPORT
+    ompt_thread_info_t oldInfo;
+    kmp_info_t *thread;
+    kmp_taskdata_t *taskdata;
+    if (ompt_enabled) {
+      // Store the threads states and restore them after the task
+      thread = __kmp_threads[gtid];
+      taskdata = KMP_TASK_TO_TASKDATA(task);
+      oldInfo = thread->th.ompt_thread_info;
+      thread->th.ompt_thread_info.wait_id = 0;
+      thread->th.ompt_thread_info.state = ompt_state_work_parallel;
+      taskdata->ompt_task_info.frame.exit_runtime_frame =
+          __builtin_frame_address(0);
     }
-    else {
-#if OMPT_SUPPORT
-        ompt_thread_info_t oldInfo;
-        kmp_info_t *thread;
-        kmp_taskdata_t *taskdata;
-        if (ompt_enabled) {
-            // Store the threads states and restore them after the task
-            thread = __kmp_threads[ gtid ];
-            taskdata = KMP_TASK_TO_TASKDATA(task);
-            oldInfo = thread->th.ompt_thread_info;
-            thread->th.ompt_thread_info.wait_id = 0;
-            thread->th.ompt_thread_info.state = ompt_state_work_parallel;
-            taskdata->ompt_task_info.frame.exit_runtime_frame =
-                __builtin_frame_address(0);
-        }
-#endif
-
-        __kmpc_omp_task_begin_if0(&loc, gtid, task);
-        func(data);
-        __kmpc_omp_task_complete_if0(&loc, gtid, task);
-
-#if OMPT_SUPPORT
-        if (ompt_enabled) {
-            thread->th.ompt_thread_info = oldInfo;
-            taskdata->ompt_task_info.frame.exit_runtime_frame = NULL;
-        }
 #endif
+
+    __kmpc_omp_task_begin_if0(&loc, gtid, task);
+    func(data);
+    __kmpc_omp_task_complete_if0(&loc, gtid, task);
+
+#if OMPT_SUPPORT
+    if (ompt_enabled) {
+      thread->th.ompt_thread_info = oldInfo;
+      taskdata->ompt_task_info.frame.exit_runtime_frame = NULL;
     }
+#endif
+  }
 
-    KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
+  KA_TRACE(20, ("GOMP_task exit: T#%d\n", gtid));
 }
 
+void xexpand(KMP_API_NAME_GOMP_TASKWAIT)(void) {
+  MKLOC(loc, "GOMP_taskwait");
+  int gtid = __kmp_entry_gtid();
 
-void
-xexpand(KMP_API_NAME_GOMP_TASKWAIT)(void)
-{
-    MKLOC(loc, "GOMP_taskwait");
-    int gtid = __kmp_entry_gtid();
-
-    KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
+  KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
 
-    __kmpc_omp_taskwait(&loc, gtid);
+  __kmpc_omp_taskwait(&loc, gtid);
 
-    KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
+  KA_TRACE(20, ("GOMP_taskwait exit: T#%d\n", gtid));
 }
 
-
-//
 // Sections worksharing constructs
 //
-
-//
 // For the sections construct, we initialize a dynamically scheduled loop
 // worksharing construct with lb 1 and stride 1, and use the iteration #'s
 // that its returns as sections ids.
 //
 // There are no special entry points for ordered sections, so we always use
 // the dynamically scheduled workshare, even if the sections aren't ordered.
-//
 
-unsigned
-xexpand(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count)
-{
-    int status;
-    kmp_int lb, ub, stride;
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_sections_start");
-    KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
-
-    KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
-
-    status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
-    if (status) {
-        KMP_DEBUG_ASSERT(stride == 1);
-        KMP_DEBUG_ASSERT(lb > 0);
-        KMP_ASSERT(lb == ub);
-    }
-    else {
-        lb = 0;
-    }
+unsigned xexpand(KMP_API_NAME_GOMP_SECTIONS_START)(unsigned count) {
+  int status;
+  kmp_int lb, ub, stride;
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_sections_start");
+  KA_TRACE(20, ("GOMP_sections_start: T#%d\n", gtid));
 
-    KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
-      (unsigned)lb));
-    return (unsigned)lb;
+  KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
+
+  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
+  if (status) {
+    KMP_DEBUG_ASSERT(stride == 1);
+    KMP_DEBUG_ASSERT(lb > 0);
+    KMP_ASSERT(lb == ub);
+  } else {
+    lb = 0;
+  }
+
+  KA_TRACE(20, ("GOMP_sections_start exit: T#%d returning %u\n", gtid,
+                (unsigned)lb));
+  return (unsigned)lb;
 }
 
+unsigned xexpand(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void) {
+  int status;
+  kmp_int lb, ub, stride;
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_sections_next");
+  KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
 
-unsigned
-xexpand(KMP_API_NAME_GOMP_SECTIONS_NEXT)(void)
-{
-    int status;
-    kmp_int lb, ub, stride;
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_sections_next");
-    KA_TRACE(20, ("GOMP_sections_next: T#%d\n", gtid));
-
-    status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
-    if (status) {
-        KMP_DEBUG_ASSERT(stride == 1);
-        KMP_DEBUG_ASSERT(lb > 0);
-        KMP_ASSERT(lb == ub);
-    }
-    else {
-        lb = 0;
-    }
+  status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, &lb, &ub, &stride);
+  if (status) {
+    KMP_DEBUG_ASSERT(stride == 1);
+    KMP_DEBUG_ASSERT(lb > 0);
+    KMP_ASSERT(lb == ub);
+  } else {
+    lb = 0;
+  }
 
-    KA_TRACE(20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid,
-      (unsigned)lb));
-    return (unsigned)lb;
+  KA_TRACE(
+      20, ("GOMP_sections_next exit: T#%d returning %u\n", gtid, (unsigned)lb));
+  return (unsigned)lb;
 }
 
-
-void
-xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task) (void *), void *data,
-  unsigned num_threads, unsigned count)
-{
-    int gtid = __kmp_entry_gtid();
+void xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task)(void *),
+                                                        void *data,
+                                                        unsigned num_threads,
+                                                        unsigned count) {
+  int gtid = __kmp_entry_gtid();
 
 #if OMPT_SUPPORT
-    ompt_frame_t *parent_frame;
+  ompt_frame_t *parent_frame;
 
-    if (ompt_enabled) {
-        parent_frame = __ompt_get_task_frame_internal(0);
-        parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
-    }
+  if (ompt_enabled) {
+    parent_frame = __ompt_get_task_frame_internal(0);
+    parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
+  }
 #endif
 
-    MKLOC(loc, "GOMP_parallel_sections_start");
-    KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
+  MKLOC(loc, "GOMP_parallel_sections_start");
+  KA_TRACE(20, ("GOMP_parallel_sections_start: T#%d\n", gtid));
 
-    if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
-        if (num_threads != 0) {
-            __kmp_push_num_threads(&loc, gtid, num_threads);
-        }
-        __kmp_GOMP_fork_call(&loc, gtid, task,
-          (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
-          num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
-          (kmp_int)count, (kmp_int)1, (kmp_int)1);
-    }
-    else {
-        __kmp_GOMP_serialized_parallel(&loc, gtid, task);
+  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
+    if (num_threads != 0) {
+      __kmp_push_num_threads(&loc, gtid, num_threads);
     }
+    __kmp_GOMP_fork_call(&loc, gtid, task,
+                         (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,
+                         task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
+                         (kmp_int)1, (kmp_int)count, (kmp_int)1, (kmp_int)1);
+  } else {
+    __kmp_GOMP_serialized_parallel(&loc, gtid, task);
+  }
 
 #if OMPT_SUPPORT
-    if (ompt_enabled) {
-        parent_frame->reenter_runtime_frame = NULL;
-    }
+  if (ompt_enabled) {
+    parent_frame->reenter_runtime_frame = NULL;
+  }
 #endif
 
-    KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
+  KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
 
-    KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
+  KA_TRACE(20, ("GOMP_parallel_sections_start exit: T#%d\n", gtid));
 }
 
+void xexpand(KMP_API_NAME_GOMP_SECTIONS_END)(void) {
+  int gtid = __kmp_get_gtid();
+  KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
 
-void
-xexpand(KMP_API_NAME_GOMP_SECTIONS_END)(void)
-{
-    int gtid = __kmp_get_gtid();
-    KA_TRACE(20, ("GOMP_sections_end: T#%d\n", gtid))
-
-    __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
 
-    KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
+  KA_TRACE(20, ("GOMP_sections_end exit: T#%d\n", gtid))
 }
 
-
-void
-xexpand(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void)
-{
-    KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
+void xexpand(KMP_API_NAME_GOMP_SECTIONS_END_NOWAIT)(void) {
+  KA_TRACE(20, ("GOMP_sections_end_nowait: T#%d\n", __kmp_get_gtid()))
 }
 
 // libgomp has an empty function for GOMP_taskyield as of 2013-10-10
-void
-xexpand(KMP_API_NAME_GOMP_TASKYIELD)(void)
-{
-    KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
-    return;
+void xexpand(KMP_API_NAME_GOMP_TASKYIELD)(void) {
+  KA_TRACE(20, ("GOMP_taskyield: T#%d\n", __kmp_get_gtid()))
+  return;
 }
 
 #if OMP_40_ENABLED // these are new GOMP_4.0 entry points
 
-void
-xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data, unsigned num_threads, unsigned int flags)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_parallel");
-    KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
+void xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data,
+                                         unsigned num_threads,
+                                         unsigned int flags) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_parallel");
+  KA_TRACE(20, ("GOMP_parallel: T#%d\n", gtid));
+
+#if OMPT_SUPPORT
+  ompt_task_info_t *parent_task_info, *task_info;
+  if (ompt_enabled) {
+    parent_task_info = __ompt_get_taskinfo(0);
+    parent_task_info->frame.reenter_runtime_frame = __builtin_frame_address(1);
+  }
+#endif
+  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
+    if (num_threads != 0) {
+      __kmp_push_num_threads(&loc, gtid, num_threads);
+    }
+    if (flags != 0) {
+      __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
+    }
+    __kmp_GOMP_fork_call(&loc, gtid, task,
+                         (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task,
+                         data);
+  } else {
+    __kmp_GOMP_serialized_parallel(&loc, gtid, task);
+  }
+#if OMPT_SUPPORT
+  if (ompt_enabled) {
+    task_info = __ompt_get_taskinfo(0);
+    task_info->frame.exit_runtime_frame = __builtin_frame_address(0);
+  }
+#endif
+  task(data);
+  xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
+#if OMPT_SUPPORT
+  if (ompt_enabled) {
+    task_info->frame.exit_runtime_frame = NULL;
+    parent_task_info->frame.reenter_runtime_frame = NULL;
+  }
+#endif
+}
+
+void xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task)(void *),
+                                                  void *data,
+                                                  unsigned num_threads,
+                                                  unsigned count,
+                                                  unsigned flags) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_parallel_sections");
+  KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
+
+  if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
+    if (num_threads != 0) {
+      __kmp_push_num_threads(&loc, gtid, num_threads);
+    }
+    if (flags != 0) {
+      __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
+    }
+    __kmp_GOMP_fork_call(&loc, gtid, task,
+                         (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,
+                         task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
+                         (kmp_int)1, (kmp_int)count, (kmp_int)1, (kmp_int)1);
+  } else {
+    __kmp_GOMP_serialized_parallel(&loc, gtid, task);
+  }
+
+  KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
+
+  task(data);
+  xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
+  KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
+}
+
+#define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_post)                     \
+  void func(void (*task)(void *), void *data, unsigned num_threads, long lb,   \
+            long ub, long str, long chunk_sz, unsigned flags) {                \
+    int gtid = __kmp_entry_gtid();                                             \
+    MKLOC(loc, #func);                                                         \
+    KA_TRACE(20,                                                               \
+             (#func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
+              gtid, lb, ub, str, chunk_sz));                                   \
+                                                                               \
+    ompt_pre();                                                                \
+    if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {                       \
+      if (num_threads != 0) {                                                  \
+        __kmp_push_num_threads(&loc, gtid, num_threads);                       \
+      }                                                                        \
+      if (flags != 0) {                                                        \
+        __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);              \
+      }                                                                        \
+      __kmp_GOMP_fork_call(&loc, gtid, task,                                   \
+                           (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, \
+                           9, task, data, num_threads, &loc, (schedule), lb,   \
+                           (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz);    \
+    } else {                                                                   \
+      __kmp_GOMP_serialized_parallel(&loc, gtid, task);                        \
+    }                                                                          \
+                                                                               \
+    KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                              \
+                      (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,          \
+                      (schedule) != kmp_sch_static);                           \
+    task(data);                                                                \
+    xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();                                 \
+    ompt_post();                                                               \
+                                                                               \
+    KA_TRACE(20, (#func " exit: T#%d\n", gtid));                               \
+  }
+
+PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC), kmp_sch_static,
+              OMPT_LOOP_PRE, OMPT_LOOP_POST)
+PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC),
+              kmp_sch_dynamic_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
+PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED),
+              kmp_sch_guided_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
+PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME), kmp_sch_runtime,
+              OMPT_LOOP_PRE, OMPT_LOOP_POST)
+
+void xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void) {
+  int gtid = __kmp_entry_gtid();
+  MKLOC(loc, "GOMP_taskgroup_start");
+  KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
+
+  __kmpc_taskgroup(&loc, gtid);
+
+  return;
+}
+
+void xexpand(KMP_API_NAME_GOMP_TASKGROUP_END)(void) {
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_taskgroup_end");
+  KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
 
-#if OMPT_SUPPORT
-    ompt_task_info_t *parent_task_info, *task_info;
-    if (ompt_enabled) {
-        parent_task_info = __ompt_get_taskinfo(0);
-        parent_task_info->frame.reenter_runtime_frame = __builtin_frame_address(1);
-    }
-#endif
-    if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
-        if (num_threads != 0) {
-            __kmp_push_num_threads(&loc, gtid, num_threads);
-        }
-        if(flags != 0) {
-            __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
-        }
-        __kmp_GOMP_fork_call(&loc, gtid, task,
-          (microtask_t)__kmp_GOMP_microtask_wrapper, 2, task, data);
-    }
-    else {
-        __kmp_GOMP_serialized_parallel(&loc, gtid, task);
-    }
-#if OMPT_SUPPORT
-    if (ompt_enabled) {
-        task_info = __ompt_get_taskinfo(0);
-        task_info->frame.exit_runtime_frame = __builtin_frame_address(0);
-    }
-#endif
-    task(data);
-    xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
-#if OMPT_SUPPORT
-    if (ompt_enabled) {
-        task_info->frame.exit_runtime_frame = NULL;
-        parent_task_info->frame.reenter_runtime_frame = NULL;
-    }
-#endif
-}
-
-void
-xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task) (void *), void *data,
-  unsigned num_threads, unsigned count, unsigned flags)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_parallel_sections");
-    KA_TRACE(20, ("GOMP_parallel_sections: T#%d\n", gtid));
-
-    if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
-        if (num_threads != 0) {
-            __kmp_push_num_threads(&loc, gtid, num_threads);
-        }
-        if(flags != 0) {
-            __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);
-        }
-        __kmp_GOMP_fork_call(&loc, gtid, task,
-          (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9, task, data,
-          num_threads, &loc, kmp_nm_dynamic_chunked, (kmp_int)1,
-          (kmp_int)count, (kmp_int)1, (kmp_int)1);
-    }
-    else {
-        __kmp_GOMP_serialized_parallel(&loc, gtid, task);
-    }
-
-    KMP_DISPATCH_INIT(&loc, gtid, kmp_nm_dynamic_chunked, 1, count, 1, 1, TRUE);
+  __kmpc_end_taskgroup(&loc, gtid);
 
-    task(data);
-    xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();
-    KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
-}
-
-#define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_post) \
-    void func (void (*task) (void *), void *data, unsigned num_threads,      \
-      long lb, long ub, long str, long chunk_sz, unsigned flags)             \
-    {                                                                        \
-        int gtid = __kmp_entry_gtid();                                       \
-        MKLOC(loc, #func);                                                   \
-        KA_TRACE(20, ( #func ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n",        \
-          gtid, lb, ub, str, chunk_sz ));                                    \
-                                                                             \
-        ompt_pre();                                                          \
-        if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {                 \
-            if (num_threads != 0) {                                          \
-                __kmp_push_num_threads(&loc, gtid, num_threads);             \
-            }                                                                \
-            if (flags != 0) {                                                \
-                __kmp_push_proc_bind(&loc, gtid, (kmp_proc_bind_t)flags);    \
-            }                                                                \
-            __kmp_GOMP_fork_call(&loc, gtid, task,                           \
-              (microtask_t)__kmp_GOMP_parallel_microtask_wrapper, 9,         \
-              task, data, num_threads, &loc, (schedule), lb,                 \
-              (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz);               \
-        }                                                                    \
-        else {                                                               \
-            __kmp_GOMP_serialized_parallel(&loc, gtid, task);                \
-        }                                                                    \
-                                                                             \
-        KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                        \
-          (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,                    \
-          (schedule) != kmp_sch_static);                                     \
-        task(data);                                                          \
-        xexpand(KMP_API_NAME_GOMP_PARALLEL_END)();                           \
-        ompt_post();                                                          \
-                                                                             \
-        KA_TRACE(20, ( #func " exit: T#%d\n", gtid));                        \
-    }
-
-PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC), kmp_sch_static, 
-                OMPT_LOOP_PRE, OMPT_LOOP_POST)
-PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC), kmp_sch_dynamic_chunked, 
-                OMPT_LOOP_PRE, OMPT_LOOP_POST)
-PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED), kmp_sch_guided_chunked, 
-                OMPT_LOOP_PRE, OMPT_LOOP_POST)
-PARALLEL_LOOP(xexpand(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME), kmp_sch_runtime, 
-                OMPT_LOOP_PRE, OMPT_LOOP_POST)
-
-
-void
-xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void)
-{
-    int gtid = __kmp_entry_gtid();
-    MKLOC(loc, "GOMP_taskgroup_start");
-    KA_TRACE(20, ("GOMP_taskgroup_start: T#%d\n", gtid));
-
-    __kmpc_taskgroup(&loc, gtid);
-
-    return;
-}
-
-void
-xexpand(KMP_API_NAME_GOMP_TASKGROUP_END)(void)
-{
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_taskgroup_end");
-    KA_TRACE(20, ("GOMP_taskgroup_end: T#%d\n", gtid));
-
-    __kmpc_end_taskgroup(&loc, gtid);
-
-    return;
+  return;
 }
 
 #ifndef KMP_DEBUG
 static
 #endif /* KMP_DEBUG */
-kmp_int32 __kmp_gomp_to_omp_cancellation_kind(int gomp_kind) {
-    kmp_int32 cncl_kind = 0;
-    switch(gomp_kind) {
-      case 1:
-        cncl_kind = cancel_parallel;
-        break;
-      case 2:
-        cncl_kind = cancel_loop;
-        break;
-      case 4:
-        cncl_kind = cancel_sections;
-        break;
-      case 8:
-        cncl_kind = cancel_taskgroup;
-        break;
-    }
-    return cncl_kind;
+    kmp_int32
+    __kmp_gomp_to_omp_cancellation_kind(int gomp_kind) {
+  kmp_int32 cncl_kind = 0;
+  switch (gomp_kind) {
+  case 1:
+    cncl_kind = cancel_parallel;
+    break;
+  case 2:
+    cncl_kind = cancel_loop;
+    break;
+  case 4:
+    cncl_kind = cancel_sections;
+    break;
+  case 8:
+    cncl_kind = cancel_taskgroup;
+    break;
+  }
+  return cncl_kind;
 }
 
-bool
-xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which)
-{
-    if(__kmp_omp_cancellation) {
-        KMP_FATAL(NoGompCancellation);
-    }
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_cancellation_point");
-    KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
+bool xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(int which) {
+  if (__kmp_omp_cancellation) {
+    KMP_FATAL(NoGompCancellation);
+  }
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_cancellation_point");
+  KA_TRACE(20, ("GOMP_cancellation_point: T#%d\n", gtid));
 
-    kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
+  kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
 
-    return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
+  return __kmpc_cancellationpoint(&loc, gtid, cncl_kind);
 }
 
-bool
-xexpand(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void)
-{
-    if(__kmp_omp_cancellation) {
-        KMP_FATAL(NoGompCancellation);
-    }
+bool xexpand(KMP_API_NAME_GOMP_BARRIER_CANCEL)(void) {
+  if (__kmp_omp_cancellation) {
     KMP_FATAL(NoGompCancellation);
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_barrier_cancel");
-    KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
-
-    return __kmpc_cancel_barrier(&loc, gtid);
-}
-
-bool
-xexpand(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel)
-{
-    if(__kmp_omp_cancellation) {
-        KMP_FATAL(NoGompCancellation);
-    } else {
-        return FALSE;
-    }
+  }
+  KMP_FATAL(NoGompCancellation);
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_barrier_cancel");
+  KA_TRACE(20, ("GOMP_barrier_cancel: T#%d\n", gtid));
 
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_cancel");
-    KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
-
-    kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
-
-    if(do_cancel == FALSE) {
-        return xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
-    } else {
-        return __kmpc_cancel(&loc, gtid, cncl_kind);
-    }
+  return __kmpc_cancel_barrier(&loc, gtid);
 }
 
-bool
-xexpand(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void)
-{
-    if(__kmp_omp_cancellation) {
-        KMP_FATAL(NoGompCancellation);
-    }
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_sections_end_cancel");
-    KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
-
-    return __kmpc_cancel_barrier(&loc, gtid);
-}
+bool xexpand(KMP_API_NAME_GOMP_CANCEL)(int which, bool do_cancel) {
+  if (__kmp_omp_cancellation) {
+    KMP_FATAL(NoGompCancellation);
+  } else {
+    return FALSE;
+  }
 
-bool
-xexpand(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void)
-{
-    if(__kmp_omp_cancellation) {
-        KMP_FATAL(NoGompCancellation);
-    }
-    int gtid = __kmp_get_gtid();
-    MKLOC(loc, "GOMP_loop_end_cancel");
-    KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_cancel");
+  KA_TRACE(20, ("GOMP_cancel: T#%d\n", gtid));
 
-    return __kmpc_cancel_barrier(&loc, gtid);
-}
+  kmp_int32 cncl_kind = __kmp_gomp_to_omp_cancellation_kind(which);
 
-// All target functions are empty as of 2014-05-29
-void
-xexpand(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn) (void *), const void *openmp_target,
-             size_t mapnum, void **hostaddrs, size_t *sizes, unsigned char *kinds)
-{
-    return;
+  if (do_cancel == FALSE) {
+    return xexpand(KMP_API_NAME_GOMP_CANCELLATION_POINT)(which);
+  } else {
+    return __kmpc_cancel(&loc, gtid, cncl_kind);
+  }
 }
 
-void
-xexpand(KMP_API_NAME_GOMP_TARGET_DATA)(int device, const void *openmp_target, size_t mapnum,
-                  void **hostaddrs, size_t *sizes, unsigned char *kinds)
-{
-    return;
-}
+bool xexpand(KMP_API_NAME_GOMP_SECTIONS_END_CANCEL)(void) {
+  if (__kmp_omp_cancellation) {
+    KMP_FATAL(NoGompCancellation);
+  }
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_sections_end_cancel");
+  KA_TRACE(20, ("GOMP_sections_end_cancel: T#%d\n", gtid));
 
-void
-xexpand(KMP_API_NAME_GOMP_TARGET_END_DATA)(void)
-{
-    return;
+  return __kmpc_cancel_barrier(&loc, gtid);
 }
 
-void
-xexpand(KMP_API_NAME_GOMP_TARGET_UPDATE)(int device, const void *openmp_target, size_t mapnum,
-                    void **hostaddrs, size_t *sizes, unsigned char *kinds)
-{
-    return;
+bool xexpand(KMP_API_NAME_GOMP_LOOP_END_CANCEL)(void) {
+  if (__kmp_omp_cancellation) {
+    KMP_FATAL(NoGompCancellation);
+  }
+  int gtid = __kmp_get_gtid();
+  MKLOC(loc, "GOMP_loop_end_cancel");
+  KA_TRACE(20, ("GOMP_loop_end_cancel: T#%d\n", gtid));
+
+  return __kmpc_cancel_barrier(&loc, gtid);
 }
 
-void
-xexpand(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams, unsigned int thread_limit)
-{
-    return;
+// All target functions are empty as of 2014-05-29
+void xexpand(KMP_API_NAME_GOMP_TARGET)(int device, void (*fn)(void *),
+                                       const void *openmp_target, size_t mapnum,
+                                       void **hostaddrs, size_t *sizes,
+                                       unsigned char *kinds) {
+  return;
+}
+
+void xexpand(KMP_API_NAME_GOMP_TARGET_DATA)(int device,
+                                            const void *openmp_target,
+                                            size_t mapnum, void **hostaddrs,
+                                            size_t *sizes,
+                                            unsigned char *kinds) {
+  return;
+}
+
+void xexpand(KMP_API_NAME_GOMP_TARGET_END_DATA)(void) { return; }
+
+void xexpand(KMP_API_NAME_GOMP_TARGET_UPDATE)(int device,
+                                              const void *openmp_target,
+                                              size_t mapnum, void **hostaddrs,
+                                              size_t *sizes,
+                                              unsigned char *kinds) {
+  return;
+}
+
+void xexpand(KMP_API_NAME_GOMP_TEAMS)(unsigned int num_teams,
+                                      unsigned int thread_limit) {
+  return;
 }
 #endif // OMP_40_ENABLED
 
-
-/*
-    The following sections of code create aliases for the GOMP_* functions,
-    then create versioned symbols using the assembler directive .symver.
-    This is only pertinent for ELF .so library
-    xaliasify and xversionify are defined in kmp_ftn_os.h
-*/
+/* The following sections of code create aliases for the GOMP_* functions, then
+   create versioned symbols using the assembler directive .symver. This is only
+   pertinent for ELF .so library xaliasify and xversionify are defined in
+   kmp_ftn_os.h  */
 
 #ifdef KMP_USE_VERSION_SYMBOLS
 
@@ -1636,7 +1503,5 @@ xversionify(KMP_API_NAME_GOMP_TEAMS, 40,
 #endif // KMP_USE_VERSION_SYMBOLS
 
 #ifdef __cplusplus
-    } //extern "C"
+} // extern "C"
 #endif // __cplusplus
-
-

Modified: openmp/trunk/runtime/src/kmp_i18n.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_i18n.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_i18n.cpp (original)
+++ openmp/trunk/runtime/src/kmp_i18n.cpp Fri May 12 13:01:32 2017
@@ -13,247 +13,208 @@
 //===----------------------------------------------------------------------===//
 
 
-
 #include "kmp_i18n.h"
 
-#include "kmp_os.h"
-#include "kmp_debug.h"
 #include "kmp.h"
+#include "kmp_debug.h"
+#include "kmp_io.h" // __kmp_printf.
 #include "kmp_lock.h"
-#include "kmp_io.h"          // __kmp_printf.
+#include "kmp_os.h"
 
-#include <stdio.h>
 #include <errno.h>
-#include <string.h>
 #include <locale.h>
 #include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
 
+#include "kmp_environment.h"
 #include "kmp_i18n_default.inc"
 #include "kmp_str.h"
-#include "kmp_environment.h"
 
 #undef KMP_I18N_OK
 
-#define get_section( id )  ( (id) >> 16 )
-#define get_number( id )   ( (id) & 0xFFFF )
+#define get_section(id) ((id) >> 16)
+#define get_number(id) ((id)&0xFFFF)
 
-kmp_msg_t           __kmp_msg_empty = { kmp_mt_dummy, 0, "", 0  };
-kmp_msg_t           __kmp_msg_null  = { kmp_mt_dummy, 0, NULL, 0 };
-static char const * no_message_available = "(No message available)";
+kmp_msg_t __kmp_msg_empty = {kmp_mt_dummy, 0, "", 0};
+kmp_msg_t __kmp_msg_null = {kmp_mt_dummy, 0, NULL, 0};
+static char const *no_message_available = "(No message available)";
 
 enum kmp_i18n_cat_status {
-    KMP_I18N_CLOSED,    // Not yet opened or closed.
-    KMP_I18N_OPENED,    // Opened successfully, ready to use.
-    KMP_I18N_ABSENT     // Opening failed, message catalog should not be used.
+  KMP_I18N_CLOSED, // Not yet opened or closed.
+  KMP_I18N_OPENED, // Opened successfully, ready to use.
+  KMP_I18N_ABSENT // Opening failed, message catalog should not be used.
 }; // enum kmp_i18n_cat_status
-typedef enum kmp_i18n_cat_status  kmp_i18n_cat_status_t;
-static volatile kmp_i18n_cat_status_t  status = KMP_I18N_CLOSED;
+typedef enum kmp_i18n_cat_status kmp_i18n_cat_status_t;
+static volatile kmp_i18n_cat_status_t status = KMP_I18N_CLOSED;
 
-/*
-    Message catalog is opened at first usage, so we have to synchronize opening to avoid race and
-    multiple openings.
+/* Message catalog is opened at first usage, so we have to synchronize opening
+   to avoid race and multiple openings.
 
-    Closing does not require synchronization, because catalog is closed very late at library
-    shutting down, when no other threads are alive.
-*/
+   Closing does not require synchronization, because catalog is closed very late
+   at library shutting down, when no other threads are alive.  */
 
 static void __kmp_i18n_do_catopen();
-static kmp_bootstrap_lock_t  lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( lock );
-    // `lock' variable may be placed into __kmp_i18n_catopen function because it is used only by
-    // that function. But we afraid a (buggy) compiler may treat it wrongly. So we put it outside of
-    // function just in case.
-
-void
-__kmp_i18n_catopen(
-) {
-    if ( status == KMP_I18N_CLOSED ) {
-        __kmp_acquire_bootstrap_lock( & lock );
-        if ( status == KMP_I18N_CLOSED ) {
-            __kmp_i18n_do_catopen();
-        }; // if
-        __kmp_release_bootstrap_lock( & lock );
+static kmp_bootstrap_lock_t lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(lock);
+// `lock' variable may be placed into __kmp_i18n_catopen function because it is
+// used only by that function. But we afraid a (buggy) compiler may treat it
+// wrongly. So we put it outside of function just in case.
+
+void __kmp_i18n_catopen() {
+  if (status == KMP_I18N_CLOSED) {
+    __kmp_acquire_bootstrap_lock(&lock);
+    if (status == KMP_I18N_CLOSED) {
+      __kmp_i18n_do_catopen();
     }; // if
+    __kmp_release_bootstrap_lock(&lock);
+  }; // if
 } // func __kmp_i18n_catopen
 
-
-/*
-    ================================================================================================
-    Linux* OS and OS X* part.
-    ================================================================================================
-*/
-
+/* Linux* OS and OS X* part */
 #if KMP_OS_UNIX
 #define KMP_I18N_OK
 
 #include <nl_types.h>
 
-#define KMP_I18N_NULLCAT ((nl_catd)( -1 ))
-static nl_catd       cat  = KMP_I18N_NULLCAT;    // !!! Shall it be volatile?
-static char const *  name = ( KMP_VERSION_MAJOR == 4 ? "libguide.cat" : "libomp.cat" );
-
-/*
-    Useful links:
-        http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html#tag_08_02
-        http://www.opengroup.org/onlinepubs/000095399/functions/catopen.html
-        http://www.opengroup.org/onlinepubs/000095399/functions/setlocale.html
+#define KMP_I18N_NULLCAT ((nl_catd)(-1))
+static nl_catd cat = KMP_I18N_NULLCAT; // !!! Shall it be volatile?
+static char const *name =
+    (KMP_VERSION_MAJOR == 4 ? "libguide.cat" : "libomp.cat");
+
+/* Useful links:
+http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html#tag_08_02
+http://www.opengroup.org/onlinepubs/000095399/functions/catopen.html
+http://www.opengroup.org/onlinepubs/000095399/functions/setlocale.html
 */
 
-void
-__kmp_i18n_do_catopen(
-) {
-    int    english = 0;
-    char * lang    = __kmp_env_get( "LANG" );
-    // TODO: What about LC_ALL or LC_MESSAGES?
-
-    KMP_DEBUG_ASSERT( status == KMP_I18N_CLOSED );
-    KMP_DEBUG_ASSERT( cat    == KMP_I18N_NULLCAT );
-
-    english =
-        lang == NULL                       ||  // In all these cases English language is used.
-        strcmp( lang, "" )            == 0 ||
-        strcmp( lang, " " )           == 0 ||
-        // Workaround for Fortran RTL bug DPD200137873 "Fortran runtime resets LANG env var
-        // to space if it is not set".
-        strcmp( lang, "C" )           == 0 ||
-        strcmp( lang, "POSIX" )       == 0;
-
-    if ( ! english ) {  // English language is not yet detected, let us continue.
-        // Format of LANG is: [language[_territory][.codeset][@modifier]]
-        // Strip all parts except language.
-        char * tail = NULL;
-        __kmp_str_split( lang, '@', & lang, & tail );
-        __kmp_str_split( lang, '.', & lang, & tail );
-        __kmp_str_split( lang, '_', & lang, & tail );
-        english = ( strcmp( lang, "en" ) == 0 );
-    }; // if
-
-    KMP_INTERNAL_FREE( lang );
-
-    // Do not try to open English catalog because internal messages are
-    // exact copy of messages in English catalog.
-    if ( english ) {
-        status = KMP_I18N_ABSENT;  // mark catalog as absent so it will not be re-opened.
-        return;
-    }
-
-    cat = catopen( name, 0 );
-    // TODO: Why do we pass 0 in flags?
-    status = ( cat == KMP_I18N_NULLCAT ? KMP_I18N_ABSENT : KMP_I18N_OPENED );
-
-    if ( status == KMP_I18N_ABSENT ) {
-        if (__kmp_generate_warnings > kmp_warnings_low) { // AC: only issue warning in case explicitly asked to
-            int    error   = errno; // Save errno immediately.
-            char * nlspath = __kmp_env_get( "NLSPATH" );
-            char * lang    = __kmp_env_get( "LANG" );
-
-            // Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
-            // __kmp_i18n_catgets() will not try to open catalog, but will return default message.
-            kmp_msg_t err_code = KMP_ERR( error );
-            __kmp_msg(
-                kmp_ms_warning,
-                KMP_MSG( CantOpenMessageCatalog, name ),
-                err_code,
-                KMP_HNT( CheckEnvVar, "NLSPATH", nlspath ),
-                KMP_HNT( CheckEnvVar, "LANG", lang ),
-                __kmp_msg_null
-            );
-            if (__kmp_generate_warnings == kmp_warnings_off) {
-                __kmp_str_free(&err_code.str);
-            }
-
-            KMP_INFORM( WillUseDefaultMessages );
-            KMP_INTERNAL_FREE( nlspath );
-            KMP_INTERNAL_FREE( lang );
-        }
-    } else { // status == KMP_I18N_OPENED
-
-        int section = get_section( kmp_i18n_prp_Version );
-        int number  = get_number( kmp_i18n_prp_Version );
-        char const * expected = __kmp_i18n_default_table.sect[ section ].str[ number ];
-        // Expected version of the catalog.
-        kmp_str_buf_t version;   // Actual version of the catalog.
-        __kmp_str_buf_init( & version );
-        __kmp_str_buf_print( & version, "%s", catgets( cat, section, number, NULL ) );
-
-        // String returned by catgets is invalid after closing the catalog, so copy it.
-        if ( strcmp( version.str, expected ) != 0 ) {
-            __kmp_i18n_catclose();     // Close bad catalog.
-            status = KMP_I18N_ABSENT;  // And mark it as absent.
-            if (__kmp_generate_warnings > kmp_warnings_low) { // AC: only issue warning in case explicitly asked to
-                // And now print a warning using default messages.
-                char const * name    = "NLSPATH";
-                char const * nlspath = __kmp_env_get( name );
-                __kmp_msg(
-                    kmp_ms_warning,
-                    KMP_MSG( WrongMessageCatalog, name, version.str, expected ),
-                    KMP_HNT( CheckEnvVar, name, nlspath ),
-                    __kmp_msg_null
-                );
-                KMP_INFORM( WillUseDefaultMessages );
-                KMP_INTERNAL_FREE( (void *) nlspath );
-            } // __kmp_generate_warnings
-        }; // if
-        __kmp_str_buf_free( & version );
+void __kmp_i18n_do_catopen() {
+  int english = 0;
+  char *lang = __kmp_env_get("LANG");
+  // TODO: What about LC_ALL or LC_MESSAGES?
+
+  KMP_DEBUG_ASSERT(status == KMP_I18N_CLOSED);
+  KMP_DEBUG_ASSERT(cat == KMP_I18N_NULLCAT);
+
+  english = lang == NULL || // In all these cases English language is used.
+            strcmp(lang, "") == 0 || strcmp(lang, " ") == 0 ||
+            // Workaround for Fortran RTL bug DPD200137873 "Fortran runtime
+            // resets LANG env var to space if it is not set".
+            strcmp(lang, "C") == 0 || strcmp(lang, "POSIX") == 0;
+
+  if (!english) { // English language is not yet detected, let us continue.
+    // Format of LANG is: [language[_territory][.codeset][@modifier]]
+    // Strip all parts except language.
+    char *tail = NULL;
+    __kmp_str_split(lang, '@', &lang, &tail);
+    __kmp_str_split(lang, '.', &lang, &tail);
+    __kmp_str_split(lang, '_', &lang, &tail);
+    english = (strcmp(lang, "en") == 0);
+  }; // if
+
+  KMP_INTERNAL_FREE(lang);
+
+  // Do not try to open English catalog because internal messages are
+  // exact copy of messages in English catalog.
+  if (english) {
+    status = KMP_I18N_ABSENT; // mark catalog as absent so it will not
+    // be re-opened.
+    return;
+  }
+
+  cat = catopen(name, 0);
+  // TODO: Why do we pass 0 in flags?
+  status = (cat == KMP_I18N_NULLCAT ? KMP_I18N_ABSENT : KMP_I18N_OPENED);
+
+  if (status == KMP_I18N_ABSENT) {
+    if (__kmp_generate_warnings > kmp_warnings_low) {
+      // AC: only issue warning in case explicitly asked to
+      int error = errno; // Save errno immediately.
+      char *nlspath = __kmp_env_get("NLSPATH");
+      char *lang = __kmp_env_get("LANG");
+
+      // Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
+      // __kmp_i18n_catgets() will not try to open catalog, but will return
+      // default message.
+      kmp_msg_t err_code = KMP_ERR(error);
+      __kmp_msg(kmp_ms_warning, KMP_MSG(CantOpenMessageCatalog, name), err_code,
+                KMP_HNT(CheckEnvVar, "NLSPATH", nlspath),
+                KMP_HNT(CheckEnvVar, "LANG", lang), __kmp_msg_null);
+      if (__kmp_generate_warnings == kmp_warnings_off) {
+        __kmp_str_free(&err_code.str);
+      }
 
+      KMP_INFORM(WillUseDefaultMessages);
+      KMP_INTERNAL_FREE(nlspath);
+      KMP_INTERNAL_FREE(lang);
+    }
+  } else { // status == KMP_I18N_OPENED
+    int section = get_section(kmp_i18n_prp_Version);
+    int number = get_number(kmp_i18n_prp_Version);
+    char const *expected = __kmp_i18n_default_table.sect[section].str[number];
+    // Expected version of the catalog.
+    kmp_str_buf_t version; // Actual version of the catalog.
+    __kmp_str_buf_init(&version);
+    __kmp_str_buf_print(&version, "%s", catgets(cat, section, number, NULL));
+
+    // String returned by catgets is invalid after closing catalog, so copy it.
+    if (strcmp(version.str, expected) != 0) {
+      __kmp_i18n_catclose(); // Close bad catalog.
+      status = KMP_I18N_ABSENT; // And mark it as absent.
+      if (__kmp_generate_warnings > kmp_warnings_low) {
+        // AC: only issue warning in case explicitly asked to
+        // And now print a warning using default messages.
+        char const *name = "NLSPATH";
+        char const *nlspath = __kmp_env_get(name);
+        __kmp_msg(kmp_ms_warning,
+                  KMP_MSG(WrongMessageCatalog, name, version.str, expected),
+                  KMP_HNT(CheckEnvVar, name, nlspath), __kmp_msg_null);
+        KMP_INFORM(WillUseDefaultMessages);
+        KMP_INTERNAL_FREE((void *)nlspath);
+      } // __kmp_generate_warnings
     }; // if
-
+    __kmp_str_buf_free(&version);
+  }; // if
 } // func __kmp_i18n_do_catopen
 
-
-void
-__kmp_i18n_catclose(
-) {
-    if ( status == KMP_I18N_OPENED ) {
-        KMP_DEBUG_ASSERT( cat != KMP_I18N_NULLCAT );
-        catclose( cat );
-        cat = KMP_I18N_NULLCAT;
-    }; // if
-    status = KMP_I18N_CLOSED;
+void __kmp_i18n_catclose() {
+  if (status == KMP_I18N_OPENED) {
+    KMP_DEBUG_ASSERT(cat != KMP_I18N_NULLCAT);
+    catclose(cat);
+    cat = KMP_I18N_NULLCAT;
+  }; // if
+  status = KMP_I18N_CLOSED;
 } // func __kmp_i18n_catclose
 
+char const *__kmp_i18n_catgets(kmp_i18n_id_t id) {
 
-char const *
-__kmp_i18n_catgets(
-    kmp_i18n_id_t  id
-) {
-
-    int section = get_section( id );
-    int number  = get_number( id );
-    char const * message = NULL;
-
-    if ( 1 <= section && section <= __kmp_i18n_default_table.size ) {
-        if ( 1 <= number && number <= __kmp_i18n_default_table.sect[ section ].size ) {
-            if ( status == KMP_I18N_CLOSED ) {
-                __kmp_i18n_catopen();
-            }; // if
-            if ( status == KMP_I18N_OPENED ) {
-                message =
-                    catgets(
-                        cat,
-                        section, number,
-                        __kmp_i18n_default_table.sect[ section ].str[ number ]
-                    );
-            }; // if
-            if ( message == NULL ) {
-                message = __kmp_i18n_default_table.sect[ section ].str[ number ];
-            }; // if
-        }; // if
-    }; // if
-    if ( message == NULL ) {
-        message = no_message_available;
-    }; // if
-    return message;
+  int section = get_section(id);
+  int number = get_number(id);
+  char const *message = NULL;
+
+  if (1 <= section && section <= __kmp_i18n_default_table.size) {
+    if (1 <= number && number <= __kmp_i18n_default_table.sect[section].size) {
+      if (status == KMP_I18N_CLOSED) {
+        __kmp_i18n_catopen();
+      }; // if
+      if (status == KMP_I18N_OPENED) {
+        message = catgets(cat, section, number,
+                          __kmp_i18n_default_table.sect[section].str[number]);
+      }; // if
+      if (message == NULL) {
+        message = __kmp_i18n_default_table.sect[section].str[number];
+      }; // if
+    }; // if
+  }; // if
+  if (message == NULL) {
+    message = no_message_available;
+  }; // if
+  return message;
 
 } // func __kmp_i18n_catgets
 
-
 #endif // KMP_OS_UNIX
 
-/*
-    ================================================================================================
-    Windows* OS part.
-    ================================================================================================
-*/
+/* Windows* OS part. */
 
 #if KMP_OS_WINDOWS
 #define KMP_I18N_OK
@@ -261,737 +222,645 @@ __kmp_i18n_catgets(
 #include "kmp_environment.h"
 #include <windows.h>
 
-#define KMP_I18N_NULLCAT  NULL
-static HMODULE       cat  = KMP_I18N_NULLCAT;    // !!! Shall it be volatile?
-static char const *  name = ( KMP_VERSION_MAJOR == 4 ? "libguide40ui.dll" : "libompui.dll" );
-
-static kmp_i18n_table_t  table             = { 0, NULL };
-    // Messages formatted by FormatMessage() should be freed, but catgets() interface assumes
-    // user will not free messages. So we cache all the retrieved messages in the table, which
-    // are freed at catclose().
-static UINT const        default_code_page = CP_OEMCP;
-static UINT              code_page         = default_code_page;
-
-static char const * ___catgets( kmp_i18n_id_t  id );
-static UINT         get_code_page();
-static void         kmp_i18n_table_free( kmp_i18n_table_t * table );
-
-
-static UINT
-get_code_page(
-) {
-
-    UINT cp = default_code_page;
-    char const * value = __kmp_env_get( "KMP_CODEPAGE" );
-    if ( value != NULL ) {
-        if ( _stricmp( value, "ANSI" ) == 0 ) {
-            cp = CP_ACP;
-        } else if ( _stricmp( value, "OEM" ) == 0 ) {
-            cp = CP_OEMCP;
-        } else if ( _stricmp( value, "UTF-8" ) == 0 || _stricmp( value, "UTF8" ) == 0 ) {
-            cp = CP_UTF8;
-        } else if ( _stricmp( value, "UTF-7" ) == 0 || _stricmp( value, "UTF7" ) == 0 ) {
-            cp = CP_UTF7;
-        } else {
-            // !!! TODO: Issue a warning?
-        }; // if
-    }; // if
-    KMP_INTERNAL_FREE( (void *) value );
-    return cp;
+#define KMP_I18N_NULLCAT NULL
+static HMODULE cat = KMP_I18N_NULLCAT; // !!! Shall it be volatile?
+static char const *name =
+    (KMP_VERSION_MAJOR == 4 ? "libguide40ui.dll" : "libompui.dll");
+
+static kmp_i18n_table_t table = {0, NULL};
+// Messages formatted by FormatMessage() should be freed, but catgets()
+// interface assumes user will not free messages. So we cache all the retrieved
+// messages in the table, which are freed at catclose().
+static UINT const default_code_page = CP_OEMCP;
+static UINT code_page = default_code_page;
+
+static char const *___catgets(kmp_i18n_id_t id);
+static UINT get_code_page();
+static void kmp_i18n_table_free(kmp_i18n_table_t *table);
+
+static UINT get_code_page() {
+
+  UINT cp = default_code_page;
+  char const *value = __kmp_env_get("KMP_CODEPAGE");
+  if (value != NULL) {
+    if (_stricmp(value, "ANSI") == 0) {
+      cp = CP_ACP;
+    } else if (_stricmp(value, "OEM") == 0) {
+      cp = CP_OEMCP;
+    } else if (_stricmp(value, "UTF-8") == 0 || _stricmp(value, "UTF8") == 0) {
+      cp = CP_UTF8;
+    } else if (_stricmp(value, "UTF-7") == 0 || _stricmp(value, "UTF7") == 0) {
+      cp = CP_UTF7;
+    } else {
+      // !!! TODO: Issue a warning?
+    }; // if
+  }; // if
+  KMP_INTERNAL_FREE((void *)value);
+  return cp;
 
 } // func get_code_page
 
-
-static void
-kmp_i18n_table_free(
-    kmp_i18n_table_t * table
-) {
-    int s;
-    int m;
-    for ( s = 0; s < table->size; ++ s ) {
-        for ( m = 0; m < table->sect[ s ].size; ++ m ) {
-            // Free message.
-            KMP_INTERNAL_FREE( (void *) table->sect[ s ].str[ m ] );
-            table->sect[ s ].str[ m ] = NULL;
-        }; // for m
-        table->sect[ s ].size = 0;
-        // Free section itself.
-        KMP_INTERNAL_FREE ( (void *) table->sect[ s ].str );
-        table->sect[ s ].str = NULL;
-    }; // for s
-    table->size = 0;
-    KMP_INTERNAL_FREE( (void *) table->sect );
-    table->sect = NULL;
+static void kmp_i18n_table_free(kmp_i18n_table_t *table) {
+  int s;
+  int m;
+  for (s = 0; s < table->size; ++s) {
+    for (m = 0; m < table->sect[s].size; ++m) {
+      // Free message.
+      KMP_INTERNAL_FREE((void *)table->sect[s].str[m]);
+      table->sect[s].str[m] = NULL;
+    }; // for m
+    table->sect[s].size = 0;
+    // Free section itself.
+    KMP_INTERNAL_FREE((void *)table->sect[s].str);
+    table->sect[s].str = NULL;
+  }; // for s
+  table->size = 0;
+  KMP_INTERNAL_FREE((void *)table->sect);
+  table->sect = NULL;
 } // kmp_i18n_table_free
 
+void __kmp_i18n_do_catopen() {
 
-void
-__kmp_i18n_do_catopen(
-) {
-
-    LCID          locale_id = GetThreadLocale();
-    WORD          lang_id = LANGIDFROMLCID( locale_id );
-    WORD          primary_lang_id = PRIMARYLANGID( lang_id );
-    kmp_str_buf_t path;
-
-    KMP_DEBUG_ASSERT( status == KMP_I18N_CLOSED );
-    KMP_DEBUG_ASSERT( cat    == KMP_I18N_NULLCAT );
-
-    __kmp_str_buf_init( & path );
-
-    // Do not try to open English catalog because internal messages are
-    // exact copy of messages in English catalog.
-    if ( primary_lang_id == LANG_ENGLISH ) {
-        status = KMP_I18N_ABSENT;  // mark catalog as absent so it will not be re-opened.
+  LCID locale_id = GetThreadLocale();
+  WORD lang_id = LANGIDFROMLCID(locale_id);
+  WORD primary_lang_id = PRIMARYLANGID(lang_id);
+  kmp_str_buf_t path;
+
+  KMP_DEBUG_ASSERT(status == KMP_I18N_CLOSED);
+  KMP_DEBUG_ASSERT(cat == KMP_I18N_NULLCAT);
+
+  __kmp_str_buf_init(&path);
+
+  // Do not try to open English catalog because internal messages are exact copy
+  // of messages in English catalog.
+  if (primary_lang_id == LANG_ENGLISH) {
+    status = KMP_I18N_ABSENT; // mark catalog as absent so it will not
+    // be re-opened.
+    goto end;
+  }; // if
+
+  // Construct resource DLL name.
+  /* Simple LoadLibrary( name ) is not suitable due to security issue (see
+     http://www.microsoft.com/technet/security/advisory/2269637.mspx). We have
+     to specify full path to the message catalog.  */
+  {
+    // Get handle of our DLL first.
+    HMODULE handle;
+    BOOL brc = GetModuleHandleEx(
+        GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+            GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+        reinterpret_cast<LPCSTR>(&__kmp_i18n_do_catopen), &handle);
+    if (!brc) { // Error occurred.
+      status = KMP_I18N_ABSENT; // mark catalog as absent so it will not be
+      // re-opened.
+      goto end;
+      // TODO: Enable multiple messages (KMP_MSG) to be passed to __kmp_msg; and
+      // print a proper warning.
+    }; // if
+
+    // Now get path to the our DLL.
+    for (;;) {
+      DWORD drc = GetModuleFileName(handle, path.str, path.size);
+      if (drc == 0) { // Error occurred.
+        status = KMP_I18N_ABSENT;
         goto end;
-    }; // if
-
-    // Construct resource DLL name.
-    /*
-        Simple
-            LoadLibrary( name )
-        is not suitable due to security issue (see
-        http://www.microsoft.com/technet/security/advisory/2269637.mspx). We have to specify full
-        path to the message catalog.
-    */
-    {
-
-        // Get handle of our DLL first.
-        HMODULE handle;
-        BOOL brc =
-            GetModuleHandleEx(
-                GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
-                reinterpret_cast< LPCSTR >( & __kmp_i18n_do_catopen ),
-                & handle
-            );
-        if ( ! brc ) {    // Error occurred.
-            status = KMP_I18N_ABSENT;  // mark catalog as absent so it will not be re-opened.
-            goto end;
-            // TODO: Enable multiple messages (KMP_MSG) to be passed to __kmp_msg; and print
-            // a proper warning.
-        }; // if
-
-        // Now get path to the our DLL.
-        for ( ; ; ) {
-            DWORD drc = GetModuleFileName( handle, path.str, path.size );
-            if ( drc == 0 ) {    // Error occurred.
-                status = KMP_I18N_ABSENT;
-                goto end;
-            }; // if
-            if ( drc < path.size ) {
-                path.used = drc;
-                break;
-            }; // if
-            __kmp_str_buf_reserve( & path, path.size * 2 );
-        }; // forever
-
-        // Now construct the name of message catalog.
-        kmp_str_fname fname;
-        __kmp_str_fname_init( & fname, path.str );
-        __kmp_str_buf_clear( & path );
-        __kmp_str_buf_print( & path, "%s%lu/%s", fname.dir, (unsigned long)( locale_id ), name );
-        __kmp_str_fname_free( & fname );
-
-    }
-
-    // For security reasons, use LoadLibraryEx() and load message catalog as a data file.
-    cat = LoadLibraryEx( path.str, NULL, LOAD_LIBRARY_AS_DATAFILE );
-    status = ( cat == KMP_I18N_NULLCAT ? KMP_I18N_ABSENT : KMP_I18N_OPENED );
-
-    if ( status == KMP_I18N_ABSENT ) {
-      if (__kmp_generate_warnings > kmp_warnings_low) { // AC: only issue warning in case explicitly asked to
-        DWORD error = GetLastError();
-        // Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
-        // __kmp_i18n_catgets() will not try to open catalog but will return default message.
-        /*
-          If message catalog for another architecture found (e.g. OpenMP RTL
-          for IA-32 architecture opens libompui.dll for Intel(R) 64)
-          Windows* OS returns error 193 (ERROR_BAD_EXE_FORMAT). However,
-          FormatMessage fails to return a message for this error, so user
-          will see:
-
-          OMP: Warning #2: Cannot open message catalog "1041\libompui.dll":
-          OMP: System error #193: (No system error message available)
-          OMP: Info #3: Default messages will be used.
-
-          Issue a hint in this case to let cause of trouble more understandable.
-        */
-        kmp_msg_t err_code = KMP_SYSERRCODE(error);
-        __kmp_msg(
-            kmp_ms_warning,
-            KMP_MSG( CantOpenMessageCatalog, path.str ),
-            err_code,
-            ( error == ERROR_BAD_EXE_FORMAT ? KMP_HNT( BadExeFormat, path.str, KMP_ARCH_STR ) : __kmp_msg_null ),
-            __kmp_msg_null
-        );
-        if (__kmp_generate_warnings == kmp_warnings_off) {
-            __kmp_str_free(&err_code.str);
-        }
+      }; // if
+      if (drc < path.size) {
+        path.used = drc;
+        break;
+      }; // if
+      __kmp_str_buf_reserve(&path, path.size * 2);
+    }; // forever
 
-        KMP_INFORM( WillUseDefaultMessages );
+    // Now construct the name of message catalog.
+    kmp_str_fname fname;
+    __kmp_str_fname_init(&fname, path.str);
+    __kmp_str_buf_clear(&path);
+    __kmp_str_buf_print(&path, "%s%lu/%s", fname.dir,
+                        (unsigned long)(locale_id), name);
+    __kmp_str_fname_free(&fname);
+  }
+
+  // For security reasons, use LoadLibraryEx() and load message catalog as a
+  // data file.
+  cat = LoadLibraryEx(path.str, NULL, LOAD_LIBRARY_AS_DATAFILE);
+  status = (cat == KMP_I18N_NULLCAT ? KMP_I18N_ABSENT : KMP_I18N_OPENED);
+
+  if (status == KMP_I18N_ABSENT) {
+    if (__kmp_generate_warnings > kmp_warnings_low) {
+      // AC: only issue warning in case explicitly asked to
+      DWORD error = GetLastError();
+      // Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
+      // __kmp_i18n_catgets() will not try to open catalog but will return
+      // default message.
+      /* If message catalog for another architecture found (e.g. OpenMP RTL for
+         IA-32 architecture opens libompui.dll for Intel(R) 64) Windows* OS
+         returns error 193 (ERROR_BAD_EXE_FORMAT). However, FormatMessage fails
+         to return a message for this error, so user will see:
+
+         OMP: Warning #2: Cannot open message catalog "1041\libompui.dll":
+         OMP: System error #193: (No system error message available)
+         OMP: Info #3: Default messages will be used.
+
+         Issue hint in this case so cause of trouble is more understandable. */
+      kmp_msg_t err_code = KMP_SYSERRCODE(error);
+      __kmp_msg(kmp_ms_warning, KMP_MSG(CantOpenMessageCatalog, path.str),
+                err_code, (error == ERROR_BAD_EXE_FORMAT
+                               ? KMP_HNT(BadExeFormat, path.str, KMP_ARCH_STR)
+                               : __kmp_msg_null),
+                __kmp_msg_null);
+      if (__kmp_generate_warnings == kmp_warnings_off) {
+        __kmp_str_free(&err_code.str);
       }
-    } else { // status == KMP_I18N_OPENED
-
-        int section = get_section( kmp_i18n_prp_Version );
-        int number  = get_number( kmp_i18n_prp_Version );
-        char const * expected = __kmp_i18n_default_table.sect[ section ].str[ number ];
-        kmp_str_buf_t version;   // Actual version of the catalog.
-        __kmp_str_buf_init( & version );
-        __kmp_str_buf_print( & version, "%s", ___catgets( kmp_i18n_prp_Version ) );
-            // String returned by catgets is invalid after closing the catalog, so copy it.
-        if ( strcmp( version.str, expected ) != 0 ) {
-            // Close bad catalog.
-            __kmp_i18n_catclose();
-            status = KMP_I18N_ABSENT;  // And mark it as absent.
-            if (__kmp_generate_warnings > kmp_warnings_low) {
-                // And now print a warning using default messages.
-                __kmp_msg(
-                    kmp_ms_warning,
-                    KMP_MSG( WrongMessageCatalog, path.str, version.str, expected ),
-                    __kmp_msg_null
-                );
-                KMP_INFORM( WillUseDefaultMessages );
-            } // __kmp_generate_warnings
-        }; // if
-        __kmp_str_buf_free( & version );
-
-    }; // if
-    code_page = get_code_page();
-
-    end:
-        __kmp_str_buf_free( & path );
-        return;
+      KMP_INFORM(WillUseDefaultMessages);
+    }
+  } else { // status == KMP_I18N_OPENED
 
+    int section = get_section(kmp_i18n_prp_Version);
+    int number = get_number(kmp_i18n_prp_Version);
+    char const *expected = __kmp_i18n_default_table.sect[section].str[number];
+    kmp_str_buf_t version; // Actual version of the catalog.
+    __kmp_str_buf_init(&version);
+    __kmp_str_buf_print(&version, "%s", ___catgets(kmp_i18n_prp_Version));
+    // String returned by catgets is invalid after closing catalog, so copy it.
+    if (strcmp(version.str, expected) != 0) {
+      // Close bad catalog.
+      __kmp_i18n_catclose();
+      status = KMP_I18N_ABSENT; // And mark it as absent.
+      if (__kmp_generate_warnings > kmp_warnings_low) {
+        // And now print a warning using default messages.
+        __kmp_msg(kmp_ms_warning,
+                  KMP_MSG(WrongMessageCatalog, path.str, version.str, expected),
+                  __kmp_msg_null);
+        KMP_INFORM(WillUseDefaultMessages);
+      } // __kmp_generate_warnings
+    }; // if
+    __kmp_str_buf_free(&version);
+
+  }; // if
+  code_page = get_code_page();
+
+end:
+  __kmp_str_buf_free(&path);
+  return;
 } // func __kmp_i18n_do_catopen
 
-
-void
-__kmp_i18n_catclose(
-) {
-    if ( status == KMP_I18N_OPENED ) {
-        KMP_DEBUG_ASSERT( cat != KMP_I18N_NULLCAT );
-        kmp_i18n_table_free( & table );
-        FreeLibrary( cat );
-        cat = KMP_I18N_NULLCAT;
-    }; // if
-    code_page = default_code_page;
-    status = KMP_I18N_CLOSED;
+void __kmp_i18n_catclose() {
+  if (status == KMP_I18N_OPENED) {
+    KMP_DEBUG_ASSERT(cat != KMP_I18N_NULLCAT);
+    kmp_i18n_table_free(&table);
+    FreeLibrary(cat);
+    cat = KMP_I18N_NULLCAT;
+  }; // if
+  code_page = default_code_page;
+  status = KMP_I18N_CLOSED;
 } // func __kmp_i18n_catclose
 
-/*
-    We use FormatMessage() to get strings from catalog, get system error messages, etc.
-    FormatMessage() tends to return Windows* OS-style end-of-lines, "\r\n". When string is printed,
-    printf() also replaces all the occurrences of "\n" with "\r\n" (again!), so sequences like
-    "\r\r\r\n" appear in output. It is not too good.
-
-    Additional mess comes from message catalog: Our catalog source en_US.mc file (generated by
-    message-converter.pl) contains only "\n" characters, but en_US_msg_1033.bin file (produced by
-    mc.exe) may contain "\r\n" or just "\n". This mess goes from en_US_msg_1033.bin file to
-    message catalog, libompui.dll. For example, message
-
-        Error
-
-    (there is "\n" at the end) is compiled by mc.exe to "Error\r\n", while
-
-        OMP: Error %1!d!: %2!s!\n
-
-    (there is "\n" at the end as well) is compiled to "OMP: Error %1!d!: %2!s!\r\n\n".
-
-    Thus, stripping all "\r" normalizes string and returns it to canonical form, so printf() will
-    produce correct end-of-line sequences.
-
-    ___strip_crs() serves for this purpose: it removes all the occurrences of "\r" in-place and
-    returns new length of string.
-*/
-static
-int
-___strip_crs(
-    char * str
-) {
-    int in  = 0;  // Input character index.
-    int out = 0;  // Output character index.
-    for ( ; ; ) {
-        if ( str[ in ] != '\r' ) {
-            str[ out ] = str[ in ];
-            ++ out;
-        }; // if
-        if ( str[ in ] == 0 ) {
-            break;
-        }; // if
-        ++ in;
-    }; // forever
-    return out - 1;
+/* We use FormatMessage() to get strings from catalog, get system error
+   messages, etc. FormatMessage() tends to return Windows* OS-style
+   end-of-lines, "\r\n". When string is printed, printf() also replaces all the
+   occurrences of "\n" with "\r\n" (again!), so sequences like "\r\r\r\n"
+   appear in output. It is not too good.
+
+   Additional mess comes from message catalog: Our catalog source en_US.mc file
+   (generated by message-converter.pl) contains only "\n" characters, but
+   en_US_msg_1033.bin file (produced by mc.exe) may contain "\r\n" or just "\n".
+   This mess goes from en_US_msg_1033.bin file to message catalog,
+   libompui.dll. For example, message
+
+   Error
+
+   (there is "\n" at the end) is compiled by mc.exe to "Error\r\n", while
+
+   OMP: Error %1!d!: %2!s!\n
+
+   (there is "\n" at the end as well) is compiled to "OMP: Error %1!d!:
+   %2!s!\r\n\n".
+
+   Thus, stripping all "\r" normalizes string and returns it to canonical form,
+   so printf() will produce correct end-of-line sequences.
+
+   ___strip_crs() serves for this purpose: it removes all the occurrences of
+   "\r" in-place and returns new length of string.  */
+static int ___strip_crs(char *str) {
+  int in = 0; // Input character index.
+  int out = 0; // Output character index.
+  for (;;) {
+    if (str[in] != '\r') {
+      str[out] = str[in];
+      ++out;
+    }; // if
+    if (str[in] == 0) {
+      break;
+    }; // if
+    ++in;
+  }; // forever
+  return out - 1;
 } // func __strip_crs
 
+static char const *___catgets(kmp_i18n_id_t id) {
 
-static
-char const *
-___catgets(
-    kmp_i18n_id_t  id
-) {
-
-    char *    result = NULL;
-    PVOID     addr   = NULL;
-    wchar_t * wmsg   = NULL;
-    DWORD     wlen   = 0;
-    char *    msg    = NULL;
-    int       len    = 0;
-    int       rc;
-
-    KMP_DEBUG_ASSERT( cat != KMP_I18N_NULLCAT );
-    wlen =    // wlen does *not* include terminating null.
-        FormatMessageW(
-            FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE |
-                FORMAT_MESSAGE_IGNORE_INSERTS,
-            cat,
-            id,
-            0,             // LangId
-            (LPWSTR) & addr,
-            0,             // Size in elements, not in bytes.
-            NULL
-        );
-    if ( wlen <= 0 ) {
-        goto end;
-    }; // if
-    wmsg = (wchar_t *) addr;  // Warning: wmsg may be not nul-terminated!
-
-    // Calculate length of multibyte message.
-    len =     // Since wlen does not include terminating null, len does not include it also.
-        WideCharToMultiByte(
-            code_page,
-            0,                // Flags.
-            wmsg, wlen,       // Wide buffer and size.
-            NULL, 0,          // Buffer and size.
-            NULL, NULL        // Default char and used default char.
-        );
-    if ( len <= 0 ) {
-        goto end;
-    }; // if
-
-    // Allocate memory.
-    msg = (char *) KMP_INTERNAL_MALLOC( len + 1 );
-
-    // Convert wide message to multibyte one.
-    rc =
-        WideCharToMultiByte(
-            code_page,
-            0,                // Flags.
-            wmsg, wlen,       // Wide buffer and size.
-            msg, len,         // Buffer and size.
-            NULL, NULL        // Default char and used default char.
-        );
-    if ( rc <= 0 || rc > len ) {
-        goto end;
-    }; // if
-    KMP_DEBUG_ASSERT( rc == len );
-    len = rc;
-    msg[ len ] = 0;           // Put terminating null to the end.
-
-    // Stripping all "\r" before stripping last end-of-line simplifies the task.
-    len = ___strip_crs( msg );
-
-    // Every message in catalog is terminated with "\n". Strip it.
-    if ( len >= 1 && msg[ len - 1 ] == '\n' ) {
-        -- len;
-        msg[ len ] = 0;
-    }; // if
-
-    // Everything looks ok.
-    result = msg;
-    msg    = NULL;
-
-    end:
+  char *result = NULL;
+  PVOID addr = NULL;
+  wchar_t *wmsg = NULL;
+  DWORD wlen = 0;
+  char *msg = NULL;
+  int len = 0;
+  int rc;
+
+  KMP_DEBUG_ASSERT(cat != KMP_I18N_NULLCAT);
+  wlen = // wlen does *not* include terminating null.
+      FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                         FORMAT_MESSAGE_FROM_HMODULE |
+                         FORMAT_MESSAGE_IGNORE_INSERTS,
+                     cat, id,
+                     0, // LangId
+                     (LPWSTR)&addr,
+                     0, // Size in elements, not in bytes.
+                     NULL);
+  if (wlen <= 0) {
+    goto end;
+  }; // if
+  wmsg = (wchar_t *)addr; // Warning: wmsg may be not nul-terminated!
+
+  // Calculate length of multibyte message.
+  // Since wlen does not include terminating null, len does not include it also.
+  len = WideCharToMultiByte(code_page,
+                            0, // Flags.
+                            wmsg, wlen, // Wide buffer and size.
+                            NULL, 0, // Buffer and size.
+                            NULL, NULL // Default char and used default char.
+                            );
+  if (len <= 0) {
+    goto end;
+  }; // if
+
+  // Allocate memory.
+  msg = (char *)KMP_INTERNAL_MALLOC(len + 1);
+
+  // Convert wide message to multibyte one.
+  rc = WideCharToMultiByte(code_page,
+                           0, // Flags.
+                           wmsg, wlen, // Wide buffer and size.
+                           msg, len, // Buffer and size.
+                           NULL, NULL // Default char and used default char.
+                           );
+  if (rc <= 0 || rc > len) {
+    goto end;
+  }; // if
+  KMP_DEBUG_ASSERT(rc == len);
+  len = rc;
+  msg[len] = 0; // Put terminating null to the end.
+
+  // Stripping all "\r" before stripping last end-of-line simplifies the task.
+  len = ___strip_crs(msg);
+
+  // Every message in catalog is terminated with "\n". Strip it.
+  if (len >= 1 && msg[len - 1] == '\n') {
+    --len;
+    msg[len] = 0;
+  }; // if
+
+  // Everything looks ok.
+  result = msg;
+  msg = NULL;
+
+end:
+
+  if (msg != NULL) {
+    KMP_INTERNAL_FREE(msg);
+  }; // if
+  if (wmsg != NULL) {
+    LocalFree(wmsg);
+  }; // if
 
-    if ( msg != NULL ) {
-        KMP_INTERNAL_FREE( msg );
-    }; // if
-    if ( wmsg != NULL ) {
-        LocalFree( wmsg );
-    }; // if
-
-    return result;
+  return result;
 
 } // ___catgets
 
+char const *__kmp_i18n_catgets(kmp_i18n_id_t id) {
 
-char const *
-__kmp_i18n_catgets(
-    kmp_i18n_id_t  id
-) {
-
-    int section = get_section( id );
-    int number  = get_number( id );
-    char const * message = NULL;
-
-    if ( 1 <= section && section <= __kmp_i18n_default_table.size ) {
-        if ( 1 <= number && number <= __kmp_i18n_default_table.sect[ section ].size ) {
-            if ( status == KMP_I18N_CLOSED ) {
-                __kmp_i18n_catopen();
-            }; // if
-            if ( cat != KMP_I18N_NULLCAT ) {
-                if ( table.size == 0 ) {
-                    table.sect = (kmp_i18n_section_t *)
-                        KMP_INTERNAL_CALLOC(
-                            ( __kmp_i18n_default_table.size + 2 ),
-                            sizeof( kmp_i18n_section_t )
-                        );
-                    table.size = __kmp_i18n_default_table.size;
-                }; // if
-                if ( table.sect[ section ].size == 0 ) {
-                    table.sect[ section ].str = (const char **)
-                        KMP_INTERNAL_CALLOC(
-                            __kmp_i18n_default_table.sect[ section ].size + 2,
-                            sizeof( char const * )
-                        );
-                    table.sect[ section ].size = __kmp_i18n_default_table.sect[ section ].size;
-                }; // if
-                if ( table.sect[ section ].str[ number ] == NULL ) {
-                    table.sect[ section ].str[ number ] = ___catgets( id );
-                }; // if
-                message = table.sect[ section ].str[ number ];
-            }; // if
-            if ( message == NULL ) {
-                // Catalog is not opened or message is not found, return default message.
-                message = __kmp_i18n_default_table.sect[ section ].str[ number ];
-            }; // if
-        }; // if
-    }; // if
-    if ( message == NULL ) {
-        message = no_message_available;
-    }; // if
-    return message;
+  int section = get_section(id);
+  int number = get_number(id);
+  char const *message = NULL;
+
+  if (1 <= section && section <= __kmp_i18n_default_table.size) {
+    if (1 <= number && number <= __kmp_i18n_default_table.sect[section].size) {
+      if (status == KMP_I18N_CLOSED) {
+        __kmp_i18n_catopen();
+      }; // if
+      if (cat != KMP_I18N_NULLCAT) {
+        if (table.size == 0) {
+          table.sect = (kmp_i18n_section_t *)KMP_INTERNAL_CALLOC(
+              (__kmp_i18n_default_table.size + 2), sizeof(kmp_i18n_section_t));
+          table.size = __kmp_i18n_default_table.size;
+        }; // if
+        if (table.sect[section].size == 0) {
+          table.sect[section].str = (const char **)KMP_INTERNAL_CALLOC(
+              __kmp_i18n_default_table.sect[section].size + 2,
+              sizeof(char const *));
+          table.sect[section].size =
+              __kmp_i18n_default_table.sect[section].size;
+        }; // if
+        if (table.sect[section].str[number] == NULL) {
+          table.sect[section].str[number] = ___catgets(id);
+        }; // if
+        message = table.sect[section].str[number];
+      }; // if
+      if (message == NULL) {
+        // Catalog is not opened or message is not found, return default
+        // message.
+        message = __kmp_i18n_default_table.sect[section].str[number];
+      }; // if
+    }; // if
+  }; // if
+  if (message == NULL) {
+    message = no_message_available;
+  }; // if
+  return message;
 
 } // func __kmp_i18n_catgets
 
-
 #endif // KMP_OS_WINDOWS
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 
 #ifndef KMP_I18N_OK
-    #error I18n support is not implemented for this OS.
+#error I18n support is not implemented for this OS.
 #endif // KMP_I18N_OK
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+
+void __kmp_i18n_dump_catalog(kmp_str_buf_t *buffer) {
 
-void
-__kmp_i18n_dump_catalog(
-    kmp_str_buf_t * buffer
-) {
-
-    struct kmp_i18n_id_range_t {
-        kmp_i18n_id_t  first;
-        kmp_i18n_id_t  last;
-    }; // struct kmp_i18n_id_range_t
-
-    static struct kmp_i18n_id_range_t ranges[] = {
-        { kmp_i18n_prp_first, kmp_i18n_prp_last },
-        { kmp_i18n_str_first, kmp_i18n_str_last },
-        { kmp_i18n_fmt_first, kmp_i18n_fmt_last },
-        { kmp_i18n_msg_first, kmp_i18n_msg_last },
-        { kmp_i18n_hnt_first, kmp_i18n_hnt_last }
-    }; // ranges
-
-    int           num_of_ranges = sizeof( ranges ) / sizeof( struct kmp_i18n_id_range_t );
-    int           range;
-    kmp_i18n_id_t id;
-
-    for ( range = 0; range < num_of_ranges; ++ range ) {
-        __kmp_str_buf_print( buffer, "*** Set #%d ***\n", range + 1 );
-        for ( id = (kmp_i18n_id_t)( ranges[ range ].first + 1 );
-              id < ranges[ range ].last;
-              id = (kmp_i18n_id_t)( id + 1 ) ) {
-             __kmp_str_buf_print( buffer, "%d: <<%s>>\n", id, __kmp_i18n_catgets( id ) );
-        }; // for id
-    }; // for range
+  struct kmp_i18n_id_range_t {
+    kmp_i18n_id_t first;
+    kmp_i18n_id_t last;
+  }; // struct kmp_i18n_id_range_t
+
+  static struct kmp_i18n_id_range_t ranges[] = {
+      {kmp_i18n_prp_first, kmp_i18n_prp_last},
+      {kmp_i18n_str_first, kmp_i18n_str_last},
+      {kmp_i18n_fmt_first, kmp_i18n_fmt_last},
+      {kmp_i18n_msg_first, kmp_i18n_msg_last},
+      {kmp_i18n_hnt_first, kmp_i18n_hnt_last}}; // ranges
+
+  int num_of_ranges = sizeof(ranges) / sizeof(struct kmp_i18n_id_range_t);
+  int range;
+  kmp_i18n_id_t id;
+
+  for (range = 0; range < num_of_ranges; ++range) {
+    __kmp_str_buf_print(buffer, "*** Set #%d ***\n", range + 1);
+    for (id = (kmp_i18n_id_t)(ranges[range].first + 1); id < ranges[range].last;
+         id = (kmp_i18n_id_t)(id + 1)) {
+      __kmp_str_buf_print(buffer, "%d: <<%s>>\n", id, __kmp_i18n_catgets(id));
+    }; // for id
+  }; // for range
 
-    __kmp_printf( "%s", buffer->str );
+  __kmp_printf("%s", buffer->str);
 
 } // __kmp_i18n_dump_catalog
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+kmp_msg_t __kmp_msg_format(unsigned id_arg, ...) {
+
+  kmp_msg_t msg;
+  va_list args;
+  kmp_str_buf_t buffer;
+  __kmp_str_buf_init(&buffer);
+
+  va_start(args, id_arg);
+
+  // We use unsigned for the ID argument and explicitly cast it here to the
+  // right enumerator because variadic functions are not compatible with
+  // default promotions.
+  kmp_i18n_id_t id = (kmp_i18n_id_t)id_arg;
 
-kmp_msg_t
-__kmp_msg_format(
-    unsigned id_arg,
-    ...
-) {
-
-    kmp_msg_t      msg;
-    va_list        args;
-    kmp_str_buf_t  buffer;
-    __kmp_str_buf_init( & buffer );
-
-    va_start( args, id_arg );
-
-    // We use unsigned for the ID argument and explicitly cast it here to the
-    // right enumerator because variadic functions are not compatible with
-    // default promotions.
-    kmp_i18n_id_t id = (kmp_i18n_id_t)id_arg;
-
-    #if KMP_OS_UNIX
-        // On Linux* OS and OS X*, printf() family functions process parameter numbers, for example:
-        // "%2$s %1$s".
-        __kmp_str_buf_vprint( & buffer, __kmp_i18n_catgets( id ), args );
-    #elif KMP_OS_WINDOWS
-        // On Winodws, printf() family functions does not recognize GNU style parameter numbers,
-        // so we have to use FormatMessage() instead. It recognizes parameter numbers, e. g.:
-        // "%2!s! "%1!s!".
-        {
-            LPTSTR str = NULL;
-            int    len;
-            FormatMessage(
-                FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
-                __kmp_i18n_catgets( id ),
-                0, 0,
-                (LPTSTR)( & str ),
-                0,
-                & args
-            );
-            len = ___strip_crs( str );
-            __kmp_str_buf_cat( & buffer, str, len );
-            LocalFree( str );
-        }
-    #else
-        #error
-    #endif
-    va_end( args );
-    __kmp_str_buf_detach( & buffer );
-
-    msg.type = (kmp_msg_type_t)( id >> 16 );
-    msg.num  = id & 0xFFFF;
-    msg.str  = buffer.str;
-    msg.len  = buffer.used;
+#if KMP_OS_UNIX
+  // On Linux* OS and OS X*, printf() family functions process parameter
+  // numbers, for example:  "%2$s %1$s".
+  __kmp_str_buf_vprint(&buffer, __kmp_i18n_catgets(id), args);
+#elif KMP_OS_WINDOWS
+  // On Winodws, printf() family functions does not recognize GNU style
+  // parameter numbers, so we have to use FormatMessage() instead. It recognizes
+  // parameter numbers, e. g.:  "%2!s! "%1!s!".
+  {
+    LPTSTR str = NULL;
+    int len;
+    FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+                  __kmp_i18n_catgets(id), 0, 0, (LPTSTR)(&str), 0, &args);
+    len = ___strip_crs(str);
+    __kmp_str_buf_cat(&buffer, str, len);
+    LocalFree(str);
+  }
+#else
+#error
+#endif
+  va_end(args);
+  __kmp_str_buf_detach(&buffer);
+
+  msg.type = (kmp_msg_type_t)(id >> 16);
+  msg.num = id & 0xFFFF;
+  msg.str = buffer.str;
+  msg.len = buffer.used;
 
-    return msg;
+  return msg;
 
 } // __kmp_msg_format
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+static char *sys_error(int err) {
 
-static
-char *
-sys_error(
-    int err
-) {
-
-    char * message = NULL;
-
-    #if KMP_OS_WINDOWS
-
-        LPVOID  buffer = NULL;
-        int     len;
-        DWORD   rc;
-        rc =
-            FormatMessage(
-                FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
-                NULL,
-                err,
-                MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language.
-                (LPTSTR) & buffer,
-                0,
-                NULL
-            );
-        if ( rc > 0 ) {
-            // Message formatted. Copy it (so we can free it later with normal free().
-            message = __kmp_str_format( "%s", (char *) buffer );
-            len = ___strip_crs( message ); // Delete carriage returns if any.
-            // Strip trailing newlines.
-            while ( len > 0 && message[ len - 1 ] == '\n' ) {
-                -- len;
-            }; // while
-            message[ len ] = 0;
-        } else {
-            // FormatMessage() failed to format system error message. GetLastError() would give us
-            // error code, which we would convert to message... this it dangerous recursion, which
-            // cannot clarify original error, so we will not even start it.
-        }; // if
-        if ( buffer != NULL ) {
-            LocalFree( buffer );
-        }; // if
+  char *message = NULL;
 
-    #else // Non-Windows* OS: Linux* OS or OS X*
+#if KMP_OS_WINDOWS
 
-        /*
-            There are 2 incompatible versions of strerror_r:
+  LPVOID buffer = NULL;
+  int len;
+  DWORD rc;
+  rc = FormatMessage(
+      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
+      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language.
+      (LPTSTR)&buffer, 0, NULL);
+  if (rc > 0) {
+    // Message formatted. Copy it (so we can free it later with normal free().
+    message = __kmp_str_format("%s", (char *)buffer);
+    len = ___strip_crs(message); // Delete carriage returns if any.
+    // Strip trailing newlines.
+    while (len > 0 && message[len - 1] == '\n') {
+      --len;
+    }; // while
+    message[len] = 0;
+  } else {
+    // FormatMessage() failed to format system error message. GetLastError()
+    // would give us error code, which we would convert to message... this it
+    // dangerous recursion, which cannot clarify original error, so we will not
+    // even start it.
+  }; // if
+  if (buffer != NULL) {
+    LocalFree(buffer);
+  }; // if
 
-                char * strerror_r( int, char *, size_t );  // GNU version
-                int    strerror_r( int, char *, size_t );  // XSI version
-        */
-
-        #if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || \
-            (defined(__BIONIC__) && defined(_GNU_SOURCE) && \
-             __ANDROID_API__ >= __ANDROID_API_M__)
-
-            // GNU version of strerror_r.
-
-            char   buffer[ 2048 ];
-            char * const err_msg = strerror_r( err, buffer, sizeof( buffer ) );
-                // Do not eliminate this assignment to temporary variable, otherwise compiler would
-                // not issue warning if strerror_r() returns `int' instead of expected `char *'.
-            message = __kmp_str_format( "%s", err_msg );
-
-        #else // OS X*, FreeBSD* etc.
-
-            // XSI version of strerror_r.
-
-            int    size   = 2048;
-            char * buffer = (char *) KMP_INTERNAL_MALLOC( size );
-            int    rc;
-            if (buffer == NULL) {
-                KMP_FATAL(MemoryAllocFailed);
-            }
-            rc = strerror_r( err, buffer, size );
-            if ( rc == -1 ) {
-                rc = errno;            // XSI version sets errno.
-            }; // if
-            while ( rc == ERANGE ) {   // ERANGE means the buffer is too small.
-                KMP_INTERNAL_FREE( buffer );
-                size *= 2;
-                buffer = (char *) KMP_INTERNAL_MALLOC( size );
-                if (buffer == NULL) {
-                    KMP_FATAL(MemoryAllocFailed);
-                }
-                rc = strerror_r( err, buffer, size );
-                if ( rc == -1 ) {
-                    rc = errno;        // XSI version sets errno.
-                }; // if
-            }; // while
-            if ( rc == 0 ) {
-                message = buffer;
-            } else {
-                // Buffer is unused. Free it.
-                KMP_INTERNAL_FREE( buffer );
-            }; // if
-
-        #endif
-
-    #endif /* KMP_OS_WINDOWS */
-
-    if ( message == NULL ) {
-        // TODO: I18n this message.
-        message = __kmp_str_format( "%s", "(No system error message available)" );
-    }; // if
-    return message;
+#else // Non-Windows* OS: Linux* OS or OS X*
+
+/* There are 2 incompatible versions of strerror_r:
 
+   char * strerror_r( int, char *, size_t );  // GNU version
+   int    strerror_r( int, char *, size_t );  // XSI version
+*/
+
+#if (defined(__GLIBC__) && defined(_GNU_SOURCE)) ||                            \
+    (defined(__BIONIC__) && defined(_GNU_SOURCE) &&                            \
+     __ANDROID_API__ >= __ANDROID_API_M__)
+  // GNU version of strerror_r.
+
+  char buffer[2048];
+  char *const err_msg = strerror_r(err, buffer, sizeof(buffer));
+  // Do not eliminate this assignment to temporary variable, otherwise compiler
+  // would not issue warning if strerror_r() returns `int' instead of expected
+  // `char *'.
+  message = __kmp_str_format("%s", err_msg);
+
+#else // OS X*, FreeBSD* etc.
+  // XSI version of strerror_r.
+  int size = 2048;
+  char *buffer = (char *)KMP_INTERNAL_MALLOC(size);
+  int rc;
+  if (buffer == NULL) {
+    KMP_FATAL(MemoryAllocFailed);
+  }
+  rc = strerror_r(err, buffer, size);
+  if (rc == -1) {
+    rc = errno; // XSI version sets errno.
+  }; // if
+  while (rc == ERANGE) { // ERANGE means the buffer is too small.
+    KMP_INTERNAL_FREE(buffer);
+    size *= 2;
+    buffer = (char *)KMP_INTERNAL_MALLOC(size);
+    if (buffer == NULL) {
+      KMP_FATAL(MemoryAllocFailed);
+    }
+    rc = strerror_r(err, buffer, size);
+    if (rc == -1) {
+      rc = errno; // XSI version sets errno.
+    }; // if
+  }; // while
+  if (rc == 0) {
+    message = buffer;
+  } else { // Buffer is unused. Free it.
+    KMP_INTERNAL_FREE(buffer);
+  }; // if
+
+#endif
+
+#endif /* KMP_OS_WINDOWS */
+
+  if (message == NULL) {
+    // TODO: I18n this message.
+    message = __kmp_str_format("%s", "(No system error message available)");
+  }; // if
+  return message;
 } // sys_error
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+kmp_msg_t __kmp_msg_error_code(int code) {
 
-kmp_msg_t
-__kmp_msg_error_code(
-    int  code
-) {
-
-    kmp_msg_t      msg;
-    msg.type = kmp_mt_syserr;
-    msg.num  = code;
-    msg.str  = sys_error( code );
-    msg.len  = KMP_STRLEN( msg.str );
-    return msg;
+  kmp_msg_t msg;
+  msg.type = kmp_mt_syserr;
+  msg.num = code;
+  msg.str = sys_error(code);
+  msg.len = KMP_STRLEN(msg.str);
+  return msg;
 
 } // __kmp_msg_error_code
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+kmp_msg_t __kmp_msg_error_mesg(char const *mesg) {
 
-kmp_msg_t
-__kmp_msg_error_mesg(
-    char const * mesg
-) {
-
-    kmp_msg_t      msg;
-    msg.type = kmp_mt_syserr;
-    msg.num  = 0;
-    msg.str  = __kmp_str_format( "%s", mesg );
-    msg.len  = KMP_STRLEN( msg.str );
-    return msg;
+  kmp_msg_t msg;
+  msg.type = kmp_mt_syserr;
+  msg.num = 0;
+  msg.str = __kmp_str_format("%s", mesg);
+  msg.len = KMP_STRLEN(msg.str);
+  return msg;
 
 } // __kmp_msg_error_mesg
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void __kmp_msg(kmp_msg_severity_t severity, kmp_msg_t message, ...) {
 
-void
-__kmp_msg(
-    kmp_msg_severity_t  severity,
-    kmp_msg_t           message,
-    ...
-) {
-
-    va_list        args;
-    kmp_i18n_id_t  format;      // format identifier
-    kmp_msg_t      fmsg;        // formatted message
-    kmp_str_buf_t  buffer;
-
-    if ( severity != kmp_ms_fatal && __kmp_generate_warnings == kmp_warnings_off )
-        return; // no reason to form a string in order to not print it
-
-    __kmp_str_buf_init( & buffer );
-
-    // Format the primary message.
-    switch ( severity ) {
-        case kmp_ms_inform : {
-            format = kmp_i18n_fmt_Info;
-        } break;
-        case kmp_ms_warning : {
-            format = kmp_i18n_fmt_Warning;
-        } break;
-        case kmp_ms_fatal : {
-            format = kmp_i18n_fmt_Fatal;
-        } break;
-        default : {
-            KMP_DEBUG_ASSERT( 0 );
-        };
+  va_list args;
+  kmp_i18n_id_t format; // format identifier
+  kmp_msg_t fmsg; // formatted message
+  kmp_str_buf_t buffer;
+
+  if (severity != kmp_ms_fatal && __kmp_generate_warnings == kmp_warnings_off)
+    return; // no reason to form a string in order to not print it
+
+  __kmp_str_buf_init(&buffer);
+
+  // Format the primary message.
+  switch (severity) {
+  case kmp_ms_inform: {
+    format = kmp_i18n_fmt_Info;
+  } break;
+  case kmp_ms_warning: {
+    format = kmp_i18n_fmt_Warning;
+  } break;
+  case kmp_ms_fatal: {
+    format = kmp_i18n_fmt_Fatal;
+  } break;
+  default: { KMP_DEBUG_ASSERT(0); };
+  }; // switch
+  fmsg = __kmp_msg_format(format, message.num, message.str);
+  __kmp_str_free(&message.str);
+  __kmp_str_buf_cat(&buffer, fmsg.str, fmsg.len);
+  __kmp_str_free(&fmsg.str);
+
+  // Format other messages.
+  va_start(args, message);
+  for (;;) {
+    message = va_arg(args, kmp_msg_t);
+    if (message.type == kmp_mt_dummy && message.str == NULL) {
+      break;
+    }; // if
+    if (message.type == kmp_mt_dummy && message.str == __kmp_msg_empty.str) {
+      continue;
+    }; // if
+    switch (message.type) {
+    case kmp_mt_hint: {
+      format = kmp_i18n_fmt_Hint;
+    } break;
+    case kmp_mt_syserr: {
+      format = kmp_i18n_fmt_SysErr;
+    } break;
+    default: { KMP_DEBUG_ASSERT(0); };
     }; // switch
-    fmsg = __kmp_msg_format( format, message.num, message.str );
+    fmsg = __kmp_msg_format(format, message.num, message.str);
     __kmp_str_free(&message.str);
-    __kmp_str_buf_cat( & buffer, fmsg.str, fmsg.len );
+    __kmp_str_buf_cat(&buffer, fmsg.str, fmsg.len);
     __kmp_str_free(&fmsg.str);
+  }; // forever
+  va_end(args);
 
-    // Format other messages.
-    va_start( args, message );
-    for ( ; ; ) {
-        message = va_arg( args, kmp_msg_t );
-        if ( message.type == kmp_mt_dummy && message.str == NULL ) {
-            break;
-        }; // if
-        if ( message.type == kmp_mt_dummy && message.str == __kmp_msg_empty.str ) {
-            continue;
-        }; // if
-        switch ( message.type ) {
-            case kmp_mt_hint : {
-                format = kmp_i18n_fmt_Hint;
-            } break;
-            case kmp_mt_syserr : {
-                format = kmp_i18n_fmt_SysErr;
-            } break;
-            default : {
-                KMP_DEBUG_ASSERT( 0 );
-            };
-        }; // switch
-        fmsg = __kmp_msg_format( format, message.num, message.str );
-        __kmp_str_free(&message.str);
-        __kmp_str_buf_cat( & buffer, fmsg.str, fmsg.len );
-        __kmp_str_free(&fmsg.str);
-    }; // forever
-    va_end( args );
+  // Print formatted messages.
+  // This lock prevents multiple fatal errors on the same problem.
+  // __kmp_acquire_bootstrap_lock( & lock );    // GEH - This lock causing tests
+  // to hang on OS X*.
+  __kmp_printf("%s", buffer.str);
+  __kmp_str_buf_free(&buffer);
 
-    // Print formatted messages.
-    // This lock prevents multiple fatal errors on the same problem.
-    // __kmp_acquire_bootstrap_lock( & lock );    // GEH - This lock causing tests to hang on OS X*.
-    __kmp_printf( "%s", buffer.str );
-    __kmp_str_buf_free( & buffer );
-
-    if ( severity == kmp_ms_fatal ) {
-        #if KMP_OS_WINDOWS
-        __kmp_thread_sleep( 500 );   /* Delay to give message a chance to appear before reaping */
-        #endif
-        __kmp_abort_process();
-    }; // if
+  if (severity == kmp_ms_fatal) {
+#if KMP_OS_WINDOWS
+    __kmp_thread_sleep(
+        500); /* Delay to give message a chance to appear before reaping */
+#endif
+    __kmp_abort_process();
+  }; // if
 
-    // __kmp_release_bootstrap_lock( & lock );  // GEH - this lock causing tests to hang on OS X*.
+  // __kmp_release_bootstrap_lock( & lock );  // GEH - this lock causing tests
+  // to hang on OS X*.
 
 } // __kmp_msg
 
-// -------------------------------------------------------------------------------------------------
-
 // end of file //

Modified: openmp/trunk/runtime/src/kmp_i18n.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_i18n.h?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_i18n.h (original)
+++ openmp/trunk/runtime/src/kmp_i18n.h Fri May 12 13:01:32 2017
@@ -19,173 +19,164 @@
 #include "kmp_str.h"
 
 #ifdef __cplusplus
-    extern "C" {
+extern "C" {
 #endif // __cplusplus
 
-/*
-    kmp_i18n_id.inc defines kmp_i18n_id_t type. It is an enumeration with identifiers of all the
-    messages in the catalog. There is one special identifier: kmp_i18n_null, which denotes absence
-    of message.
-*/
+/* kmp_i18n_id.inc defines kmp_i18n_id_t type. It is an enumeration with
+   identifiers of all the messages in the catalog. There is one special
+   identifier: kmp_i18n_null, which denotes absence of message. */
 #include "kmp_i18n_id.inc" // Generated file. Do not edit it manually.
 
-/*
-    Low-level functions handling message catalog. __kmp_i18n_open() opens message catalog,
-    __kmp_i18n_closes() it. Explicit opening is not required: if message catalog is not yet open,
-    __kmp_i18n_catgets() will open it implicitly. However, catalog should be explicitly closed,
-    otherwise resources (mamory, handles) may leak.
+/* Low-level functions handling message catalog. __kmp_i18n_open() opens message
+   catalog, __kmp_i18n_closes() it. Explicit opening is not required: if message
+   catalog is not yet open, __kmp_i18n_catgets() will open it implicitly.
+   However, catalog should be explicitly closed, otherwise resources (mamory,
+   handles) may leak.
 
-    __kmp_i18n_catgets() returns read-only string. It should not be freed.
+   __kmp_i18n_catgets() returns read-only string. It should not be freed.
 
-    KMP_I18N_STR macro simplifies acces to strings in message catalog a bit. Following two lines are
-    equivalent:
+   KMP_I18N_STR macro simplifies acces to strings in message catalog a bit.
+   Following two lines are equivalent:
 
-        __kmp_i18n_catgets( kmp_i18n_str_Warning )
-        KMP_I18N_STR( Warning )
+   __kmp_i18n_catgets( kmp_i18n_str_Warning )
+   KMP_I18N_STR( Warning )
 */
 
-void            __kmp_i18n_catopen();
-void            __kmp_i18n_catclose();
-char const *    __kmp_i18n_catgets( kmp_i18n_id_t id );
-
-#define KMP_I18N_STR( id )    __kmp_i18n_catgets( kmp_i18n_str_ ## id )
-
-
-/*
-    ------------------------------------------------------------------------------------------------
-
-    High-level interface for printing strings targeted to the user.
-
-    All the strings are divided into 3 types:
-
-        * messages,
-        * hints,
-        * system errors.
-
-    There are 3 kind of message severities:
-
-        * informational messages,
-        * warnings (non-fatal errors),
-        * fatal errors.
-
-    For example:
-
-        OMP: Warning #2: Cannot open message catalog "libguide.cat":   (1)
-        OMP: System error #2: No such file or directory                (2)
-        OMP: Hint: Please check NLSPATH environment variable.          (3)
-        OMP: Info #3: Default messages will be used.                   (4)
-
-    where
-
-        (1) is a message of warning severity,
-        (2) is a system error caused the previous warning,
-        (3) is a hint for the user how to fix the problem,
-        (4) is a message of informational severity.
+void __kmp_i18n_catopen();
+void __kmp_i18n_catclose();
+char const *__kmp_i18n_catgets(kmp_i18n_id_t id);
+
+#define KMP_I18N_STR(id) __kmp_i18n_catgets(kmp_i18n_str_##id)
+
+/* High-level interface for printing strings targeted to the user.
+
+   All the strings are divided into 3 types:
+   * messages,
+   * hints,
+   * system errors.
+
+   There are 3 kind of message severities:
+   * informational messages,
+   * warnings (non-fatal errors),
+   * fatal errors.
+
+   For example:
+     OMP: Warning #2: Cannot open message catalog "libguide.cat":   (1)
+     OMP: System error #2: No such file or directory                (2)
+     OMP: Hint: Please check NLSPATH environment variable.          (3)
+     OMP: Info #3: Default messages will be used.                   (4)
+
+   where
+   (1) is a message of warning severity,
+   (2) is a system error caused the previous warning,
+   (3) is a hint for the user how to fix the problem,
+   (4) is a message of informational severity.
 
    Usage in complex cases (message is accompanied with hints and system errors):
 
-       int error = errno;   // We need save errno immediately, because it may be changed.
-       __kmp_msg(
-           kmp_ms_warning,                            // Severity
-           KMP_MSG( CantOpenMessageCatalog, name ),   // Primary message
-           KMP_ERR( error ),                          // System error
-           KMP_HNT( CheckNLSPATH ),                   // Hint
-           __kmp_msg_null                             // Variadic argument list finisher
-       );
-
-    Usage in simple cases (just a message, no system errors or hints):
-
-        KMP_INFORM( WillUseDefaultMessages );
-        KMP_WARNING( CantOpenMessageCatalog, name );
-        KMP_FATAL( StackOverlap );
-        KMP_SYSFAIL( "pthread_create", status );
-        KMP_CHECK_SYSFAIL( "pthread_create", status );
-        KMP_CHECK_SYSFAIL_ERRNO( "gettimeofday", status );
-
-    ------------------------------------------------------------------------------------------------
+   int error = errno; // We need save errno immediately, because it may
+                      // be changed.
+   __kmp_msg(
+       kmp_ms_warning,                        // Severity
+       KMP_MSG( CantOpenMessageCatalog, name ), // Primary message
+       KMP_ERR( error ),                      // System error
+       KMP_HNT( CheckNLSPATH ),               // Hint
+       __kmp_msg_null                         // Variadic argument list finisher
+   );
+
+   Usage in simple cases (just a message, no system errors or hints):
+   KMP_INFORM( WillUseDefaultMessages );
+   KMP_WARNING( CantOpenMessageCatalog, name );
+   KMP_FATAL( StackOverlap );
+   KMP_SYSFAIL( "pthread_create", status );
+   KMP_CHECK_SYSFAIL( "pthread_create", status );
+   KMP_CHECK_SYSFAIL_ERRNO( "gettimeofday", status );
 */
 
 enum kmp_msg_type {
-    kmp_mt_dummy  =  0, // Special type for internal purposes.
-    kmp_mt_mesg   =  4, // Primary OpenMP message, could be information, warning, or fatal.
-    kmp_mt_hint   =  5, // Hint to the user.
-    kmp_mt_syserr = -1  // System error message.
+  kmp_mt_dummy = 0, // Special type for internal purposes.
+  kmp_mt_mesg =
+      4, // Primary OpenMP message, could be information, warning, or fatal.
+  kmp_mt_hint = 5, // Hint to the user.
+  kmp_mt_syserr = -1 // System error message.
 }; // enum kmp_msg_type
-typedef enum kmp_msg_type  kmp_msg_type_t;
+typedef enum kmp_msg_type kmp_msg_type_t;
 
 struct kmp_msg {
-    kmp_msg_type_t  type;
-    int             num;
-    char const *    str;
-    int             len;
+  kmp_msg_type_t type;
+  int num;
+  char const *str;
+  int len;
 }; // struct kmp_message
-typedef struct kmp_msg  kmp_msg_t;
+typedef struct kmp_msg kmp_msg_t;
 
 // Two special messages.
-extern kmp_msg_t __kmp_msg_empty;  // Can be used in place where message is required syntactically.
-extern kmp_msg_t __kmp_msg_null;   // Denotes the end of variadic list of arguments.
-
-// Helper functions. Creates messages either from message catalog or from system. Note: these
-// functions allocate memory. You should pass created messages to __kmp_msg() function, it will
-// print messages and destroy them.
-kmp_msg_t  __kmp_msg_format( unsigned id_arg, ... );
-kmp_msg_t  __kmp_msg_error_code( int code );
-kmp_msg_t  __kmp_msg_error_mesg( char const * mesg );
+extern kmp_msg_t __kmp_msg_empty; // Can be used in place where message is
+// required syntactically.
+extern kmp_msg_t
+    __kmp_msg_null; // Denotes the end of variadic list of arguments.
+
+// Helper functions. Creates messages either from message catalog or from
+// system. Note: these functions allocate memory. You should pass created
+// messages to __kmp_msg() function, it will print messages and destroy them.
+kmp_msg_t __kmp_msg_format(unsigned id_arg, ...);
+kmp_msg_t __kmp_msg_error_code(int code);
+kmp_msg_t __kmp_msg_error_mesg(char const *mesg);
 
 // Helper macros to make calls shorter.
-#define KMP_MSG( ...  )   __kmp_msg_format( kmp_i18n_msg_ ## __VA_ARGS__ )
-#define KMP_HNT( ...  )   __kmp_msg_format( kmp_i18n_hnt_ ## __VA_ARGS__ )
-#define KMP_SYSERRCODE( code )  __kmp_msg_error_code( code )
-#define KMP_SYSERRMESG( mesg )  __kmp_msg_error_mesg( mesg )
+#define KMP_MSG(...) __kmp_msg_format(kmp_i18n_msg_##__VA_ARGS__)
+#define KMP_HNT(...) __kmp_msg_format(kmp_i18n_hnt_##__VA_ARGS__)
+#define KMP_SYSERRCODE(code) __kmp_msg_error_code(code)
+#define KMP_SYSERRMESG(mesg) __kmp_msg_error_mesg(mesg)
 #define KMP_ERR KMP_SYSERRCODE
 
 // Message severity.
 enum kmp_msg_severity {
-    kmp_ms_inform,      // Just information for the user.
-    kmp_ms_warning,     // Non-fatal error, execution continues.
-    kmp_ms_fatal        // Fatal error, program aborts.
+  kmp_ms_inform, // Just information for the user.
+  kmp_ms_warning, // Non-fatal error, execution continues.
+  kmp_ms_fatal // Fatal error, program aborts.
 }; // enum kmp_msg_severity
-typedef enum kmp_msg_severity  kmp_msg_severity_t;
+typedef enum kmp_msg_severity kmp_msg_severity_t;
 
-// Primary function for printing messages for the user. The first message is mandatory. Any number
-// of system errors and hints may be specified. Argument list must be finished with __kmp_msg_null.
-void    __kmp_msg( kmp_msg_severity_t severity, kmp_msg_t message, ... );
+// Primary function for printing messages for the user. The first message is
+// mandatory. Any number of system errors and hints may be specified. Argument
+// list must be finished with __kmp_msg_null.
+void __kmp_msg(kmp_msg_severity_t severity, kmp_msg_t message, ...);
 
 // Helper macros to make calls shorter in simple cases.
-#define KMP_INFORM( ...  ) __kmp_msg( kmp_ms_inform,  KMP_MSG( __VA_ARGS__ ), __kmp_msg_null )
-#define KMP_WARNING( ... ) __kmp_msg( kmp_ms_warning, KMP_MSG( __VA_ARGS__ ), __kmp_msg_null )
-#define KMP_FATAL(   ... ) __kmp_msg( kmp_ms_fatal,   KMP_MSG( __VA_ARGS__ ), __kmp_msg_null )
-#define KMP_SYSFAIL( func, error )                                                                 \
-    __kmp_msg(                                                                                     \
-        kmp_ms_fatal,                                                                              \
-        KMP_MSG( FunctionError, func ),                                                            \
-        KMP_SYSERRCODE( error ),                                                                   \
-        __kmp_msg_null                                                                             \
-    )
+#define KMP_INFORM(...)                                                        \
+  __kmp_msg(kmp_ms_inform, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
+#define KMP_WARNING(...)                                                       \
+  __kmp_msg(kmp_ms_warning, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
+#define KMP_FATAL(...)                                                         \
+  __kmp_msg(kmp_ms_fatal, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
+#define KMP_SYSFAIL(func, error)                                               \
+  __kmp_msg(kmp_ms_fatal, KMP_MSG(FunctionError, func), KMP_SYSERRCODE(error), \
+            __kmp_msg_null)
 
 // Check error, if not zero, generate fatal error message.
-#define KMP_CHECK_SYSFAIL( func, error )                                                           \
-    {                                                                                              \
-        if ( error ) {                                                                             \
-            KMP_SYSFAIL( func, error );                                                            \
-        };                                                                                         \
-    }
+#define KMP_CHECK_SYSFAIL(func, error)                                         \
+  {                                                                            \
+    if (error) {                                                               \
+      KMP_SYSFAIL(func, error);                                                \
+    };                                                                         \
+  }
 
 // Check status, if not zero, generate fatal error message using errno.
-#define KMP_CHECK_SYSFAIL_ERRNO( func, status )                                                    \
-    {                                                                                              \
-        if ( status != 0 ) {                                                                       \
-            int error = errno;                                                                     \
-            KMP_SYSFAIL( func, error );                                                            \
-        };                                                                                         \
-    }
+#define KMP_CHECK_SYSFAIL_ERRNO(func, status)                                  \
+  {                                                                            \
+    if (status != 0) {                                                         \
+      int error = errno;                                                       \
+      KMP_SYSFAIL(func, error);                                                \
+    };                                                                         \
+  }
 
 #ifdef KMP_DEBUG
-    void __kmp_i18n_dump_catalog( kmp_str_buf_t * buffer );
+void __kmp_i18n_dump_catalog(kmp_str_buf_t *buffer);
 #endif // KMP_DEBUG
 
 #ifdef __cplusplus
-    }; // extern "C"
+}; // extern "C"
 #endif // __cplusplus
 
 #endif // KMP_I18N_H

Modified: openmp/trunk/runtime/src/kmp_import.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_import.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_import.cpp (original)
+++ openmp/trunk/runtime/src/kmp_import.cpp Fri May 12 13:01:32 2017
@@ -13,26 +13,20 @@
 //===----------------------------------------------------------------------===//
 
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Object generated from this source file is linked to Windows* OS DLL import library (libompmd.lib)
-    only! It is not a part of regular static or dynamic OpenMP RTL. Any code that just needs to go
-    in the libompmd.lib (but not in libompmt.lib and libompmd.dll) should be placed in this
-    file.
-    ------------------------------------------------------------------------------------------------
-*/
+/* Object generated from this source file is linked to Windows* OS DLL import
+   library (libompmd.lib) only! It is not a part of regular static or dynamic
+   OpenMP RTL. Any code that just needs to go in the libompmd.lib (but not in
+   libompmt.lib and libompmd.dll) should be placed in this file. */
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/*
-    These symbols are required for mutual exclusion with Microsoft OpenMP RTL (and compatibility
-    with MS Compiler).
-*/
+/*These symbols are required for mutual exclusion with Microsoft OpenMP RTL
+  (and compatibility with MS Compiler). */
 
 int _You_must_link_with_exactly_one_OpenMP_library = 1;
-int _You_must_link_with_Intel_OpenMP_library       = 1;
+int _You_must_link_with_Intel_OpenMP_library = 1;
 int _You_must_link_with_Microsoft_OpenMP_library = 1;
 
 #ifdef __cplusplus

Modified: openmp/trunk/runtime/src/kmp_io.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_io.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_io.cpp (original)
+++ openmp/trunk/runtime/src/kmp_io.cpp Fri May 12 13:01:32 2017
@@ -13,236 +13,218 @@
 //===----------------------------------------------------------------------===//
 
 
+#include <stdarg.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stddef.h>
-#include <stdarg.h>
 #include <string.h>
 #ifndef __ABSOFT_WIN
-# include <sys/types.h>
+#include <sys/types.h>
 #endif
 
-#include "kmp_os.h"
+#include "kmp.h" // KMP_GTID_DNE, __kmp_debug_buf, etc
+#include "kmp_io.h"
 #include "kmp_lock.h"
+#include "kmp_os.h"
 #include "kmp_str.h"
-#include "kmp_io.h"
-#include "kmp.h" // KMP_GTID_DNE, __kmp_debug_buf, etc
 
 #if KMP_OS_WINDOWS
-# pragma warning( push )
-# pragma warning( disable: 271 310 )
-# include <windows.h>
-# pragma warning( pop )
+#pragma warning(push)
+#pragma warning(disable : 271 310)
+#include <windows.h>
+#pragma warning(pop)
 #endif
 
 /* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
 
-kmp_bootstrap_lock_t __kmp_stdio_lock   = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_stdio_lock   ); /* Control stdio functions */
-kmp_bootstrap_lock_t __kmp_console_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_console_lock ); /* Control console initialization */
+kmp_bootstrap_lock_t __kmp_stdio_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
+    __kmp_stdio_lock); /* Control stdio functions */
+kmp_bootstrap_lock_t __kmp_console_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER(
+    __kmp_console_lock); /* Control console initialization */
 
 #if KMP_OS_WINDOWS
 
-    # ifdef KMP_DEBUG
-    /* __kmp_stdout is used only for dev build */
-    static HANDLE    __kmp_stdout = NULL;
-    # endif
-    static HANDLE        __kmp_stderr = NULL;
-    static int           __kmp_console_exists = FALSE;
-    static kmp_str_buf_t __kmp_console_buf;
-
-    static int
-    is_console( void )
-    {
-        char buffer[ 128 ];
-        DWORD rc  = 0;
-        DWORD err = 0;
-        // Try to get console title.
-        SetLastError( 0 );
-            // GetConsoleTitle does not reset last error in case of success or short buffer,
-            // so we need to clear it explicitly.
-        rc = GetConsoleTitle( buffer, sizeof( buffer ) );
-        if ( rc == 0 ) {
-            // rc == 0 means getting console title failed. Let us find out why.
-            err = GetLastError();
-            // err == 0 means buffer too short (we suppose console exists).
-            // In Window applications we usually have err == 6 (invalid handle).
-        }; // if
-        return rc > 0 || err == 0;
-    }
+#ifdef KMP_DEBUG
+/* __kmp_stdout is used only for dev build */
+static HANDLE __kmp_stdout = NULL;
+#endif
+static HANDLE __kmp_stderr = NULL;
+static int __kmp_console_exists = FALSE;
+static kmp_str_buf_t __kmp_console_buf;
+
+static int is_console(void) {
+  char buffer[128];
+  DWORD rc = 0;
+  DWORD err = 0;
+  // Try to get console title.
+  SetLastError(0);
+  // GetConsoleTitle does not reset last error in case of success or short
+  // buffer, so we need to clear it explicitly.
+  rc = GetConsoleTitle(buffer, sizeof(buffer));
+  if (rc == 0) {
+    // rc == 0 means getting console title failed. Let us find out why.
+    err = GetLastError();
+    // err == 0 means buffer too short (we suppose console exists).
+    // In Window applications we usually have err == 6 (invalid handle).
+  }; // if
+  return rc > 0 || err == 0;
+}
+
+void __kmp_close_console(void) {
+  /* wait until user presses return before closing window */
+  /* TODO only close if a window was opened */
+  if (__kmp_console_exists) {
+#ifdef KMP_DEBUG
+    /* standard out is used only in dev build */
+    __kmp_stdout = NULL;
+#endif
+    __kmp_stderr = NULL;
+    __kmp_str_buf_free(&__kmp_console_buf);
+    __kmp_console_exists = FALSE;
+  }
+}
+
+/* For windows, call this before stdout, stderr, or stdin are used.
+   It opens a console window and starts processing */
+static void __kmp_redirect_output(void) {
+  __kmp_acquire_bootstrap_lock(&__kmp_console_lock);
+
+  if (!__kmp_console_exists) {
+#ifdef KMP_DEBUG
+    /* standard out is used only in dev build */
+    HANDLE ho;
+#endif
+    HANDLE he;
+
+    __kmp_str_buf_init(&__kmp_console_buf);
+
+    AllocConsole();
+// We do not check the result of AllocConsole because
+//  1. the call is harmless
+//  2. it is not clear how to communicate failue
+//  3. we will detect failure later when we get handle(s)
+
+#ifdef KMP_DEBUG
+    ho = GetStdHandle(STD_OUTPUT_HANDLE);
+    if (ho == INVALID_HANDLE_VALUE || ho == NULL) {
+
+      DWORD err = GetLastError();
+      // TODO: output error somehow (maybe message box)
+      __kmp_stdout = NULL;
 
-    void
-    __kmp_close_console( void )
-    {
-        /* wait until user presses return before closing window */
-        /* TODO only close if a window was opened */
-        if( __kmp_console_exists ) {
-            #ifdef KMP_DEBUG
-            /* standard out is used only in dev build */
-            __kmp_stdout = NULL;
-            #endif
-            __kmp_stderr = NULL;
-            __kmp_str_buf_free( &__kmp_console_buf );
-            __kmp_console_exists = FALSE;
-        }
+    } else {
+
+      __kmp_stdout = ho; // temporary code, need new global for ho
     }
+#endif
+    he = GetStdHandle(STD_ERROR_HANDLE);
+    if (he == INVALID_HANDLE_VALUE || he == NULL) {
 
-    /* For windows, call this before stdout, stderr, or stdin are used.
-     * It opens a console window and starts processing */
-    static void
-    __kmp_redirect_output( void )
-    {
-        __kmp_acquire_bootstrap_lock( &__kmp_console_lock );
-
-        if( ! __kmp_console_exists ) {
-            #ifdef KMP_DEBUG
-            /* standard out is used only in dev build */
-            HANDLE ho;
-            #endif
-            HANDLE he;
-
-            __kmp_str_buf_init( &__kmp_console_buf );
-
-            AllocConsole();
-            // We do not check the result of AllocConsole because
-            //  1. the call is harmless
-            //  2. it is not clear how to communicate failue
-            //  3. we will detect failure later when we get handle(s)
-
-            #ifdef KMP_DEBUG
-                ho = GetStdHandle( STD_OUTPUT_HANDLE );
-                if ( ho == INVALID_HANDLE_VALUE || ho == NULL ) {
-
-                    DWORD  err = GetLastError();
-                    // TODO: output error somehow (maybe message box)
-                    __kmp_stdout = NULL;
-
-                } else {
-
-                    __kmp_stdout = ho; // temporary code, need new global for ho
-
-                }
-            #endif
-            he = GetStdHandle( STD_ERROR_HANDLE );
-            if ( he == INVALID_HANDLE_VALUE || he == NULL ) {
-
-                DWORD  err = GetLastError();
-                // TODO: output error somehow (maybe message box)
-                __kmp_stderr = NULL;
-
-            } else {
-
-                __kmp_stderr = he; // temporary code, need new global
-            }
-            __kmp_console_exists = TRUE;
-        }
-        __kmp_release_bootstrap_lock( &__kmp_console_lock );
+      DWORD err = GetLastError();
+      // TODO: output error somehow (maybe message box)
+      __kmp_stderr = NULL;
+
+    } else {
+
+      __kmp_stderr = he; // temporary code, need new global
     }
+    __kmp_console_exists = TRUE;
+  }
+  __kmp_release_bootstrap_lock(&__kmp_console_lock);
+}
 
 #else
-    #define       __kmp_stderr     (stderr)
+#define __kmp_stderr (stderr)
 #endif /* KMP_OS_WINDOWS */
 
-void
-__kmp_vprintf( enum kmp_io __kmp_io, char const * format, va_list ap )
-{
-    #if KMP_OS_WINDOWS
-        if( !__kmp_console_exists ) {
-            __kmp_redirect_output();
-        }
-            if( ! __kmp_stderr && __kmp_io == kmp_err ) {
-            return;
-        }
-        #ifdef KMP_DEBUG
-            if( ! __kmp_stdout && __kmp_io == kmp_out ) {
-                return;
-            }
-        #endif
-    #endif /* KMP_OS_WINDOWS */
-
-    if ( __kmp_debug_buf && __kmp_debug_buffer != NULL ) {
-
-        int dc = ( __kmp_debug_buf_atomic ?
-                   KMP_TEST_THEN_INC32( & __kmp_debug_count) : __kmp_debug_count++ )
-                   % __kmp_debug_buf_lines;
-        char *db = & __kmp_debug_buffer[ dc * __kmp_debug_buf_chars ];
-        int chars = 0;
-
-        #ifdef KMP_DEBUG_PIDS
-            chars = KMP_SNPRINTF( db, __kmp_debug_buf_chars, "pid=%d: ", (kmp_int32)getpid() );
-        #endif
-        chars += KMP_VSNPRINTF( db, __kmp_debug_buf_chars, format, ap );
-
-        if ( chars + 1 > __kmp_debug_buf_chars ) {
-            if ( chars + 1 > __kmp_debug_buf_warn_chars ) {
-                #if KMP_OS_WINDOWS
-                    DWORD count;
-                    __kmp_str_buf_print( &__kmp_console_buf,
-                        "OMP warning: Debugging buffer overflow; increase KMP_DEBUG_BUF_CHARS to %d\n",
-                        chars + 1 );
-                    WriteFile( __kmp_stderr, __kmp_console_buf.str, __kmp_console_buf.used, &count, NULL );
-                    __kmp_str_buf_clear( &__kmp_console_buf );
-                #else
-                    fprintf( __kmp_stderr,
-                         "OMP warning: Debugging buffer overflow; increase KMP_DEBUG_BUF_CHARS to %d\n",
-                         chars + 1 );
-                    fflush( __kmp_stderr );
-                #endif
-                __kmp_debug_buf_warn_chars = chars + 1;
-            }
-            /* terminate string if overflow occurred */
-            db[ __kmp_debug_buf_chars - 2 ] = '\n';
-            db[ __kmp_debug_buf_chars - 1 ] = '\0';
-        }
-    } else {
-        #if KMP_OS_WINDOWS
-            DWORD count;
-            #ifdef KMP_DEBUG_PIDS
-                __kmp_str_buf_print( &__kmp_console_buf, "pid=%d: ",
-                  (kmp_int32)getpid() );
-            #endif
-            __kmp_str_buf_vprint( &__kmp_console_buf, format, ap );
-            WriteFile(
-                __kmp_stderr,
-                __kmp_console_buf.str,
-                __kmp_console_buf.used,
-                &count,
-                NULL
-            );
-            __kmp_str_buf_clear( &__kmp_console_buf );
-        #else
-            #ifdef KMP_DEBUG_PIDS
-                fprintf( __kmp_stderr, "pid=%d: ", (kmp_int32)getpid() );
-            #endif
-            vfprintf( __kmp_stderr, format, ap );
-            fflush( __kmp_stderr );
-        #endif
+void __kmp_vprintf(enum kmp_io __kmp_io, char const *format, va_list ap) {
+#if KMP_OS_WINDOWS
+  if (!__kmp_console_exists) {
+    __kmp_redirect_output();
+  }
+  if (!__kmp_stderr && __kmp_io == kmp_err) {
+    return;
+  }
+#ifdef KMP_DEBUG
+  if (!__kmp_stdout && __kmp_io == kmp_out) {
+    return;
+  }
+#endif
+#endif /* KMP_OS_WINDOWS */
+
+  if (__kmp_debug_buf && __kmp_debug_buffer != NULL) {
+
+    int dc = (__kmp_debug_buf_atomic ? KMP_TEST_THEN_INC32(&__kmp_debug_count)
+                                     : __kmp_debug_count++) %
+             __kmp_debug_buf_lines;
+    char *db = &__kmp_debug_buffer[dc * __kmp_debug_buf_chars];
+    int chars = 0;
+
+#ifdef KMP_DEBUG_PIDS
+    chars = KMP_SNPRINTF(db, __kmp_debug_buf_chars, "pid=%d: ",
+                         (kmp_int32)getpid());
+#endif
+    chars += KMP_VSNPRINTF(db, __kmp_debug_buf_chars, format, ap);
+
+    if (chars + 1 > __kmp_debug_buf_chars) {
+      if (chars + 1 > __kmp_debug_buf_warn_chars) {
+#if KMP_OS_WINDOWS
+        DWORD count;
+        __kmp_str_buf_print(&__kmp_console_buf, "OMP warning: Debugging buffer "
+                                                "overflow; increase "
+                                                "KMP_DEBUG_BUF_CHARS to %d\n",
+                            chars + 1);
+        WriteFile(__kmp_stderr, __kmp_console_buf.str, __kmp_console_buf.used,
+                  &count, NULL);
+        __kmp_str_buf_clear(&__kmp_console_buf);
+#else
+        fprintf(__kmp_stderr, "OMP warning: Debugging buffer overflow; "
+                              "increase KMP_DEBUG_BUF_CHARS to %d\n",
+                chars + 1);
+        fflush(__kmp_stderr);
+#endif
+        __kmp_debug_buf_warn_chars = chars + 1;
+      }
+      /* terminate string if overflow occurred */
+      db[__kmp_debug_buf_chars - 2] = '\n';
+      db[__kmp_debug_buf_chars - 1] = '\0';
     }
+  } else {
+#if KMP_OS_WINDOWS
+    DWORD count;
+#ifdef KMP_DEBUG_PIDS
+    __kmp_str_buf_print(&__kmp_console_buf, "pid=%d: ", (kmp_int32)getpid());
+#endif
+    __kmp_str_buf_vprint(&__kmp_console_buf, format, ap);
+    WriteFile(__kmp_stderr, __kmp_console_buf.str, __kmp_console_buf.used,
+              &count, NULL);
+    __kmp_str_buf_clear(&__kmp_console_buf);
+#else
+#ifdef KMP_DEBUG_PIDS
+    fprintf(__kmp_stderr, "pid=%d: ", (kmp_int32)getpid());
+#endif
+    vfprintf(__kmp_stderr, format, ap);
+    fflush(__kmp_stderr);
+#endif
+  }
 }
 
-void
-__kmp_printf( char const * format, ... )
-{
-    va_list ap;
-    va_start( ap, format );
-
-    __kmp_acquire_bootstrap_lock( & __kmp_stdio_lock );
-    __kmp_vprintf( kmp_err, format, ap );
-    __kmp_release_bootstrap_lock( & __kmp_stdio_lock );
+void __kmp_printf(char const *format, ...) {
+  va_list ap;
+  va_start(ap, format);
+
+  __kmp_acquire_bootstrap_lock(&__kmp_stdio_lock);
+  __kmp_vprintf(kmp_err, format, ap);
+  __kmp_release_bootstrap_lock(&__kmp_stdio_lock);
 
-    va_end( ap );
+  va_end(ap);
 }
 
-void
-__kmp_printf_no_lock( char const * format, ... )
-{
-    va_list ap;
-    va_start( ap, format );
+void __kmp_printf_no_lock(char const *format, ...) {
+  va_list ap;
+  va_start(ap, format);
 
-    __kmp_vprintf( kmp_err, format, ap );
+  __kmp_vprintf(kmp_err, format, ap);
 
-    va_end( ap );
+  va_end(ap);
 }
-
-/* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */

Modified: openmp/trunk/runtime/src/kmp_io.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_io.h?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_io.h (original)
+++ openmp/trunk/runtime/src/kmp_io.h Fri May 12 13:01:32 2017
@@ -21,24 +21,20 @@ extern "C" {
 #endif
 
 /* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
 
-enum kmp_io {
-    kmp_out = 0,
-    kmp_err
-};
-
-extern kmp_bootstrap_lock_t __kmp_stdio_lock;     /* Control stdio functions */
-extern kmp_bootstrap_lock_t __kmp_console_lock;   /* Control console initialization */
-
-extern void __kmp_vprintf( enum kmp_io __kmp_io, char const * format, va_list ap );
-extern void __kmp_printf( char const * format, ... );
-extern void __kmp_printf_no_lock( char const * format, ... );
-extern void __kmp_close_console( void );
+enum kmp_io { kmp_out = 0, kmp_err };
+
+extern kmp_bootstrap_lock_t __kmp_stdio_lock; /* Control stdio functions */
+extern kmp_bootstrap_lock_t
+    __kmp_console_lock; /* Control console initialization */
+
+extern void __kmp_vprintf(enum kmp_io __kmp_io, char const *format, va_list ap);
+extern void __kmp_printf(char const *format, ...);
+extern void __kmp_printf_no_lock(char const *format, ...);
+extern void __kmp_close_console(void);
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* KMP_IO_H */
-

Modified: openmp/trunk/runtime/src/kmp_itt.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_itt.cpp?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_itt.cpp (original)
+++ openmp/trunk/runtime/src/kmp_itt.cpp Fri May 12 13:01:32 2017
@@ -19,145 +19,133 @@
 #include "kmp_itt.h"
 
 #if KMP_DEBUG
-    #include "kmp_itt.inl"
+#include "kmp_itt.inl"
 #endif
 
-
 #if USE_ITT_NOTIFY
 
-    kmp_int32 __kmp_barrier_domain_count;
-    kmp_int32 __kmp_region_domain_count;
-    __itt_domain* __kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
-    __itt_domain* __kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
-    __itt_domain* __kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
-    kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
-    __itt_domain * metadata_domain = NULL;
-    __itt_string_handle * string_handle_imbl = NULL;
-    __itt_string_handle * string_handle_loop = NULL;
-    __itt_string_handle * string_handle_sngl = NULL;
-
-    #include "kmp_version.h"
-    #include "kmp_i18n.h"
-    #include "kmp_str.h"
-
-    KMP_BUILD_ASSERT( sizeof( kmp_itt_mark_t ) == sizeof( __itt_mark_type ) );
-
-    /*
-        Previously used warnings:
-
-        KMP_WARNING( IttAllNotifDisabled );
-        KMP_WARNING( IttObjNotifDisabled );
-        KMP_WARNING( IttMarkNotifDisabled );
-        KMP_WARNING( IttUnloadLibFailed, libittnotify );
-    */
-
-
-    kmp_int32 __kmp_itt_prepare_delay = 0;
-    kmp_bootstrap_lock_t __kmp_itt_debug_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( __kmp_itt_debug_lock );
+kmp_int32 __kmp_barrier_domain_count;
+kmp_int32 __kmp_region_domain_count;
+__itt_domain *__kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
+__itt_domain *__kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
+__itt_domain *__kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
+kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
+__itt_domain *metadata_domain = NULL;
+__itt_string_handle *string_handle_imbl = NULL;
+__itt_string_handle *string_handle_loop = NULL;
+__itt_string_handle *string_handle_sngl = NULL;
+
+#include "kmp_i18n.h"
+#include "kmp_str.h"
+#include "kmp_version.h"
+
+KMP_BUILD_ASSERT(sizeof(kmp_itt_mark_t) == sizeof(__itt_mark_type));
+
+/* Previously used warnings:
+
+   KMP_WARNING( IttAllNotifDisabled );
+   KMP_WARNING( IttObjNotifDisabled );
+   KMP_WARNING( IttMarkNotifDisabled );
+   KMP_WARNING( IttUnloadLibFailed, libittnotify );
+*/
+
+kmp_int32 __kmp_itt_prepare_delay = 0;
+kmp_bootstrap_lock_t __kmp_itt_debug_lock =
+    KMP_BOOTSTRAP_LOCK_INITIALIZER(__kmp_itt_debug_lock);
 
 #endif // USE_ITT_NOTIFY
 
 void __kmp_itt_initialize() {
 
-    // ITTNotify library is loaded and initialized at first call to any ittnotify function,
-    // so we do not need to explicitly load it any more.
-    // Jusr report OMP RTL version to ITTNotify.
-
-    #if USE_ITT_NOTIFY
-        // Report OpenMP RTL version.
-        kmp_str_buf_t       buf;
-        __itt_mark_type     version;
-        __kmp_str_buf_init( & buf );
-        __kmp_str_buf_print(
-            & buf,
-            "OMP RTL Version %d.%d.%d",
-            __kmp_version_major,
-            __kmp_version_minor,
-            __kmp_version_build
-        );
-        if ( __itt_api_version_ptr != NULL ) {
-            __kmp_str_buf_print( & buf, ":%s", __itt_api_version() );
-        }; // if
-        version = __itt_mark_create( buf.str );
-        __itt_mark( version, NULL );
-        __kmp_str_buf_free( & buf );
-    #endif
+// ITTNotify library is loaded and initialized at first call to any ittnotify
+// function, so we do not need to explicitly load it any more. Just report OMP
+// RTL version to ITTNotify.
 
-} // __kmp_itt_initialize
+#if USE_ITT_NOTIFY
+  // Report OpenMP RTL version.
+  kmp_str_buf_t buf;
+  __itt_mark_type version;
+  __kmp_str_buf_init(&buf);
+  __kmp_str_buf_print(&buf, "OMP RTL Version %d.%d.%d", __kmp_version_major,
+                      __kmp_version_minor, __kmp_version_build);
+  if (__itt_api_version_ptr != NULL) {
+    __kmp_str_buf_print(&buf, ":%s", __itt_api_version());
+  }; // if
+  version = __itt_mark_create(buf.str);
+  __itt_mark(version, NULL);
+  __kmp_str_buf_free(&buf);
+#endif
 
+} // __kmp_itt_initialize
 
 void __kmp_itt_destroy() {
-    #if USE_ITT_NOTIFY
-        __kmp_itt_fini_ittlib();
-    #endif
+#if USE_ITT_NOTIFY
+  __kmp_itt_fini_ittlib();
+#endif
 } // __kmp_itt_destroy
 
+extern "C" void __itt_error_handler(__itt_error_code err, va_list args) {
 
-extern "C"
-void
-__itt_error_handler(
-    __itt_error_code err,
-    va_list args
-) {
-
-    switch ( err ) {
-        case __itt_error_no_module : {
-            char const * library = va_arg( args, char const * );
+  switch (err) {
+  case __itt_error_no_module: {
+    char const *library = va_arg(args, char const *);
 #if KMP_OS_WINDOWS
-            int sys_err = va_arg( args, int );
-            kmp_msg_t err_code = KMP_SYSERRCODE( sys_err );
-            __kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), err_code, __kmp_msg_null );
-            if (__kmp_generate_warnings == kmp_warnings_off) {
-              __kmp_str_free(&err_code.str);
-            }
+    int sys_err = va_arg(args, int);
+    kmp_msg_t err_code = KMP_SYSERRCODE(sys_err);
+    __kmp_msg(kmp_ms_warning, KMP_MSG(IttLoadLibFailed, library), err_code,
+              __kmp_msg_null);
+    if (__kmp_generate_warnings == kmp_warnings_off) {
+      __kmp_str_free(&err_code.str);
+    }
 #else
-            char const * sys_err = va_arg( args, char const * );
-            kmp_msg_t err_code = KMP_SYSERRMESG( sys_err );
-            __kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), err_code, __kmp_msg_null );
-            if (__kmp_generate_warnings == kmp_warnings_off) {
-              __kmp_str_free(&err_code.str);
-            }
+    char const *sys_err = va_arg(args, char const *);
+    kmp_msg_t err_code = KMP_SYSERRMESG(sys_err);
+    __kmp_msg(kmp_ms_warning, KMP_MSG(IttLoadLibFailed, library), err_code,
+              __kmp_msg_null);
+    if (__kmp_generate_warnings == kmp_warnings_off) {
+      __kmp_str_free(&err_code.str);
+    }
 #endif
-        } break;
-        case __itt_error_no_symbol : {
-            char const * library = va_arg( args, char const * );
-            char const * symbol  = va_arg( args, char const * );
-            KMP_WARNING( IttLookupFailed, symbol, library );
-        } break;
-        case __itt_error_unknown_group : {
-            char const * var   = va_arg( args, char const * );
-            char const * group = va_arg( args, char const * );
-            KMP_WARNING( IttUnknownGroup, var, group );
-        } break;
-        case __itt_error_env_too_long : {
-            char const * var     = va_arg( args, char const * );
-            size_t       act_len = va_arg( args, size_t );
-            size_t       max_len = va_arg( args, size_t );
-            KMP_WARNING( IttEnvVarTooLong, var, (unsigned long) act_len, (unsigned long) max_len );
-        } break;
-        case __itt_error_cant_read_env : {
-            char const * var     = va_arg( args, char const * );
-            int          sys_err = va_arg( args, int );
-            kmp_msg_t err_code = KMP_ERR( sys_err );
-            __kmp_msg( kmp_ms_warning, KMP_MSG( CantGetEnvVar, var ), err_code, __kmp_msg_null );
-            if (__kmp_generate_warnings == kmp_warnings_off) {
-              __kmp_str_free(&err_code.str);
-            }
-        } break;
-        case __itt_error_system : {
-            char const * func    = va_arg( args, char const * );
-            int          sys_err = va_arg( args, int );
-            kmp_msg_t err_code = KMP_SYSERRCODE( sys_err );
-            __kmp_msg( kmp_ms_warning, KMP_MSG( IttFunctionError, func ), err_code, __kmp_msg_null );
-            if (__kmp_generate_warnings == kmp_warnings_off) {
-              __kmp_str_free(&err_code.str);
-            }
-        } break;
-        default : {
-            KMP_WARNING( IttUnknownError, err );
-        };
-    }; // switch
-
+  } break;
+  case __itt_error_no_symbol: {
+    char const *library = va_arg(args, char const *);
+    char const *symbol = va_arg(args, char const *);
+    KMP_WARNING(IttLookupFailed, symbol, library);
+  } break;
+  case __itt_error_unknown_group: {
+    char const *var = va_arg(args, char const *);
+    char const *group = va_arg(args, char const *);
+    KMP_WARNING(IttUnknownGroup, var, group);
+  } break;
+  case __itt_error_env_too_long: {
+    char const *var = va_arg(args, char const *);
+    size_t act_len = va_arg(args, size_t);
+    size_t max_len = va_arg(args, size_t);
+    KMP_WARNING(IttEnvVarTooLong, var, (unsigned long)act_len,
+                (unsigned long)max_len);
+  } break;
+  case __itt_error_cant_read_env: {
+    char const *var = va_arg(args, char const *);
+    int sys_err = va_arg(args, int);
+    kmp_msg_t err_code = KMP_ERR(sys_err);
+    __kmp_msg(kmp_ms_warning, KMP_MSG(CantGetEnvVar, var), err_code,
+              __kmp_msg_null);
+    if (__kmp_generate_warnings == kmp_warnings_off) {
+      __kmp_str_free(&err_code.str);
+    }
+  } break;
+  case __itt_error_system: {
+    char const *func = va_arg(args, char const *);
+    int sys_err = va_arg(args, int);
+    kmp_msg_t err_code = KMP_SYSERRCODE(sys_err);
+    __kmp_msg(kmp_ms_warning, KMP_MSG(IttFunctionError, func), err_code,
+              __kmp_msg_null);
+    if (__kmp_generate_warnings == kmp_warnings_off) {
+      __kmp_str_free(&err_code.str);
+    }
+  } break;
+  default: { KMP_WARNING(IttUnknownError, err); };
+  }; // switch
 } // __itt_error_handler
 
 #endif /* USE_ITT_BUILD */

Modified: openmp/trunk/runtime/src/kmp_itt.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_itt.h?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_itt.h (original)
+++ openmp/trunk/runtime/src/kmp_itt.h Fri May 12 13:01:32 2017
@@ -24,104 +24,121 @@
 #include "legacy/ittnotify.h"
 
 #if KMP_DEBUG
-    #define __kmp_inline           // Turn off inlining in debug mode.
+#define __kmp_inline // Turn off inlining in debug mode.
 #else
-    #define __kmp_inline static inline
+#define __kmp_inline static inline
 #endif
 
 #if USE_ITT_NOTIFY
-    extern kmp_int32  __kmp_itt_prepare_delay;
-# ifdef __cplusplus
-    extern "C" void __kmp_itt_fini_ittlib(void);
-# else
-    extern void __kmp_itt_fini_ittlib(void);
-# endif
+extern kmp_int32 __kmp_itt_prepare_delay;
+#ifdef __cplusplus
+extern "C" void __kmp_itt_fini_ittlib(void);
+#else
+extern void __kmp_itt_fini_ittlib(void);
+#endif
 #endif
 
-// Simplify the handling of an argument that is only required when USE_ITT_BUILD is enabled.
-#define USE_ITT_BUILD_ARG(x) ,x
+// Simplify the handling of an argument that is only required when USE_ITT_BUILD
+// is enabled.
+#define USE_ITT_BUILD_ARG(x) , x
 
 void __kmp_itt_initialize();
 void __kmp_itt_destroy();
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // New stuff for reporting high-level constructs.
-// -------------------------------------------------------------------------------------------------
 
 // Note the naming convention:
 //     __kmp_itt_xxxing() function should be called before action, while
 //     __kmp_itt_xxxed()  function should be called after action.
 
 // --- Parallel region reporting ---
-__kmp_inline void __kmp_itt_region_forking(  int gtid, int team_size, int barriers ); // Master only, before forking threads.
-__kmp_inline void __kmp_itt_region_joined(   int gtid ); // Master only, after joining threads.
-    // (*) Note: A thread may execute tasks after this point, though.
+__kmp_inline void
+__kmp_itt_region_forking(int gtid, int team_size,
+                         int barriers); // Master only, before forking threads.
+__kmp_inline void
+__kmp_itt_region_joined(int gtid); // Master only, after joining threads.
+// (*) Note: A thread may execute tasks after this point, though.
 
 // --- Frame reporting ---
-// region = 0 - no regions, region = 1 - parallel, region = 2 - serialized parallel
-__kmp_inline void __kmp_itt_frame_submit( int gtid, __itt_timestamp begin, __itt_timestamp end, int imbalance, ident_t *loc, int team_size, int region = 0 );
+// region=0: no regions, region=1: parallel, region=2: serialized parallel
+__kmp_inline void __kmp_itt_frame_submit(int gtid, __itt_timestamp begin,
+                                         __itt_timestamp end, int imbalance,
+                                         ident_t *loc, int team_size,
+                                         int region = 0);
 
 // --- Metadata reporting ---
-// begin/end - begin/end timestamps of a barrier frame, imbalance - aggregated wait time value, reduction -if this is a reduction barrier
-__kmp_inline void __kmp_itt_metadata_imbalance( int gtid, kmp_uint64 begin, kmp_uint64 end, kmp_uint64 imbalance, kmp_uint64 reduction );
-// sched_type: 0 - static, 1 - dynamic, 2 - guided, 3 - custom (all others); iterations - loop trip count, chunk - chunk size
-__kmp_inline void __kmp_itt_metadata_loop( ident_t * loc, kmp_uint64 sched_type, kmp_uint64 iterations, kmp_uint64 chunk );
-__kmp_inline void __kmp_itt_metadata_single( ident_t * loc );
+// begin/end - begin/end timestamps of a barrier frame, imbalance - aggregated
+// wait time value, reduction -if this is a reduction barrier
+__kmp_inline void __kmp_itt_metadata_imbalance(int gtid, kmp_uint64 begin,
+                                               kmp_uint64 end,
+                                               kmp_uint64 imbalance,
+                                               kmp_uint64 reduction);
+// sched_type: 0 - static, 1 - dynamic, 2 - guided, 3 - custom (all others);
+// iterations - loop trip count, chunk - chunk size
+__kmp_inline void __kmp_itt_metadata_loop(ident_t *loc, kmp_uint64 sched_type,
+                                          kmp_uint64 iterations,
+                                          kmp_uint64 chunk);
+__kmp_inline void __kmp_itt_metadata_single(ident_t *loc);
 
 // --- Barrier reporting ---
-__kmp_inline void * __kmp_itt_barrier_object( int gtid, int bt, int set_name = 0, int delta = 0 );
-__kmp_inline void   __kmp_itt_barrier_starting( int gtid, void * object );
-__kmp_inline void   __kmp_itt_barrier_middle(   int gtid, void * object );
-__kmp_inline void   __kmp_itt_barrier_finished( int gtid, void * object );
+__kmp_inline void *__kmp_itt_barrier_object(int gtid, int bt, int set_name = 0,
+                                            int delta = 0);
+__kmp_inline void __kmp_itt_barrier_starting(int gtid, void *object);
+__kmp_inline void __kmp_itt_barrier_middle(int gtid, void *object);
+__kmp_inline void __kmp_itt_barrier_finished(int gtid, void *object);
 
 // --- Taskwait reporting ---
-__kmp_inline void * __kmp_itt_taskwait_object( int gtid );
-__kmp_inline void   __kmp_itt_taskwait_starting( int gtid, void * object );
-__kmp_inline void   __kmp_itt_taskwait_finished(   int gtid, void * object );
+__kmp_inline void *__kmp_itt_taskwait_object(int gtid);
+__kmp_inline void __kmp_itt_taskwait_starting(int gtid, void *object);
+__kmp_inline void __kmp_itt_taskwait_finished(int gtid, void *object);
 
 // --- Task reporting ---
-__kmp_inline void   __kmp_itt_task_starting( void * object );
-__kmp_inline void   __kmp_itt_task_finished( void * object );
+__kmp_inline void __kmp_itt_task_starting(void *object);
+__kmp_inline void __kmp_itt_task_finished(void *object);
 
 // --- Lock reporting ---
 #if KMP_USE_DYNAMIC_LOCK
-__kmp_inline void   __kmp_itt_lock_creating(  kmp_user_lock_p lock, const ident_t * );
+__kmp_inline void __kmp_itt_lock_creating(kmp_user_lock_p lock,
+                                          const ident_t *);
 #else
-__kmp_inline void   __kmp_itt_lock_creating(  kmp_user_lock_p lock );
+__kmp_inline void __kmp_itt_lock_creating(kmp_user_lock_p lock);
 #endif
-__kmp_inline void   __kmp_itt_lock_acquiring( kmp_user_lock_p lock );
-__kmp_inline void   __kmp_itt_lock_acquired(  kmp_user_lock_p lock );
-__kmp_inline void   __kmp_itt_lock_releasing( kmp_user_lock_p lock );
-__kmp_inline void   __kmp_itt_lock_cancelled( kmp_user_lock_p lock );
-__kmp_inline void   __kmp_itt_lock_destroyed( kmp_user_lock_p lock );
+__kmp_inline void __kmp_itt_lock_acquiring(kmp_user_lock_p lock);
+__kmp_inline void __kmp_itt_lock_acquired(kmp_user_lock_p lock);
+__kmp_inline void __kmp_itt_lock_releasing(kmp_user_lock_p lock);
+__kmp_inline void __kmp_itt_lock_cancelled(kmp_user_lock_p lock);
+__kmp_inline void __kmp_itt_lock_destroyed(kmp_user_lock_p lock);
 
 // --- Critical reporting ---
 #if KMP_USE_DYNAMIC_LOCK
-__kmp_inline void   __kmp_itt_critical_creating(  kmp_user_lock_p lock, const ident_t * );
+__kmp_inline void __kmp_itt_critical_creating(kmp_user_lock_p lock,
+                                              const ident_t *);
 #else
-__kmp_inline void   __kmp_itt_critical_creating(  kmp_user_lock_p lock );
+__kmp_inline void __kmp_itt_critical_creating(kmp_user_lock_p lock);
 #endif
-__kmp_inline void   __kmp_itt_critical_acquiring( kmp_user_lock_p lock );
-__kmp_inline void   __kmp_itt_critical_acquired(  kmp_user_lock_p lock );
-__kmp_inline void   __kmp_itt_critical_releasing( kmp_user_lock_p lock );
-__kmp_inline void   __kmp_itt_critical_destroyed( kmp_user_lock_p lock );
+__kmp_inline void __kmp_itt_critical_acquiring(kmp_user_lock_p lock);
+__kmp_inline void __kmp_itt_critical_acquired(kmp_user_lock_p lock);
+__kmp_inline void __kmp_itt_critical_releasing(kmp_user_lock_p lock);
+__kmp_inline void __kmp_itt_critical_destroyed(kmp_user_lock_p lock);
 
 // --- Single reporting ---
-__kmp_inline void   __kmp_itt_single_start( int gtid );
-__kmp_inline void   __kmp_itt_single_end(   int gtid );
+__kmp_inline void __kmp_itt_single_start(int gtid);
+__kmp_inline void __kmp_itt_single_end(int gtid);
 
 // --- Ordered reporting ---
-__kmp_inline void   __kmp_itt_ordered_init(  int gtid );
-__kmp_inline void   __kmp_itt_ordered_prep(  int gtid );
-__kmp_inline void   __kmp_itt_ordered_start( int gtid );
-__kmp_inline void   __kmp_itt_ordered_end(   int gtid );
+__kmp_inline void __kmp_itt_ordered_init(int gtid);
+__kmp_inline void __kmp_itt_ordered_prep(int gtid);
+__kmp_inline void __kmp_itt_ordered_start(int gtid);
+__kmp_inline void __kmp_itt_ordered_end(int gtid);
 
 // --- Threads reporting ---
-__kmp_inline void  __kmp_itt_thread_ignore();
-__kmp_inline void  __kmp_itt_thread_name( int gtid );
+__kmp_inline void __kmp_itt_thread_ignore();
+__kmp_inline void __kmp_itt_thread_name(int gtid);
 
 // --- System objects ---
-__kmp_inline void   __kmp_itt_system_object_created( void * object, char const * name );
+__kmp_inline void __kmp_itt_system_object_created(void *object,
+                                                  char const *name);
 
 // --- Stack stitching ---
 __kmp_inline __itt_caller __kmp_itt_stack_caller_create(void);
@@ -129,184 +146,189 @@ __kmp_inline void __kmp_itt_stack_caller
 __kmp_inline void __kmp_itt_stack_callee_enter(__itt_caller);
 __kmp_inline void __kmp_itt_stack_callee_leave(__itt_caller);
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // Old stuff for reporting low-level internal synchronization.
-// -------------------------------------------------------------------------------------------------
 
 #if USE_ITT_NOTIFY
 
-    /*
-     * Support for SSC marks, which are used by SDE
-     * http://software.intel.com/en-us/articles/intel-software-development-emulator
-     * to mark points in instruction traces that represent spin-loops and are
-     * therefore uninteresting when collecting traces for architecture simulation.
-     */
-    #ifndef INCLUDE_SSC_MARKS
-    # define INCLUDE_SSC_MARKS (KMP_OS_LINUX && KMP_ARCH_X86_64)
-    #endif
-
-    /* Linux 64 only for now */
-    #if (INCLUDE_SSC_MARKS && KMP_OS_LINUX && KMP_ARCH_X86_64)
-    // Portable (at least for gcc and icc) code to insert the necessary instructions
-    // to set %ebx and execute the unlikely no-op.
-      #if defined( __INTEL_COMPILER )
-      # define INSERT_SSC_MARK(tag) __SSC_MARK(tag)
-      #else
-      # define INSERT_SSC_MARK(tag)                                          \
-      __asm__ __volatile__ ("movl %0, %%ebx; .byte 0x64, 0x67, 0x90 " ::"i"(tag):"%ebx")
-      #endif
-    #else
-    # define INSERT_SSC_MARK(tag) ((void)0)
-    #endif
-
-    /* Markers for the start and end of regions that represent polling and
-     * are therefore uninteresting to architectural simulations 0x4376 and
-     * 0x4377 are arbitrary numbers that should be unique in the space of
-     * SSC tags, but there is no central issuing authority rather
-     * randomness is expected to work.
-     */
-    #define SSC_MARK_SPIN_START() INSERT_SSC_MARK(0x4376)
-    #define SSC_MARK_SPIN_END()   INSERT_SSC_MARK(0x4377)
-
-    // Markers for architecture simulation.
-    // FORKING      : Before the master thread forks.
-    // JOINING      : At the start of the join.
-    // INVOKING     : Before the threads invoke microtasks.
-    // DISPATCH_INIT: At the start of dynamically scheduled loop.
-    // DISPATCH_NEXT: After claming next iteration of dynamically scheduled loop.
-    #define SSC_MARK_FORKING()          INSERT_SSC_MARK(0xd693)
-    #define SSC_MARK_JOINING()          INSERT_SSC_MARK(0xd694)
-    #define SSC_MARK_INVOKING()         INSERT_SSC_MARK(0xd695)
-    #define SSC_MARK_DISPATCH_INIT()    INSERT_SSC_MARK(0xd696)
-    #define SSC_MARK_DISPATCH_NEXT()    INSERT_SSC_MARK(0xd697)
-
-    // The object is an address that associates a specific set of the prepare, acquire, release,
-    // and cancel operations.
-
-    /* Sync prepare indicates a thread is going to start waiting for another thread
-       to send a release event.  This operation should be done just before the thread
-       begins checking for the existence of the release event */
-
-    /* Sync cancel indicates a thread is cancelling a wait on another thread anc
-       continuing execution without waiting for the other thread to release it */
-
-    /* Sync acquired indicates a thread has received a release event from another
-       thread and has stopped waiting.  This operation must occur only after the release
-       event is received. */
-
-    /* Sync release indicates a thread is going to send a release event to another thread
-       so it will stop waiting and continue execution. This operation must just happen before
-       the release event. */
-
-    #define KMP_FSYNC_PREPARE(   obj )  __itt_fsync_prepare(   (void *)( obj ) )
-    #define KMP_FSYNC_CANCEL(    obj )  __itt_fsync_cancel(    (void *)( obj ) )
-    #define KMP_FSYNC_ACQUIRED(  obj )  __itt_fsync_acquired(  (void *)( obj ) )
-    #define KMP_FSYNC_RELEASING( obj )  __itt_fsync_releasing( (void *)( obj ) )
-
-    /*
-        In case of waiting in a spin loop, ITT wants KMP_FSYNC_PREPARE() to be called with a delay
-        (and not called at all if waiting time is small). So, in spin loops, do not use
-        KMP_FSYNC_PREPARE(), but use KMP_FSYNC_SPIN_INIT() (before spin loop),
-        KMP_FSYNC_SPIN_PREPARE() (whithin the spin loop), and KMP_FSYNC_SPIN_ACQUIRED().
-        See KMP_WAIT_YIELD() for example.
-    */
-
-    #undef  KMP_FSYNC_SPIN_INIT
-    #define KMP_FSYNC_SPIN_INIT( obj, spin )    \
-        int sync_iters = 0;                     \
-        if ( __itt_fsync_prepare_ptr ) {        \
-            if ( obj == NULL ) {                \
-                obj = spin;                     \
-            } /* if */                          \
-        } /* if */                              \
-        SSC_MARK_SPIN_START()
-
-    #undef  KMP_FSYNC_SPIN_PREPARE
-    #define KMP_FSYNC_SPIN_PREPARE( obj ) do {                          \
-        if ( __itt_fsync_prepare_ptr && sync_iters < __kmp_itt_prepare_delay ) { \
-            ++ sync_iters;                                              \
-            if ( sync_iters >= __kmp_itt_prepare_delay ) {              \
-                KMP_FSYNC_PREPARE( (void*) obj );                       \
-            } /* if */                                                  \
-        } /* if */                                                      \
-     } while (0)
-    #undef  KMP_FSYNC_SPIN_ACQUIRED
-    #define KMP_FSYNC_SPIN_ACQUIRED( obj ) do {         \
-        SSC_MARK_SPIN_END();                            \
-        if ( sync_iters >= __kmp_itt_prepare_delay ) {  \
-            KMP_FSYNC_ACQUIRED( (void*) obj );          \
-        } /* if */                                      \
-     } while (0)
-
-    /* ITT will not report objects created within KMP_ITT_IGNORE(), e. g.:
-           KMP_ITT_IGNORE(
-               ptr = malloc( size );
-           );
-    */
-    #define KMP_ITT_IGNORE( statement ) do {                            \
-            __itt_state_t __itt_state_;                                 \
-            if ( __itt_state_get_ptr ) {                                \
-                __itt_state_ = __itt_state_get();                       \
-                __itt_obj_mode_set( __itt_obj_prop_ignore, __itt_obj_state_set ); \
-            }  /* if */                                                 \
-            { statement }                                               \
-            if ( __itt_state_get_ptr ) {                                \
-                __itt_state_set( __itt_state_ );                        \
-            }  /* if */                                                 \
-    } while (0)
-
-    const int KMP_MAX_FRAME_DOMAINS = 512; // Maximum number of frame domains to use (maps to
-                                           // different OpenMP regions in the user source code).
-    extern kmp_int32 __kmp_barrier_domain_count;
-    extern kmp_int32 __kmp_region_domain_count;
-    extern __itt_domain* __kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
-    extern __itt_domain* __kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
-    extern __itt_domain* __kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
-    extern kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
-    extern __itt_domain * metadata_domain;
-    extern __itt_string_handle * string_handle_imbl;
-    extern __itt_string_handle * string_handle_loop;
-    extern __itt_string_handle * string_handle_sngl;
+/* Support for SSC marks, which are used by SDE
+   http://software.intel.com/en-us/articles/intel-software-development-emulator
+   to mark points in instruction traces that represent spin-loops and are
+   therefore uninteresting when collecting traces for architecture simulation.
+ */
+#ifndef INCLUDE_SSC_MARKS
+#define INCLUDE_SSC_MARKS (KMP_OS_LINUX && KMP_ARCH_X86_64)
+#endif
 
+/* Linux 64 only for now */
+#if (INCLUDE_SSC_MARKS && KMP_OS_LINUX && KMP_ARCH_X86_64)
+// Portable (at least for gcc and icc) code to insert the necessary instructions
+// to set %ebx and execute the unlikely no-op.
+#if defined(__INTEL_COMPILER)
+#define INSERT_SSC_MARK(tag) __SSC_MARK(tag)
 #else
+#define INSERT_SSC_MARK(tag)                                                   \
+  __asm__ __volatile__("movl %0, %%ebx; .byte 0x64, 0x67, 0x90 " ::"i"(tag)    \
+                       : "%ebx")
+#endif
+#else
+#define INSERT_SSC_MARK(tag) ((void)0)
+#endif
 
-// Null definitions of the synchronization tracing functions.
-# define KMP_FSYNC_PREPARE(   obj )        ((void)0)
-# define KMP_FSYNC_CANCEL(    obj )        ((void)0)
-# define KMP_FSYNC_ACQUIRED(  obj )        ((void)0)
-# define KMP_FSYNC_RELEASING( obj )        ((void)0)
-
-# define KMP_FSYNC_SPIN_INIT( obj, spin )  ((void)0)
-# define KMP_FSYNC_SPIN_PREPARE(  obj )    ((void)0)
-# define KMP_FSYNC_SPIN_ACQUIRED( obj )    ((void)0)
+/* Markers for the start and end of regions that represent polling and are
+   therefore uninteresting to architectural simulations 0x4376 and 0x4377 are
+   arbitrary numbers that should be unique in the space of SSC tags, but there
+   is no central issuing authority rather randomness is expected to work. */
+#define SSC_MARK_SPIN_START() INSERT_SSC_MARK(0x4376)
+#define SSC_MARK_SPIN_END() INSERT_SSC_MARK(0x4377)
+
+// Markers for architecture simulation.
+// FORKING      : Before the master thread forks.
+// JOINING      : At the start of the join.
+// INVOKING     : Before the threads invoke microtasks.
+// DISPATCH_INIT: At the start of dynamically scheduled loop.
+// DISPATCH_NEXT: After claming next iteration of dynamically scheduled loop.
+#define SSC_MARK_FORKING() INSERT_SSC_MARK(0xd693)
+#define SSC_MARK_JOINING() INSERT_SSC_MARK(0xd694)
+#define SSC_MARK_INVOKING() INSERT_SSC_MARK(0xd695)
+#define SSC_MARK_DISPATCH_INIT() INSERT_SSC_MARK(0xd696)
+#define SSC_MARK_DISPATCH_NEXT() INSERT_SSC_MARK(0xd697)
+
+// The object is an address that associates a specific set of the prepare,
+// acquire, release, and cancel operations.
+
+/* Sync prepare indicates a thread is going to start waiting for another thread
+   to send a release event.  This operation should be done just before the
+   thread begins checking for the existence of the release event */
+
+/* Sync cancel indicates a thread is cancelling a wait on another thread and
+   continuing execution without waiting for the other thread to release it */
+
+/* Sync acquired indicates a thread has received a release event from another
+   thread and has stopped waiting.  This operation must occur only after the
+   release event is received. */
+
+/* Sync release indicates a thread is going to send a release event to another
+   thread so it will stop waiting and continue execution. This operation must
+   just happen before the release event. */
+
+#define KMP_FSYNC_PREPARE(obj) __itt_fsync_prepare((void *)(obj))
+#define KMP_FSYNC_CANCEL(obj) __itt_fsync_cancel((void *)(obj))
+#define KMP_FSYNC_ACQUIRED(obj) __itt_fsync_acquired((void *)(obj))
+#define KMP_FSYNC_RELEASING(obj) __itt_fsync_releasing((void *)(obj))
+
+/* In case of waiting in a spin loop, ITT wants KMP_FSYNC_PREPARE() to be called
+   with a delay (and not called at all if waiting time is small). So, in spin
+   loops, do not use KMP_FSYNC_PREPARE(), but use KMP_FSYNC_SPIN_INIT() (before
+   spin loop), KMP_FSYNC_SPIN_PREPARE() (whithin the spin loop), and
+   KMP_FSYNC_SPIN_ACQUIRED(). See KMP_WAIT_YIELD() for example. */
+
+#undef KMP_FSYNC_SPIN_INIT
+#define KMP_FSYNC_SPIN_INIT(obj, spin)                                         \
+  int sync_iters = 0;                                                          \
+  if (__itt_fsync_prepare_ptr) {                                               \
+    if (obj == NULL) {                                                         \
+      obj = spin;                                                              \
+    } /* if */                                                                 \
+  } /* if */                                                                   \
+  SSC_MARK_SPIN_START()
+
+#undef KMP_FSYNC_SPIN_PREPARE
+#define KMP_FSYNC_SPIN_PREPARE(obj)                                            \
+  do {                                                                         \
+    if (__itt_fsync_prepare_ptr && sync_iters < __kmp_itt_prepare_delay) {     \
+      ++sync_iters;                                                            \
+      if (sync_iters >= __kmp_itt_prepare_delay) {                             \
+        KMP_FSYNC_PREPARE((void *)obj);                                        \
+      } /* if */                                                               \
+    } /* if */                                                                 \
+  } while (0)
+#undef KMP_FSYNC_SPIN_ACQUIRED
+#define KMP_FSYNC_SPIN_ACQUIRED(obj)                                           \
+  do {                                                                         \
+    SSC_MARK_SPIN_END();                                                       \
+    if (sync_iters >= __kmp_itt_prepare_delay) {                               \
+      KMP_FSYNC_ACQUIRED((void *)obj);                                         \
+    } /* if */                                                                 \
+  } while (0)
+
+/* ITT will not report objects created within KMP_ITT_IGNORE(), e. g.:
+       KMP_ITT_IGNORE(
+           ptr = malloc( size );
+       );
+*/
+#define KMP_ITT_IGNORE(statement)                                              \
+  do {                                                                         \
+    __itt_state_t __itt_state_;                                                \
+    if (__itt_state_get_ptr) {                                                 \
+      __itt_state_ = __itt_state_get();                                        \
+      __itt_obj_mode_set(__itt_obj_prop_ignore, __itt_obj_state_set);          \
+    } /* if */                                                                 \
+    { statement }                                                              \
+    if (__itt_state_get_ptr) {                                                 \
+      __itt_state_set(__itt_state_);                                           \
+    } /* if */                                                                 \
+  } while (0)
+
+const int KMP_MAX_FRAME_DOMAINS =
+    512; // Maximum number of frame domains to use (maps to
+// different OpenMP regions in the user source code).
+extern kmp_int32 __kmp_barrier_domain_count;
+extern kmp_int32 __kmp_region_domain_count;
+extern __itt_domain *__kmp_itt_barrier_domains[KMP_MAX_FRAME_DOMAINS];
+extern __itt_domain *__kmp_itt_region_domains[KMP_MAX_FRAME_DOMAINS];
+extern __itt_domain *__kmp_itt_imbalance_domains[KMP_MAX_FRAME_DOMAINS];
+extern kmp_int32 __kmp_itt_region_team_size[KMP_MAX_FRAME_DOMAINS];
+extern __itt_domain *metadata_domain;
+extern __itt_string_handle *string_handle_imbl;
+extern __itt_string_handle *string_handle_loop;
+extern __itt_string_handle *string_handle_sngl;
 
-# define KMP_ITT_IGNORE(stmt ) do { stmt } while (0)
+#else
+
+// Null definitions of the synchronization tracing functions.
+#define KMP_FSYNC_PREPARE(obj) ((void)0)
+#define KMP_FSYNC_CANCEL(obj) ((void)0)
+#define KMP_FSYNC_ACQUIRED(obj) ((void)0)
+#define KMP_FSYNC_RELEASING(obj) ((void)0)
+
+#define KMP_FSYNC_SPIN_INIT(obj, spin) ((void)0)
+#define KMP_FSYNC_SPIN_PREPARE(obj) ((void)0)
+#define KMP_FSYNC_SPIN_ACQUIRED(obj) ((void)0)
+
+#define KMP_ITT_IGNORE(stmt)                                                   \
+  do {                                                                         \
+    stmt                                                                       \
+  } while (0)
 
 #endif // USE_ITT_NOTIFY
 
-#if ! KMP_DEBUG
-    // In release mode include definitions of inline functions.
-    #include "kmp_itt.inl"
+#if !KMP_DEBUG
+// In release mode include definitions of inline functions.
+#include "kmp_itt.inl"
 #endif
 
 #endif // KMP_ITT_H
 
-#else  /* USE_ITT_BUILD */
+#else /* USE_ITT_BUILD */
 
 // Null definitions of the synchronization tracing functions.
 // If USE_ITT_BULID is not enabled, USE_ITT_NOTIFY cannot be either.
 // By defining these we avoid unpleasant ifdef tests in many places.
-# define KMP_FSYNC_PREPARE(   obj )        ((void)0)
-# define KMP_FSYNC_CANCEL(    obj )        ((void)0)
-# define KMP_FSYNC_ACQUIRED(  obj )        ((void)0)
-# define KMP_FSYNC_RELEASING( obj )        ((void)0)
-
-# define KMP_FSYNC_SPIN_INIT( obj, spin )  ((void)0)
-# define KMP_FSYNC_SPIN_PREPARE(  obj )    ((void)0)
-# define KMP_FSYNC_SPIN_ACQUIRED( obj )    ((void)0)
-
-# define KMP_ITT_IGNORE(stmt ) do { stmt } while (0)
+#define KMP_FSYNC_PREPARE(obj) ((void)0)
+#define KMP_FSYNC_CANCEL(obj) ((void)0)
+#define KMP_FSYNC_ACQUIRED(obj) ((void)0)
+#define KMP_FSYNC_RELEASING(obj) ((void)0)
+
+#define KMP_FSYNC_SPIN_INIT(obj, spin) ((void)0)
+#define KMP_FSYNC_SPIN_PREPARE(obj) ((void)0)
+#define KMP_FSYNC_SPIN_ACQUIRED(obj) ((void)0)
+
+#define KMP_ITT_IGNORE(stmt)                                                   \
+  do {                                                                         \
+    stmt                                                                       \
+  } while (0)
 
-# define USE_ITT_BUILD_ARG(x)
+#define USE_ITT_BUILD_ARG(x)
 
 #endif /* USE_ITT_BUILD */

Modified: openmp/trunk/runtime/src/kmp_itt.inl
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_itt.inl?rev=302929&r1=302928&r2=302929&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_itt.inl (original)
+++ openmp/trunk/runtime/src/kmp_itt.inl Fri May 12 13:01:32 2017
@@ -14,1134 +14,1030 @@
 //===----------------------------------------------------------------------===//
 
 
-// Inline function definitions. This file should be included into kmp_itt.h file for prodiction
-// build (to let compliler inline functions) or into kmp_itt.c file for debug build (to reduce
-// the number of files to recompile and save build time).
-
+// Inline function definitions. This file should be included into kmp_itt.h file
+// for production build (to let compliler inline functions) or into kmp_itt.c
+// file for debug build (to reduce the number of files to recompile and save
+// build time).
 
 #include "kmp.h"
 #include "kmp_str.h"
 
 #if KMP_ITT_DEBUG
-    extern kmp_bootstrap_lock_t __kmp_itt_debug_lock;
-    #define KMP_ITT_DEBUG_LOCK() {                                   \
-        __kmp_acquire_bootstrap_lock( & __kmp_itt_debug_lock );      \
-    }
-    #define KMP_ITT_DEBUG_PRINT( ... ) {                             \
-        fprintf( stderr, "#%02d: ", __kmp_get_gtid() );              \
-        fprintf( stderr, __VA_ARGS__ );                              \
-        fflush( stderr );                                            \
-        __kmp_release_bootstrap_lock( & __kmp_itt_debug_lock );      \
-    }
+extern kmp_bootstrap_lock_t __kmp_itt_debug_lock;
+#define KMP_ITT_DEBUG_LOCK()                                                   \
+  { __kmp_acquire_bootstrap_lock(&__kmp_itt_debug_lock); }
+#define KMP_ITT_DEBUG_PRINT(...)                                               \
+  {                                                                            \
+    fprintf(stderr, "#%02d: ", __kmp_get_gtid());                              \
+    fprintf(stderr, __VA_ARGS__);                                              \
+    fflush(stderr);                                                            \
+    __kmp_release_bootstrap_lock(&__kmp_itt_debug_lock);                       \
+  }
 #else
-    #define KMP_ITT_DEBUG_LOCK()
-    #define KMP_ITT_DEBUG_PRINT( ... )
+#define KMP_ITT_DEBUG_LOCK()
+#define KMP_ITT_DEBUG_PRINT(...)
 #endif // KMP_ITT_DEBUG
 
-// Ensure that the functions are static if they're supposed to be
-// being inlined. Otherwise they cannot be used in more than one file,
-// since there will be multiple definitions.
+// Ensure that the functions are static if they're supposed to be being inlined.
+// Otherwise they cannot be used in more than one file, since there will be
+// multiple definitions.
 #if KMP_DEBUG
-# define LINKAGE
+#define LINKAGE
 #else
-# define LINKAGE static inline
+#define LINKAGE static inline
 #endif
 
-// ZCA interface used by Intel(R) Inspector. Intel(R) Parallel Amplifier uses this
-// API to support user-defined synchronization primitives, but does not use ZCA;
-// it would be safe to turn this off until wider support becomes available.
+// ZCA interface used by Intel(R) Inspector. Intel(R) Parallel Amplifier uses
+// this API to support user-defined synchronization primitives, but does not use
+// ZCA; it would be safe to turn this off until wider support becomes available.
 #if USE_ITT_ZCA
 #ifdef __INTEL_COMPILER
-#   if __INTEL_COMPILER >= 1200
-#       undef __itt_sync_acquired
-#       undef __itt_sync_releasing
-#       define __itt_sync_acquired(addr)    __notify_zc_intrinsic((char *)"sync_acquired", addr)
-#       define __itt_sync_releasing(addr)   __notify_intrinsic((char *)"sync_releasing", addr)
-#   endif
+#if __INTEL_COMPILER >= 1200
+#undef __itt_sync_acquired
+#undef __itt_sync_releasing
+#define __itt_sync_acquired(addr)                                              \
+  __notify_zc_intrinsic((char *)"sync_acquired", addr)
+#define __itt_sync_releasing(addr)                                             \
+  __notify_intrinsic((char *)"sync_releasing", addr)
+#endif
 #endif
 #endif
 
-static kmp_bootstrap_lock_t  metadata_lock = KMP_BOOTSTRAP_LOCK_INITIALIZER( metadata_lock );
-
-/*
-    ------------------------------------------------------------------------------------------------
-    Parallel region reporting.
-
-        * __kmp_itt_region_forking should be called by master thread of a team. Exact moment of
-          call does not matter, but it should be completed before any thread of this team calls
-          __kmp_itt_region_starting.
-        * __kmp_itt_region_starting should be called by each thread of a team just before entering
-          parallel region body.
-        * __kmp_itt_region_finished should be called by each thread of a team right after returning
-          from parallel region body.
-        * __kmp_itt_region_joined should be called by master thread of a team, after all threads
-          called __kmp_itt_region_finished.
-
-    Note: Thread waiting at join barrier (after __kmp_itt_region_finished) can execute some more
-    user code -- such a thread can execute tasks.
-
-    Note: The overhead of logging region_starting and region_finished in each thread is too large,
-    so these calls are not used.
-
-    ------------------------------------------------------------------------------------------------
-*/
-
-// -------------------------------------------------------------------------------------------------
-
-LINKAGE void
-__kmp_itt_region_forking( int gtid, int team_size, int barriers ) {
-#if USE_ITT_NOTIFY
-    kmp_team_t *      team = __kmp_team_from_gtid( gtid );
-    if (team->t.t_active_level > 1)
-    {
-        // The frame notifications are only supported for the outermost teams.
-        return;
-    }
-    ident_t *         loc  = __kmp_thread_from_gtid( gtid )->th.th_ident;
-    if (loc) {
-        // Use the reserved_2 field to store the index to the region domain.
-        // Assume that reserved_2 contains zero initially.  Since zero is special
-        // value here, store the index into domain array increased by 1.
-        if (loc->reserved_2 == 0) {
-            if (__kmp_region_domain_count < KMP_MAX_FRAME_DOMAINS) {
-                int frm = KMP_TEST_THEN_INC32( & __kmp_region_domain_count ); // get "old" value
-                if (frm >= KMP_MAX_FRAME_DOMAINS) {
-                    KMP_TEST_THEN_DEC32( & __kmp_region_domain_count );       // revert the count
-                    return;                      // loc->reserved_2 is still 0
-                }
-                //if (!KMP_COMPARE_AND_STORE_ACQ32( &loc->reserved_2, 0, frm + 1 )) {
-                //    frm = loc->reserved_2 - 1;   // get value saved by other thread for same loc
-                //} // AC: this block is to replace next unsynchronized line
-
-                // We need to save indexes for both region and barrier frames. We'll use loc->reserved_2
-                // field but put region index to the low two bytes and barrier indexes to the high
-                // two bytes. It is OK because KMP_MAX_FRAME_DOMAINS = 512.
-                loc->reserved_2 |= (frm + 1);                                    // save "new" value
-
-                // Transform compiler-generated region location into the format
-                // that the tools more or less standardized on:
-                //                               "<func>$omp$parallel@[file:]<line>[:<col>]"
-                const char * buff = NULL;
-                kmp_str_loc_t str_loc = __kmp_str_loc_init( loc->psource, 1 );
-                buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d",
-                                        str_loc.func, team_size, str_loc.file,
-                                        str_loc.line, str_loc.col);
-
-                __itt_suppress_push(__itt_suppress_memory_errors);
-                __kmp_itt_region_domains[ frm ] = __itt_domain_create( buff );
-                __itt_suppress_pop();
-
-                __kmp_str_free( &buff );
-                if( barriers ) {
-                    if (__kmp_barrier_domain_count < KMP_MAX_FRAME_DOMAINS) {
-                        int frm = KMP_TEST_THEN_INC32( & __kmp_barrier_domain_count ); // get "old" value
-                        if (frm >= KMP_MAX_FRAME_DOMAINS) {
-                            KMP_TEST_THEN_DEC32( & __kmp_barrier_domain_count );       // revert the count
-                            return;                      // loc->reserved_2 is still 0
-                        }
-                        const char * buff = NULL;
-                        buff = __kmp_str_format("%s$omp$barrier@%s:%d",
-                                                str_loc.func, str_loc.file, str_loc.col);
-                        __itt_suppress_push(__itt_suppress_memory_errors);
-                        __kmp_itt_barrier_domains[ frm ] = __itt_domain_create( buff );
-                        __itt_suppress_pop();
-                        __kmp_str_free( &buff );
-                        // Save the barrier frame index to the high two bytes.
-                        loc->reserved_2 |= (frm + 1) << 16;
-                    }
-                }
-                __kmp_str_loc_free( &str_loc );
-                __itt_frame_begin_v3(__kmp_itt_region_domains[ frm ], NULL);
-            }
-        } else { // Region domain exists for this location
-            // Check if team size was changed. Then create new region domain for this location
-            int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
-            if( __kmp_itt_region_team_size[frm] != team_size ) {
-                const char * buff = NULL;
-                kmp_str_loc_t str_loc = __kmp_str_loc_init( loc->psource, 1 );
-                buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d",
-                                        str_loc.func, team_size, str_loc.file,
-                                        str_loc.line, str_loc.col);
-
-                __itt_suppress_push(__itt_suppress_memory_errors);
-                __kmp_itt_region_domains[ frm ] = __itt_domain_create( buff );
-                __itt_suppress_pop();
-
-                __kmp_str_free( &buff );
-                __kmp_str_loc_free( &str_loc );
-                __kmp_itt_region_team_size[frm] = team_size;
-                __itt_frame_begin_v3(__kmp_itt_region_domains[frm], NULL);
-            } else { // Team size was not changed. Use existing domain.
-                __itt_frame_begin_v3(__kmp_itt_region_domains[frm], NULL);
+static kmp_bootstrap_lock_t metadata_lock =
+    KMP_BOOTSTRAP_LOCK_INITIALIZER(metadata_lock);
+
+/* Parallel region reporting.
+ * __kmp_itt_region_forking should be called by master thread of a team.
+   Exact moment of call does not matter, but it should be completed before any
+   thread of this team calls __kmp_itt_region_starting.
+ * __kmp_itt_region_starting should be called by each thread of a team just
+   before entering parallel region body.
+ * __kmp_itt_region_finished should be called by each thread of a team right
+   after returning from parallel region body.
+ * __kmp_itt_region_joined should be called by master thread of a team, after
+   all threads called __kmp_itt_region_finished.
+
+ Note: Thread waiting at join barrier (after __kmp_itt_region_finished) can
+ execute some more user code -- such a thread can execute tasks.
+
+ Note: The overhead of logging region_starting and region_finished in each
+ thread is too large, so these calls are not used. */
+
+LINKAGE void __kmp_itt_region_forking(int gtid, int team_size, int barriers) {
+#if USE_ITT_NOTIFY
+  kmp_team_t *team = __kmp_team_from_gtid(gtid);
+  if (team->t.t_active_level > 1) {
+    // The frame notifications are only supported for the outermost teams.
+    return;
+  }
+  ident_t *loc = __kmp_thread_from_gtid(gtid)->th.th_ident;
+  if (loc) {
+    // Use the reserved_2 field to store the index to the region domain.
+    // Assume that reserved_2 contains zero initially.  Since zero is special
+    // value here, store the index into domain array increased by 1.
+    if (loc->reserved_2 == 0) {
+      if (__kmp_region_domain_count < KMP_MAX_FRAME_DOMAINS) {
+        int frm =
+            KMP_TEST_THEN_INC32(&__kmp_region_domain_count); // get "old" value
+        if (frm >= KMP_MAX_FRAME_DOMAINS) {
+          KMP_TEST_THEN_DEC32(&__kmp_region_domain_count); // revert the count
+          return; // loc->reserved_2 is still 0
+        }
+        // if (!KMP_COMPARE_AND_STORE_ACQ32( &loc->reserved_2, 0, frm + 1 )) {
+        //    frm = loc->reserved_2 - 1;   // get value saved by other thread
+        //    for same loc
+        //} // AC: this block is to replace next unsynchronized line
+
+        // We need to save indexes for both region and barrier frames. We'll use
+        // loc->reserved_2 field but put region index to the low two bytes and
+        // barrier indexes to the high two bytes. It is OK because
+        // KMP_MAX_FRAME_DOMAINS = 512.
+        loc->reserved_2 |= (frm + 1); // save "new" value
+
+        // Transform compiler-generated region location into the format
+        // that the tools more or less standardized on:
+        //   "<func>$omp$parallel@[file:]<line>[:<col>]"
+        const char *buff = NULL;
+        kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
+        buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d", str_loc.func,
+                                team_size, str_loc.file, str_loc.line,
+                                str_loc.col);
+
+        __itt_suppress_push(__itt_suppress_memory_errors);
+        __kmp_itt_region_domains[frm] = __itt_domain_create(buff);
+        __itt_suppress_pop();
+
+        __kmp_str_free(&buff);
+        if (barriers) {
+          if (__kmp_barrier_domain_count < KMP_MAX_FRAME_DOMAINS) {
+            int frm = KMP_TEST_THEN_INC32(
+                &__kmp_barrier_domain_count); // get "old" value
+            if (frm >= KMP_MAX_FRAME_DOMAINS) {
+              KMP_TEST_THEN_DEC32(
+                  &__kmp_barrier_domain_count); // revert the count
+              return; // loc->reserved_2 is still 0
             }
+            const char *buff = NULL;
+            buff = __kmp_str_format("%s$omp$barrier@%s:%d", str_loc.func,
+                                    str_loc.file, str_loc.col);
+            __itt_suppress_push(__itt_suppress_memory_errors);
+            __kmp_itt_barrier_domains[frm] = __itt_domain_create(buff);
+            __itt_suppress_pop();
+            __kmp_str_free(&buff);
+            // Save the barrier frame index to the high two bytes.
+            loc->reserved_2 |= (frm + 1) << 16;
+          }
         }
-        KMP_ITT_DEBUG_LOCK();
-        KMP_ITT_DEBUG_PRINT( "[frm beg] gtid=%d, idx=%x, loc:%p\n",
-                         gtid, loc->reserved_2, loc );
+        __kmp_str_loc_free(&str_loc);
+        __itt_frame_begin_v3(__kmp_itt_region_domains[frm], NULL);
+      }
+    } else { // Region domain exists for this location
+      // Check if team size was changed. Then create new region domain for this
+      // location
+      int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
+      if (__kmp_itt_region_team_size[frm] != team_size) {
+        const char *buff = NULL;
+        kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
+        buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d", str_loc.func,
+                                team_size, str_loc.file, str_loc.line,
+                                str_loc.col);
+
+        __itt_suppress_push(__itt_suppress_memory_errors);
+        __kmp_itt_region_domains[frm] = __itt_domain_create(buff);
+        __itt_suppress_pop();
+
+        __kmp_str_free(&buff);
+        __kmp_str_loc_free(&str_loc);
+        __kmp_itt_region_team_size[frm] = team_size;
+        __itt_frame_begin_v3(__kmp_itt_region_domains[frm], NULL);
+      } else { // Team size was not changed. Use existing domain.
+        __itt_frame_begin_v3(__kmp_itt_region_domains[frm], NULL);
+      }
     }
+    KMP_ITT_DEBUG_LOCK();
+    KMP_ITT_DEBUG_PRINT("[frm beg] gtid=%d, idx=%x, loc:%p\n", gtid,
+                        loc->reserved_2, loc);
+  }
 #endif
 } // __kmp_itt_region_forking
 
-// -------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+LINKAGE void __kmp_itt_frame_submit(int gtid, __itt_timestamp begin,
+                                    __itt_timestamp end, int imbalance,
+                                    ident_t *loc, int team_size, int region) {
+#if USE_ITT_NOTIFY
+  if (region) {
+    kmp_team_t *team = __kmp_team_from_gtid(gtid);
+    int serialized = (region == 2 ? 1 : 0);
+    if (team->t.t_active_level + serialized > 1) {
+      // The frame notifications are only supported for the outermost teams.
+      return;
+    }
+    // Check region domain has not been created before. It's index is saved in
+    // the low two bytes.
+    if ((loc->reserved_2 & 0x0000FFFF) == 0) {
+      if (__kmp_region_domain_count < KMP_MAX_FRAME_DOMAINS) {
+        int frm =
+            KMP_TEST_THEN_INC32(&__kmp_region_domain_count); // get "old" value
+        if (frm >= KMP_MAX_FRAME_DOMAINS) {
+          KMP_TEST_THEN_DEC32(&__kmp_region_domain_count); // revert the count
+          return; // loc->reserved_2 is still 0
+        }
 
-LINKAGE void
-__kmp_itt_frame_submit( int gtid, __itt_timestamp begin, __itt_timestamp end, int imbalance, ident_t * loc, int team_size, int region ) {
-#if USE_ITT_NOTIFY
-    if( region ) {
-        kmp_team_t *      team = __kmp_team_from_gtid( gtid );
-        int serialized = ( region == 2 ? 1 : 0 );
-        if (team->t.t_active_level + serialized > 1)
-        {
-            // The frame notifications are only supported for the outermost teams.
-            return;
+        // We need to save indexes for both region and barrier frames. We'll use
+        // loc->reserved_2 field but put region index to the low two bytes and
+        // barrier indexes to the high two bytes. It is OK because
+        // KMP_MAX_FRAME_DOMAINS = 512.
+        loc->reserved_2 |= (frm + 1); // save "new" value
+
+        // Transform compiler-generated region location into the format
+        // that the tools more or less standardized on:
+        //   "<func>$omp$parallel:team_size@[file:]<line>[:<col>]"
+        const char *buff = NULL;
+        kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
+        buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d", str_loc.func,
+                                team_size, str_loc.file, str_loc.line,
+                                str_loc.col);
+
+        __itt_suppress_push(__itt_suppress_memory_errors);
+        __kmp_itt_region_domains[frm] = __itt_domain_create(buff);
+        __itt_suppress_pop();
+
+        __kmp_str_free(&buff);
+        __kmp_str_loc_free(&str_loc);
+        __kmp_itt_region_team_size[frm] = team_size;
+        __itt_frame_submit_v3(__kmp_itt_region_domains[frm], NULL, begin, end);
+      }
+    } else { // Region domain exists for this location
+      // Check if team size was changed. Then create new region domain for this
+      // location
+      int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
+      if (__kmp_itt_region_team_size[frm] != team_size) {
+        const char *buff = NULL;
+        kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
+        buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d", str_loc.func,
+                                team_size, str_loc.file, str_loc.line,
+                                str_loc.col);
+
+        __itt_suppress_push(__itt_suppress_memory_errors);
+        __kmp_itt_region_domains[frm] = __itt_domain_create(buff);
+        __itt_suppress_pop();
+
+        __kmp_str_free(&buff);
+        __kmp_str_loc_free(&str_loc);
+        __kmp_itt_region_team_size[frm] = team_size;
+        __itt_frame_submit_v3(__kmp_itt_region_domains[frm], NULL, begin, end);
+      } else { // Team size was not changed. Use existing domain.
+        __itt_frame_submit_v3(__kmp_itt_region_domains[frm], NULL, begin, end);
+      }
+    }
+    KMP_ITT_DEBUG_LOCK();
+    KMP_ITT_DEBUG_PRINT(
+        "[reg sub] gtid=%d, idx=%x, region:%d, loc:%p, beg:%llu, end:%llu\n",
+        gtid, loc->reserved_2, region, loc, begin, end);
+    return;
+  } else { // called for barrier reporting
+    if (loc) {
+      if ((loc->reserved_2 & 0xFFFF0000) == 0) {
+        if (__kmp_barrier_domain_count < KMP_MAX_FRAME_DOMAINS) {
+          int frm = KMP_TEST_THEN_INC32(
+              &__kmp_barrier_domain_count); // get "old" value
+          if (frm >= KMP_MAX_FRAME_DOMAINS) {
+            KMP_TEST_THEN_DEC32(
+                &__kmp_barrier_domain_count); // revert the count
+            return; // loc->reserved_2 is still 0
+          }
+          // Save the barrier frame index to the high two bytes.
+          loc->reserved_2 |= (frm + 1) << 16; // save "new" value
+
+          // Transform compiler-generated region location into the format
+          // that the tools more or less standardized on:
+          //   "<func>$omp$frame@[file:]<line>[:<col>]"
+          kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
+          if (imbalance) {
+            const char *buff_imb = NULL;
+            buff_imb = __kmp_str_format("%s$omp$barrier-imbalance:%d@%s:%d",
+                                        str_loc.func, team_size, str_loc.file,
+                                        str_loc.col);
+            __itt_suppress_push(__itt_suppress_memory_errors);
+            __kmp_itt_imbalance_domains[frm] = __itt_domain_create(buff_imb);
+            __itt_suppress_pop();
+            __itt_frame_submit_v3(__kmp_itt_imbalance_domains[frm], NULL, begin,
+                                  end);
+            __kmp_str_free(&buff_imb);
+          } else {
+            const char *buff = NULL;
+            buff = __kmp_str_format("%s$omp$barrier@%s:%d", str_loc.func,
+                                    str_loc.file, str_loc.col);
+            __itt_suppress_push(__itt_suppress_memory_errors);
+            __kmp_itt_barrier_domains[frm] = __itt_domain_create(buff);
+            __itt_suppress_pop();
+            __itt_frame_submit_v3(__kmp_itt_barrier_domains[frm], NULL, begin,
+                                  end);
+            __kmp_str_free(&buff);
+          }
+          __kmp_str_loc_free(&str_loc);
         }
-         //Check region domain has not been created before. It's index is saved in the low two bytes.
-         if ((loc->reserved_2 & 0x0000FFFF) == 0) {
-             if (__kmp_region_domain_count < KMP_MAX_FRAME_DOMAINS) {
-                 int frm = KMP_TEST_THEN_INC32( & __kmp_region_domain_count ); // get "old" value
-                 if (frm >= KMP_MAX_FRAME_DOMAINS) {
-                     KMP_TEST_THEN_DEC32( & __kmp_region_domain_count );       // revert the count
-                     return;                      // loc->reserved_2 is still 0
-                 }
-
-                 // We need to save indexes for both region and barrier frames. We'll use loc->reserved_2
-                 // field but put region index to the low two bytes and barrier indexes to the high
-                 // two bytes. It is OK because KMP_MAX_FRAME_DOMAINS = 512.
-                 loc->reserved_2 |= (frm + 1);                                 // save "new" value
-
-                 // Transform compiler-generated region location into the format
-                 // that the tools more or less standardized on:
-                 //                               "<func>$omp$parallel:team_size@[file:]<line>[:<col>]"
-                 const char * buff = NULL;
-                 kmp_str_loc_t str_loc = __kmp_str_loc_init( loc->psource, 1 );
-                 buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d",
-                                         str_loc.func, team_size, str_loc.file,
-                                         str_loc.line, str_loc.col);
-
-                 __itt_suppress_push(__itt_suppress_memory_errors);
-                 __kmp_itt_region_domains[ frm ] = __itt_domain_create( buff );
-                 __itt_suppress_pop();
-
-                 __kmp_str_free( &buff );
-                 __kmp_str_loc_free( &str_loc );
-                 __kmp_itt_region_team_size[frm] = team_size;
-                 __itt_frame_submit_v3(__kmp_itt_region_domains[ frm ], NULL, begin, end );
-             }
-         } else { // Region domain exists for this location
-             // Check if team size was changed. Then create new region domain for this location
-             int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
-             if( __kmp_itt_region_team_size[frm] != team_size ) {
-                 const char * buff = NULL;
-                 kmp_str_loc_t str_loc = __kmp_str_loc_init( loc->psource, 1 );
-                 buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d",
-                                         str_loc.func, team_size, str_loc.file,
-                                         str_loc.line, str_loc.col);
-
-                 __itt_suppress_push(__itt_suppress_memory_errors);
-                 __kmp_itt_region_domains[ frm ] = __itt_domain_create( buff );
-                 __itt_suppress_pop();
-
-                 __kmp_str_free( &buff );
-                 __kmp_str_loc_free( &str_loc );
-                 __kmp_itt_region_team_size[frm] = team_size;
-                 __itt_frame_submit_v3(__kmp_itt_region_domains[ frm ], NULL, begin, end );
-             } else { // Team size was not changed. Use existing domain.
-                 __itt_frame_submit_v3(__kmp_itt_region_domains[ frm ], NULL, begin, end );
-             }
-         }
-         KMP_ITT_DEBUG_LOCK();
-         KMP_ITT_DEBUG_PRINT( "[reg sub] gtid=%d, idx=%x, region:%d, loc:%p, beg:%llu, end:%llu\n",
-                          gtid, loc->reserved_2, region, loc, begin, end );
-         return;
-    } else { // called for barrier reporting
-        if (loc) {
-            if ((loc->reserved_2 & 0xFFFF0000) == 0) {
-                if (__kmp_barrier_domain_count < KMP_MAX_FRAME_DOMAINS) {
-                    int frm = KMP_TEST_THEN_INC32( & __kmp_barrier_domain_count ); // get "old" value
-                    if (frm >= KMP_MAX_FRAME_DOMAINS) {
-                        KMP_TEST_THEN_DEC32( & __kmp_barrier_domain_count );       // revert the count
-                        return;                      // loc->reserved_2 is still 0
-                    }
-                    // Save the barrier frame index to the high two bytes.
-                    loc->reserved_2 |= (frm + 1) << 16;                          // save "new" value
-
-                    // Transform compiler-generated region location into the format
-                    // that the tools more or less standardized on:
-                    //                               "<func>$omp$frame@[file:]<line>[:<col>]"
-                    kmp_str_loc_t str_loc = __kmp_str_loc_init( loc->psource, 1 );
-                    if( imbalance ) {
-                        const char * buff_imb = NULL;
-                        buff_imb = __kmp_str_format("%s$omp$barrier-imbalance:%d@%s:%d",
-                                                str_loc.func, team_size, str_loc.file, str_loc.col);
-                        __itt_suppress_push(__itt_suppress_memory_errors);
-                        __kmp_itt_imbalance_domains[ frm ] = __itt_domain_create( buff_imb );
-                        __itt_suppress_pop();
-                        __itt_frame_submit_v3(__kmp_itt_imbalance_domains[ frm ], NULL, begin, end );
-                        __kmp_str_free( &buff_imb );
-                    } else {
-                        const char * buff = NULL;
-                        buff = __kmp_str_format("%s$omp$barrier@%s:%d",
-                                                str_loc.func, str_loc.file, str_loc.col);
-                        __itt_suppress_push(__itt_suppress_memory_errors);
-                        __kmp_itt_barrier_domains[ frm ] = __itt_domain_create( buff );
-                        __itt_suppress_pop();
-                        __itt_frame_submit_v3(__kmp_itt_barrier_domains[ frm ], NULL, begin, end );
-                        __kmp_str_free( &buff );
-                    }
-                    __kmp_str_loc_free( &str_loc );
-                }
-            } else { // if it is not 0 then it should be <= KMP_MAX_FRAME_DOMAINS
-                if( imbalance ) {
-                    __itt_frame_submit_v3(__kmp_itt_imbalance_domains[ (loc->reserved_2 >> 16) - 1 ], NULL, begin, end );
-                } else {
-                    __itt_frame_submit_v3(__kmp_itt_barrier_domains[(loc->reserved_2 >> 16) - 1], NULL, begin, end );
-                }
-            }
-            KMP_ITT_DEBUG_LOCK();
-            KMP_ITT_DEBUG_PRINT( "[frm sub] gtid=%d, idx=%x, loc:%p, beg:%llu, end:%llu\n",
-                             gtid, loc->reserved_2, loc, begin, end );
+      } else { // if it is not 0 then it should be <= KMP_MAX_FRAME_DOMAINS
+        if (imbalance) {
+          __itt_frame_submit_v3(
+              __kmp_itt_imbalance_domains[(loc->reserved_2 >> 16) - 1], NULL,
+              begin, end);
+        } else {
+          __itt_frame_submit_v3(
+              __kmp_itt_barrier_domains[(loc->reserved_2 >> 16) - 1], NULL,
+              begin, end);
         }
+      }
+      KMP_ITT_DEBUG_LOCK();
+      KMP_ITT_DEBUG_PRINT(
+          "[frm sub] gtid=%d, idx=%x, loc:%p, beg:%llu, end:%llu\n", gtid,
+          loc->reserved_2, loc, begin, end);
     }
+  }
 #endif
 } // __kmp_itt_frame_submit
 
-// -------------------------------------------------------------------------------------------------
-
-LINKAGE void
-__kmp_itt_metadata_imbalance( int gtid, kmp_uint64 begin, kmp_uint64 end, kmp_uint64 imbalance, kmp_uint64 reduction ) {
-#if USE_ITT_NOTIFY
-    if( metadata_domain == NULL) {
-        __kmp_acquire_bootstrap_lock( & metadata_lock );
-        if( metadata_domain == NULL) {
-            __itt_suppress_push(__itt_suppress_memory_errors);
-            metadata_domain = __itt_domain_create( "OMP Metadata" );
-            string_handle_imbl = __itt_string_handle_create( "omp_metadata_imbalance");
-            string_handle_loop = __itt_string_handle_create( "omp_metadata_loop");
-            string_handle_sngl = __itt_string_handle_create( "omp_metadata_single");
-            __itt_suppress_pop();
-        }
-        __kmp_release_bootstrap_lock( & metadata_lock );
+// -----------------------------------------------------------------------------
+LINKAGE void __kmp_itt_metadata_imbalance(int gtid, kmp_uint64 begin,
+                                          kmp_uint64 end, kmp_uint64 imbalance,
+                                          kmp_uint64 reduction) {
+#if USE_ITT_NOTIFY
+  if (metadata_domain == NULL) {
+    __kmp_acquire_bootstrap_lock(&metadata_lock);
+    if (metadata_domain == NULL) {
+      __itt_suppress_push(__itt_suppress_memory_errors);
+      metadata_domain = __itt_domain_create("OMP Metadata");
+      string_handle_imbl = __itt_string_handle_create("omp_metadata_imbalance");
+      string_handle_loop = __itt_string_handle_create("omp_metadata_loop");
+      string_handle_sngl = __itt_string_handle_create("omp_metadata_single");
+      __itt_suppress_pop();
     }
+    __kmp_release_bootstrap_lock(&metadata_lock);
+  }
 
-    kmp_uint64 imbalance_data[ 4 ];
-    imbalance_data[ 0 ] = begin;
-    imbalance_data[ 1 ] = end;
-    imbalance_data[ 2 ] = imbalance;
-    imbalance_data[ 3 ] = reduction;
+  kmp_uint64 imbalance_data[4];
+  imbalance_data[0] = begin;
+  imbalance_data[1] = end;
+  imbalance_data[2] = imbalance;
+  imbalance_data[3] = reduction;
 
-    __itt_metadata_add(metadata_domain, __itt_null, string_handle_imbl, __itt_metadata_u64, 4, imbalance_data);
+  __itt_metadata_add(metadata_domain, __itt_null, string_handle_imbl,
+                     __itt_metadata_u64, 4, imbalance_data);
 #endif
 } // __kmp_itt_metadata_imbalance
 
-// -------------------------------------------------------------------------------------------------
-
-LINKAGE void
-__kmp_itt_metadata_loop( ident_t * loc, kmp_uint64 sched_type, kmp_uint64 iterations, kmp_uint64 chunk ) {
-#if USE_ITT_NOTIFY
-    if( metadata_domain == NULL) {
-        __kmp_acquire_bootstrap_lock( & metadata_lock );
-        if( metadata_domain == NULL) {
-            __itt_suppress_push(__itt_suppress_memory_errors);
-            metadata_domain = __itt_domain_create( "OMP Metadata" );
-            string_handle_imbl = __itt_string_handle_create( "omp_metadata_imbalance");
-            string_handle_loop = __itt_string_handle_create( "omp_metadata_loop");
-            string_handle_sngl = __itt_string_handle_create( "omp_metadata_single");
-            __itt_suppress_pop();
-        }
-        __kmp_release_bootstrap_lock( & metadata_lock );
+// -----------------------------------------------------------------------------
+LINKAGE void __kmp_itt_metadata_loop(ident_t *loc, kmp_uint64 sched_type,
+                                     kmp_uint64 iterations, kmp_uint64 chunk) {
+#if USE_ITT_NOTIFY
+  if (metadata_domain == NULL) {
+    __kmp_acquire_bootstrap_lock(&metadata_lock);
+    if (metadata_domain == NULL) {
+      __itt_suppress_push(__itt_suppress_memory_errors);
+      metadata_domain = __itt_domain_create("OMP Metadata");
+      string_handle_imbl = __itt_string_handle_create("omp_metadata_imbalance");
+      string_handle_loop = __itt_string_handle_create("omp_metadata_loop");
+      string_handle_sngl = __itt_string_handle_create("omp_metadata_single");
+      __itt_suppress_pop();
     }
+    __kmp_release_bootstrap_lock(&metadata_lock);
+  }
 
-    // Parse line and column from psource string: ";file;func;line;col;;"
-    char * s_line;
-    char * s_col;
-    KMP_DEBUG_ASSERT(loc->psource);
+  // Parse line and column from psource string: ";file;func;line;col;;"
+  char *s_line;
+  char *s_col;
+  KMP_DEBUG_ASSERT(loc->psource);
 #ifdef __cplusplus
-    s_line = strchr((char*)loc->psource, ';');
+  s_line = strchr((char *)loc->psource, ';');
 #else
-    s_line = strchr(loc->psource, ';');
+  s_line = strchr(loc->psource, ';');
 #endif
-    KMP_DEBUG_ASSERT(s_line);
-    s_line = strchr(s_line + 1, ';');   // 2-nd semicolon
-    KMP_DEBUG_ASSERT(s_line);
-    s_line = strchr(s_line + 1, ';');   // 3-rd semicolon
-    KMP_DEBUG_ASSERT(s_line);
-    s_col = strchr(s_line + 1, ';');    // 4-th semicolon
-    KMP_DEBUG_ASSERT(s_col);
-
-    kmp_uint64 loop_data[ 5 ];
-    loop_data[ 0 ] = atoi(s_line + 1); // read line
-    loop_data[ 1 ] = atoi(s_col + 1);  // read column
-    loop_data[ 2 ] = sched_type;
-    loop_data[ 3 ] = iterations;
-    loop_data[ 4 ] = chunk;
+  KMP_DEBUG_ASSERT(s_line);
+  s_line = strchr(s_line + 1, ';'); // 2-nd semicolon
+  KMP_DEBUG_ASSERT(s_line);
+  s_line = strchr(s_line + 1, ';'); // 3-rd semicolon
+  KMP_DEBUG_ASSERT(s_line);
+  s_col = strchr(s_line + 1, ';'); // 4-th semicolon
+  KMP_DEBUG_ASSERT(s_col);
+
+  kmp_uint64 loop_data[5];
+  loop_data[0] = atoi(s_line + 1); // read line
+  loop_data[1] = atoi(s_col + 1); // read column
+  loop_data[2] = sched_type;
+  loop_data[3] = iterations;
+  loop_data[4] = chunk;
 
-    __itt_metadata_add(metadata_domain, __itt_null, string_handle_loop, __itt_metadata_u64, 5, loop_data);
+  __itt_metadata_add(metadata_domain, __itt_null, string_handle_loop,
+                     __itt_metadata_u64, 5, loop_data);
 #endif
 } // __kmp_itt_metadata_loop
 
-// -------------------------------------------------------------------------------------------------
-
-LINKAGE void
-__kmp_itt_metadata_single( ident_t * loc ) {
+// -----------------------------------------------------------------------------
+LINKAGE void __kmp_itt_metadata_single(ident_t *loc) {
 #if USE_ITT_NOTIFY
-    if( metadata_domain == NULL) {
-        __kmp_acquire_bootstrap_lock( & metadata_lock );
-        if( metadata_domain == NULL) {
-            __itt_suppress_push(__itt_suppress_memory_errors);
-            metadata_domain = __itt_domain_create( "OMP Metadata" );
-            string_handle_imbl = __itt_string_handle_create( "omp_metadata_imbalance");
-            string_handle_loop = __itt_string_handle_create( "omp_metadata_loop");
-            string_handle_sngl = __itt_string_handle_create( "omp_metadata_single");
-            __itt_suppress_pop();
-        }
-        __kmp_release_bootstrap_lock( & metadata_lock );
+  if (metadata_domain == NULL) {
+    __kmp_acquire_bootstrap_lock(&metadata_lock);
+    if (metadata_domain == NULL) {
+      __itt_suppress_push(__itt_suppress_memory_errors);
+      metadata_domain = __itt_domain_create("OMP Metadata");
+      string_handle_imbl = __itt_string_handle_create("omp_metadata_imbalance");
+      string_handle_loop = __itt_string_handle_create("omp_metadata_loop");
+      string_handle_sngl = __itt_string_handle_create("omp_metadata_single");
+      __itt_suppress_pop();
     }
+    __kmp_release_bootstrap_lock(&metadata_lock);
+  }
 
-    kmp_str_loc_t str_loc = __kmp_str_loc_init( loc->psource, 1 );
-    kmp_uint64 single_data[ 2 ];
-    single_data[ 0 ] = str_loc.line;
-    single_data[ 1 ] = str_loc.col;
+  kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
+  kmp_uint64 single_data[2];
+  single_data[0] = str_loc.line;
+  single_data[1] = str_loc.col;
 
-    __kmp_str_loc_free( &str_loc );
+  __kmp_str_loc_free(&str_loc);
 
-    __itt_metadata_add(metadata_domain, __itt_null, string_handle_sngl, __itt_metadata_u64, 2, single_data);
+  __itt_metadata_add(metadata_domain, __itt_null, string_handle_sngl,
+                     __itt_metadata_u64, 2, single_data);
 #endif
 } // __kmp_itt_metadata_single
 
-// -------------------------------------------------------------------------------------------------
-
-LINKAGE void
-__kmp_itt_region_starting( int gtid ) {
+// -----------------------------------------------------------------------------
+LINKAGE void __kmp_itt_region_starting(int gtid) {
 #if USE_ITT_NOTIFY
 #endif
 } // __kmp_itt_region_starting
 
-// -------------------------------------------------------------------------------------------------
-
-LINKAGE void
-__kmp_itt_region_finished( int gtid ) {
+// -----------------------------------------------------------------------------
+LINKAGE void __kmp_itt_region_finished(int gtid) {
 #if USE_ITT_NOTIFY
 #endif
 } // __kmp_itt_region_finished
 
-// -------------------------------------------------------------------------------------------------
-
-LINKAGE void
-__kmp_itt_region_joined( int gtid ) {
+// ----------------------------------------------------------------------------
+LINKAGE void __kmp_itt_region_joined(int gtid) {
 #if USE_ITT_NOTIFY
-    kmp_team_t *      team = __kmp_team_from_gtid( gtid );
-    if (team->t.t_active_level > 1)
-    {
-        // The frame notifications are only supported for the outermost teams.
-        return;
-    }
-    ident_t *         loc  = __kmp_thread_from_gtid( gtid )->th.th_ident;
-    if (loc && loc->reserved_2)
-    {
-        int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
-        if(frm < KMP_MAX_FRAME_DOMAINS) {
-            KMP_ITT_DEBUG_LOCK();
-            __itt_frame_end_v3(__kmp_itt_region_domains[frm], NULL);
-            KMP_ITT_DEBUG_PRINT( "[frm end] gtid=%d, idx=%x, loc:%p\n",
-                         gtid, loc->reserved_2, loc );
-        }
+  kmp_team_t *team = __kmp_team_from_gtid(gtid);
+  if (team->t.t_active_level > 1) {
+    // The frame notifications are only supported for the outermost teams.
+    return;
+  }
+  ident_t *loc = __kmp_thread_from_gtid(gtid)->th.th_ident;
+  if (loc && loc->reserved_2) {
+    int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
+    if (frm < KMP_MAX_FRAME_DOMAINS) {
+      KMP_ITT_DEBUG_LOCK();
+      __itt_frame_end_v3(__kmp_itt_region_domains[frm], NULL);
+      KMP_ITT_DEBUG_PRINT("[frm end] gtid=%d, idx=%x, loc:%p\n", gtid,
+                          loc->reserved_2, loc);
     }
+  }
 #endif
 } // __kmp_itt_region_joined
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Barriers reporting.
-
-    A barrier consists of two phases:
-
-        1. Gather -- master waits for arriving of all the worker threads; each worker thread
-           registers arrival and goes further.
-        2. Release -- each worker threads waits until master lets it go; master lets worker threads
-           go.
-
-    Function should be called by each thread:
-
-        * __kmp_itt_barrier_starting() -- before arriving to the gather phase.
-        * __kmp_itt_barrier_middle()   -- between gather and release phases.
-        * __kmp_itt_barrier_finished() -- after release phase.
-
-    Note: Call __kmp_itt_barrier_object() before call to __kmp_itt_barrier_starting() and save
-    result in local variable. __kmp_itt_barrier_object(), being called too late (e. g. after gather
-    phase) would return itt sync object for the next barrier!
-
-    ITT need an address (void *) to be specified as a sync object. OpenMP RTL does not have
-    barrier object or barrier data structure. Barrier is just a counter in team and thread
-    structures. We could use an address of team structure as an barrier sync object, but ITT wants
-    different objects for different barriers (even whithin the same team). So let us use
-    team address as barrier sync object for the first barrier, then increase it by one for the next
-    barrier, and so on (but wrap it not to use addresses outside of team structure).
-
-    ------------------------------------------------------------------------------------------------
-*/
-
-void *
-__kmp_itt_barrier_object(
-    int  gtid,
-    int  bt,
-    int  set_name,
-    int  delta    // 0 (current barrier) is default value; specify -1 to get previous barrier.
-) {
-    void * object = NULL;
-#if USE_ITT_NOTIFY
-    kmp_info_t *    thr  = __kmp_thread_from_gtid( gtid );
-    kmp_team_t *    team = thr->th.th_team;
-
-    // NOTE:
-    // If the function is called from __kmp_fork_barrier, team pointer can be NULL. This "if"
-    // helps to avoid crash. However, this is not complete solution, and reporting fork/join
-    // barriers to ITT should be revisited.
-
-    if ( team != NULL ) {
-
-        // Master thread increases b_arrived by KMP_BARRIER_STATE_BUMP each time. Divide b_arrived
-        // by KMP_BARRIER_STATE_BUMP to get plain barrier counter.
-        kmp_uint64 counter = team->t.t_bar[ bt ].b_arrived / KMP_BARRIER_STATE_BUMP + delta;
-        // Now form the barrier id. Encode barrier type (bt) in barrier id too, so barriers of
-        // different types do not have the same ids.
-        KMP_BUILD_ASSERT( sizeof( kmp_team_t ) >= bs_last_barrier );
-            // This conditon is a must (we would have zero divide otherwise).
-        KMP_BUILD_ASSERT( sizeof( kmp_team_t ) >= 2 * bs_last_barrier );
-            // More strong condition: make sure we have room at least for for two differtent ids
-            // (for each barrier type).
-        object =
-            reinterpret_cast< void * >(
-                kmp_uintptr_t( team )
-                    + counter % ( sizeof( kmp_team_t ) / bs_last_barrier ) * bs_last_barrier
-                    + bt
-            );
-        KMP_ITT_DEBUG_LOCK();
-        KMP_ITT_DEBUG_PRINT( "[bar obj] type=%d, counter=%lld, object=%p\n", bt, counter, object );
-
-        if ( set_name ) {
-            ident_t const * loc  = NULL;
-            char const *    src  = NULL;
-            char const *    type = "OMP Barrier";
-            switch ( bt ) {
-                case bs_plain_barrier : {
-                    // For plain barrier compiler calls __kmpc_barrier() function, which saves
-                    // location in thr->th.th_ident.
-                    loc = thr->th.th_ident;
-                    // Get the barrier type from flags provided by compiler.
-                    kmp_int32   expl = 0;
-                    kmp_uint32  impl = 0;
-                    if ( loc != NULL ) {
-                        src  = loc->psource;
-                        expl = ( loc->flags & KMP_IDENT_BARRIER_EXPL ) != 0;
-                        impl = ( loc->flags & KMP_IDENT_BARRIER_IMPL ) != 0;
-                    }; // if
-                    if ( impl ) {
-                        switch ( loc->flags & KMP_IDENT_BARRIER_IMPL_MASK ) {
-                            case KMP_IDENT_BARRIER_IMPL_FOR : {
-                                type = "OMP For Barrier";
-                            } break;
-                            case KMP_IDENT_BARRIER_IMPL_SECTIONS : {
-                                type = "OMP Sections Barrier";
-                            } break;
-                            case KMP_IDENT_BARRIER_IMPL_SINGLE : {
-                                type = "OMP Single Barrier";
-                            } break;
-                            case KMP_IDENT_BARRIER_IMPL_WORKSHARE : {
-                                type = "OMP Workshare Barrier";
-                            } break;
-                            default : {
-                                type = "OMP Implicit Barrier";
-                                KMP_DEBUG_ASSERT( 0 );
-                            };
-                        }; /* switch */
-                    } else if ( expl ) {
-                        type = "OMP Explicit Barrier";
-                    }; /* if */
-                } break;
-                case bs_forkjoin_barrier : {
-                    // In case of fork/join barrier we can read thr->th.th_ident, because it
-                    // contains location of last passed construct (while join barrier is not
-                    // such one). Use th_ident of master thread instead -- __kmp_join_call()
-                    // called by the master thread saves location.
-                    //
-                    // AC: cannot read from master because __kmp_join_call may be not called
-                    //    yet, so we read the location from team. This is the same location.
-                    //    And team is valid at the enter to join barrier where this happens.
-                    loc  = team->t.t_ident;
-                    if ( loc != NULL ) {
-                        src  = loc->psource;
-                    }; // if
-                    type = "OMP Join Barrier";
-                } break;
-            }; // switch
-            KMP_ITT_DEBUG_LOCK();
-            __itt_sync_create( object, type, src, __itt_attr_barrier );
-            KMP_ITT_DEBUG_PRINT( "[bar sta] scre( %p, \"%s\", \"%s\", __itt_attr_barrier )\n", object, type, src );
-        }; // if
+/* Barriers reporting.
 
+   A barrier consists of two phases:
+   1. Gather -- master waits for arriving of all the worker threads; each
+      worker thread registers arrival and goes further.
+   2. Release -- each worker threads waits until master lets it go; master lets
+      worker threads go.
+
+   Function should be called by each thread:
+   * __kmp_itt_barrier_starting() -- before arriving to the gather phase.
+   * __kmp_itt_barrier_middle()   -- between gather and release phases.
+   * __kmp_itt_barrier_finished() -- after release phase.
+
+   Note: Call __kmp_itt_barrier_object() before call to
+   __kmp_itt_barrier_starting() and save result in local variable.
+   __kmp_itt_barrier_object(), being called too late (e. g. after gather phase)
+   would return itt sync object for the next barrier!
+
+   ITT need an address (void *) to be specified as a sync object. OpenMP RTL
+   does not have barrier object or barrier data structure. Barrier is just a
+   counter in team and thread structures. We could use an address of team
+   structure as an barrier sync object, but ITT wants different objects for
+   different barriers (even whithin the same team). So let us use team address
+   as barrier sync object for the first barrier, then increase it by one for the
+   next barrier, and so on (but wrap it not to use addresses outside of team
+   structure). */
+
+void *__kmp_itt_barrier_object(int gtid, int bt, int set_name,
+                               int delta // 0 (current barrier) is default
+                               // value; specify -1 to get previous
+                               // barrier.
+                               ) {
+  void *object = NULL;
+#if USE_ITT_NOTIFY
+  kmp_info_t *thr = __kmp_thread_from_gtid(gtid);
+  kmp_team_t *team = thr->th.th_team;
+
+  // NOTE: If the function is called from __kmp_fork_barrier, team pointer can
+  // be NULL. This "if" helps to avoid crash. However, this is not complete
+  // solution, and reporting fork/join barriers to ITT should be revisited.
+
+  if (team != NULL) {
+    // Master thread increases b_arrived by KMP_BARRIER_STATE_BUMP each time.
+    // Divide b_arrived by KMP_BARRIER_STATE_BUMP to get plain barrier counter.
+    kmp_uint64 counter =
+        team->t.t_bar[bt].b_arrived / KMP_BARRIER_STATE_BUMP + delta;
+    // Now form the barrier id. Encode barrier type (bt) in barrier id too, so
+    // barriers of different types do not have the same ids.
+    KMP_BUILD_ASSERT(sizeof(kmp_team_t) >= bs_last_barrier);
+    // This conditon is a must (we would have zero divide otherwise).
+    KMP_BUILD_ASSERT(sizeof(kmp_team_t) >= 2 * bs_last_barrier);
+    // More strong condition: make sure we have room at least for for two
+    // differtent ids (for each barrier type).
+    object = reinterpret_cast<void *>(
+        kmp_uintptr_t(team) +
+        counter % (sizeof(kmp_team_t) / bs_last_barrier) * bs_last_barrier +
+        bt);
+    KMP_ITT_DEBUG_LOCK();
+    KMP_ITT_DEBUG_PRINT("[bar obj] type=%d, counter=%lld, object=%p\n", bt,
+                        counter, object);
+
+    if (set_name) {
+      ident_t const *loc = NULL;
+      char const *src = NULL;
+      char const *type = "OMP Barrier";
+      switch (bt) {
+      case bs_plain_barrier: {
+        // For plain barrier compiler calls __kmpc_barrier() function, which
+        // saves location in thr->th.th_ident.
+        loc = thr->th.th_ident;
+        // Get the barrier type from flags provided by compiler.
+        kmp_int32 expl = 0;
+        kmp_uint32 impl = 0;
+        if (loc != NULL) {
+          src = loc->psource;
+          expl = (loc->flags & KMP_IDENT_BARRIER_EXPL) != 0;
+          impl = (loc->flags & KMP_IDENT_BARRIER_IMPL) != 0;
+        }; // if
+        if (impl) {
+          switch (loc->flags & KMP_IDENT_BARRIER_IMPL_MASK) {
+          case KMP_IDENT_BARRIER_IMPL_FOR: {
+            type = "OMP For Barrier";
+          } break;
+          case KMP_IDENT_BARRIER_IMPL_SECTIONS: {
+            type = "OMP Sections Barrier";
+          } break;
+          case KMP_IDENT_BARRIER_IMPL_SINGLE: {
+            type = "OMP Single Barrier";
+          } break;
+          case KMP_IDENT_BARRIER_IMPL_WORKSHARE: {
+            type = "OMP Workshare Barrier";
+          } break;
+          default: {
+            type = "OMP Implicit Barrier";
+            KMP_DEBUG_ASSERT(0);
+          };
+          }; /* switch */
+        } else if (expl) {
+          type = "OMP Explicit Barrier";
+        }; /* if */
+      } break;
+      case bs_forkjoin_barrier: {
+        // In case of fork/join barrier we can read thr->th.th_ident, because it
+        // contains location of last passed construct (while join barrier is not
+        // such one). Use th_ident of master thread instead -- __kmp_join_call()
+        // called by the master thread saves location.
+        //
+        // AC: cannot read from master because __kmp_join_call may be not called
+        //    yet, so we read the location from team. This is the same location.
+        //    And team is valid at the enter to join barrier where this happens.
+        loc = team->t.t_ident;
+        if (loc != NULL) {
+          src = loc->psource;
+        }; // if
+        type = "OMP Join Barrier";
+      } break;
+      }; // switch
+      KMP_ITT_DEBUG_LOCK();
+      __itt_sync_create(object, type, src, __itt_attr_barrier);
+      KMP_ITT_DEBUG_PRINT(
+          "[bar sta] scre( %p, \"%s\", \"%s\", __itt_attr_barrier )\n", object,
+          type, src);
     }; // if
+
+  }; // if
 #endif
-    return object;
+  return object;
 } // __kmp_itt_barrier_object
 
-// -------------------------------------------------------------------------------------------------
-
-void
-__kmp_itt_barrier_starting( int gtid, void * object ) {
+// -----------------------------------------------------------------------------
+void __kmp_itt_barrier_starting(int gtid, void *object) {
 #if USE_ITT_NOTIFY
-    if ( !KMP_MASTER_GTID( gtid ) ) {
-        KMP_ITT_DEBUG_LOCK();
-        __itt_sync_releasing( object );
-        KMP_ITT_DEBUG_PRINT( "[bar sta] srel( %p )\n", object );
-    }; // if
+  if (!KMP_MASTER_GTID(gtid)) {
     KMP_ITT_DEBUG_LOCK();
-    __itt_sync_prepare( object );
-    KMP_ITT_DEBUG_PRINT( "[bar sta] spre( %p )\n", object );
+    __itt_sync_releasing(object);
+    KMP_ITT_DEBUG_PRINT("[bar sta] srel( %p )\n", object);
+  }; // if
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_prepare(object);
+  KMP_ITT_DEBUG_PRINT("[bar sta] spre( %p )\n", object);
 #endif
 } // __kmp_itt_barrier_starting
 
-// -------------------------------------------------------------------------------------------------
-
-void
-__kmp_itt_barrier_middle( int gtid, void * object ) {
+// -----------------------------------------------------------------------------
+void __kmp_itt_barrier_middle(int gtid, void *object) {
 #if USE_ITT_NOTIFY
-    if ( KMP_MASTER_GTID( gtid ) ) {
-        KMP_ITT_DEBUG_LOCK();
-        __itt_sync_acquired( object );
-        KMP_ITT_DEBUG_PRINT( "[bar mid] sacq( %p )\n", object );
-        KMP_ITT_DEBUG_LOCK();
-        __itt_sync_releasing( object );
-        KMP_ITT_DEBUG_PRINT( "[bar mid] srel( %p )\n", object );
-    } else {
-    }; // if
+  if (KMP_MASTER_GTID(gtid)) {
+    KMP_ITT_DEBUG_LOCK();
+    __itt_sync_acquired(object);
+    KMP_ITT_DEBUG_PRINT("[bar mid] sacq( %p )\n", object);
+    KMP_ITT_DEBUG_LOCK();
+    __itt_sync_releasing(object);
+    KMP_ITT_DEBUG_PRINT("[bar mid] srel( %p )\n", object);
+  } else {
+  }; // if
 #endif
 } // __kmp_itt_barrier_middle
 
-// -------------------------------------------------------------------------------------------------
-
-void
-__kmp_itt_barrier_finished( int gtid, void * object ) {
+// -----------------------------------------------------------------------------
+void __kmp_itt_barrier_finished(int gtid, void *object) {
 #if USE_ITT_NOTIFY
-    if ( KMP_MASTER_GTID( gtid ) ) {
-    } else {
-        KMP_ITT_DEBUG_LOCK();
-        __itt_sync_acquired( object );
-        KMP_ITT_DEBUG_PRINT( "[bar end] sacq( %p )\n", object );
-    }; // if
+  if (KMP_MASTER_GTID(gtid)) {
+  } else {
+    KMP_ITT_DEBUG_LOCK();
+    __itt_sync_acquired(object);
+    KMP_ITT_DEBUG_PRINT("[bar end] sacq( %p )\n", object);
+  }; // if
 #endif
 } // __kmp_itt_barrier_finished
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Taskwait reporting.
-
-    ITT need an address (void *) to be specified as a sync object. OpenMP RTL does not have taskwait
-    structure, so we need to construct something.
-
-*/
-
-void *
-__kmp_itt_taskwait_object( int gtid ) {
-    void * object = NULL;
-#if USE_ITT_NOTIFY
-    if ( __itt_sync_create_ptr ) {
-        kmp_info_t *     thread   = __kmp_thread_from_gtid( gtid );
-        kmp_taskdata_t * taskdata = thread -> th.th_current_task;
-        object =
-            reinterpret_cast< void * >(
-                kmp_uintptr_t( taskdata ) + taskdata->td_taskwait_counter % sizeof( kmp_taskdata_t )
-            );
-    }; // if
+/* Taskwait reporting.
+   ITT need an address (void *) to be specified as a sync object. OpenMP RTL
+   does not have taskwait structure, so we need to construct something. */
+
+void *__kmp_itt_taskwait_object(int gtid) {
+  void *object = NULL;
+#if USE_ITT_NOTIFY
+  if (__itt_sync_create_ptr) {
+    kmp_info_t *thread = __kmp_thread_from_gtid(gtid);
+    kmp_taskdata_t *taskdata = thread->th.th_current_task;
+    object = reinterpret_cast<void *>(kmp_uintptr_t(taskdata) +
+                                      taskdata->td_taskwait_counter %
+                                          sizeof(kmp_taskdata_t));
+  }; // if
 #endif
-    return object;
+  return object;
 } // __kmp_itt_taskwait_object
 
-void
-__kmp_itt_taskwait_starting(
-    int     gtid,
-    void *  object
-) {
-#if USE_ITT_NOTIFY
-    kmp_info_t *     thread   = __kmp_thread_from_gtid( gtid );
-    kmp_taskdata_t * taskdata = thread -> th.th_current_task;
-    ident_t const *  loc      = taskdata->td_taskwait_ident;
-    char const *     src      = ( loc == NULL? NULL : loc->psource );
-    KMP_ITT_DEBUG_LOCK();
-    __itt_sync_create( object, "OMP Taskwait", src, 0 );
-    KMP_ITT_DEBUG_PRINT( "[twa sta] scre( %p, \"OMP Taskwait\", \"%s\", 0 )\n", object, src );
-    KMP_ITT_DEBUG_LOCK();
-    __itt_sync_prepare( object );
-    KMP_ITT_DEBUG_PRINT( "[twa sta] spre( %p )\n", object );
+void __kmp_itt_taskwait_starting(int gtid, void *object) {
+#if USE_ITT_NOTIFY
+  kmp_info_t *thread = __kmp_thread_from_gtid(gtid);
+  kmp_taskdata_t *taskdata = thread->th.th_current_task;
+  ident_t const *loc = taskdata->td_taskwait_ident;
+  char const *src = (loc == NULL ? NULL : loc->psource);
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_create(object, "OMP Taskwait", src, 0);
+  KMP_ITT_DEBUG_PRINT("[twa sta] scre( %p, \"OMP Taskwait\", \"%s\", 0 )\n",
+                      object, src);
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_prepare(object);
+  KMP_ITT_DEBUG_PRINT("[twa sta] spre( %p )\n", object);
 #endif
 } // __kmp_itt_taskwait_starting
 
-void
-__kmp_itt_taskwait_finished(
-    int     gtid,
-    void *  object
-) {
+void __kmp_itt_taskwait_finished(int gtid, void *object) {
 #if USE_ITT_NOTIFY
-    KMP_ITT_DEBUG_LOCK();
-    __itt_sync_acquired( object );
-    KMP_ITT_DEBUG_PRINT( "[twa end] sacq( %p )\n", object );
-    KMP_ITT_DEBUG_LOCK();
-    __itt_sync_destroy( object );
-    KMP_ITT_DEBUG_PRINT( "[twa end] sdes( %p )\n", object );
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_acquired(object);
+  KMP_ITT_DEBUG_PRINT("[twa end] sacq( %p )\n", object);
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_destroy(object);
+  KMP_ITT_DEBUG_PRINT("[twa end] sdes( %p )\n", object);
 #endif
 } // __kmp_itt_taskwait_finished
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Task reporting.
-
-    Only those tasks are reported which are executed by a thread spinning at barrier (or taskwait).
-    Synch object passed to the function must be barrier of taskwait the threads waiting at.
-    ------------------------------------------------------------------------------------------------
-*/
-
-void
-__kmp_itt_task_starting(
-    void * object     // ITT sync object: barrier or taskwait.
-) {
-#if USE_ITT_NOTIFY
-    if ( object != NULL ) {
-        KMP_ITT_DEBUG_LOCK();
-        __itt_sync_cancel( object );
-        KMP_ITT_DEBUG_PRINT( "[tsk sta] scan( %p )\n", object );
-    }; // if
+/* Task reporting.
+   Only those tasks are reported which are executed by a thread spinning at
+   barrier (or taskwait). Synch object passed to the function must be barrier of
+   taskwait the threads waiting at. */
+
+void __kmp_itt_task_starting(
+    void *object // ITT sync object: barrier or taskwait.
+    ) {
+#if USE_ITT_NOTIFY
+  if (object != NULL) {
+    KMP_ITT_DEBUG_LOCK();
+    __itt_sync_cancel(object);
+    KMP_ITT_DEBUG_PRINT("[tsk sta] scan( %p )\n", object);
+  }; // if
 #endif
 } // __kmp_itt_task_starting
 
-// -------------------------------------------------------------------------------------------------
-
-void
-__kmp_itt_task_finished(
-    void * object     // ITT sync object: barrier or taskwait.
-) {
-#if USE_ITT_NOTIFY
-    KMP_ITT_DEBUG_LOCK();
-    __itt_sync_prepare( object );
-    KMP_ITT_DEBUG_PRINT( "[tsk end] spre( %p )\n", object );
+// -----------------------------------------------------------------------------
+void __kmp_itt_task_finished(
+    void *object // ITT sync object: barrier or taskwait.
+    ) {
+#if USE_ITT_NOTIFY
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_prepare(object);
+  KMP_ITT_DEBUG_PRINT("[tsk end] spre( %p )\n", object);
 #endif
 } // __kmp_itt_task_finished
 
-// -------------------------------------------------------------------------------------------------
-
-/*
-    ------------------------------------------------------------------------------------------------
-    Lock reporting.
-
-        * __kmp_itt_lock_creating( lock ) should be called *before* the first lock operation
-          (set/unset). It is not a real event shown to the user but just setting a name for
-          synchronization object. `lock' is an address of sync object, the same address should be
-          used in all subsequent calls.
-
-        * __kmp_itt_lock_acquiring() should be called before setting the lock.
-
-        * __kmp_itt_lock_acquired() should be called after setting the lock.
-
-        * __kmp_itt_lock_realeasing() should be called before unsetting the lock.
-
-        * __kmp_itt_lock_cancelled() should be called after thread cancelled waiting for the lock.
-
-        * __kmp_itt_lock_destroyed( lock ) should be called after the last lock operation. After
-          __kmp_itt_lock_destroyed() all the references to the same address will be considered
-          as another sync object, not related with the original one.
-    ------------------------------------------------------------------------------------------------
-*/
-
-// -------------------------------------------------------------------------------------------------
+/* Lock reporting.
+ * __kmp_itt_lock_creating( lock ) should be called *before* the first lock
+   operation (set/unset). It is not a real event shown to the user but just
+   setting a name for synchronization object. `lock' is an address of sync
+   object, the same address should be used in all subsequent calls.
+ * __kmp_itt_lock_acquiring() should be called before setting the lock.
+ * __kmp_itt_lock_acquired() should be called after setting the lock.
+ * __kmp_itt_lock_realeasing() should be called before unsetting the lock.
+ * __kmp_itt_lock_cancelled() should be called after thread cancelled waiting
+   for the lock.
+ * __kmp_itt_lock_destroyed( lock ) should be called after the last lock
+   operation. After __kmp_itt_lock_destroyed() all the references to the same
+   address will be considered as another sync object, not related with the
+   original one.  */
 
 #if KMP_USE_DYNAMIC_LOCK
 // Takes location information directly
-__kmp_inline
-void
-___kmp_itt_lock_init( kmp_user_lock_p lock, char const *type, const ident_t *loc ) {
-#if USE_ITT_NOTIFY
-    if ( __itt_sync_create_ptr ) {
-        char const *    src = ( loc == NULL ? NULL : loc->psource );
-        KMP_ITT_DEBUG_LOCK();
-        __itt_sync_create( lock, type, src, 0 );
-        KMP_ITT_DEBUG_PRINT( "[lck ini] scre( %p, \"%s\", \"%s\", 0 )\n", lock, type, src );
-    }
+__kmp_inline void ___kmp_itt_lock_init(kmp_user_lock_p lock, char const *type,
+                                       const ident_t *loc) {
+#if USE_ITT_NOTIFY
+  if (__itt_sync_create_ptr) {
+    char const *src = (loc == NULL ? NULL : loc->psource);
+    KMP_ITT_DEBUG_LOCK();
+    __itt_sync_create(lock, type, src, 0);
+    KMP_ITT_DEBUG_PRINT("[lck ini] scre( %p, \"%s\", \"%s\", 0 )\n", lock, type,
+                        src);
+  }
 #endif
 }
 #else // KMP_USE_DYNAMIC_LOCK
-// Internal guts -- common code for locks and critical sections, do not call directly.
-__kmp_inline
-void
-___kmp_itt_lock_init( kmp_user_lock_p lock, char const * type ) {
-#if USE_ITT_NOTIFY
-    if ( __itt_sync_create_ptr ) {
-        ident_t const * loc = NULL;
-        if ( __kmp_get_user_lock_location_ != NULL )
-            loc = __kmp_get_user_lock_location_( (lock) );
-        char const *    src = ( loc == NULL ? NULL : loc->psource );
-        KMP_ITT_DEBUG_LOCK();
-        __itt_sync_create( lock, type, src, 0 );
-        KMP_ITT_DEBUG_PRINT( "[lck ini] scre( %p, \"%s\", \"%s\", 0 )\n", lock, type, src );
-    }; // if
+// Internal guts -- common code for locks and critical sections, do not call
+// directly.
+__kmp_inline void ___kmp_itt_lock_init(kmp_user_lock_p lock, char const *type) {
+#if USE_ITT_NOTIFY
+  if (__itt_sync_create_ptr) {
+    ident_t const *loc = NULL;
+    if (__kmp_get_user_lock_location_ != NULL)
+      loc = __kmp_get_user_lock_location_((lock));
+    char const *src = (loc == NULL ? NULL : loc->psource);
+    KMP_ITT_DEBUG_LOCK();
+    __itt_sync_create(lock, type, src, 0);
+    KMP_ITT_DEBUG_PRINT("[lck ini] scre( %p, \"%s\", \"%s\", 0 )\n", lock, type,
+                        src);
+  }; // if
 #endif
 } // ___kmp_itt_lock_init
 #endif // KMP_USE_DYNAMIC_LOCK
 
-// Internal guts -- common code for locks and critical sections, do not call directly.
-__kmp_inline
-void
-___kmp_itt_lock_fini( kmp_user_lock_p lock, char const * type ) {
-#if USE_ITT_NOTIFY
-    KMP_ITT_DEBUG_LOCK();
-    __itt_sync_destroy( lock );
-    KMP_ITT_DEBUG_PRINT( "[lck dst] sdes( %p )\n", lock );
+// Internal guts -- common code for locks and critical sections, do not call
+// directly.
+__kmp_inline void ___kmp_itt_lock_fini(kmp_user_lock_p lock, char const *type) {
+#if USE_ITT_NOTIFY
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_destroy(lock);
+  KMP_ITT_DEBUG_PRINT("[lck dst] sdes( %p )\n", lock);
 #endif
 } // ___kmp_itt_lock_fini
 
-
-// -------------------------------------------------------------------------------------------------
-
+// -----------------------------------------------------------------------------
 #if KMP_USE_DYNAMIC_LOCK
-void
-__kmp_itt_lock_creating( kmp_user_lock_p lock, const ident_t *loc ) {
-    ___kmp_itt_lock_init( lock, "OMP Lock", loc );
+void __kmp_itt_lock_creating(kmp_user_lock_p lock, const ident_t *loc) {
+  ___kmp_itt_lock_init(lock, "OMP Lock", loc);
 }
 #else
-void
-__kmp_itt_lock_creating( kmp_user_lock_p lock ) {
-    ___kmp_itt_lock_init( lock, "OMP Lock" );
+void __kmp_itt_lock_creating(kmp_user_lock_p lock) {
+  ___kmp_itt_lock_init(lock, "OMP Lock");
 } // __kmp_itt_lock_creating
 #endif
 
-void
-__kmp_itt_lock_acquiring( kmp_user_lock_p lock ) {
+void __kmp_itt_lock_acquiring(kmp_user_lock_p lock) {
 #if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
-    // postpone lock object access
-    if ( __itt_sync_prepare_ptr ) {
-        if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
-            kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
-            __itt_sync_prepare( ilk->lock );
-        } else {
-            __itt_sync_prepare( lock );
-        }
+  // postpone lock object access
+  if (__itt_sync_prepare_ptr) {
+    if (KMP_EXTRACT_D_TAG(lock) == 0) {
+      kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
+      __itt_sync_prepare(ilk->lock);
+    } else {
+      __itt_sync_prepare(lock);
     }
+  }
 #else
-    __itt_sync_prepare( lock );
+  __itt_sync_prepare(lock);
 #endif
 } // __kmp_itt_lock_acquiring
 
-void
-__kmp_itt_lock_acquired( kmp_user_lock_p lock ) {
+void __kmp_itt_lock_acquired(kmp_user_lock_p lock) {
 #if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
-    // postpone lock object access
-    if ( __itt_sync_acquired_ptr ) {
-        if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
-            kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
-            __itt_sync_acquired( ilk->lock );
-        } else {
-            __itt_sync_acquired( lock );
-        }
+  // postpone lock object access
+  if (__itt_sync_acquired_ptr) {
+    if (KMP_EXTRACT_D_TAG(lock) == 0) {
+      kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
+      __itt_sync_acquired(ilk->lock);
+    } else {
+      __itt_sync_acquired(lock);
     }
+  }
 #else
-    __itt_sync_acquired( lock );
+  __itt_sync_acquired(lock);
 #endif
 } // __kmp_itt_lock_acquired
 
-void
-__kmp_itt_lock_releasing( kmp_user_lock_p lock ) {
+void __kmp_itt_lock_releasing(kmp_user_lock_p lock) {
 #if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
-    if ( __itt_sync_releasing_ptr ) {
-        if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
-            kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
-            __itt_sync_releasing( ilk->lock );
-        } else {
-            __itt_sync_releasing( lock );
-        }
+  if (__itt_sync_releasing_ptr) {
+    if (KMP_EXTRACT_D_TAG(lock) == 0) {
+      kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
+      __itt_sync_releasing(ilk->lock);
+    } else {
+      __itt_sync_releasing(lock);
     }
+  }
 #else
-    __itt_sync_releasing( lock );
+  __itt_sync_releasing(lock);
 #endif
 } // __kmp_itt_lock_releasing
 
-void
-__kmp_itt_lock_cancelled( kmp_user_lock_p lock ) {
+void __kmp_itt_lock_cancelled(kmp_user_lock_p lock) {
 #if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
-    if ( __itt_sync_cancel_ptr ) {
-        if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
-            kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
-            __itt_sync_cancel( ilk->lock );
-        } else {
-            __itt_sync_cancel( lock );
-        }
+  if (__itt_sync_cancel_ptr) {
+    if (KMP_EXTRACT_D_TAG(lock) == 0) {
+      kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
+      __itt_sync_cancel(ilk->lock);
+    } else {
+      __itt_sync_cancel(lock);
     }
+  }
 #else
-    __itt_sync_cancel( lock );
+  __itt_sync_cancel(lock);
 #endif
 } // __kmp_itt_lock_cancelled
 
-void
-__kmp_itt_lock_destroyed( kmp_user_lock_p lock ) {
-    ___kmp_itt_lock_fini( lock, "OMP Lock" );
+void __kmp_itt_lock_destroyed(kmp_user_lock_p lock) {
+  ___kmp_itt_lock_fini(lock, "OMP Lock");
 } // __kmp_itt_lock_destroyed
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Critical reporting.
-
-    Critical sections are treated exactly as locks (but have different object type).
-    ------------------------------------------------------------------------------------------------
-*/
+/* Critical reporting.
+   Critical sections are treated exactly as locks (but have different object
+   type). */
 #if KMP_USE_DYNAMIC_LOCK
-void
-__kmp_itt_critical_creating( kmp_user_lock_p lock, const ident_t *loc ) {
-    ___kmp_itt_lock_init( lock, "OMP Critical", loc);
+void __kmp_itt_critical_creating(kmp_user_lock_p lock, const ident_t *loc) {
+  ___kmp_itt_lock_init(lock, "OMP Critical", loc);
 }
 #else
-void
-__kmp_itt_critical_creating( kmp_user_lock_p lock ) {
-    ___kmp_itt_lock_init( lock, "OMP Critical" );
+void __kmp_itt_critical_creating(kmp_user_lock_p lock) {
+  ___kmp_itt_lock_init(lock, "OMP Critical");
 } // __kmp_itt_critical_creating
 #endif
 
-void
-__kmp_itt_critical_acquiring( kmp_user_lock_p lock ) {
-    __itt_sync_prepare( lock );
+void __kmp_itt_critical_acquiring(kmp_user_lock_p lock) {
+  __itt_sync_prepare(lock);
 } // __kmp_itt_critical_acquiring
 
-void
-__kmp_itt_critical_acquired( kmp_user_lock_p lock ) {
-    __itt_sync_acquired( lock );
+void __kmp_itt_critical_acquired(kmp_user_lock_p lock) {
+  __itt_sync_acquired(lock);
 } // __kmp_itt_critical_acquired
 
-void
-__kmp_itt_critical_releasing( kmp_user_lock_p lock ) {
-    __itt_sync_releasing( lock );
+void __kmp_itt_critical_releasing(kmp_user_lock_p lock) {
+  __itt_sync_releasing(lock);
 } // __kmp_itt_critical_releasing
 
-void
-__kmp_itt_critical_destroyed( kmp_user_lock_p lock ) {
-    ___kmp_itt_lock_fini( lock, "OMP Critical" );
+void __kmp_itt_critical_destroyed(kmp_user_lock_p lock) {
+  ___kmp_itt_lock_fini(lock, "OMP Critical");
 } // __kmp_itt_critical_destroyed
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Single reporting.
-    ------------------------------------------------------------------------------------------------
-*/
-
-void
-__kmp_itt_single_start( int gtid ) {
-#if USE_ITT_NOTIFY
-    if ( __itt_mark_create_ptr || KMP_ITT_DEBUG ) {
-        kmp_info_t *   thr = __kmp_thread_from_gtid( (gtid) );
-        ident_t *      loc = thr->th.th_ident;
-        char const *   src = ( loc == NULL ? NULL : loc->psource );
-        kmp_str_buf_t  name;
-        __kmp_str_buf_init( & name );
-        __kmp_str_buf_print( & name, "OMP Single-%s", src );
-        KMP_ITT_DEBUG_LOCK();
-        thr->th.th_itt_mark_single = __itt_mark_create( name.str );
-        KMP_ITT_DEBUG_PRINT( "[sin sta] mcre( \"%s\") -> %d\n", name.str, thr->th.th_itt_mark_single );
-        __kmp_str_buf_free( & name );
-        KMP_ITT_DEBUG_LOCK();
-        __itt_mark( thr->th.th_itt_mark_single, NULL );
-        KMP_ITT_DEBUG_PRINT( "[sin sta] mark( %d, NULL )\n", thr->th.th_itt_mark_single );
-    }; // if
+/* Single reporting. */
+
+void __kmp_itt_single_start(int gtid) {
+#if USE_ITT_NOTIFY
+  if (__itt_mark_create_ptr || KMP_ITT_DEBUG) {
+    kmp_info_t *thr = __kmp_thread_from_gtid((gtid));
+    ident_t *loc = thr->th.th_ident;
+    char const *src = (loc == NULL ? NULL : loc->psource);
+    kmp_str_buf_t name;
+    __kmp_str_buf_init(&name);
+    __kmp_str_buf_print(&name, "OMP Single-%s", src);
+    KMP_ITT_DEBUG_LOCK();
+    thr->th.th_itt_mark_single = __itt_mark_create(name.str);
+    KMP_ITT_DEBUG_PRINT("[sin sta] mcre( \"%s\") -> %d\n", name.str,
+                        thr->th.th_itt_mark_single);
+    __kmp_str_buf_free(&name);
+    KMP_ITT_DEBUG_LOCK();
+    __itt_mark(thr->th.th_itt_mark_single, NULL);
+    KMP_ITT_DEBUG_PRINT("[sin sta] mark( %d, NULL )\n",
+                        thr->th.th_itt_mark_single);
+  }; // if
 #endif
 } // __kmp_itt_single_start
 
-void
-__kmp_itt_single_end( int gtid ) {
+void __kmp_itt_single_end(int gtid) {
 #if USE_ITT_NOTIFY
-    __itt_mark_type  mark = __kmp_thread_from_gtid( gtid )->th.th_itt_mark_single;
-    KMP_ITT_DEBUG_LOCK();
-    __itt_mark_off( mark );
-    KMP_ITT_DEBUG_PRINT( "[sin end] moff( %d )\n", mark );
+  __itt_mark_type mark = __kmp_thread_from_gtid(gtid)->th.th_itt_mark_single;
+  KMP_ITT_DEBUG_LOCK();
+  __itt_mark_off(mark);
+  KMP_ITT_DEBUG_PRINT("[sin end] moff( %d )\n", mark);
 #endif
 } // __kmp_itt_single_end
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Ordered reporting.
-
-    __kmp_itt_ordered_init is called by each thread *before* first using sync
-    object. ITT team would like it to be called once, but it requires extra synchronization.
-
-    __kmp_itt_ordered_prep is called when thread is going to enter ordered section
-    (before synchronization).
-
-    __kmp_itt_ordered_start is called just before entering user code (after
-    synchronization).
-
-    __kmp_itt_ordered_end is called after returning from user code.
-
-    Sync object is th->th.th_dispatch->th_dispatch_sh_current.
-
-    Events are not generated in case of serialized team.
-    ------------------------------------------------------------------------------------------------
-*/
-
-void
-__kmp_itt_ordered_init( int gtid ) {
-#if USE_ITT_NOTIFY
-    if ( __itt_sync_create_ptr ) {
-        kmp_info_t *   thr   = __kmp_thread_from_gtid( gtid );
-        ident_t const * loc  = thr->th.th_ident;
-        char const *    src  = ( loc == NULL ? NULL : loc->psource );
-        __itt_sync_create(
-            thr->th.th_dispatch->th_dispatch_sh_current, "OMP Ordered", src, 0
-        );
-    }; // if
+/* Ordered reporting.
+ * __kmp_itt_ordered_init is called by each thread *before* first using sync
+   object. ITT team would like it to be called once, but it requires extra
+   synchronization.
+ * __kmp_itt_ordered_prep is called when thread is going to enter ordered
+   section (before synchronization).
+ * __kmp_itt_ordered_start is called just before entering user code (after
+   synchronization).
+ * __kmp_itt_ordered_end is called after returning from user code.
+
+ Sync object is th->th.th_dispatch->th_dispatch_sh_current.
+ Events are not generated in case of serialized team. */
+
+void __kmp_itt_ordered_init(int gtid) {
+#if USE_ITT_NOTIFY
+  if (__itt_sync_create_ptr) {
+    kmp_info_t *thr = __kmp_thread_from_gtid(gtid);
+    ident_t const *loc = thr->th.th_ident;
+    char const *src = (loc == NULL ? NULL : loc->psource);
+    __itt_sync_create(thr->th.th_dispatch->th_dispatch_sh_current,
+                      "OMP Ordered", src, 0);
+  }; // if
 #endif
 } // __kmp_itt_ordered_init
 
-void
-__kmp_itt_ordered_prep( int gtid ) {
+void __kmp_itt_ordered_prep(int gtid) {
 #if USE_ITT_NOTIFY
-    if ( __itt_sync_create_ptr ) {
-        kmp_team_t * t = __kmp_team_from_gtid( gtid );
-        if ( ! t->t.t_serialized ) {
-            kmp_info_t * th = __kmp_thread_from_gtid( gtid );
-            __itt_sync_prepare( th->th.th_dispatch->th_dispatch_sh_current );
-        }; // if
+  if (__itt_sync_create_ptr) {
+    kmp_team_t *t = __kmp_team_from_gtid(gtid);
+    if (!t->t.t_serialized) {
+      kmp_info_t *th = __kmp_thread_from_gtid(gtid);
+      __itt_sync_prepare(th->th.th_dispatch->th_dispatch_sh_current);
     }; // if
+  }; // if
 #endif
 } // __kmp_itt_ordered_prep
 
-void
-__kmp_itt_ordered_start( int gtid ) {
+void __kmp_itt_ordered_start(int gtid) {
 #if USE_ITT_NOTIFY
-    if ( __itt_sync_create_ptr ) {
-        kmp_team_t * t = __kmp_team_from_gtid( gtid );
-        if ( ! t->t.t_serialized ) {
-            kmp_info_t * th = __kmp_thread_from_gtid( gtid );
-            __itt_sync_acquired( th->th.th_dispatch->th_dispatch_sh_current );
-        }; // if
+  if (__itt_sync_create_ptr) {
+    kmp_team_t *t = __kmp_team_from_gtid(gtid);
+    if (!t->t.t_serialized) {
+      kmp_info_t *th = __kmp_thread_from_gtid(gtid);
+      __itt_sync_acquired(th->th.th_dispatch->th_dispatch_sh_current);
     }; // if
+  }; // if
 #endif
 } // __kmp_itt_ordered_start
 
-void
-__kmp_itt_ordered_end( int gtid ) {
+void __kmp_itt_ordered_end(int gtid) {
 #if USE_ITT_NOTIFY
-    if ( __itt_sync_create_ptr ) {
-        kmp_team_t * t = __kmp_team_from_gtid( gtid );
-        if ( ! t->t.t_serialized ) {
-            kmp_info_t * th = __kmp_thread_from_gtid( gtid );
-            __itt_sync_releasing( th->th.th_dispatch->th_dispatch_sh_current );
-        }; // if
+  if (__itt_sync_create_ptr) {
+    kmp_team_t *t = __kmp_team_from_gtid(gtid);
+    if (!t->t.t_serialized) {
+      kmp_info_t *th = __kmp_thread_from_gtid(gtid);
+      __itt_sync_releasing(th->th.th_dispatch->th_dispatch_sh_current);
     }; // if
+  }; // if
 #endif
 } // __kmp_itt_ordered_end
 
+/* Threads reporting. */
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Threads reporting.
-    ------------------------------------------------------------------------------------------------
-*/
-
-void
-__kmp_itt_thread_ignore() {
-    __itt_thr_ignore();
+void __kmp_itt_thread_ignore() {
+  __itt_thr_ignore();
 } // __kmp_itt_thread_ignore
 
-void
-__kmp_itt_thread_name( int gtid ) {
+void __kmp_itt_thread_name(int gtid) {
 #if USE_ITT_NOTIFY
-    if ( __itt_thr_name_set_ptr ) {
-        kmp_str_buf_t name;
-        __kmp_str_buf_init( & name );
-        if( KMP_MASTER_GTID(gtid) ) {
-            __kmp_str_buf_print( & name, "OMP Master Thread #%d", gtid );
-        } else {
-            __kmp_str_buf_print( & name, "OMP Worker Thread #%d", gtid );
-        }
-        KMP_ITT_DEBUG_LOCK();
-        __itt_thr_name_set( name.str, name.used );
-        KMP_ITT_DEBUG_PRINT( "[thr nam] name( \"%s\")\n", name.str );
-        __kmp_str_buf_free( & name );
-    }; // if
+  if (__itt_thr_name_set_ptr) {
+    kmp_str_buf_t name;
+    __kmp_str_buf_init(&name);
+    if (KMP_MASTER_GTID(gtid)) {
+      __kmp_str_buf_print(&name, "OMP Master Thread #%d", gtid);
+    } else {
+      __kmp_str_buf_print(&name, "OMP Worker Thread #%d", gtid);
+    }
+    KMP_ITT_DEBUG_LOCK();
+    __itt_thr_name_set(name.str, name.used);
+    KMP_ITT_DEBUG_PRINT("[thr nam] name( \"%s\")\n", name.str);
+    __kmp_str_buf_free(&name);
+  }; // if
 #endif
 } // __kmp_itt_thread_name
 
-
-/*
-    --------------------------------------------------------------------------
-    System object reporting.
-
-    ITT catches operations with system sync objects (like Windows* OS on IA-32
-    architecture API critical sections and events). We only need to specify
-    name ("OMP Scheduler") for the object to let ITT know it is an object used
-    by OpenMP RTL for internal purposes.
-    --------------------------------------------------------------------------
-*/
-
-void
-__kmp_itt_system_object_created( void * object, char const * name ) {
-#if USE_ITT_NOTIFY
-    KMP_ITT_DEBUG_LOCK();
-    __itt_sync_create( object, "OMP Scheduler", name, 0 );
-   KMP_ITT_DEBUG_PRINT( "[sys obj] scre( %p, \"OMP Scheduler\", \"%s\", 0 )\n", object, name );
+/* System object reporting.
+   ITT catches operations with system sync objects (like Windows* OS on IA-32
+   architecture API critical sections and events). We only need to specify
+   name ("OMP Scheduler") for the object to let ITT know it is an object used
+   by OpenMP RTL for internal purposes. */
+
+void __kmp_itt_system_object_created(void *object, char const *name) {
+#if USE_ITT_NOTIFY
+  KMP_ITT_DEBUG_LOCK();
+  __itt_sync_create(object, "OMP Scheduler", name, 0);
+  KMP_ITT_DEBUG_PRINT("[sys obj] scre( %p, \"OMP Scheduler\", \"%s\", 0 )\n",
+                      object, name);
 #endif
 } // __kmp_itt_system_object_created
 
+/* Stack stitching api.
+   Master calls "create" and put the stitching id into team structure.
+   Workers read the stitching id and call "enter" / "leave" api.
+   Master calls "destroy" at the end of the parallel region. */
 
-/*
-    ------------------------------------------------------------------------------------------------
-    Stack stitching api.
-
-    Master calls "create" and put the stitching id into team structure.
-    Workers read the stitching id and call "enter" / "leave" api.
-    Master calls "destroy" at the end of the parallel region.
-    ------------------------------------------------------------------------------------------------
-*/
-
-__itt_caller
-__kmp_itt_stack_caller_create()
-{
+__itt_caller __kmp_itt_stack_caller_create() {
 #if USE_ITT_NOTIFY
-    if ( !__itt_stack_caller_create_ptr )
-        return NULL;
-    KMP_ITT_DEBUG_LOCK();
-    __itt_caller id = __itt_stack_caller_create();
-    KMP_ITT_DEBUG_PRINT( "[stk cre] %p\n", id );
-    return id;
-#endif
+  if (!__itt_stack_caller_create_ptr)
     return NULL;
+  KMP_ITT_DEBUG_LOCK();
+  __itt_caller id = __itt_stack_caller_create();
+  KMP_ITT_DEBUG_PRINT("[stk cre] %p\n", id);
+  return id;
+#endif
+  return NULL;
 }
 
-void
-__kmp_itt_stack_caller_destroy( __itt_caller id )
-{
-#if USE_ITT_NOTIFY
-    if ( __itt_stack_caller_destroy_ptr ) {
-        KMP_ITT_DEBUG_LOCK();
-        __itt_stack_caller_destroy( id );
-        KMP_ITT_DEBUG_PRINT( "[stk des] %p\n", id );
-    }
+void __kmp_itt_stack_caller_destroy(__itt_caller id) {
+#if USE_ITT_NOTIFY
+  if (__itt_stack_caller_destroy_ptr) {
+    KMP_ITT_DEBUG_LOCK();
+    __itt_stack_caller_destroy(id);
+    KMP_ITT_DEBUG_PRINT("[stk des] %p\n", id);
+  }
 #endif
 }
 
-void
-__kmp_itt_stack_callee_enter( __itt_caller id )
-{
-#if USE_ITT_NOTIFY
-    if ( __itt_stack_callee_enter_ptr ) {
-        KMP_ITT_DEBUG_LOCK();
-        __itt_stack_callee_enter( id );
-        KMP_ITT_DEBUG_PRINT( "[stk ent] %p\n", id );
-    }
+void __kmp_itt_stack_callee_enter(__itt_caller id) {
+#if USE_ITT_NOTIFY
+  if (__itt_stack_callee_enter_ptr) {
+    KMP_ITT_DEBUG_LOCK();
+    __itt_stack_callee_enter(id);
+    KMP_ITT_DEBUG_PRINT("[stk ent] %p\n", id);
+  }
 #endif
 }
 
-void
-__kmp_itt_stack_callee_leave( __itt_caller id )
-{
-#if USE_ITT_NOTIFY
-    if ( __itt_stack_callee_leave_ptr ) {
-        KMP_ITT_DEBUG_LOCK();
-        __itt_stack_callee_leave( id );
-        KMP_ITT_DEBUG_PRINT( "[stk lea] %p\n", id );
-    }
+void __kmp_itt_stack_callee_leave(__itt_caller id) {
+#if USE_ITT_NOTIFY
+  if (__itt_stack_callee_leave_ptr) {
+    KMP_ITT_DEBUG_LOCK();
+    __itt_stack_callee_leave(id);
+    KMP_ITT_DEBUG_PRINT("[stk lea] %p\n", id);
+  }
 #endif
 }
 




More information about the Openmp-commits mailing list