Index: openmp/trunk/runtime/src/i18n/en_US.txt =================================================================== --- openmp/trunk/runtime/src/i18n/en_US.txt +++ openmp/trunk/runtime/src/i18n/en_US.txt @@ -38,7 +38,7 @@ Country "USA" LangId "1033" Version "2" -Revision "20161216" +Revision "20170327" @@ -433,7 +433,7 @@ OBSOLETE "Check NLSPATH environment variable, its value is \"%1$s\"." ChangeStackLimit "Please try changing the shell stack limit or adjusting the " "OMP_STACKSIZE environment variable." -Unset_ALL_THREADS "Consider unsetting KMP_DEVICE_THREAD_LIMIT (KMP_ALL_THREADS) and OMP_THREAD_LIMIT (if either is set)." +Unset_ALL_THREADS "Consider unsetting KMP_DEVICE_THREAD_LIMIT (KMP_ALL_THREADS), KMP_TEAMS_THREAD_LIMIT, and OMP_THREAD_LIMIT (if any are set)." Set_ALL_THREADPRIVATE "Consider setting KMP_ALL_THREADPRIVATE to a value larger than %1$d." PossibleSystemLimitOnThreads "This could also be due to a system-related limit on the number of threads." DuplicateLibrary "This means that multiple copies of the OpenMP runtime have been " Index: openmp/trunk/runtime/src/kmp.h =================================================================== --- openmp/trunk/runtime/src/kmp.h +++ openmp/trunk/runtime/src/kmp.h @@ -2868,6 +2868,7 @@ extern int __kmp_max_nth; // maximum total number of concurrently-existing threads in a contention group extern int __kmp_cg_max_nth; +extern int __kmp_teams_max_nth; // max threads used in a teams construct extern int __kmp_threads_capacity; /* capacity of the arrays __kmp_threads and __kmp_root */ extern int __kmp_dflt_team_nth; /* default number of threads in a parallel Index: openmp/trunk/runtime/src/kmp_global.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_global.cpp +++ openmp/trunk/runtime/src/kmp_global.cpp @@ -136,6 +136,7 @@ int __kmp_sys_max_nth = KMP_MAX_NTH; int __kmp_max_nth = 0; int __kmp_cg_max_nth = 0; +int __kmp_teams_max_nth = 0; int __kmp_threads_capacity = 0; int __kmp_dflt_team_nth = 0; int __kmp_dflt_team_nth_ub = 0; Index: openmp/trunk/runtime/src/kmp_runtime.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_runtime.cpp +++ openmp/trunk/runtime/src/kmp_runtime.cpp @@ -6413,6 +6413,10 @@ } __kmp_max_nth = __kmp_sys_max_nth; __kmp_cg_max_nth = __kmp_sys_max_nth; + __kmp_teams_max_nth = __kmp_xproc; // set a "reasonable" default + if (__kmp_teams_max_nth > __kmp_sys_max_nth) { + __kmp_teams_max_nth = __kmp_sys_max_nth; + } // Three vars below moved here from __kmp_env_initialize() "KMP_BLOCKTIME" // part @@ -6989,14 +6993,14 @@ if (num_teams == 0) num_teams = 1; // default number of teams is 1. - if (num_teams > __kmp_max_nth) { // if too many teams requested? + if (num_teams > __kmp_teams_max_nth) { // if too many teams requested? if (!__kmp_reserve_warn) { __kmp_reserve_warn = 1; __kmp_msg(kmp_ms_warning, - KMP_MSG(CantFormThrTeam, num_teams, __kmp_max_nth), + KMP_MSG(CantFormThrTeam, num_teams, __kmp_teams_max_nth), KMP_HNT(Unset_ALL_THREADS), __kmp_msg_null); } - num_teams = __kmp_max_nth; + num_teams = __kmp_teams_max_nth; } // Set number of teams (number of threads in the outer "parallel" of the // teams) @@ -7007,15 +7011,15 @@ if (!TCR_4(__kmp_init_middle)) __kmp_middle_initialize(); // get __kmp_avail_proc calculated num_threads = __kmp_avail_proc / num_teams; - if (num_teams * num_threads > __kmp_max_nth) { + if (num_teams * num_threads > __kmp_teams_max_nth) { // adjust num_threads w/o warning as it is not user setting - num_threads = __kmp_max_nth / num_teams; + num_threads = __kmp_teams_max_nth / num_teams; } } else { - if (num_teams * num_threads > __kmp_max_nth) { - int new_threads = __kmp_max_nth / num_teams; + if (num_teams * num_threads > __kmp_teams_max_nth) { + int new_threads = __kmp_teams_max_nth / num_teams; if (!__kmp_reserve_warn) { // user asked for too many threads - __kmp_reserve_warn = 1; // that conflicts with KMP_DEVICE_THREAD_LIMIT + __kmp_reserve_warn = 1; // that conflicts with KMP_TEAMS_THREAD_LIMIT __kmp_msg(kmp_ms_warning, KMP_MSG(CantFormThrTeam, num_threads, new_threads), KMP_HNT(Unset_ALL_THREADS), __kmp_msg_null); Index: openmp/trunk/runtime/src/kmp_settings.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_settings.cpp +++ openmp/trunk/runtime/src/kmp_settings.cpp @@ -613,6 +613,18 @@ } // __kmp_stg_print_thread_limit // ----------------------------------------------------------------------------- +// KMP_TEAMS_THREAD_LIMIT +static void __kmp_stg_parse_teams_thread_limit(char const *name, + char const *value, void *data) { + __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth); +} // __kmp_stg_teams_thread_limit + +static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer, + char const *name, void *data) { + __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth); +} // __kmp_stg_print_teams_thread_limit + +// ----------------------------------------------------------------------------- // KMP_BLOCKTIME static void __kmp_stg_parse_blocktime(char const *name, char const *value, @@ -4402,6 +4414,8 @@ #endif {"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit, __kmp_stg_print_thread_limit, NULL, 0, 0}, + {"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit, + __kmp_stg_print_teams_thread_limit, NULL, 0, 0}, {"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0}, {"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,