[Openmp-commits] [openmp] r249725 - Formatting/Whitespace/Comment changes associated with wait/release improvements.

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Oct 8 12:44:16 PDT 2015


Author: jlpeyton
Date: Thu Oct  8 14:44:16 2015
New Revision: 249725

URL: http://llvm.org/viewvc/llvm-project?rev=249725&view=rev
Log:
Formatting/Whitespace/Comment changes associated with wait/release improvements.

Modified:
    openmp/trunk/runtime/src/kmp_barrier.cpp
    openmp/trunk/runtime/src/kmp_global.c
    openmp/trunk/runtime/src/kmp_runtime.c
    openmp/trunk/runtime/src/kmp_tasking.c
    openmp/trunk/runtime/src/kmp_wait_release.h
    openmp/trunk/runtime/src/z_Linux_util.c

Modified: openmp/trunk/runtime/src/kmp_barrier.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_barrier.cpp?rev=249725&r1=249724&r2=249725&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_barrier.cpp (original)
+++ openmp/trunk/runtime/src/kmp_barrier.cpp Thu Oct  8 14:44:16 2015
@@ -461,7 +461,7 @@ __kmp_hyper_barrier_gather(enum barrier_
                a worker thread may not assume that the team is valid any more - it could be
                deallocated by the master thread at any time.  */
             p_flag.set_waiter(other_threads[parent_tid]);
-	    p_flag.release();
+            p_flag.release();
             break;
         }
 

Modified: openmp/trunk/runtime/src/kmp_global.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_global.c?rev=249725&r1=249724&r2=249725&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_global.c (original)
+++ openmp/trunk/runtime/src/kmp_global.c Thu Oct  8 14:44:16 2015
@@ -103,8 +103,7 @@ char const *__kmp_barrier_type_name
                                     , "reduction"
                                 #endif // KMP_FAST_REDUCTION_BARRIER
                             };
-char const *__kmp_barrier_pattern_name [ bp_last_bar ] = { "linear", "tree", "hyper", "hierarchical" };
-
+char const *__kmp_barrier_pattern_name[bp_last_bar] = {"linear","tree","hyper","hierarchical"};
 
 int       __kmp_allThreadsSpecified = 0;
 size_t    __kmp_align_alloc = CACHE_LINE;

