@@ -3639,37 +3639,15 @@ int __kmp_register_root(int initial_thread) {
3639
3639
}
3640
3640
}
3641
3641
3642
- // When hidden helper task is enabled, __kmp_threads is organized as follows:
3643
- // 0: initial thread, also a regular OpenMP thread.
3644
- // [1, __kmp_hidden_helper_threads_num]: slots for hidden helper threads.
3645
- // [__kmp_hidden_helper_threads_num + 1, __kmp_threads_capacity): slots for
3646
- // regular OpenMP threads.
3647
- if (TCR_4 (__kmp_init_hidden_helper_threads)) {
3648
- // Find an available thread slot for hidden helper thread. Slots for hidden
3649
- // helper threads start from 1 to __kmp_hidden_helper_threads_num.
3650
- for (gtid = 1 ; TCR_PTR (__kmp_threads[gtid]) != NULL &&
3651
- gtid <= __kmp_hidden_helper_threads_num;
3652
- gtid++)
3653
- ;
3654
- KMP_ASSERT (gtid <= __kmp_hidden_helper_threads_num);
3655
- KA_TRACE (1 , (" __kmp_register_root: found slot in threads array for "
3656
- " hidden helper thread: T#%d\n " ,
3657
- gtid));
3658
- } else {
3659
- /* find an available thread slot */
3660
- // Don't reassign the zero slot since we need that to only be used by
3661
- // initial thread. Slots for hidden helper threads should also be skipped.
3662
- if (initial_thread && __kmp_threads[0 ] == NULL ) {
3663
- gtid = 0 ;
3664
- } else {
3665
- for (gtid = __kmp_hidden_helper_threads_num + 1 ;
3666
- TCR_PTR (__kmp_threads[gtid]) != NULL ; gtid++)
3667
- ;
3668
- }
3669
- KA_TRACE (
3670
- 1 , (" __kmp_register_root: found slot in threads array: T#%d\n " , gtid));
3671
- KMP_ASSERT (gtid < __kmp_threads_capacity);
3672
- }
3642
+ /* find an available thread slot */
3643
+ /* Don't reassign the zero slot since we need that to only be used by initial
3644
+ thread */
3645
+ for (gtid = (initial_thread ? 0 : 1 ); TCR_PTR (__kmp_threads[gtid]) != NULL ;
3646
+ gtid++)
3647
+ ;
3648
+ KA_TRACE (1 ,
3649
+ (" __kmp_register_root: found slot in threads array: T#%d\n " , gtid));
3650
+ KMP_ASSERT (gtid < __kmp_threads_capacity);
3673
3651
3674
3652
/* update global accounting */
3675
3653
__kmp_all_nth++;
@@ -4320,20 +4298,8 @@ kmp_info_t *__kmp_allocate_thread(kmp_root_t *root, kmp_team_t *team,
4320
4298
#endif
4321
4299
4322
4300
KMP_MB ();
4323
-
4324
- {
4325
- int new_start_gtid = TCR_4 (__kmp_init_hidden_helper_threads)
4326
- ? 1
4327
- : __kmp_hidden_helper_threads_num + 1 ;
4328
-
4329
- for (new_gtid = new_start_gtid; TCR_PTR (__kmp_threads[new_gtid]) != NULL ;
4330
- ++new_gtid) {
4331
- KMP_DEBUG_ASSERT (new_gtid < __kmp_threads_capacity);
4332
- }
4333
-
4334
- if (TCR_4 (__kmp_init_hidden_helper_threads)) {
4335
- KMP_DEBUG_ASSERT (new_gtid <= __kmp_hidden_helper_threads_num);
4336
- }
4301
+ for (new_gtid = 1 ; TCR_PTR (__kmp_threads[new_gtid]) != NULL ; ++new_gtid) {
4302
+ KMP_DEBUG_ASSERT (new_gtid < __kmp_threads_capacity);
4337
4303
}
4338
4304
4339
4305
/* allocate space for it. */
@@ -6267,15 +6233,6 @@ void __kmp_internal_end_thread(int gtid_req) {
6267
6233
return ;
6268
6234
}
6269
6235
6270
- // If hidden helper team has been initialized, we need to deinit it
6271
- if (TCR_4 (__kmp_init_hidden_helper)) {
6272
- TCW_SYNC_4 (__kmp_hidden_helper_team_done, TRUE );
6273
- // First release the main thread to let it continue its work
6274
- __kmp_hidden_helper_main_thread_release ();
6275
- // Wait until the hidden helper team has been destroyed
6276
- __kmp_hidden_helper_threads_deinitz_wait ();
6277
- }
6278
-
6279
6236
KMP_MB (); /* Flush all pending memory write invalidates. */
6280
6237
6281
6238
/* find out who we are and what we should do */
@@ -7152,41 +7109,6 @@ void __kmp_parallel_initialize(void) {
7152
7109
__kmp_release_bootstrap_lock (&__kmp_initz_lock);
7153
7110
}
7154
7111
7155
- void __kmp_hidden_helper_initialize () {
7156
- if (TCR_4 (__kmp_init_hidden_helper))
7157
- return ;
7158
-
7159
- // __kmp_parallel_initialize is required before we initialize hidden helper
7160
- if (!TCR_4 (__kmp_init_parallel))
7161
- __kmp_parallel_initialize ();
7162
-
7163
- // Double check. Note that this double check should not be placed before
7164
- // __kmp_parallel_initialize as it will cause dead lock.
7165
- __kmp_acquire_bootstrap_lock (&__kmp_initz_lock);
7166
- if (TCR_4 (__kmp_init_hidden_helper)) {
7167
- __kmp_release_bootstrap_lock (&__kmp_initz_lock);
7168
- return ;
7169
- }
7170
-
7171
- // Set the count of hidden helper tasks to be executed to zero
7172
- KMP_ATOMIC_ST_REL (&__kmp_unexecuted_hidden_helper_tasks, 0 );
7173
-
7174
- // Set the global variable indicating that we're initializing hidden helper
7175
- // team/threads
7176
- TCW_SYNC_4 (__kmp_init_hidden_helper_threads, TRUE );
7177
-
7178
- // Platform independent initialization
7179
- __kmp_do_initialize_hidden_helper_threads ();
7180
-
7181
- // Wait here for the finish of initialization of hidden helper teams
7182
- __kmp_hidden_helper_threads_initz_wait ();
7183
-
7184
- // We have finished hidden helper initialization
7185
- TCW_SYNC_4 (__kmp_init_hidden_helper, TRUE );
7186
-
7187
- __kmp_release_bootstrap_lock (&__kmp_initz_lock);
7188
- }
7189
-
7190
7112
/* ------------------------------------------------------------------------ */
7191
7113
7192
7114
void __kmp_run_before_invoked_task (int gtid, int tid, kmp_info_t *this_thr,
@@ -8532,62 +8454,11 @@ int __kmp_pause_resource(kmp_pause_status_t level) {
8532
8454
}
8533
8455
}
8534
8456
8457
+
8535
8458
void __kmp_omp_display_env (int verbose) {
8536
8459
__kmp_acquire_bootstrap_lock (&__kmp_initz_lock);
8537
8460
if (__kmp_init_serial == 0 )
8538
8461
__kmp_do_serial_initialize ();
8539
8462
__kmp_display_env_impl (!verbose, verbose);
8540
8463
__kmp_release_bootstrap_lock (&__kmp_initz_lock);
8541
8464
}
8542
-
8543
- // Globals and functions for hidden helper task
8544
- kmp_info_t **__kmp_hidden_helper_threads;
8545
- kmp_info_t *__kmp_hidden_helper_main_thread;
8546
- kmp_int32 __kmp_hidden_helper_threads_num = 8 ;
8547
- std::atomic<kmp_int32> __kmp_unexecuted_hidden_helper_tasks;
8548
- kmp_int32 __kmp_enable_hidden_helper = TRUE ;
8549
-
8550
- namespace {
8551
- std::atomic<kmp_int32> __kmp_hit_hidden_helper_threads_num;
8552
-
8553
- void __kmp_hidden_helper_wrapper_fn (int *gtid, int *, ...) {
8554
- // This is an explicit synchronization on all hidden helper threads in case
8555
- // that when a regular thread pushes a hidden helper task to one hidden
8556
- // helper thread, the thread has not been awaken once since they're released
8557
- // by the main thread after creating the team.
8558
- KMP_ATOMIC_INC (&__kmp_hit_hidden_helper_threads_num);
8559
- while (KMP_ATOMIC_LD_ACQ (&__kmp_hit_hidden_helper_threads_num) !=
8560
- __kmp_hidden_helper_threads_num)
8561
- ;
8562
-
8563
- // If main thread, then wait for signal
8564
- if (__kmpc_master (nullptr , *gtid)) {
8565
- // First, unset the initial state and release the initial thread
8566
- TCW_4 (__kmp_init_hidden_helper_threads, FALSE );
8567
- __kmp_hidden_helper_initz_release ();
8568
- __kmp_hidden_helper_main_thread_wait ();
8569
- // Now wake up all worker threads
8570
- for (int i = 1 ; i < __kmp_hit_hidden_helper_threads_num; ++i) {
8571
- __kmp_hidden_helper_worker_thread_signal ();
8572
- }
8573
- }
8574
- }
8575
- } // namespace
8576
-
8577
- void __kmp_hidden_helper_threads_initz_routine () {
8578
- // Create a new root for hidden helper team/threads
8579
- const int gtid = __kmp_register_root (TRUE );
8580
- __kmp_hidden_helper_main_thread = __kmp_threads[gtid];
8581
- __kmp_hidden_helper_threads = &__kmp_threads[gtid];
8582
- __kmp_hidden_helper_main_thread->th .th_set_nproc =
8583
- __kmp_hidden_helper_threads_num;
8584
-
8585
- KMP_ATOMIC_ST_REL (&__kmp_hit_hidden_helper_threads_num, 0 );
8586
-
8587
- __kmpc_fork_call (nullptr , 0 , __kmp_hidden_helper_wrapper_fn);
8588
-
8589
- // Set the initialization flag to FALSE
8590
- TCW_SYNC_4 (__kmp_init_hidden_helper, FALSE );
8591
-
8592
- __kmp_hidden_helper_threads_deinitz_release ();
8593
- }
0 commit comments