41 #include "kmp_error.h"
43 #define MAX_MESSAGE 512
64 if (__kmp_ignore_mppbeg() == FALSE) {
65 __kmp_internal_begin();
67 KC_TRACE( 10, (
"__kmpc_begin: called\n" ) );
85 if (__kmp_ignore_mppend() == FALSE) {
86 KC_TRACE( 10, (
"__kmpc_end: called\n" ) );
87 KA_TRACE( 30, (
"__kmpc_end\n" ));
89 __kmp_internal_end_thread( -1 );
115 kmp_int32 gtid = __kmp_entry_gtid();
117 KC_TRACE( 10, (
"__kmpc_global_thread_num: T#%d\n", gtid ) );
138 KC_TRACE( 10, (
"__kmpc_global_num_threads: num_threads = %d\n", __kmp_nth ) );
140 return TCR_4(__kmp_nth);
152 KC_TRACE( 10, (
"__kmpc_bound_thread_num: called\n" ) );
153 return __kmp_tid_from_gtid( __kmp_entry_gtid() );
164 KC_TRACE( 10, (
"__kmpc_bound_num_threads: called\n" ) );
166 return __kmp_entry_thread() -> th.th_team -> t.t_nproc;
188 if (__kmp_par_range == 0) {
195 semi2 = strchr(semi2,
';');
199 semi2 = strchr(semi2 + 1,
';');
203 if (__kmp_par_range_filename[0]) {
204 const char *name = semi2 - 1;
205 while ((name > loc->
psource) && (*name !=
'/') && (*name !=
';')) {
208 if ((*name ==
'/') || (*name ==
';')) {
211 if (strncmp(__kmp_par_range_filename, name, semi2 - name)) {
212 return __kmp_par_range < 0;
215 semi3 = strchr(semi2 + 1,
';');
216 if (__kmp_par_range_routine[0]) {
217 if ((semi3 != NULL) && (semi3 > semi2)
218 && (strncmp(__kmp_par_range_routine, semi2 + 1, semi3 - semi2 - 1))) {
219 return __kmp_par_range < 0;
222 if (sscanf(semi3 + 1,
"%d", &line_no) == 1) {
223 if ((line_no >= __kmp_par_range_lb) && (line_no <= __kmp_par_range_ub)) {
224 return __kmp_par_range > 0;
226 return __kmp_par_range < 0;
242 return __kmp_entry_thread() -> th.th_root -> r.r_active;
257 KA_TRACE( 20, (
"__kmpc_push_num_threads: enter T#%d num_threads=%d\n",
258 global_tid, num_threads ) );
260 __kmp_push_num_threads( loc, global_tid, num_threads );
264 __kmpc_pop_num_threads(
ident_t *loc, kmp_int32 global_tid )
266 KA_TRACE( 20, (
"__kmpc_pop_num_threads: enter\n" ) );
275 __kmpc_push_proc_bind(
ident_t *loc, kmp_int32 global_tid, kmp_int32 proc_bind )
277 KA_TRACE( 20, (
"__kmpc_push_proc_bind: enter T#%d proc_bind=%d\n",
278 global_tid, proc_bind ) );
280 __kmp_push_proc_bind( loc, global_tid, (kmp_proc_bind_t)proc_bind );
298 int gtid = __kmp_entry_gtid();
302 va_start( ap, microtask );
304 __kmp_fork_call( loc, gtid, TRUE,
306 VOLATILE_CAST(microtask_t) microtask,
307 VOLATILE_CAST(launch_t) __kmp_invoke_task_func,
309 #
if KMP_ARCH_X86_64 && KMP_OS_LINUX
315 __kmp_join_call( loc, gtid );
335 KA_TRACE( 20, (
"__kmpc_push_num_teams: enter T#%d num_teams=%d num_threads=%d\n",
336 global_tid, num_teams, num_threads ) );
338 __kmp_push_num_teams( loc, global_tid, num_teams, num_threads );
353 int gtid = __kmp_entry_gtid();
354 kmp_info_t *this_thr = __kmp_threads[ gtid ];
356 va_start( ap, microtask );
359 this_thr->th.th_team_microtask = microtask;
360 this_thr->th.th_teams_level = this_thr->th.th_team->t.t_level;
363 if ( this_thr->th.th_set_nth_teams == 0 ) {
364 __kmp_push_num_teams( loc, gtid, 0, 0 );
366 KMP_DEBUG_ASSERT(this_thr->th.th_set_nproc >= 1);
367 KMP_DEBUG_ASSERT(this_thr->th.th_set_nth_teams >= 1);
369 __kmp_fork_call( loc, gtid, TRUE,
371 VOLATILE_CAST(microtask_t) __kmp_teams_master,
372 VOLATILE_CAST(launch_t) __kmp_invoke_teams_master,
373 #
if KMP_ARCH_X86_64 && KMP_OS_LINUX
379 __kmp_join_call( loc, gtid );
380 this_thr->th.th_team_microtask = NULL;
381 this_thr->th.th_teams_level = 0;
395 __kmpc_invoke_task_func(
int gtid )
397 return __kmp_invoke_task_func( gtid );
415 kmp_info_t *this_thr;
416 kmp_team_t *serial_team;
418 KC_TRACE( 10, (
"__kmpc_serialized_parallel: called by T#%d\n", global_tid ) );
425 if( ! TCR_4( __kmp_init_parallel ) )
426 __kmp_parallel_initialize();
428 this_thr = __kmp_threads[ global_tid ];
429 serial_team = this_thr -> th.th_serial_team;
432 KMP_DEBUG_ASSERT( serial_team );
436 if ( __kmp_tasking_mode != tskm_immediate_exec ) {
437 KMP_DEBUG_ASSERT( this_thr -> th.th_task_team == this_thr -> th.th_team -> t.t_task_team );
438 KMP_DEBUG_ASSERT( serial_team -> t.t_task_team == NULL );
439 KA_TRACE( 20, (
"__kmpc_serialized_parallel: T#%d pushing task_team %p / team %p, new task_team = NULL\n",
440 global_tid, this_thr -> th.th_task_team, this_thr -> th.th_team ) );
441 this_thr -> th.th_task_team = NULL;
443 #endif // OMP_30_ENABLED
446 kmp_proc_bind_t proc_bind = this_thr->th.th_set_proc_bind;
447 if ( this_thr->th.th_current_task->td_icvs.proc_bind == proc_bind_false ) {
448 proc_bind = proc_bind_false;
450 else if ( proc_bind == proc_bind_default ) {
455 proc_bind = this_thr->th.th_current_task->td_icvs.proc_bind;
460 this_thr->th.th_set_proc_bind = proc_bind_default;
463 if( this_thr -> th.th_team != serial_team ) {
466 int level = this_thr->th.th_team->t.t_level;
468 if( serial_team -> t.t_serialized ) {
471 kmp_team_t *new_team;
472 int tid = this_thr->th.th_info.ds.ds_tid;
474 __kmp_acquire_bootstrap_lock( &__kmp_forkjoin_lock );
476 new_team = __kmp_allocate_team(this_thr->th.th_root, 1, 1,
481 & this_thr->th.th_current_task->td_icvs,
483 this_thr->th.th_team->t.t_set_nproc[tid],
484 this_thr->th.th_team->t.t_set_dynamic[tid],
485 this_thr->th.th_team->t.t_set_nested[tid],
486 this_thr->th.th_team->t.t_set_blocktime[tid],
487 this_thr->th.th_team->t.t_set_bt_intervals[tid],
488 this_thr->th.th_team->t.t_set_bt_set[tid],
491 __kmp_release_bootstrap_lock( &__kmp_forkjoin_lock );
492 KMP_ASSERT( new_team );
495 new_team -> t.t_threads[0] = this_thr;
496 new_team -> t.t_parent = this_thr -> th.th_team;
497 serial_team = new_team;
498 this_thr -> th.th_serial_team = serial_team;
500 KF_TRACE( 10, (
"__kmpc_serialized_parallel: T#%d allocated new serial team %p\n",
501 global_tid, serial_team ) );
508 KF_TRACE( 10, (
"__kmpc_serialized_parallel: T#%d reusing cached serial team %p\n",
509 global_tid, serial_team ) );
513 KMP_DEBUG_ASSERT( serial_team->t.t_threads );
514 KMP_DEBUG_ASSERT( serial_team->t.t_threads[0] == this_thr );
515 KMP_DEBUG_ASSERT( this_thr->th.th_team != serial_team );
516 serial_team -> t.t_ident = loc;
517 serial_team -> t.t_serialized = 1;
518 serial_team -> t.t_nproc = 1;
519 serial_team -> t.t_parent = this_thr->th.th_team;
521 serial_team -> t.t_sched = this_thr->th.th_team->t.t_sched;
522 #endif // OMP_30_ENABLED
523 this_thr -> th.th_team = serial_team;
524 serial_team -> t.t_master_tid = this_thr->th.th_info.ds.ds_tid;
527 KF_TRACE( 10, (
"__kmpc_serialized_parallel: T#d curtask=%p\n",
528 global_tid, this_thr->th.th_current_task ) );
529 KMP_ASSERT( this_thr->th.th_current_task->td_flags.executing == 1 );
530 this_thr->th.th_current_task->td_flags.executing = 0;
532 __kmp_push_current_task_to_thread( this_thr, serial_team, 0 );
537 & this_thr->th.th_current_task->td_icvs,
538 & this_thr->th.th_current_task->td_parent->td_icvs );
541 if ( __kmp_nested_nth.used && ( level + 1 < __kmp_nested_nth.used ) ) {
542 this_thr->th.th_current_task->td_icvs.nproc = __kmp_nested_nth.nth[ level + 1 ];
546 if ( __kmp_nested_proc_bind.used && ( level + 1 < __kmp_nested_proc_bind.used ) ) {
547 this_thr->th.th_current_task->td_icvs.proc_bind
548 = __kmp_nested_proc_bind.bind_types[ level + 1 ];
553 serial_team -> t.t_set_nproc[0] = serial_team->t.t_parent->
554 t.t_set_nproc[serial_team->
556 serial_team -> t.t_set_dynamic[0] = serial_team->t.t_parent->
557 t.t_set_dynamic[serial_team->
559 serial_team -> t.t_set_nested[0] = serial_team->t.t_parent->
560 t.t_set_nested[serial_team->
562 serial_team -> t.t_set_blocktime[0] = serial_team->t.t_parent->
563 t.t_set_blocktime[serial_team->
565 serial_team -> t.t_set_bt_intervals[0] = serial_team->t.t_parent->
566 t.t_set_bt_intervals[serial_team->
568 serial_team -> t.t_set_bt_set[0] = serial_team->t.t_parent->
569 t.t_set_bt_set[serial_team->
571 #endif // OMP_30_ENABLED
572 this_thr -> th.th_info.ds.ds_tid = 0;
575 this_thr -> th.th_team_nproc = 1;
576 this_thr -> th.th_team_master = this_thr;
577 this_thr -> th.th_team_serialized = 1;
580 serial_team -> t.t_level = serial_team -> t.t_parent -> t.t_level + 1;
581 serial_team -> t.t_active_level = serial_team -> t.t_parent -> t.t_active_level;
582 #endif // OMP_30_ENABLED
584 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
585 if ( __kmp_inherit_fp_control ) {
586 __kmp_store_x87_fpu_control_word( &serial_team->t.t_x87_fpu_control_word );
587 __kmp_store_mxcsr( &serial_team->t.t_mxcsr );
588 serial_team->t.t_mxcsr &= KMP_X86_MXCSR_MASK;
589 serial_team->t.t_fp_control_saved = TRUE;
591 serial_team->t.t_fp_control_saved = FALSE;
595 KMP_DEBUG_ASSERT(serial_team->t.t_dispatch);
596 if ( !serial_team->t.t_dispatch->th_disp_buffer ) {
597 serial_team->t.t_dispatch->th_disp_buffer = (dispatch_private_info_t *)
598 __kmp_allocate(
sizeof( dispatch_private_info_t ) );
600 this_thr -> th.th_dispatch = serial_team->t.t_dispatch;
607 KMP_DEBUG_ASSERT( this_thr->th.th_team == serial_team );
608 KMP_DEBUG_ASSERT( serial_team -> t.t_threads );
609 KMP_DEBUG_ASSERT( serial_team -> t.t_threads[0] == this_thr );
610 ++ serial_team -> t.t_serialized;
611 this_thr -> th.th_team_serialized = serial_team -> t.t_serialized;
615 int level = this_thr->th.th_team->t.t_level;
617 if ( __kmp_nested_nth.used && ( level + 1 < __kmp_nested_nth.used ) ) {
618 this_thr->th.th_current_task->td_icvs.nproc = __kmp_nested_nth.nth[ level + 1 ];
620 serial_team -> t.t_level++;
621 KF_TRACE( 10, (
"__kmpc_serialized_parallel: T#%d increasing nesting level of serial team %p to %d\n",
622 global_tid, serial_team, serial_team -> t.t_level ) );
624 KF_TRACE( 10, (
"__kmpc_serialized_parallel: T#%d reusing team %p for nested serialized parallel region\n",
625 global_tid, serial_team ) );
626 #endif // OMP_30_ENABLED
629 KMP_DEBUG_ASSERT(serial_team->t.t_dispatch);
631 dispatch_private_info_t * disp_buffer = (dispatch_private_info_t *)
632 __kmp_allocate(
sizeof( dispatch_private_info_t ) );
633 disp_buffer->next = serial_team->t.t_dispatch->th_disp_buffer;
634 serial_team->t.t_dispatch->th_disp_buffer = disp_buffer;
636 this_thr -> th.th_dispatch = serial_team->t.t_dispatch;
641 if ( __kmp_env_consistency_check )
642 __kmp_push_parallel( global_tid, NULL );
646 if ( ( __itt_frame_begin_v3_ptr && __kmp_forkjoin_frames ) || KMP_ITT_DEBUG )
648 __kmp_itt_region_forking( global_tid, 1 );
664 kmp_internal_control_t *top;
665 kmp_info_t *this_thr;
666 kmp_team_t *serial_team;
668 KC_TRACE( 10, (
"__kmpc_end_serialized_parallel: called by T#%d\n", global_tid ) );
676 if( ! TCR_4( __kmp_init_parallel ) )
677 __kmp_parallel_initialize();
679 this_thr = __kmp_threads[ global_tid ];
680 serial_team = this_thr->th.th_serial_team;
683 KMP_DEBUG_ASSERT( serial_team );
684 KMP_ASSERT( serial_team -> t.t_serialized );
685 KMP_DEBUG_ASSERT( this_thr -> th.th_team == serial_team );
686 KMP_DEBUG_ASSERT( serial_team != this_thr->th.th_root->r.r_root_team );
687 KMP_DEBUG_ASSERT( serial_team -> t.t_threads );
688 KMP_DEBUG_ASSERT( serial_team -> t.t_threads[0] == this_thr );
691 top = serial_team -> t.t_control_stack_top;
692 if ( top && top -> serial_nesting_level == serial_team -> t.t_serialized ) {
695 &serial_team -> t.t_threads[0] -> th.th_current_task -> td_icvs,
698 serial_team -> t.t_set_nproc[0] = top -> nproc;
699 serial_team -> t.t_set_dynamic[0] = top -> dynamic;
700 serial_team -> t.t_set_nested[0] = top -> nested;
701 serial_team -> t.t_set_blocktime[0] = top -> blocktime;
702 serial_team -> t.t_set_bt_intervals[0] = top -> bt_intervals;
703 serial_team -> t.t_set_bt_set[0] = top -> bt_set;
704 #endif // OMP_30_ENABLED
705 serial_team -> t.t_control_stack_top = top -> next;
711 serial_team -> t.t_level--;
712 #endif // OMP_30_ENABLED
715 KMP_DEBUG_ASSERT(serial_team->t.t_dispatch->th_disp_buffer);
717 dispatch_private_info_t * disp_buffer = serial_team->t.t_dispatch->th_disp_buffer;
718 serial_team->t.t_dispatch->th_disp_buffer =
719 serial_team->t.t_dispatch->th_disp_buffer->next;
720 __kmp_free( disp_buffer );
723 -- serial_team -> t.t_serialized;
724 if ( serial_team -> t.t_serialized == 0 ) {
728 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
729 if ( __kmp_inherit_fp_control && serial_team->t.t_fp_control_saved ) {
730 __kmp_clear_x87_fpu_status_word();
731 __kmp_load_x87_fpu_control_word( &serial_team->t.t_x87_fpu_control_word );
732 __kmp_load_mxcsr( &serial_team->t.t_mxcsr );
736 this_thr -> th.th_team = serial_team -> t.t_parent;
737 this_thr -> th.th_info.ds.ds_tid = serial_team -> t.t_master_tid;
740 this_thr -> th.th_team_nproc = serial_team -> t.t_parent -> t.t_nproc;
741 this_thr -> th.th_team_master = serial_team -> t.t_parent -> t.t_threads[0];
742 this_thr -> th.th_team_serialized = this_thr -> th.th_team -> t.t_serialized;
745 this_thr -> th.th_dispatch = & this_thr -> th.th_team ->
746 t.t_dispatch[ serial_team -> t.t_master_tid ];
749 __kmp_pop_current_task_from_thread( this_thr );
751 KMP_ASSERT( this_thr -> th.th_current_task -> td_flags.executing == 0 );
752 this_thr -> th.th_current_task -> td_flags.executing = 1;
754 if ( __kmp_tasking_mode != tskm_immediate_exec ) {
759 if ( ( this_thr -> th.th_task_team = this_thr -> th.th_team -> t.t_task_team ) != NULL ) {
760 this_thr -> th.th_task_state = this_thr -> th.th_task_team -> tt.tt_state;
762 KA_TRACE( 20, (
"__kmpc_end_serialized_parallel: T#%d restoring task_team %p / team %p\n",
763 global_tid, this_thr -> th.th_task_team, this_thr -> th.th_team ) );
765 #endif // OMP_30_ENABLED
771 if ( __kmp_tasking_mode != tskm_immediate_exec ) {
772 KA_TRACE( 20, (
"__kmpc_end_serialized_parallel: T#%d decreasing nesting depth of serial team %p to %d\n",
773 global_tid, serial_team, serial_team -> t.t_serialized ) );
775 #endif // OMP_30_ENABLED
781 if ( ( __itt_frame_end_v3_ptr && __kmp_forkjoin_frames ) || KMP_ITT_DEBUG )
783 __kmp_itt_region_joined( global_tid, 1 );
787 if ( __kmp_env_consistency_check )
788 __kmp_pop_parallel( global_tid, NULL );
806 KC_TRACE( 10, (
"__kmpc_flush: called\n" ) );
815 #if ( KMP_ARCH_X86 || KMP_ARCH_X86_64 )
828 if ( ! __kmp_cpuinfo.initialized ) {
829 __kmp_query_cpuid( & __kmp_cpuinfo );
831 if ( ! __kmp_cpuinfo.sse2 ) {
834 #if defined( __GNUC__ ) && !defined( __INTEL_COMPILER )
835 __sync_synchronize();
842 #error Unknown or unsupported architecture
844 #endif // OMP_30_ENABLED
862 int explicit_barrier_flag;
863 KC_TRACE( 10, (
"__kmpc_barrier: called T#%d\n", global_tid ) );
865 if (! TCR_4(__kmp_init_parallel))
866 __kmp_parallel_initialize();
868 if ( __kmp_env_consistency_check ) {
870 KMP_WARNING( ConstructIdentInvalid );
873 __kmp_check_barrier( global_tid, ct_barrier, loc );
876 __kmp_threads[ global_tid ]->th.th_ident = loc;
884 __kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
899 KC_TRACE( 10, (
"__kmpc_master: called T#%d\n", global_tid ) );
901 if( ! TCR_4( __kmp_init_parallel ) )
902 __kmp_parallel_initialize();
904 if( KMP_MASTER_GTID( global_tid ))
907 if ( __kmp_env_consistency_check ) {
909 __kmp_push_sync( global_tid, ct_master, loc, NULL );
911 __kmp_check_sync( global_tid, ct_master, loc, NULL );
928 KC_TRACE( 10, (
"__kmpc_end_master: called T#%d\n", global_tid ) );
930 KMP_DEBUG_ASSERT( KMP_MASTER_GTID( global_tid ));
932 if ( __kmp_env_consistency_check ) {
934 KMP_WARNING( ThreadIdentInvalid );
936 if( KMP_MASTER_GTID( global_tid ))
937 __kmp_pop_sync( global_tid, ct_master, loc );
953 KMP_DEBUG_ASSERT( __kmp_init_serial );
955 KC_TRACE( 10, (
"__kmpc_ordered: called T#%d\n", gtid ));
957 if (! TCR_4(__kmp_init_parallel))
958 __kmp_parallel_initialize();
961 __kmp_itt_ordered_prep( gtid );
965 th = __kmp_threads[ gtid ];
967 if ( th -> th.th_dispatch -> th_deo_fcn != 0 )
968 (*th->th.th_dispatch->th_deo_fcn)( & gtid, & cid, loc );
970 __kmp_parallel_deo( & gtid, & cid, loc );
973 __kmp_itt_ordered_start( gtid );
990 KC_TRACE( 10, (
"__kmpc_end_ordered: called T#%d\n", gtid ) );
993 __kmp_itt_ordered_end( gtid );
997 th = __kmp_threads[ gtid ];
999 if ( th -> th.th_dispatch -> th_dxo_fcn != 0 )
1000 (*th->th.th_dispatch->th_dxo_fcn)( & gtid, & cid, loc );
1002 __kmp_parallel_dxo( & gtid, & cid, loc );
1006 __kmp_static_yield(
int arg ) {
1010 static kmp_user_lock_p
1011 __kmp_get_critical_section_ptr( kmp_critical_name * crit,
ident_t const * loc, kmp_int32 gtid )
1013 kmp_user_lock_p *lck_pp = (kmp_user_lock_p *)crit;
1019 kmp_user_lock_p lck = (kmp_user_lock_p)TCR_PTR( *lck_pp );
1021 if ( lck == NULL ) {
1026 lck = __kmp_user_lock_allocate( &idx, gtid, kmp_lf_critical_section );
1027 __kmp_init_user_lock_with_checks( lck );
1028 __kmp_set_user_lock_location( lck, loc );
1030 __kmp_itt_critical_creating( lck );
1043 int status = KMP_COMPARE_AND_STORE_PTR( lck_pp, 0, lck );
1045 if ( status == 0 ) {
1048 __kmp_itt_critical_destroyed( lck );
1052 __kmp_destroy_user_lock_with_checks( lck );
1053 __kmp_user_lock_free( &idx, gtid, lck );
1054 lck = (kmp_user_lock_p)TCR_PTR( *lck_pp );
1055 KMP_DEBUG_ASSERT( lck != NULL );
1074 kmp_user_lock_p lck;
1076 KC_TRACE( 10, (
"__kmpc_critical: called T#%d\n", global_tid ) );
1080 KMP_CHECK_USER_LOCK_INIT();
1082 if ( ( __kmp_user_lock_kind == lk_tas )
1083 && (
sizeof( lck->tas.lk.poll ) <= OMP_CRITICAL_SIZE ) ) {
1084 lck = (kmp_user_lock_p)crit;
1086 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1087 else if ( ( __kmp_user_lock_kind == lk_futex )
1088 && (
sizeof( lck->futex.lk.poll ) <= OMP_CRITICAL_SIZE ) ) {
1089 lck = (kmp_user_lock_p)crit;
1093 lck = __kmp_get_critical_section_ptr( crit, loc, global_tid );
1096 if ( __kmp_env_consistency_check )
1097 __kmp_push_sync( global_tid, ct_critical, loc, lck );
1106 __kmp_itt_critical_acquiring( lck );
1110 __kmp_acquire_user_lock_with_checks( lck, global_tid );
1113 __kmp_itt_critical_acquired( lck );
1116 KA_TRACE( 15, (
"__kmpc_critical: done T#%d\n", global_tid ));
1131 kmp_user_lock_p lck;
1133 KC_TRACE( 10, (
"__kmpc_end_critical: called T#%d\n", global_tid ));
1135 if ( ( __kmp_user_lock_kind == lk_tas )
1136 && (
sizeof( lck->tas.lk.poll ) <= OMP_CRITICAL_SIZE ) ) {
1137 lck = (kmp_user_lock_p)crit;
1139 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1140 else if ( ( __kmp_user_lock_kind == lk_futex )
1141 && (
sizeof( lck->futex.lk.poll ) <= OMP_CRITICAL_SIZE ) ) {
1142 lck = (kmp_user_lock_p)crit;
1146 lck = (kmp_user_lock_p) TCR_PTR(*((kmp_user_lock_p *)crit));
1149 KMP_ASSERT(lck != NULL);
1151 if ( __kmp_env_consistency_check )
1152 __kmp_pop_sync( global_tid, ct_critical, loc );
1155 __kmp_itt_critical_releasing( lck );
1159 __kmp_release_user_lock_with_checks( lck, global_tid );
1161 KA_TRACE( 15, (
"__kmpc_end_critical: done T#%d\n", global_tid ));
1177 KC_TRACE( 10, (
"__kmpc_barrier_master: called T#%d\n", global_tid ) );
1179 if (! TCR_4(__kmp_init_parallel))
1180 __kmp_parallel_initialize();
1182 if ( __kmp_env_consistency_check )
1183 __kmp_check_barrier( global_tid, ct_barrier, loc );
1185 status = __kmp_barrier( bs_plain_barrier, global_tid, TRUE, 0, NULL, NULL );
1187 return (status != 0) ? 0 : 1;
1202 KC_TRACE( 10, (
"__kmpc_end_barrier_master: called T#%d\n", global_tid ));
1204 __kmp_end_split_barrier ( bs_plain_barrier, global_tid );
1222 KC_TRACE( 10, (
"__kmpc_barrier_master_nowait: called T#%d\n", global_tid ));
1224 if (! TCR_4(__kmp_init_parallel))
1225 __kmp_parallel_initialize();
1227 if ( __kmp_env_consistency_check ) {
1229 KMP_WARNING( ConstructIdentInvalid );
1231 __kmp_check_barrier( global_tid, ct_barrier, loc );
1234 __kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
1238 if ( __kmp_env_consistency_check ) {
1242 if ( global_tid < 0 ) {
1243 KMP_WARNING( ThreadIdentInvalid );
1249 __kmp_pop_sync( global_tid, ct_master, loc );
1271 kmp_int32 rc = __kmp_enter_single( global_tid, loc, TRUE );
1287 __kmp_exit_single( global_tid );
1300 KE_TRACE( 10, (
"__kmpc_for_static_fini called T#%d\n", global_tid));
1302 if ( __kmp_env_consistency_check )
1303 __kmp_pop_workshare( global_tid, ct_pdo, loc );
1312 ompc_set_num_threads(
int arg )
1315 __kmp_set_num_threads( arg, __kmp_entry_gtid() );
1319 ompc_set_dynamic(
int flag )
1324 thread = __kmp_entry_thread();
1326 __kmp_save_internal_controls( thread );
1328 set__dynamic( thread, flag ? TRUE : FALSE );
1332 ompc_set_nested(
int flag )
1337 thread = __kmp_entry_thread();
1339 __kmp_save_internal_controls( thread );
1341 set__nested( thread, flag ? TRUE : FALSE );
1347 ompc_set_max_active_levels(
int max_active_levels )
1353 __kmp_set_max_active_levels( __kmp_entry_gtid(), max_active_levels );
1357 ompc_set_schedule( omp_sched_t kind,
int modifier )
1360 __kmp_set_schedule( __kmp_entry_gtid(), ( kmp_sched_t ) kind, modifier );
1364 ompc_get_ancestor_thread_num(
int level )
1366 return __kmp_get_ancestor_thread_num( __kmp_entry_gtid(), level );
1370 ompc_get_team_size(
int level )
1372 return __kmp_get_team_size( __kmp_entry_gtid(), level );
1375 #endif // OMP_30_ENABLED
1378 kmpc_set_stacksize(
int arg )
1381 __kmp_aux_set_stacksize( arg );
1385 kmpc_set_stacksize_s(
size_t arg )
1388 __kmp_aux_set_stacksize( arg );
1392 kmpc_set_blocktime(
int arg )
1397 gtid = __kmp_entry_gtid();
1398 tid = __kmp_tid_from_gtid(gtid);
1399 thread = __kmp_thread_from_gtid(gtid);
1401 __kmp_aux_set_blocktime( arg, thread, tid );
1405 kmpc_set_library(
int arg )
1408 __kmp_user_set_library( (
enum library_type)arg );
1412 kmpc_set_defaults(
char const * str )
1415 __kmp_aux_set_defaults( str, strlen( str ) );
1418 #ifdef OMP_30_ENABLED
1421 kmpc_set_affinity_mask_proc(
int proc,
void **mask )
1423 #if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
1426 if ( ! TCR_4(__kmp_init_middle) ) {
1427 __kmp_middle_initialize();
1429 return __kmp_aux_set_affinity_mask_proc( proc, mask );
1434 kmpc_unset_affinity_mask_proc(
int proc,
void **mask )
1436 #if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
1439 if ( ! TCR_4(__kmp_init_middle) ) {
1440 __kmp_middle_initialize();
1442 return __kmp_aux_unset_affinity_mask_proc( proc, mask );
1447 kmpc_get_affinity_mask_proc(
int proc,
void **mask )
1449 #if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
1452 if ( ! TCR_4(__kmp_init_middle) ) {
1453 __kmp_middle_initialize();
1455 return __kmp_aux_get_affinity_mask_proc( proc, mask );
1507 KC_TRACE( 10, (
"__kmpc_copyprivate: called T#%d\n", gtid ));
1511 data_ptr = & __kmp_team_from_gtid( gtid )->t.t_copypriv_data;
1513 if ( __kmp_env_consistency_check ) {
1515 KMP_WARNING( ConstructIdentInvalid );
1521 if (didit) *data_ptr = cpy_data;
1524 __kmp_barrier( bs_plain_barrier, gtid, FALSE , 0, NULL, NULL );
1526 if (! didit) (*cpy_func)( cpy_data, *data_ptr );
1531 __kmp_barrier( bs_plain_barrier, gtid, FALSE , 0, NULL, NULL );
1536 #define INIT_LOCK __kmp_init_user_lock_with_checks
1537 #define INIT_NESTED_LOCK __kmp_init_nested_user_lock_with_checks
1538 #define ACQUIRE_LOCK __kmp_acquire_user_lock_with_checks
1539 #define ACQUIRE_LOCK_TIMED __kmp_acquire_user_lock_with_checks_timed
1540 #define ACQUIRE_NESTED_LOCK __kmp_acquire_nested_user_lock_with_checks
1541 #define ACQUIRE_NESTED_LOCK_TIMED __kmp_acquire_nested_user_lock_with_checks_timed
1542 #define RELEASE_LOCK __kmp_release_user_lock_with_checks
1543 #define RELEASE_NESTED_LOCK __kmp_release_nested_user_lock_with_checks
1544 #define TEST_LOCK __kmp_test_user_lock_with_checks
1545 #define TEST_NESTED_LOCK __kmp_test_nested_user_lock_with_checks
1546 #define DESTROY_LOCK __kmp_destroy_user_lock_with_checks
1547 #define DESTROY_NESTED_LOCK __kmp_destroy_nested_user_lock_with_checks
1557 __kmpc_init_lock(
ident_t * loc, kmp_int32 gtid,
void ** user_lock ) {
1558 static char const *
const func =
"omp_init_lock";
1559 kmp_user_lock_p lck;
1560 KMP_DEBUG_ASSERT( __kmp_init_serial );
1562 if ( __kmp_env_consistency_check ) {
1563 if ( user_lock == NULL ) {
1564 KMP_FATAL( LockIsUninitialized, func );
1568 KMP_CHECK_USER_LOCK_INIT();
1570 if ( ( __kmp_user_lock_kind == lk_tas )
1571 && (
sizeof( lck->tas.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1572 lck = (kmp_user_lock_p)user_lock;
1574 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1575 else if ( ( __kmp_user_lock_kind == lk_futex )
1576 && (
sizeof( lck->futex.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1577 lck = (kmp_user_lock_p)user_lock;
1581 lck = __kmp_user_lock_allocate( user_lock, gtid );
1584 __kmp_set_user_lock_location( lck, loc );
1587 __kmp_itt_lock_creating( lck );
1593 __kmpc_init_nest_lock(
ident_t * loc, kmp_int32 gtid,
void ** user_lock ) {
1594 static char const *
const func =
"omp_init_nest_lock";
1595 kmp_user_lock_p lck;
1596 KMP_DEBUG_ASSERT( __kmp_init_serial );
1598 if ( __kmp_env_consistency_check ) {
1599 if ( user_lock == NULL ) {
1600 KMP_FATAL( LockIsUninitialized, func );
1604 KMP_CHECK_USER_LOCK_INIT();
1606 if ( ( __kmp_user_lock_kind == lk_tas ) && (
sizeof( lck->tas.lk.poll )
1607 +
sizeof( lck->tas.lk.depth_locked ) <= OMP_NEST_LOCK_T_SIZE ) ) {
1608 lck = (kmp_user_lock_p)user_lock;
1610 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1611 else if ( ( __kmp_user_lock_kind == lk_futex )
1612 && (
sizeof( lck->futex.lk.poll ) +
sizeof( lck->futex.lk.depth_locked )
1613 <= OMP_NEST_LOCK_T_SIZE ) ) {
1614 lck = (kmp_user_lock_p)user_lock;
1618 lck = __kmp_user_lock_allocate( user_lock, gtid );
1621 INIT_NESTED_LOCK( lck );
1622 __kmp_set_user_lock_location( lck, loc );
1625 __kmp_itt_lock_creating( lck );
1630 __kmpc_destroy_lock(
ident_t * loc, kmp_int32 gtid,
void ** user_lock ) {
1632 kmp_user_lock_p lck;
1634 if ( ( __kmp_user_lock_kind == lk_tas )
1635 && (
sizeof( lck->tas.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1636 lck = (kmp_user_lock_p)user_lock;
1638 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1639 else if ( ( __kmp_user_lock_kind == lk_futex )
1640 && (
sizeof( lck->futex.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1641 lck = (kmp_user_lock_p)user_lock;
1645 lck = __kmp_lookup_user_lock( user_lock,
"omp_destroy_lock" );
1649 __kmp_itt_lock_destroyed( lck );
1651 DESTROY_LOCK( lck );
1653 if ( ( __kmp_user_lock_kind == lk_tas )
1654 && (
sizeof( lck->tas.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1657 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1658 else if ( ( __kmp_user_lock_kind == lk_futex )
1659 && (
sizeof( lck->futex.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1664 __kmp_user_lock_free( user_lock, gtid, lck );
1670 __kmpc_destroy_nest_lock(
ident_t * loc, kmp_int32 gtid,
void ** user_lock ) {
1672 kmp_user_lock_p lck;
1674 if ( ( __kmp_user_lock_kind == lk_tas ) && (
sizeof( lck->tas.lk.poll )
1675 +
sizeof( lck->tas.lk.depth_locked ) <= OMP_NEST_LOCK_T_SIZE ) ) {
1676 lck = (kmp_user_lock_p)user_lock;
1678 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1679 else if ( ( __kmp_user_lock_kind == lk_futex )
1680 && (
sizeof( lck->futex.lk.poll ) +
sizeof( lck->futex.lk.depth_locked )
1681 <= OMP_NEST_LOCK_T_SIZE ) ) {
1682 lck = (kmp_user_lock_p)user_lock;
1686 lck = __kmp_lookup_user_lock( user_lock,
"omp_destroy_nest_lock" );
1690 __kmp_itt_lock_destroyed( lck );
1693 DESTROY_NESTED_LOCK( lck );
1695 if ( ( __kmp_user_lock_kind == lk_tas ) && (
sizeof( lck->tas.lk.poll )
1696 +
sizeof( lck->tas.lk.depth_locked ) <= OMP_NEST_LOCK_T_SIZE ) ) {
1699 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1700 else if ( ( __kmp_user_lock_kind == lk_futex )
1701 && (
sizeof( lck->futex.lk.poll ) +
sizeof( lck->futex.lk.depth_locked )
1702 <= OMP_NEST_LOCK_T_SIZE ) ) {
1707 __kmp_user_lock_free( user_lock, gtid, lck );
1712 __kmpc_set_lock(
ident_t * loc, kmp_int32 gtid,
void ** user_lock ) {
1713 kmp_user_lock_p lck;
1715 if ( ( __kmp_user_lock_kind == lk_tas )
1716 && (
sizeof( lck->tas.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1717 lck = (kmp_user_lock_p)user_lock;
1719 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1720 else if ( ( __kmp_user_lock_kind == lk_futex )
1721 && (
sizeof( lck->futex.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1722 lck = (kmp_user_lock_p)user_lock;
1726 lck = __kmp_lookup_user_lock( user_lock,
"omp_set_lock" );
1730 __kmp_itt_lock_acquiring( lck );
1733 ACQUIRE_LOCK( lck, gtid );
1736 __kmp_itt_lock_acquired( lck );
1742 __kmpc_set_nest_lock(
ident_t * loc, kmp_int32 gtid,
void ** user_lock ) {
1743 kmp_user_lock_p lck;
1745 if ( ( __kmp_user_lock_kind == lk_tas ) && (
sizeof( lck->tas.lk.poll )
1746 +
sizeof( lck->tas.lk.depth_locked ) <= OMP_NEST_LOCK_T_SIZE ) ) {
1747 lck = (kmp_user_lock_p)user_lock;
1749 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1750 else if ( ( __kmp_user_lock_kind == lk_futex )
1751 && (
sizeof( lck->futex.lk.poll ) +
sizeof( lck->futex.lk.depth_locked )
1752 <= OMP_NEST_LOCK_T_SIZE ) ) {
1753 lck = (kmp_user_lock_p)user_lock;
1757 lck = __kmp_lookup_user_lock( user_lock,
"omp_set_nest_lock" );
1761 __kmp_itt_lock_acquiring( lck );
1764 ACQUIRE_NESTED_LOCK( lck, gtid );
1767 __kmp_itt_lock_acquired( lck );
1772 __kmpc_unset_lock(
ident_t *loc, kmp_int32 gtid,
void **user_lock )
1774 kmp_user_lock_p lck;
1779 if ( ( __kmp_user_lock_kind == lk_tas )
1780 && (
sizeof( lck->tas.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1781 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1784 __kmp_itt_lock_releasing( (kmp_user_lock_p)user_lock );
1786 TCW_4(((kmp_user_lock_p)user_lock)->tas.lk.poll, 0);
1790 lck = (kmp_user_lock_p)user_lock;
1793 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1794 else if ( ( __kmp_user_lock_kind == lk_futex )
1795 && (
sizeof( lck->futex.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1796 lck = (kmp_user_lock_p)user_lock;
1800 lck = __kmp_lookup_user_lock( user_lock,
"omp_unset_lock" );
1804 __kmp_itt_lock_releasing( lck );
1807 RELEASE_LOCK( lck, gtid );
1812 __kmpc_unset_nest_lock(
ident_t *loc, kmp_int32 gtid,
void **user_lock )
1814 kmp_user_lock_p lck;
1818 if ( ( __kmp_user_lock_kind == lk_tas ) && (
sizeof( lck->tas.lk.poll )
1819 +
sizeof( lck->tas.lk.depth_locked ) <= OMP_NEST_LOCK_T_SIZE ) ) {
1820 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1822 kmp_tas_lock_t *tl = (kmp_tas_lock_t*)user_lock;
1824 __kmp_itt_lock_releasing( (kmp_user_lock_p)user_lock );
1826 if ( --(tl->lk.depth_locked) == 0 ) {
1827 TCW_4(tl->lk.poll, 0);
1832 lck = (kmp_user_lock_p)user_lock;
1835 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1836 else if ( ( __kmp_user_lock_kind == lk_futex )
1837 && (
sizeof( lck->futex.lk.poll ) +
sizeof( lck->futex.lk.depth_locked )
1838 <= OMP_NEST_LOCK_T_SIZE ) ) {
1839 lck = (kmp_user_lock_p)user_lock;
1843 lck = __kmp_lookup_user_lock( user_lock,
"omp_unset_nest_lock" );
1847 __kmp_itt_lock_releasing( lck );
1850 RELEASE_NESTED_LOCK( lck, gtid );
1855 __kmpc_test_lock(
ident_t *loc, kmp_int32 gtid,
void **user_lock )
1857 kmp_user_lock_p lck;
1860 if ( ( __kmp_user_lock_kind == lk_tas )
1861 && (
sizeof( lck->tas.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1862 lck = (kmp_user_lock_p)user_lock;
1864 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1865 else if ( ( __kmp_user_lock_kind == lk_futex )
1866 && (
sizeof( lck->futex.lk.poll ) <= OMP_LOCK_T_SIZE ) ) {
1867 lck = (kmp_user_lock_p)user_lock;
1871 lck = __kmp_lookup_user_lock( user_lock,
"omp_test_lock" );
1875 __kmp_itt_lock_acquiring( lck );
1878 rc = TEST_LOCK( lck, gtid );
1881 __kmp_itt_lock_acquired( lck );
1883 __kmp_itt_lock_cancelled( lck );
1886 return ( rc ? FTN_TRUE : FTN_FALSE );
1893 __kmpc_test_nest_lock(
ident_t *loc, kmp_int32 gtid,
void **user_lock )
1895 kmp_user_lock_p lck;
1898 if ( ( __kmp_user_lock_kind == lk_tas ) && (
sizeof( lck->tas.lk.poll )
1899 +
sizeof( lck->tas.lk.depth_locked ) <= OMP_NEST_LOCK_T_SIZE ) ) {
1900 lck = (kmp_user_lock_p)user_lock;
1902 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
1903 else if ( ( __kmp_user_lock_kind == lk_futex )
1904 && (
sizeof( lck->futex.lk.poll ) +
sizeof( lck->futex.lk.depth_locked )
1905 <= OMP_NEST_LOCK_T_SIZE ) ) {
1906 lck = (kmp_user_lock_p)user_lock;
1910 lck = __kmp_lookup_user_lock( user_lock,
"omp_test_nest_lock" );
1914 __kmp_itt_lock_acquiring( lck );
1917 rc = TEST_NESTED_LOCK( lck, gtid );
1920 __kmp_itt_lock_acquired( lck );
1922 __kmp_itt_lock_cancelled( lck );
1940 #define __KMP_SET_REDUCTION_METHOD(gtid,rmethod) \
1941 ( ( __kmp_threads[ ( gtid ) ] -> th.th_local.packed_reduction_method ) = ( rmethod ) )
1943 #define __KMP_GET_REDUCTION_METHOD(gtid) \
1944 ( __kmp_threads[ ( gtid ) ] -> th.th_local.packed_reduction_method )
1950 static __forceinline
void
1951 __kmp_enter_critical_section_reduce_block(
ident_t * loc, kmp_int32 global_tid, kmp_critical_name * crit ) {
1957 kmp_user_lock_p lck;
1962 if ( __kmp_base_user_lock_size <= INTEL_CRITICAL_SIZE ) {
1963 lck = (kmp_user_lock_p)crit;
1966 lck = __kmp_get_critical_section_ptr( crit, loc, global_tid );
1968 KMP_DEBUG_ASSERT( lck != NULL );
1970 if ( __kmp_env_consistency_check )
1971 __kmp_push_sync( global_tid, ct_critical, loc, lck );
1973 __kmp_acquire_user_lock_with_checks( lck, global_tid );
1977 static __forceinline
void
1978 __kmp_end_critical_section_reduce_block(
ident_t * loc, kmp_int32 global_tid, kmp_critical_name * crit ) {
1980 kmp_user_lock_p lck;
1984 if ( __kmp_base_user_lock_size > 32 ) {
1985 lck = *( (kmp_user_lock_p *) crit );
1986 KMP_ASSERT( lck != NULL );
1988 lck = (kmp_user_lock_p) crit;
1991 if ( __kmp_env_consistency_check )
1992 __kmp_pop_sync( global_tid, ct_critical, loc );
1994 __kmp_release_user_lock_with_checks( lck, global_tid );
2015 ident_t *loc, kmp_int32 global_tid,
2016 kmp_int32 num_vars,
size_t reduce_size,
void *reduce_data,
void (*reduce_func)(
void *lhs_data,
void *rhs_data),
2017 kmp_critical_name *lck ) {
2020 PACKED_REDUCTION_METHOD_T packed_reduction_method;
2022 KA_TRACE( 10, (
"__kmpc_reduce_nowait() enter: called T#%d\n", global_tid ) );
2029 if( ! TCR_4( __kmp_init_parallel ) )
2030 __kmp_parallel_initialize();
2033 if ( __kmp_env_consistency_check )
2034 __kmp_push_sync( global_tid, ct_reduce, loc, NULL );
2047 packed_reduction_method = __kmp_determine_reduction_method( loc, global_tid, num_vars, reduce_size, reduce_data, reduce_func, lck );
2048 __KMP_SET_REDUCTION_METHOD( global_tid, packed_reduction_method );
2050 if( packed_reduction_method == critical_reduce_block ) {
2052 __kmp_enter_critical_section_reduce_block( loc, global_tid, lck );
2055 }
else if( packed_reduction_method == empty_reduce_block ) {
2060 }
else if( packed_reduction_method == atomic_reduce_block ) {
2067 if ( __kmp_env_consistency_check )
2068 __kmp_pop_sync( global_tid, ct_reduce, loc );
2070 }
else if( TEST_REDUCTION_METHOD( packed_reduction_method, tree_reduce_block ) ) {
2082 retval = __kmp_barrier( UNPACK_REDUCTION_BARRIER( packed_reduction_method ), global_tid, FALSE, reduce_size, reduce_data, reduce_func );
2083 retval = ( retval != 0 ) ? ( 0 ) : ( 1 );
2087 if ( __kmp_env_consistency_check ) {
2089 __kmp_pop_sync( global_tid, ct_reduce, loc );
2100 KA_TRACE( 10, (
"__kmpc_reduce_nowait() exit: called T#%d: method %08x, returns %08x\n", global_tid, packed_reduction_method, retval ) );
2116 PACKED_REDUCTION_METHOD_T packed_reduction_method;
2118 KA_TRACE( 10, (
"__kmpc_end_reduce_nowait() enter: called T#%d\n", global_tid ) );
2120 packed_reduction_method = __KMP_GET_REDUCTION_METHOD( global_tid );
2122 if( packed_reduction_method == critical_reduce_block ) {
2124 __kmp_end_critical_section_reduce_block( loc, global_tid, lck );
2126 }
else if( packed_reduction_method == empty_reduce_block ) {
2130 }
else if( packed_reduction_method == atomic_reduce_block ) {
2137 }
else if( TEST_REDUCTION_METHOD( packed_reduction_method, tree_reduce_block ) ) {
2148 if ( __kmp_env_consistency_check )
2149 __kmp_pop_sync( global_tid, ct_reduce, loc );
2151 KA_TRACE( 10, (
"__kmpc_end_reduce_nowait() exit: called T#%d: method %08x\n", global_tid, packed_reduction_method ) );
2173 ident_t *loc, kmp_int32 global_tid,
2174 kmp_int32 num_vars,
size_t reduce_size,
void *reduce_data,
2175 void (*reduce_func)(
void *lhs_data,
void *rhs_data),
2176 kmp_critical_name *lck )
2179 PACKED_REDUCTION_METHOD_T packed_reduction_method;
2181 KA_TRACE( 10, (
"__kmpc_reduce() enter: called T#%d\n", global_tid ) );
2188 if( ! TCR_4( __kmp_init_parallel ) )
2189 __kmp_parallel_initialize();
2192 if ( __kmp_env_consistency_check )
2193 __kmp_push_sync( global_tid, ct_reduce, loc, NULL );
2197 packed_reduction_method = __kmp_determine_reduction_method( loc, global_tid, num_vars, reduce_size, reduce_data, reduce_func, lck );
2198 __KMP_SET_REDUCTION_METHOD( global_tid, packed_reduction_method );
2200 if( packed_reduction_method == critical_reduce_block ) {
2202 __kmp_enter_critical_section_reduce_block( loc, global_tid, lck );
2205 }
else if( packed_reduction_method == empty_reduce_block ) {
2210 }
else if( packed_reduction_method == atomic_reduce_block ) {
2214 }
else if( TEST_REDUCTION_METHOD( packed_reduction_method, tree_reduce_block ) ) {
2219 retval = __kmp_barrier( UNPACK_REDUCTION_BARRIER( packed_reduction_method ), global_tid, TRUE, reduce_size, reduce_data, reduce_func );
2220 retval = ( retval != 0 ) ? ( 0 ) : ( 1 );
2224 if ( __kmp_env_consistency_check ) {
2226 __kmp_pop_sync( global_tid, ct_reduce, loc );
2237 KA_TRACE( 10, (
"__kmpc_reduce() exit: called T#%d: method %08x, returns %08x\n", global_tid, packed_reduction_method, retval ) );
2254 PACKED_REDUCTION_METHOD_T packed_reduction_method;
2256 KA_TRACE( 10, (
"__kmpc_end_reduce() enter: called T#%d\n", global_tid ) );
2258 packed_reduction_method = __KMP_GET_REDUCTION_METHOD( global_tid );
2263 if( packed_reduction_method == critical_reduce_block ) {
2265 __kmp_end_critical_section_reduce_block( loc, global_tid, lck );
2268 __kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
2270 }
else if( packed_reduction_method == empty_reduce_block ) {
2275 __kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
2277 }
else if( packed_reduction_method == atomic_reduce_block ) {
2280 __kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
2282 }
else if( TEST_REDUCTION_METHOD( packed_reduction_method, tree_reduce_block ) ) {
2285 __kmp_end_split_barrier( UNPACK_REDUCTION_BARRIER( packed_reduction_method ), global_tid );
2294 if ( __kmp_env_consistency_check )
2295 __kmp_pop_sync( global_tid, ct_reduce, loc );
2297 KA_TRACE( 10, (
"__kmpc_end_reduce() exit: called T#%d: method %08x\n", global_tid, packed_reduction_method ) );
2302 #undef __KMP_GET_REDUCTION_METHOD
2303 #undef __KMP_SET_REDUCTION_METHOD
2308 __kmpc_get_taskid() {
2313 kmp_info_t * thread;
2315 gtid = __kmp_get_gtid();
2319 thread = __kmp_thread_from_gtid( gtid );
2320 return thread->th.th_current_task->td_task_id;
2332 __kmpc_get_parent_taskid() {
2337 kmp_info_t * thread;
2338 kmp_taskdata_t * parent_task;
2340 gtid = __kmp_get_gtid();
2344 thread = __kmp_thread_from_gtid( gtid );
2345 parent_task = thread->th.th_current_task->td_parent;
2346 return ( parent_task == NULL ? 0 : parent_task->td_task_id );
2356 void __kmpc_place_threads(
int nC,
int nT,
int nO)
2359 if ( ! __kmp_init_serial ) {
2360 __kmp_serial_initialize();
2362 __kmp_place_num_cores = nC;
2363 __kmp_place_num_threads_per_core = nT;
2364 __kmp_place_core_offset = nO;