[Openmp-commits] [openmp] r319379 - Make kmp_r_sched_t into a union

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 29 14:47:52 PST 2017


Author: jlpeyton
Date: Wed Nov 29 14:47:52 2017
New Revision: 319379

URL: http://llvm.org/viewvc/llvm-project?rev=319379&view=rev
Log:
Make kmp_r_sched_t into a union

This change makes kmp_r_sched_t type into a union for simpler
comparisons and assignments

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D40374

Modified:
    openmp/trunk/runtime/src/kmp.h
    openmp/trunk/runtime/src/kmp_runtime.cpp

Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=319379&r1=319378&r2=319379&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Wed Nov 29 14:47:52 2017
@@ -314,7 +314,7 @@ typedef enum kmp_sched {
  @ingroup WORK_SHARING
  * Describes the loop schedule to be used for a parallel for loop.
  */
-enum sched_type {
+enum sched_type : kmp_int32 {
   kmp_sch_lower = 32, /**< lower bound for unordered values */
   kmp_sch_static_chunked = 33,
   kmp_sch_static = 34, /**< static unspecialized */
@@ -433,9 +433,12 @@ enum sched_type {
 };
 
 /* Type to keep runtime schedule set via OMP_SCHEDULE or omp_set_schedule() */
-typedef struct kmp_r_sched {
-  enum sched_type r_sched_type;
-  int chunk;
+typedef union kmp_r_sched {
+  struct {
+    enum sched_type r_sched_type;
+    int chunk;
+  };
+  kmp_int64 sched;
 } kmp_r_sched_t;
 
 extern enum sched_type __kmp_sch_map[]; // map OMP 3.0 schedule types with our

Modified: openmp/trunk/runtime/src/kmp_runtime.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_runtime.cpp?rev=319379&r1=319378&r2=319379&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_runtime.cpp (original)
+++ openmp/trunk/runtime/src/kmp_runtime.cpp Wed Nov 29 14:47:52 2017
@@ -1268,7 +1268,7 @@ void __kmp_serialized_parallel(ident_t *
     serial_team->t.t_serialized = 1;
     serial_team->t.t_nproc = 1;
     serial_team->t.t_parent = this_thr->th.th_team;
-    serial_team->t.t_sched = this_thr->th.th_team->t.t_sched;
+    serial_team->t.t_sched.sched = this_thr->th.th_team->t.t_sched.sched;
     this_thr->th.th_team = serial_team;
     serial_team->t.t_master_tid = this_thr->th.th_info.ds.ds_tid;
 
@@ -2061,10 +2061,8 @@ int __kmp_fork_call(ident_t *loc, int gt
     }
 #endif /* OMP_40_ENABLED */
     kmp_r_sched_t new_sched = get__sched_2(parent_team, master_tid);
-    if (team->t.t_sched.r_sched_type != new_sched.r_sched_type ||
-        team->t.t_sched.chunk != new_sched.chunk)
-      team->t.t_sched =
-          new_sched; // set master's schedule as new run-time schedule
+    // set master's schedule as new run-time schedule
+    KMP_CHECK_UPDATE(team->t.t_sched.sched, new_sched.sched);
 
 #if OMP_40_ENABLED
     KMP_CHECK_UPDATE(team->t.t_cancel_request, cancel_noreq);
@@ -2966,18 +2964,17 @@ kmp_r_sched_t __kmp_get_schedule_global(
   // KMP_SCHEDULE multiple times, and thus have different run-time schedules in
   // different roots (even in OMP 2.5)
   if (__kmp_sched == kmp_sch_static) {
-    r_sched.r_sched_type = __kmp_static; // replace STATIC with more detailed
-    // schedule (balanced or greedy)
+    // replace STATIC with more detailed schedule (balanced or greedy)
+    r_sched.r_sched_type = __kmp_static;
   } else if (__kmp_sched == kmp_sch_guided_chunked) {
-    r_sched.r_sched_type = __kmp_guided; // replace GUIDED with more detailed
-    // schedule (iterative or analytical)
-  } else {
-    r_sched.r_sched_type =
-        __kmp_sched; // (STATIC_CHUNKED), or (DYNAMIC_CHUNKED), or other
+    // replace GUIDED with more detailed schedule (iterative or analytical)
+    r_sched.r_sched_type = __kmp_guided;
+  } else { // (STATIC_CHUNKED), or (DYNAMIC_CHUNKED), or other
+    r_sched.r_sched_type = __kmp_sched;
   }
 
-  if (__kmp_chunk < KMP_DEFAULT_CHUNK) { // __kmp_chunk may be wrong here (if it
-    // was not ever set)
+  if (__kmp_chunk < KMP_DEFAULT_CHUNK) {
+    // __kmp_chunk may be wrong here (if it was not ever set)
     r_sched.chunk = KMP_DEFAULT_CHUNK;
   } else {
     r_sched.chunk = __kmp_chunk;
@@ -3193,8 +3190,7 @@ static void __kmp_initialize_root(kmp_ro
   root_team->t.t_nproc = 1;
   root_team->t.t_serialized = 1;
   // TODO???: root_team->t.t_max_active_levels = __kmp_dflt_max_active_levels;
-  root_team->t.t_sched.r_sched_type = r_sched.r_sched_type;
-  root_team->t.t_sched.chunk = r_sched.chunk;
+  root_team->t.t_sched.sched = r_sched.sched;
   KA_TRACE(
       20,
       ("__kmp_initialize_root: init root team %d arrived: join=%u, plain=%u\n",
@@ -3233,8 +3229,7 @@ static void __kmp_initialize_root(kmp_ro
   }
   hot_team->t.t_nproc = 1;
   // TODO???: hot_team->t.t_max_active_levels = __kmp_dflt_max_active_levels;
-  hot_team->t.t_sched.r_sched_type = r_sched.r_sched_type;
-  hot_team->t.t_sched.chunk = r_sched.chunk;
+  hot_team->t.t_sched.sched = r_sched.sched;
   hot_team->t.t_size_changed = 0;
 }
 
@@ -4473,7 +4468,7 @@ static void __kmp_initialize_team(kmp_te
   team->t.t_invoke = NULL; /* not needed */
 
   // TODO???: team->t.t_max_active_levels       = new_max_active_levels;
-  team->t.t_sched = new_icvs->sched;
+  team->t.t_sched.sched = new_icvs->sched.sched;
 
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
   team->t.t_fp_control_saved = FALSE; /* not needed */
@@ -4928,10 +4923,8 @@ __kmp_allocate_team(kmp_root_t *root, in
 
       // TODO???: team->t.t_max_active_levels = new_max_active_levels;
       kmp_r_sched_t new_sched = new_icvs->sched;
-      if (team->t.t_sched.r_sched_type != new_sched.r_sched_type ||
-          team->t.t_sched.chunk != new_sched.chunk)
-        team->t.t_sched =
-            new_sched; // set master's schedule as new run-time schedule
+      // set master's schedule as new run-time schedule
+      KMP_CHECK_UPDATE(team->t.t_sched.sched, new_sched.sched);
 
       __kmp_reinitialize_team(team, new_icvs,
                               root->r.r_uber_thread->th.th_ident);
@@ -5003,9 +4996,7 @@ __kmp_allocate_team(kmp_root_t *root, in
 #endif // KMP_NESTED_HOT_TEAMS
       team->t.t_nproc = new_nproc;
       // TODO???: team->t.t_max_active_levels = new_max_active_levels;
-      if (team->t.t_sched.r_sched_type != new_icvs->sched.r_sched_type ||
-          team->t.t_sched.chunk != new_icvs->sched.chunk)
-        team->t.t_sched = new_icvs->sched;
+      KMP_CHECK_UPDATE(team->t.t_sched.sched, new_icvs->sched.sched);
       __kmp_reinitialize_team(team, new_icvs,
                               root->r.r_uber_thread->th.th_ident);
 




More information about the Openmp-commits mailing list