Modified: openmp/trunk/runtime/src/kmp_runtime.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_runtime.c?rev=249725&r1=249724&r2=249725&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_runtime.c (original)
+++ openmp/trunk/runtime/src/kmp_runtime.c Thu Oct  8 14:44:16 2015
@@ -5096,14 +5096,12 @@ __kmp_allocate_team( kmp_root_t *root, i
             /* reinitialize the threads */
             KMP_DEBUG_ASSERT(team->t.t_nproc == new_nproc);
             if (level) {
-                for( f = 0  ;  f < team->t.t_nproc  ;  f++ ) {
-                    __kmp_initialize_info( team->t.t_threads[ f ], team, f,
-                                           __kmp_gtid_from_tid( f, team ) );
-                }
+                for (f=0;  f < team->t.t_nproc; ++f)
+                    __kmp_initialize_info( team->t.t_threads[ f ], team, f, __kmp_gtid_from_tid( f, team ) );
             }
             else {
                 int old_state = team->t.t_threads[0]->th.th_task_state;
-                for (f=0;  f < team->t.t_nproc; ++f) {
+                for (f=0;  f<team->t.t_nproc; ++f) {
                     __kmp_initialize_info( team->t.t_threads[ f ], team, f, __kmp_gtid_from_tid( f, team ) );
                     team->t.t_threads[f]->th.th_task_state = old_state;
                     team->t.t_threads[f]->th.th_task_team = team->t.t_task_team[old_state];
@@ -6495,7 +6493,7 @@ __kmp_do_serial_initialize( void )
 #if KMP_ARCH_X86_64 && (KMP_OS_LINUX || KMP_OS_WINDOWS)
     if( __kmp_mic_type != non_mic ) {
         // AC: plane=3,2, forkjoin=2,1 are optimal for 240 threads on KNC
-        __kmp_barrier_gather_branch_bits [ bs_plain_barrier ] = 3;  // plane gather
+        __kmp_barrier_gather_branch_bits [ bs_plain_barrier ] = 3;  // plain gather
         __kmp_barrier_release_branch_bits[ bs_forkjoin_barrier ] = 1;  // forkjoin release
         __kmp_barrier_gather_pattern [ bs_forkjoin_barrier ] = bp_hierarchical_bar;
         __kmp_barrier_release_pattern[ bs_forkjoin_barrier ] = bp_hierarchical_bar;

Modified: openmp/trunk/runtime/src/kmp_tasking.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.c?rev=249725&r1=249724&r2=249725&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_tasking.c (original)
+++ openmp/trunk/runtime/src/kmp_tasking.c Thu Oct  8 14:44:16 2015
@@ -1328,7 +1328,7 @@ __kmpc_omp_taskwait( ident_t *loc_ref, k
 #else
         if ( ! taskdata->td_flags.team_serial ) 
 #endif
-	{
+        {
             // GEH: if team serialized, avoid reading the volatile variable below.
             kmp_flag_32 flag(&(taskdata->td_incomplete_child_tasks), 0U);
             while ( TCR_4(taskdata -> td_incomplete_child_tasks) != 0 ) {
@@ -1457,7 +1457,7 @@ __kmpc_end_taskgroup( ident_t* loc, int
 #else
         if ( ! taskdata->td_flags.team_serial ) 
 #endif
-	{
+        {
             kmp_flag_32 flag(&(taskgroup->count), 0U);
             while ( TCR_4(taskgroup->count) != 0 ) {
                 flag.execute_tasks(thread, gtid, FALSE, &thread_finished
@@ -1831,7 +1831,7 @@ static inline int __kmp_execute_tasks_te
 #else
         if (final_spin) 
 #endif
-	{
+        {
             // First, decrement the #unfinished threads, if that has not already
             // been done.  This decrement might be to the spin location, and
             // result in the termination condition being satisfied.
@@ -1874,8 +1874,8 @@ static inline int __kmp_execute_tasks_te
 
         // There is a slight chance that __kmp_enable_tasking() did not wake up
         // all threads waiting at the barrier.  If this thread is sleeping, then
-        // then wake it up.  Since we weree going to pay the cache miss penalty
-        // for referenceing another thread's kmp_info_t struct anyway, the check
+        // wake it up.  Since we were going to pay the cache miss penalty
+        // for referencing another thread's kmp_info_t struct anyway, the check
         // shouldn't cost too much performance at this point.
         // In extra barrier mode, tasks do not sleep at the separate tasking
         // barrier, so this isn't a problem.
@@ -1886,7 +1886,7 @@ static inline int __kmp_execute_tasks_te
             __kmp_null_resume_wrapper(__kmp_gtid_from_thread(other_thread), other_thread->th.th_sleep_loc);
             // A sleeping thread should not have any tasks on it's queue.
             // There is a slight possibility that it resumes, steals a task from
-            // another thread, which spawns more tasks, all in the that it takes
+            // another thread, which spawns more tasks, all in the time that it takes
             // this thread to check => don't write an assertion that the victim's
             // queue is empty.  Try stealing from a different thread.
             goto new_victim;
@@ -1946,7 +1946,7 @@ static inline int __kmp_execute_tasks_te
 #else
         if (final_spin) 
 #endif
-	{
+        {
             // First, decrement the #unfinished threads, if that has not already
             // been done.  This decrement might be to the spin location, and
             // result in the termination condition being satisfied.
@@ -2227,8 +2227,8 @@ __kmp_realloc_task_threads_data( kmp_inf
                             __kmp_allocate( nthreads * sizeof(kmp_thread_data_t) );
                 // copy old data to new data
                 KMP_MEMCPY_S( (void *) new_data, nthreads * sizeof(kmp_thread_data_t),
-			(void *) old_data, 
-                        maxthreads * sizeof(kmp_taskdata_t *) );
+                              (void *) old_data,
+                              maxthreads * sizeof(kmp_taskdata_t *) );
 
 #ifdef BUILD_TIED_TASK_STACK
                 // GEH: Figure out if this is the right thing to do
@@ -2589,9 +2589,9 @@ __kmp_task_team_sync( kmp_info_t *this_t
 }
 
 
-//------------------------------------------------------------------------------
-// __kmp_task_team_wait: Master thread waits for outstanding tasks after the
-// barrier gather phase.  Only called by master thread if #threads in team > 1 or if proxy tasks were created
+//--------------------------------------------------------------------------------------------
+// __kmp_task_team_wait: Master thread waits for outstanding tasks after the barrier gather
+// phase.  Only called by master thread if #threads in team > 1 or if proxy tasks were created
 void
 __kmp_task_team_wait( kmp_info_t *this_thr, kmp_team_t *team
                       USE_ITT_BUILD_ARG(void * itt_sync_obj)
@@ -2633,12 +2633,11 @@ __kmp_task_team_wait( kmp_info_t *this_t
 
 //------------------------------------------------------------------------------
 // __kmp_tasking_barrier:
+// This routine may only called when __kmp_tasking_mode == tskm_extra_barrier.
 // Internal function to execute all tasks prior to a regular barrier or a
 // join barrier.  It is a full barrier itself, which unfortunately turns
 // regular barriers into double barriers and join barriers into 1 1/2
 // barriers.
-// This routine may only called when __kmp_tasking_mode == tskm_extra_barrier.
-
 void
 __kmp_tasking_barrier( kmp_team_t *team, kmp_info_t *thread, int gtid )
 {

Modified: openmp/trunk/runtime/src/kmp_wait_release.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_wait_release.h?rev=249725&r1=249724&r2=249725&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_wait_release.h (original)
+++ openmp/trunk/runtime/src/kmp_wait_release.h Thu Oct  8 14:44:16 2015
@@ -160,6 +160,7 @@ static inline void __kmp_wait_template(k
                       th_gtid, __kmp_global.g.g_time.dt.t_value, hibernate,
                       hibernate - __kmp_global.g.g_time.dt.t_value));
     }
+
     KMP_MB();
 
     // Main wait spin loop
@@ -338,7 +339,7 @@ class kmp_basic_flag : public kmp_flag<F
     FlagType checker;  /**< Value to compare flag to to check if flag has been released. */
     kmp_info_t * waiting_threads[1];  /**< Array of threads sleeping on this thread. */
     kmp_uint32 num_waiting_threads;       /**< Number of threads sleeping on this thread. */
-public:
+ public:
     kmp_basic_flag(volatile FlagType *p) : kmp_flag<FlagType>(p, traits_type::t), num_waiting_threads(0) {}
     kmp_basic_flag(volatile FlagType *p, kmp_info_t *thr) : kmp_flag<FlagType>(p, traits_type::t), num_waiting_threads(1) {
         waiting_threads[0] = thr; 
@@ -418,7 +419,7 @@ public:
 };
 
 class kmp_flag_32 : public kmp_basic_flag<kmp_uint32> {
-public:
+ public:
     kmp_flag_32(volatile kmp_uint32 *p) : kmp_basic_flag<kmp_uint32>(p) {}
     kmp_flag_32(volatile kmp_uint32 *p, kmp_info_t *thr) : kmp_basic_flag<kmp_uint32>(p, thr) {}
     kmp_flag_32(volatile kmp_uint32 *p, kmp_uint32 c) : kmp_basic_flag<kmp_uint32>(p, c) {}
@@ -438,7 +439,7 @@ public:
 };
 
 class kmp_flag_64 : public kmp_basic_flag<kmp_uint64> {
-public:
+ public:
     kmp_flag_64(volatile kmp_uint64 *p) : kmp_basic_flag<kmp_uint64>(p) {}
     kmp_flag_64(volatile kmp_uint64 *p, kmp_info_t *thr) : kmp_basic_flag<kmp_uint64>(p, thr) {}
     kmp_flag_64(volatile kmp_uint64 *p, kmp_uint64 c) : kmp_basic_flag<kmp_uint64>(p, c) {}
@@ -480,29 +481,29 @@ public:
 #if USE_ITT_BUILD
                     , void *itt
 #endif
-                    ) 
+                    )
         : kmp_flag<kmp_uint64>(p, flag_oncore), checker(c), num_waiting_threads(0), offset(idx),
           flag_switch(false), bt(bar_t), this_thr(thr)
 #if USE_ITT_BUILD
         , itt_sync_obj(itt)
 #endif
         {}
-    kmp_info_t * get_waiter(kmp_uint32 i) { 
+    kmp_info_t * get_waiter(kmp_uint32 i) {
         KMP_DEBUG_ASSERT(i<num_waiting_threads);
-        return waiting_threads[i]; 
+        return waiting_threads[i];
     }
     kmp_uint32 get_num_waiters() { return num_waiting_threads; }
-    void set_waiter(kmp_info_t *thr) { 
-        waiting_threads[0] = thr; 
+    void set_waiter(kmp_info_t *thr) {
+        waiting_threads[0] = thr;
         num_waiting_threads = 1;
     }
     bool done_check_val(kmp_uint64 old_loc) { return byteref(&old_loc,offset) == checker; }
     bool done_check() { return done_check_val(*get()); }
-    bool notdone_check() { 
+    bool notdone_check() {
         // Calculate flag_switch
         if (this_thr->th.th_bar[bt].bb.wait_flag == KMP_BARRIER_SWITCH_TO_OWN_FLAG)
             flag_switch = true;
-        if (byteref(get(),offset) != 1 && !flag_switch) 
+        if (byteref(get(),offset) != 1 && !flag_switch)
             return true;
         else if (flag_switch) {
             this_thr->th.th_bar[bt].bb.wait_flag = KMP_BARRIER_SWITCHING;
@@ -525,10 +526,10 @@ public:
             (void) KMP_TEST_THEN_OR64((volatile kmp_int64 *)get(), mask);
         }
     }
-    kmp_uint64 set_sleeping() { 
+    kmp_uint64 set_sleeping() {
         return KMP_TEST_THEN_OR64((kmp_int64 volatile *)get(), KMP_BARRIER_SLEEP_STATE);
     }
-    kmp_uint64 unset_sleeping() { 
+    kmp_uint64 unset_sleeping() {
         return KMP_TEST_THEN_AND64((kmp_int64 volatile *)get(), ~KMP_BARRIER_SLEEP_STATE);
     }
     bool is_sleeping_val(kmp_uint64 old_loc) { return old_loc & KMP_BARRIER_SLEEP_STATE; }
@@ -544,12 +545,13 @@ public:
     int execute_tasks(kmp_info_t *this_thr, kmp_int32 gtid, int final_spin, int *thread_finished
                       USE_ITT_BUILD_ARG(void * itt_sync_obj), kmp_int32 is_constrained) {
         return __kmp_execute_tasks_oncore(this_thr, gtid, this, final_spin, thread_finished
-                                      USE_ITT_BUILD_ARG(itt_sync_obj), is_constrained);
+                                          USE_ITT_BUILD_ARG(itt_sync_obj), is_constrained);
     }
     kmp_uint8 *get_stolen() { return NULL; }
     enum barrier_type get_bt() { return bt; }
 };
 
+
 /*!
 @}
 */

Modified: openmp/trunk/runtime/src/z_Linux_util.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/z_Linux_util.c?rev=249725&r1=249724&r2=249725&view=diff
==============================================================================
--- openmp/trunk/runtime/src/z_Linux_util.c (original)
+++ openmp/trunk/runtime/src/z_Linux_util.c Thu Oct  8 14:44:16 2015
@@ -1757,8 +1757,7 @@ static inline void __kmp_suspend_templat
             status = pthread_cond_timedwait( &th->th.th_suspend_cv.c_cond, &th->th.th_suspend_mx.m_mutex, & now );
 #else
             KF_TRACE( 15, ( "__kmp_suspend_template: T#%d about to perform pthread_cond_wait\n",
-                               th_gtid ) );
-
+                            th_gtid ) );
             status = pthread_cond_wait( &th->th.th_suspend_cv.c_cond, &th->th.th_suspend_mx.m_mutex );
 #endif
 
@@ -1849,7 +1848,7 @@ static inline void __kmp_resume_template
         KMP_CHECK_SYSFAIL( "pthread_mutex_unlock", status );
         return;
     }
-    else {
+    else { // if multiple threads are sleeping, flag should be internally referring to a specific thread here
         typename C::flag_t old_spin = flag->unset_sleeping();
         if ( ! flag->is_sleeping_val(old_spin) ) {
             KF_TRACE( 5, ( "__kmp_resume_template: T#%d exiting, thread T#%d already awake: flag(%p): "




More information about the Openmp-commits mailing list