aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/CMakeLists.txt2
-rw-r--r--openmp/runtime/src/include/omp_lib.F90.var5
-rw-r--r--openmp/runtime/src/include/omp_lib.h.var4
-rw-r--r--openmp/runtime/src/kmp.h31
-rw-r--r--openmp/runtime/src/kmp_affinity.cpp24
-rw-r--r--openmp/runtime/src/kmp_barrier.cpp31
-rw-r--r--openmp/runtime/src/kmp_barrier.h3
-rw-r--r--openmp/runtime/src/kmp_config.h.cmake1
-rw-r--r--openmp/runtime/src/kmp_ftn_entry.h18
-rw-r--r--openmp/runtime/src/kmp_global.cpp2
-rw-r--r--openmp/runtime/src/kmp_i18n.cpp13
-rw-r--r--openmp/runtime/src/kmp_lock.cpp8
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp161
-rw-r--r--openmp/runtime/src/kmp_settings.cpp92
-rw-r--r--openmp/runtime/src/kmp_str.cpp16
15 files changed, 200 insertions, 211 deletions
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 698e185..569061c 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -11,7 +11,7 @@
include(ExtendPath)
# The generated headers will be placed in clang's resource directory if present.
-if(OPENMP_STANDALONE_BUILD OR NOT LLVM_RUNTIMES_BUILD)
+if(NOT LLVM_TREE_AVAILABLE)
set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
else()
set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
diff --git a/openmp/runtime/src/include/omp_lib.F90.var b/openmp/runtime/src/include/omp_lib.F90.var
index 20639f6..90d7e49 100644
--- a/openmp/runtime/src/include/omp_lib.F90.var
+++ b/openmp/runtime/src/include/omp_lib.F90.var
@@ -937,9 +937,8 @@
integer (kind=omp_integer_kind), value :: libnum
end subroutine kmp_set_library
- subroutine kmp_set_defaults(string) bind(c)
- use, intrinsic :: iso_c_binding
- character (kind=c_char) :: string(*)
+ subroutine kmp_set_defaults(string)
+ character (len=*) :: string
end subroutine kmp_set_defaults
function kmp_get_stacksize() bind(c)
diff --git a/openmp/runtime/src/include/omp_lib.h.var b/openmp/runtime/src/include/omp_lib.h.var
index 5793a3a..a50bb01 100644
--- a/openmp/runtime/src/include/omp_lib.h.var
+++ b/openmp/runtime/src/include/omp_lib.h.var
@@ -1010,8 +1010,8 @@
integer (kind=omp_integer_kind), value :: libnum
end subroutine kmp_set_library
- subroutine kmp_set_defaults(string) bind(c)
- character string(*)
+ subroutine kmp_set_defaults(string)
+ character (len=*) :: string
end subroutine kmp_set_defaults
function kmp_get_stacksize() bind(c)
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 307dc62..818edf9 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -160,17 +160,6 @@ class kmp_stats_list;
#define USE_FAST_MEMORY 3
#endif
-#ifndef KMP_NESTED_HOT_TEAMS
-#define KMP_NESTED_HOT_TEAMS 0
-#define USE_NESTED_HOT_ARG(x)
-#else
-#if KMP_NESTED_HOT_TEAMS
-#define USE_NESTED_HOT_ARG(x) , x
-#else
-#define USE_NESTED_HOT_ARG(x)
-#endif
-#endif
-
// Assume using BGET compare_exchange instruction instead of lock by default.
#ifndef USE_CMP_XCHG_FOR_BGET
#define USE_CMP_XCHG_FOR_BGET 1
@@ -2913,14 +2902,12 @@ typedef struct kmp_free_list {
// sync list)
} kmp_free_list_t;
#endif
-#if KMP_NESTED_HOT_TEAMS
// Hot teams array keeps hot teams and their sizes for given thread. Hot teams
// are not put in teams pool, and they don't put threads in threads pool.
typedef struct kmp_hot_team_ptr {
kmp_team_p *hot_team; // pointer to hot_team of given nesting level
kmp_int32 hot_team_nth; // number of threads allocated for the hot_team
} kmp_hot_team_ptr_t;
-#endif
typedef struct kmp_teams_size {
kmp_int32 nteams; // number of teams in a league
kmp_int32 nth; // number of threads in each team of the league
@@ -2995,9 +2982,7 @@ typedef struct KMP_ALIGN_CACHE kmp_base_info {
int th_nt_sev; // error severity for strict modifier
const char *th_nt_msg; // error message for strict modifier
int th_set_nested_nth_sz;
-#if KMP_NESTED_HOT_TEAMS
kmp_hot_team_ptr_t *th_hot_teams; /* array of hot teams */
-#endif
kmp_proc_bind_t
th_set_proc_bind; /* if != proc_bind_default, use request for next fork */
kmp_teams_size_t
@@ -3553,10 +3538,8 @@ extern int __kmp_dflt_max_active_levels;
extern bool __kmp_dflt_max_active_levels_set;
extern int __kmp_dispatch_num_buffers; /* max possible dynamic loops in
concurrent execution per team */
-#if KMP_NESTED_HOT_TEAMS
extern int __kmp_hot_teams_mode;
extern int __kmp_hot_teams_max_level;
-#endif
#if KMP_MIC_SUPPORTED
extern enum mic_type __kmp_mic_type;
@@ -4040,16 +4023,16 @@ extern void __kmp_suspend_uninitialize_thread(kmp_info_t *th);
extern kmp_info_t *__kmp_allocate_thread(kmp_root_t *root, kmp_team_t *team,
int tid);
-extern kmp_team_t *
-__kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
+extern kmp_team_t *__kmp_allocate_team(kmp_root_t *root, int new_nproc,
+ int max_nproc,
#if OMPT_SUPPORT
- ompt_data_t ompt_parallel_data,
+ ompt_data_t ompt_parallel_data,
#endif
- kmp_proc_bind_t proc_bind, kmp_internal_control_t *new_icvs,
- int argc USE_NESTED_HOT_ARG(kmp_info_t *thr));
+ kmp_proc_bind_t proc_bind,
+ kmp_internal_control_t *new_icvs,
+ int argc, kmp_info_t *thr);
extern void __kmp_free_thread(kmp_info_t *);
-extern void __kmp_free_team(kmp_root_t *,
- kmp_team_t *USE_NESTED_HOT_ARG(kmp_info_t *));
+extern void __kmp_free_team(kmp_root_t *, kmp_team_t *, kmp_info_t *);
extern kmp_team_t *__kmp_reap_team(kmp_team_t *);
/* ------------------------------------------------------------------------ */
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index a6065fe..6bfdfbf 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -1396,11 +1396,13 @@ bool kmp_topology_t::filter_hw_subset() {
// One last check that we shouldn't allow filtering entire machine
if (num_filtered == num_hw_threads) {
KMP_AFF_WARNING(__kmp_affinity, AffHWSubsetAllFiltered);
+ KMP_CPU_FREE(filtered_mask);
return false;
}
// Apply the filter
restrict_to_mask(filtered_mask);
+ KMP_CPU_FREE(filtered_mask);
return true;
}
@@ -2225,7 +2227,7 @@ public:
cache_mask_width = __kmp_cpuid_mask_width(max_threads_sharing);
cache_level = __kmp_extract_bits<5, 7>(buf2.eax);
table[depth].level = cache_level;
- table[depth].mask = ((-1) << cache_mask_width);
+ table[depth].mask = ((0xffffffffu) << cache_mask_width);
depth++;
level++;
}
@@ -2755,13 +2757,13 @@ static bool __kmp_x2apicid_get_levels(int leaf, cpuid_proc_info_t *info,
// Set the masks to & with apicid
for (unsigned i = 0; i < levels_index; ++i) {
if (levels[i].level_type != INTEL_LEVEL_TYPE_INVALID) {
- levels[i].mask = ~((-1) << levels[i].mask_width);
- levels[i].cache_mask = (-1) << levels[i].mask_width;
+ levels[i].mask = ~((0xffffffffu) << levels[i].mask_width);
+ levels[i].cache_mask = (0xffffffffu) << levels[i].mask_width;
for (unsigned j = 0; j < i; ++j)
levels[i].mask ^= levels[j].mask;
} else {
KMP_DEBUG_ASSERT(i > 0);
- levels[i].mask = (-1) << levels[i - 1].mask_width;
+ levels[i].mask = (0xffffffffu) << levels[i - 1].mask_width;
levels[i].cache_mask = 0;
}
info->description.add(info->levels[i].level_type);
@@ -4217,6 +4219,9 @@ static void __kmp_affinity_process_proclist(kmp_affinity_t &affinity) {
if (stride > 0) {
do {
ADD_MASK_OSID(start, osId2Mask, maxOsId);
+ // Prevent possible overflow calculation
+ if (end - start < stride)
+ break;
start += stride;
} while (start <= end);
} else {
@@ -4238,6 +4243,7 @@ static void __kmp_affinity_process_proclist(kmp_affinity_t &affinity) {
if (nextNewMask == 0) {
*out_masks = NULL;
KMP_CPU_INTERNAL_FREE_ARRAY(newMasks, numNewMasks);
+ KMP_CPU_FREE(sumMask);
return;
}
KMP_CPU_ALLOC_ARRAY((*out_masks), nextNewMask);
@@ -4406,6 +4412,7 @@ static void __kmp_process_place(const char **scan, kmp_affinity_t &affinity,
(*scan)++; // skip '!'
__kmp_process_place(scan, affinity, maxOsId, tempMask, setSize);
KMP_CPU_COMPLEMENT(maxOsId, tempMask);
+ KMP_CPU_AND(tempMask, __kmp_affin_fullMask);
} else if ((**scan >= '0') && (**scan <= '9')) {
next = *scan;
SKIP_DIGITS(next);
@@ -4559,6 +4566,8 @@ void __kmp_affinity_process_placelist(kmp_affinity_t &affinity) {
*out_numMasks = nextNewMask;
if (nextNewMask == 0) {
*out_masks = NULL;
+ KMP_CPU_FREE(tempMask);
+ KMP_CPU_FREE(previousMask);
KMP_CPU_INTERNAL_FREE_ARRAY(newMasks, numNewMasks);
return;
}
@@ -5280,13 +5289,18 @@ void __kmp_affinity_uninitialize(void) {
if (affinity->os_id_masks != NULL)
KMP_CPU_FREE_ARRAY(affinity->os_id_masks, affinity->num_os_id_masks);
if (affinity->proclist != NULL)
- __kmp_free(affinity->proclist);
+ KMP_INTERNAL_FREE(affinity->proclist);
if (affinity->ids != NULL)
__kmp_free(affinity->ids);
if (affinity->attrs != NULL)
__kmp_free(affinity->attrs);
*affinity = KMP_AFFINITY_INIT(affinity->env_var);
}
+ if (__kmp_affin_fullMask != NULL) {
+ KMP_CPU_FREE(__kmp_affin_fullMask);
+ __kmp_affin_fullMask = NULL;
+ }
+ __kmp_avail_proc = 0;
if (__kmp_affin_origMask != NULL) {
if (KMP_AFFINITY_CAPABLE()) {
#if KMP_OS_AIX
diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp
index d7ef57c..88a5cbb 100644
--- a/openmp/runtime/src/kmp_barrier.cpp
+++ b/openmp/runtime/src/kmp_barrier.cpp
@@ -205,6 +205,31 @@ void distributedBarrier::init(size_t nthr) {
team_icvs = __kmp_allocate(sizeof(kmp_internal_control_t));
}
+void distributedBarrier::deallocate(distributedBarrier *db) {
+ for (int i = 0; i < MAX_ITERS; ++i) {
+ if (db->flags[i])
+ KMP_INTERNAL_FREE(db->flags[i]);
+ db->flags[i] = NULL;
+ }
+ if (db->go) {
+ KMP_INTERNAL_FREE(db->go);
+ db->go = NULL;
+ }
+ if (db->iter) {
+ KMP_INTERNAL_FREE(db->iter);
+ db->iter = NULL;
+ }
+ if (db->sleep) {
+ KMP_INTERNAL_FREE(db->sleep);
+ db->sleep = NULL;
+ }
+ if (db->team_icvs) {
+ __kmp_free(db->team_icvs);
+ db->team_icvs = NULL;
+ }
+ KMP_ALIGNED_FREE(db);
+}
+
// This function is used only when KMP_BLOCKTIME is not infinite.
// static
void __kmp_dist_barrier_wakeup(enum barrier_type bt, kmp_team_t *team,
@@ -1890,8 +1915,6 @@ static int __kmp_barrier_template(enum barrier_type bt, int gtid, int is_split,
break;
}
case bp_hyper_bar: {
- // don't set branch bits to 0; use linear
- KMP_ASSERT(__kmp_barrier_gather_branch_bits[bt]);
__kmp_hyper_barrier_gather(bt, this_thr, gtid, tid,
reduce USE_ITT_BUILD_ARG(itt_sync_obj));
break;
@@ -1902,8 +1925,6 @@ static int __kmp_barrier_template(enum barrier_type bt, int gtid, int is_split,
break;
}
case bp_tree_bar: {
- // don't set branch bits to 0; use linear
- KMP_ASSERT(__kmp_barrier_gather_branch_bits[bt]);
__kmp_tree_barrier_gather(bt, this_thr, gtid, tid,
reduce USE_ITT_BUILD_ARG(itt_sync_obj));
break;
@@ -2297,7 +2318,6 @@ void __kmp_join_barrier(int gtid) {
break;
}
case bp_hyper_bar: {
- KMP_ASSERT(__kmp_barrier_gather_branch_bits[bs_forkjoin_barrier]);
__kmp_hyper_barrier_gather(bs_forkjoin_barrier, this_thr, gtid, tid,
NULL USE_ITT_BUILD_ARG(itt_sync_obj));
break;
@@ -2308,7 +2328,6 @@ void __kmp_join_barrier(int gtid) {
break;
}
case bp_tree_bar: {
- KMP_ASSERT(__kmp_barrier_gather_branch_bits[bs_forkjoin_barrier]);
__kmp_tree_barrier_gather(bs_forkjoin_barrier, this_thr, gtid, tid,
NULL USE_ITT_BUILD_ARG(itt_sync_obj));
break;
diff --git a/openmp/runtime/src/kmp_barrier.h b/openmp/runtime/src/kmp_barrier.h
index ae9b8d6..ce6100a 100644
--- a/openmp/runtime/src/kmp_barrier.h
+++ b/openmp/runtime/src/kmp_barrier.h
@@ -130,8 +130,7 @@ public:
d->init(nThreads);
return d;
}
-
- static void deallocate(distributedBarrier *db) { KMP_ALIGNED_FREE(db); }
+ static void deallocate(distributedBarrier *db);
void update_num_threads(size_t nthr) { init(nthr); }
diff --git a/openmp/runtime/src/kmp_config.h.cmake b/openmp/runtime/src/kmp_config.h.cmake
index d64c9a4..40f1087 100644
--- a/openmp/runtime/src/kmp_config.h.cmake
+++ b/openmp/runtime/src/kmp_config.h.cmake
@@ -114,7 +114,6 @@
# define BUILD_I8 1
#endif
-#define KMP_NESTED_HOT_TEAMS 1
#define KMP_ADJUST_BLOCKTIME 1
#define BUILD_PARALLEL_ORDERED 1
#define KMP_ASM_INTRINS 1
diff --git a/openmp/runtime/src/kmp_ftn_entry.h b/openmp/runtime/src/kmp_ftn_entry.h
index 59a9571..2b0063e 100644
--- a/openmp/runtime/src/kmp_ftn_entry.h
+++ b/openmp/runtime/src/kmp_ftn_entry.h
@@ -572,16 +572,14 @@ static void __kmp_fortran_strncpy_truncate(char *buffer, size_t buf_size,
// Convert a Fortran string to a C string by adding null byte
class ConvertedString {
char *buf;
- kmp_info_t *th;
public:
ConvertedString(char const *fortran_str, size_t size) {
- th = __kmp_get_thread();
- buf = (char *)__kmp_thread_malloc(th, size + 1);
+ buf = (char *)KMP_INTERNAL_MALLOC(size + 1);
KMP_STRNCPY_S(buf, size + 1, fortran_str, size);
buf[size] = '\0';
}
- ~ConvertedString() { __kmp_thread_free(th, buf); }
+ ~ConvertedString() { KMP_INTERNAL_FREE(buf); }
const char *get() const { return buf; }
};
#endif // KMP_STUB
@@ -1495,10 +1493,18 @@ void FTN_STDCALL FTN_SET_DEFAULTS(char const *str
#endif
) {
#ifndef KMP_STUB
+ size_t sz;
+ char const *defaults = str;
+
#ifdef PASS_ARGS_BY_VALUE
- int len = (int)KMP_STRLEN(str);
+ sz = KMP_STRLEN(str);
+#else
+ sz = (size_t)len;
+ ConvertedString cstr(str, sz);
+ defaults = cstr.get();
#endif
- __kmp_aux_set_defaults(str, len);
+
+ __kmp_aux_set_defaults(defaults, sz);
#endif
}
diff --git a/openmp/runtime/src/kmp_global.cpp b/openmp/runtime/src/kmp_global.cpp
index 87c0a66..323d13e 100644
--- a/openmp/runtime/src/kmp_global.cpp
+++ b/openmp/runtime/src/kmp_global.cpp
@@ -135,11 +135,9 @@ int __kmp_tp_cached = 0;
int __kmp_dispatch_num_buffers = KMP_DFLT_DISP_NUM_BUFF;
int __kmp_dflt_max_active_levels = 1; // Nesting off by default
bool __kmp_dflt_max_active_levels_set = false; // Don't override set value
-#if KMP_NESTED_HOT_TEAMS
int __kmp_hot_teams_mode = 0; /* 0 - free extra threads when reduced */
/* 1 - keep extra threads when reduced */
int __kmp_hot_teams_max_level = 1; /* nesting level of hot teams */
-#endif
enum library_type __kmp_library = library_none;
enum sched_type __kmp_sched =
kmp_sch_default; /* scheduling method for runtime scheduling */
diff --git a/openmp/runtime/src/kmp_i18n.cpp b/openmp/runtime/src/kmp_i18n.cpp
index a164aa1..f93e2b9 100644
--- a/openmp/runtime/src/kmp_i18n.cpp
+++ b/openmp/runtime/src/kmp_i18n.cpp
@@ -791,8 +791,19 @@ void __kmp_msg(kmp_msg_severity_t severity, kmp_msg_t message, va_list args) {
kmp_msg_t fmsg; // formatted message
kmp_str_buf_t buffer;
- if (severity != kmp_ms_fatal && __kmp_generate_warnings == kmp_warnings_off)
+ if (severity != kmp_ms_fatal && __kmp_generate_warnings == kmp_warnings_off) {
+ // Have to free all possible pre-allocated messages
+ // sent in through message and args
+ __kmp_str_free(&message.str);
+ for (;;) {
+ message = va_arg(args, kmp_msg_t);
+ if (message.type == kmp_mt_dummy && message.str == NULL) {
+ break;
+ }
+ __kmp_str_free(&message.str);
+ }
return; // no reason to form a string in order to not print it
+ }
__kmp_str_buf_init(&buffer);
diff --git a/openmp/runtime/src/kmp_lock.cpp b/openmp/runtime/src/kmp_lock.cpp
index 11fa233..fd13003 100644
--- a/openmp/runtime/src/kmp_lock.cpp
+++ b/openmp/runtime/src/kmp_lock.cpp
@@ -712,16 +712,9 @@ static int __kmp_test_ticket_lock_with_checks(kmp_ticket_lock_t *lck,
}
int __kmp_release_ticket_lock(kmp_ticket_lock_t *lck, kmp_int32 gtid) {
- kmp_uint32 distance = std::atomic_load_explicit(&lck->lk.next_ticket,
- std::memory_order_relaxed) -
- std::atomic_load_explicit(&lck->lk.now_serving,
- std::memory_order_relaxed);
-
std::atomic_fetch_add_explicit(&lck->lk.now_serving, 1U,
std::memory_order_release);
- KMP_YIELD(distance >
- (kmp_uint32)(__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc));
return KMP_LOCK_RELEASED;
}
@@ -3460,6 +3453,7 @@ void __kmp_cleanup_indirect_user_locks() {
}
__kmp_free(ptr->table[row]);
}
+ __kmp_free(ptr->table);
kmp_indirect_lock_table_t *next_table = ptr->next_table;
if (ptr != &__kmp_i_lock_table)
__kmp_free(ptr);
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 6afea9b..39b7834 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -977,8 +977,7 @@ static void __kmp_fork_team_threads(kmp_root_t *root, kmp_team_t *team,
master_th->th.th_team_serialized = FALSE;
master_th->th.th_dispatch = &team->t.t_dispatch[0];
-/* make sure we are not the optimized hot team */
-#if KMP_NESTED_HOT_TEAMS
+ /* make sure we are not the optimized hot team */
use_hot_team = 0;
kmp_hot_team_ptr_t *hot_teams = master_th->th.th_hot_teams;
if (hot_teams) { // hot teams array is not allocated if
@@ -1009,9 +1008,6 @@ static void __kmp_fork_team_threads(kmp_root_t *root, kmp_team_t *team,
use_hot_team = 0;
}
}
-#else
- use_hot_team = team == root->r.r_hot_team;
-#endif
if (!use_hot_team) {
/* install the primary thread */
@@ -1255,13 +1251,12 @@ void __kmp_serialized_parallel(ident_t *loc, kmp_int32 global_tid) {
__kmp_acquire_bootstrap_lock(&__kmp_forkjoin_lock);
- new_team =
- __kmp_allocate_team(this_thr->th.th_root, 1, 1,
+ new_team = __kmp_allocate_team(
+ this_thr->th.th_root, 1, 1,
#if OMPT_SUPPORT
- ompt_parallel_data,
+ ompt_parallel_data,
#endif
- proc_bind, &this_thr->th.th_current_task->td_icvs,
- 0 USE_NESTED_HOT_ARG(NULL));
+ proc_bind, &this_thr->th.th_current_task->td_icvs, 0, NULL);
__kmp_release_bootstrap_lock(&__kmp_forkjoin_lock);
KMP_ASSERT(new_team);
@@ -1952,9 +1947,7 @@ int __kmp_fork_call(ident_t *loc, int gtid,
int level;
int active_level;
int teams_level;
-#if KMP_NESTED_HOT_TEAMS
kmp_hot_team_ptr_t **p_hot_teams;
-#endif
{ // KMP_TIME_BLOCK
KMP_TIME_DEVELOPER_PARTITIONED_BLOCK(KMP_fork_call);
KMP_COUNT_VALUE(OMP_PARALLEL_args, argc);
@@ -2012,7 +2005,6 @@ int __kmp_fork_call(ident_t *loc, int gtid,
active_level = parent_team->t.t_active_level;
// needed to check nesting inside the teams
teams_level = master_th->th.th_teams_level;
-#if KMP_NESTED_HOT_TEAMS
p_hot_teams = &master_th->th.th_hot_teams;
if (*p_hot_teams == NULL && __kmp_hot_teams_max_level > 0) {
*p_hot_teams = (kmp_hot_team_ptr_t *)__kmp_allocate(
@@ -2021,7 +2013,6 @@ int __kmp_fork_call(ident_t *loc, int gtid,
// it is either actual or not needed (when active_level > 0)
(*p_hot_teams)[0].hot_team_nth = 1;
}
-#endif
#if OMPT_SUPPORT
if (ompt_enabled.enabled) {
@@ -2200,20 +2191,18 @@ int __kmp_fork_call(ident_t *loc, int gtid,
#if OMPT_SUPPORT
ompt_parallel_data,
#endif
- proc_bind, &new_icvs,
- argc USE_NESTED_HOT_ARG(master_th));
+ proc_bind, &new_icvs, argc, master_th);
if (__kmp_barrier_release_pattern[bs_forkjoin_barrier] == bp_dist_bar)
copy_icvs((kmp_internal_control_t *)team->t.b->team_icvs, &new_icvs);
} else {
/* allocate a new parallel team */
KF_TRACE(10, ("__kmp_fork_call: before __kmp_allocate_team\n"));
- team = __kmp_allocate_team(root, nthreads, nthreads,
+ team = __kmp_allocate_team(
+ root, nthreads, nthreads,
#if OMPT_SUPPORT
- ompt_parallel_data,
+ ompt_parallel_data,
#endif
- proc_bind,
- &master_th->th.th_current_task->td_icvs,
- argc USE_NESTED_HOT_ARG(master_th));
+ proc_bind, &master_th->th.th_current_task->td_icvs, argc, master_th);
if (__kmp_barrier_release_pattern[bs_forkjoin_barrier] == bp_dist_bar)
copy_icvs((kmp_internal_control_t *)team->t.b->team_icvs,
&master_th->th.th_current_task->td_icvs);
@@ -2699,8 +2688,7 @@ void __kmp_join_call(ident_t *loc, int gtid
if (root->r.r_active != master_active)
root->r.r_active = master_active;
- __kmp_free_team(root, team USE_NESTED_HOT_ARG(
- master_th)); // this will free worker threads
+ __kmp_free_team(root, team, master_th); // this will free worker threads
/* this race was fun to find. make sure the following is in the critical
region otherwise assertions may fail occasionally since the old team may be
@@ -2716,8 +2704,7 @@ void __kmp_join_call(ident_t *loc, int gtid
if (parent_team->t.t_serialized &&
parent_team != master_th->th.th_serial_team &&
parent_team != root->r.r_root_team) {
- __kmp_free_team(root,
- master_th->th.th_serial_team USE_NESTED_HOT_ARG(NULL));
+ __kmp_free_team(root, master_th->th.th_serial_team, NULL);
master_th->th.th_serial_team = parent_team;
}
@@ -2823,11 +2810,8 @@ void __kmp_set_num_threads(int new_nth, int gtid) {
// rather than waiting for the next parallel region.
root = thread->th.th_root;
if (__kmp_init_parallel && (!root->r.r_active) &&
- (root->r.r_hot_team->t.t_nproc > new_nth)
-#if KMP_NESTED_HOT_TEAMS
- && __kmp_hot_teams_max_level && !__kmp_hot_teams_mode
-#endif
- ) {
+ (root->r.r_hot_team->t.t_nproc > new_nth) && __kmp_hot_teams_max_level &&
+ !__kmp_hot_teams_mode) {
kmp_team_t *hot_team = root->r.r_hot_team;
int f;
@@ -2848,12 +2832,10 @@ void __kmp_set_num_threads(int new_nth, int gtid) {
hot_team->t.t_threads[f] = NULL;
}
hot_team->t.t_nproc = new_nth;
-#if KMP_NESTED_HOT_TEAMS
if (thread->th.th_hot_teams) {
KMP_DEBUG_ASSERT(hot_team == thread->th.th_hot_teams[0].hot_team);
thread->th.th_hot_teams[0].hot_team_nth = new_nth;
}
-#endif
if (__kmp_barrier_release_pattern[bs_forkjoin_barrier] == bp_dist_bar) {
hot_team->t.b->update_num_threads(new_nth);
@@ -3375,17 +3357,16 @@ static void __kmp_initialize_root(kmp_root_t *root) {
/* allocate the root team structure */
KF_TRACE(10, ("__kmp_initialize_root: before root_team\n"));
- root_team =
- __kmp_allocate_team(root,
- 1, // new_nproc
- 1, // max_nproc
+ root_team = __kmp_allocate_team(root,
+ 1, // new_nproc
+ 1, // max_nproc
#if OMPT_SUPPORT
- ompt_data_none, // root parallel id
+ ompt_data_none, // root parallel id
#endif
- __kmp_nested_proc_bind.bind_types[0], &r_icvs,
- 0 // argc
- USE_NESTED_HOT_ARG(NULL) // primary thread is unknown
- );
+ __kmp_nested_proc_bind.bind_types[0], &r_icvs,
+ 0, // argc
+ NULL // primary thread is unknown
+ );
#if USE_DEBUGGER
// Non-NULL value should be assigned to make the debugger display the root
// team.
@@ -3413,17 +3394,16 @@ static void __kmp_initialize_root(kmp_root_t *root) {
/* allocate the hot team structure */
KF_TRACE(10, ("__kmp_initialize_root: before hot_team\n"));
- hot_team =
- __kmp_allocate_team(root,
- 1, // new_nproc
- __kmp_dflt_team_nth_ub * 2, // max_nproc
+ hot_team = __kmp_allocate_team(root,
+ 1, // new_nproc
+ __kmp_dflt_team_nth_ub * 2, // max_nproc
#if OMPT_SUPPORT
- ompt_data_none, // root parallel id
+ ompt_data_none, // root parallel id
#endif
- __kmp_nested_proc_bind.bind_types[0], &r_icvs,
- 0 // argc
- USE_NESTED_HOT_ARG(NULL) // primary thread is unknown
- );
+ __kmp_nested_proc_bind.bind_types[0], &r_icvs,
+ 0, // argc
+ NULL // primary thread is unknown
+ );
KF_TRACE(10, ("__kmp_initialize_root: after hot_team = %p\n", hot_team));
root->r.r_hot_team = hot_team;
@@ -3962,12 +3942,12 @@ int __kmp_register_root(int initial_thread) {
if (!root_thread->th.th_serial_team) {
kmp_internal_control_t r_icvs = __kmp_get_global_icvs();
KF_TRACE(10, ("__kmp_register_root: before serial_team\n"));
- root_thread->th.th_serial_team = __kmp_allocate_team(
- root, 1, 1,
+ root_thread->th.th_serial_team =
+ __kmp_allocate_team(root, 1, 1,
#if OMPT_SUPPORT
- ompt_data_none, // root parallel id
+ ompt_data_none, // root parallel id
#endif
- proc_bind_default, &r_icvs, 0 USE_NESTED_HOT_ARG(NULL));
+ proc_bind_default, &r_icvs, 0, NULL);
}
KMP_ASSERT(root_thread->th.th_serial_team);
KF_TRACE(10, ("__kmp_register_root: after serial_team = %p\n",
@@ -4073,7 +4053,6 @@ int __kmp_register_root(int initial_thread) {
return gtid;
}
-#if KMP_NESTED_HOT_TEAMS
static int __kmp_free_hot_teams(kmp_root_t *root, kmp_info_t *thr, int level,
const int max_level) {
int i, n, nth;
@@ -4098,7 +4077,6 @@ static int __kmp_free_hot_teams(kmp_root_t *root, kmp_info_t *thr, int level,
__kmp_free_team(root, team, NULL);
return n;
}
-#endif
// Resets a root thread and clear its root and hot teams.
// Returns the number of __kmp_threads entries directly and indirectly freed.
@@ -4114,8 +4092,7 @@ static int __kmp_reset_root(int gtid, kmp_root_t *root) {
root->r.r_hot_team = NULL;
// __kmp_free_team() does not free hot teams, so we have to clear r_hot_team
// before call to __kmp_free_team().
- __kmp_free_team(root, root_team USE_NESTED_HOT_ARG(NULL));
-#if KMP_NESTED_HOT_TEAMS
+ __kmp_free_team(root, root_team, NULL);
if (__kmp_hot_teams_max_level >
0) { // need to free nested hot teams and their threads if any
for (i = 0; i < hot_team->t.t_nproc; ++i) {
@@ -4129,8 +4106,7 @@ static int __kmp_reset_root(int gtid, kmp_root_t *root) {
}
}
}
-#endif
- __kmp_free_team(root, hot_team USE_NESTED_HOT_ARG(NULL));
+ __kmp_free_team(root, hot_team, NULL);
// Before we can reap the thread, we need to make certain that all other
// threads in the teams that had this root as ancestor have stopped trying to
@@ -4437,9 +4413,6 @@ kmp_info_t *__kmp_allocate_thread(kmp_root_t *root, kmp_team_t *team,
KA_TRACE(20, ("__kmp_allocate_thread: T#%d\n", __kmp_get_gtid()));
KMP_DEBUG_ASSERT(root && team);
-#if !KMP_NESTED_HOT_TEAMS
- KMP_DEBUG_ASSERT(KMP_MASTER_GTID(__kmp_get_gtid()));
-#endif
KMP_MB();
/* first, try to get one from the thread pool unless allocating thread is
@@ -4614,8 +4587,7 @@ kmp_info_t *__kmp_allocate_thread(kmp_root_t *root, kmp_team_t *team,
#if OMPT_SUPPORT
ompt_data_none, // root parallel id
#endif
- proc_bind_default, &r_icvs,
- 0 USE_NESTED_HOT_ARG(NULL));
+ proc_bind_default, &r_icvs, 0, NULL);
}
KMP_ASSERT(serial_team);
serial_team->t.t_serialized = 0; // AC: the team created in reserve, not for
@@ -5139,14 +5111,13 @@ static void __kmp_partition_places(kmp_team_t *team, int update_master_only) {
/* allocate a new team data structure to use. take one off of the free pool if
available */
-kmp_team_t *
-__kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
+kmp_team_t *__kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
#if OMPT_SUPPORT
- ompt_data_t ompt_parallel_data,
+ ompt_data_t ompt_parallel_data,
#endif
- kmp_proc_bind_t new_proc_bind,
- kmp_internal_control_t *new_icvs,
- int argc USE_NESTED_HOT_ARG(kmp_info_t *master)) {
+ kmp_proc_bind_t new_proc_bind,
+ kmp_internal_control_t *new_icvs, int argc,
+ kmp_info_t *master) {
KMP_TIME_DEVELOPER_PARTITIONED_BLOCK(KMP_allocate_team);
int f;
kmp_team_t *team;
@@ -5159,7 +5130,6 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
KMP_DEBUG_ASSERT(max_nproc >= new_nproc);
KMP_MB();
-#if KMP_NESTED_HOT_TEAMS
kmp_hot_team_ptr_t *hot_teams;
if (master) {
team = master->th.th_team;
@@ -5193,15 +5163,10 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
// check we won't access uninitialized hot_teams, just in case
KMP_DEBUG_ASSERT(new_nproc == 1);
}
-#endif
// Optimization to use a "hot" team
if (use_hot_team && new_nproc > 1) {
KMP_DEBUG_ASSERT(new_nproc <= max_nproc);
-#if KMP_NESTED_HOT_TEAMS
team = hot_teams[level].hot_team;
-#else
- team = root->r.r_hot_team;
-#endif
#if KMP_DEBUG
if (__kmp_tasking_mode != tskm_immediate_exec) {
KA_TRACE(20, ("__kmp_allocate_team: hot team task_team[0] = %p "
@@ -5288,20 +5253,17 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
th->th.th_task_team = NULL;
}
}
-#if KMP_NESTED_HOT_TEAMS
if (__kmp_hot_teams_mode == 0) {
// AC: saved number of threads should correspond to team's value in this
// mode, can be bigger in mode 1, when hot team has threads in reserve
KMP_DEBUG_ASSERT(hot_teams[level].hot_team_nth == team->t.t_nproc);
hot_teams[level].hot_team_nth = new_nproc;
-#endif // KMP_NESTED_HOT_TEAMS
/* release the extra threads we don't need any more */
for (f = new_nproc; f < team->t.t_nproc; f++) {
KMP_DEBUG_ASSERT(team->t.t_threads[f]);
__kmp_free_thread(team->t.t_threads[f]);
team->t.t_threads[f] = NULL;
}
-#if KMP_NESTED_HOT_TEAMS
} // (__kmp_hot_teams_mode == 0)
else {
// When keeping extra threads in team, switch threads to wait on own
@@ -5317,7 +5279,6 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
}
}
}
-#endif // KMP_NESTED_HOT_TEAMS
team->t.t_nproc = new_nproc;
// TODO???: team->t.t_max_active_levels = new_max_active_levels;
KMP_CHECK_UPDATE(team->t.t_sched.sched, new_icvs->sched.sched);
@@ -5358,7 +5319,6 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
int old_nproc = team->t.t_nproc; // save old value and use to update only
team->t.t_size_changed = 1;
-#if KMP_NESTED_HOT_TEAMS
int avail_threads = hot_teams[level].hot_team_nth;
if (new_nproc < avail_threads)
avail_threads = new_nproc;
@@ -5386,7 +5346,6 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
// get reserved threads involved if any.
team->t.t_nproc = hot_teams[level].hot_team_nth;
hot_teams[level].hot_team_nth = new_nproc; // adjust hot team max size
-#endif // KMP_NESTED_HOT_TEAMS
if (team->t.t_max_nproc < new_nproc) {
/* reallocate larger arrays */
__kmp_reallocate_team_arrays(team, new_nproc);
@@ -5435,9 +5394,7 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
/* Restore initial primary thread's affinity mask */
new_temp_affinity.restore();
#endif
-#if KMP_NESTED_HOT_TEAMS
} // end of check of t_nproc vs. new_nproc vs. hot_team_nth
-#endif // KMP_NESTED_HOT_TEAMS
if (__kmp_barrier_release_pattern[bs_forkjoin_barrier] == bp_dist_bar) {
// Barrier size already increased earlier in this function
// Activate team threads via th_used_in_team
@@ -5484,7 +5441,6 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
thr->th.th_teams_size = master->th.th_teams_size;
}
}
-#if KMP_NESTED_HOT_TEAMS
if (level) {
// Sync barrier state for nested hot teams, not needed for outermost hot
// team.
@@ -5501,7 +5457,6 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
}
}
}
-#endif // KMP_NESTED_HOT_TEAMS
/* reallocate space for arguments if necessary */
__kmp_alloc_argv_entries(argc, team, TRUE);
@@ -5666,8 +5621,7 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc,
/* free the team. return it to the team pool. release all the threads
* associated with it */
-void __kmp_free_team(kmp_root_t *root,
- kmp_team_t *team USE_NESTED_HOT_ARG(kmp_info_t *master)) {
+void __kmp_free_team(kmp_root_t *root, kmp_team_t *team, kmp_info_t *master) {
int f;
KA_TRACE(20, ("__kmp_free_team: T#%d freeing team %d\n", __kmp_get_gtid(),
team->t.t_id));
@@ -5679,7 +5633,6 @@ void __kmp_free_team(kmp_root_t *root,
KMP_DEBUG_ASSERT(team->t.t_threads);
int use_hot_team = team == root->r.r_hot_team;
-#if KMP_NESTED_HOT_TEAMS
int level;
if (master) {
level = team->t.t_active_level - 1;
@@ -5702,7 +5655,6 @@ void __kmp_free_team(kmp_root_t *root,
use_hot_team = 1;
}
}
-#endif // KMP_NESTED_HOT_TEAMS
/* team is done working */
TCW_SYNC_PTR(team->t.t_pkfn,
@@ -5749,9 +5701,7 @@ void __kmp_free_team(kmp_root_t *root,
20,
("__kmp_free_team: T#%d deactivating task_team %p on team %d\n",
__kmp_get_gtid(), task_team, team->t.t_id));
-#if KMP_NESTED_HOT_TEAMS
__kmp_free_task_team(master, task_team);
-#endif
team->t.t_task_team[tt_idx] = NULL;
}
}
@@ -8331,6 +8281,7 @@ void __kmp_cleanup(void) {
__kmp_free(ptr);
ptr = next;
}
+ __kmp_old_threads_list = NULL;
#if KMP_USE_DYNAMIC_LOCK
__kmp_cleanup_indirect_user_locks();
@@ -8338,7 +8289,7 @@ void __kmp_cleanup(void) {
__kmp_cleanup_user_locks();
#endif
#if OMPD_SUPPORT
- if (ompd_state) {
+ if (ompd_env_block) {
__kmp_free(ompd_env_block);
ompd_env_block = NULL;
ompd_env_block_size = 0;
@@ -8364,6 +8315,8 @@ void __kmp_cleanup(void) {
__kmp_nested_proc_bind.bind_types = NULL;
__kmp_nested_proc_bind.size = 0;
__kmp_nested_proc_bind.used = 0;
+ __kmp_dflt_team_nth = 0;
+ __kmp_dflt_team_nth_ub = 0;
if (__kmp_affinity_format) {
KMP_INTERNAL_FREE(__kmp_affinity_format);
__kmp_affinity_format = NULL;
@@ -8371,6 +8324,9 @@ void __kmp_cleanup(void) {
__kmp_i18n_catclose();
+ if (__kmp_nesting_nth_level)
+ KMP_INTERNAL_FREE(__kmp_nesting_nth_level);
+
#if KMP_USE_HIER_SCHED
__kmp_hier_scheds.deallocate();
#endif
@@ -8379,6 +8335,9 @@ void __kmp_cleanup(void) {
__kmp_stats_fini();
#endif
+ __kmpc_destroy_allocator(KMP_GTID_SHUTDOWN, __kmp_def_allocator);
+ __kmp_def_allocator = omp_default_mem_alloc;
+
KA_TRACE(10, ("__kmp_cleanup: exit\n"));
}
@@ -8774,11 +8733,15 @@ static int __kmp_aux_capture_affinity_field(int gtid, const kmp_info_t *th,
break;
#if KMP_AFFINITY_SUPPORTED
case 'A': {
- kmp_str_buf_t buf;
- __kmp_str_buf_init(&buf);
- __kmp_affinity_str_buf_mask(&buf, th->th.th_affin_mask);
- rc = __kmp_str_buf_print(field_buffer, format, buf.str);
- __kmp_str_buf_free(&buf);
+ if (th->th.th_affin_mask) {
+ kmp_str_buf_t buf;
+ __kmp_str_buf_init(&buf);
+ __kmp_affinity_str_buf_mask(&buf, th->th.th_affin_mask);
+ rc = __kmp_str_buf_print(field_buffer, format, buf.str);
+ __kmp_str_buf_free(&buf);
+ } else {
+ rc = __kmp_str_buf_print(field_buffer, "%s", "disabled");
+ }
} break;
#endif
default:
diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index 392a02e..31342c8 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -1158,7 +1158,6 @@ static void __kmp_parse_nested_num_threads(const char *var, const char *env,
}
if (!__kmp_dflt_max_active_levels_set && total > 1)
__kmp_dflt_max_active_levels = KMP_MAX_ACTIVE_LEVELS_LIMIT;
- KMP_DEBUG_ASSERT(total > 0);
if (total <= 0) {
KMP_WARNING(NthSyntaxError, var, env);
return;
@@ -1248,8 +1247,11 @@ static void __kmp_stg_parse_num_threads(char const *name, char const *value,
// TODO: Remove this option. OMP_NUM_THREADS is a list of positive integers!
if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) {
// The array of 1 element
- __kmp_nested_nth.nth = (int *)KMP_INTERNAL_MALLOC(sizeof(int));
- __kmp_nested_nth.size = __kmp_nested_nth.used = 1;
+ if (!__kmp_nested_nth.nth) {
+ __kmp_nested_nth.nth = (int *)KMP_INTERNAL_MALLOC(sizeof(int));
+ __kmp_nested_nth.size = 1;
+ }
+ __kmp_nested_nth.used = 1;
__kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub =
__kmp_xproc;
} else {
@@ -1361,6 +1363,11 @@ static void __kmp_stg_parse_tasking(char const *name, char const *value,
void *data) {
__kmp_stg_parse_int(name, value, 0, (int)tskm_max,
(int *)&__kmp_tasking_mode);
+ // KMP_TASKING=1 (task barrier) doesn't work anymore, change to task_teams (2)
+ if (__kmp_tasking_mode == tskm_extra_barrier) {
+ KMP_WARNING(StgInvalidValue, name, value);
+ __kmp_tasking_mode = tskm_task_teams;
+ }
} // __kmp_stg_parse_tasking
static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer, char const *name,
@@ -1501,7 +1508,6 @@ static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer,
__kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers);
} // __kmp_stg_print_disp_buffers
-#if KMP_NESTED_HOT_TEAMS
// -----------------------------------------------------------------------------
// KMP_HOT_TEAMS_MAX_LEVEL, KMP_HOT_TEAMS_MODE
@@ -1511,8 +1517,8 @@ static void __kmp_stg_parse_hot_teams_level(char const *name, char const *value,
KMP_WARNING(EnvParallelWarn, name);
return;
} // read value before first parallel only
- __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT,
- &__kmp_hot_teams_max_level);
+ __kmp_stg_parse_int(name, value, 0, 1024, &__kmp_hot_teams_max_level);
+
} // __kmp_stg_parse_hot_teams_level
static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer,
@@ -1535,8 +1541,6 @@ static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer,
__kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode);
} // __kmp_stg_print_hot_teams_mode
-#endif // KMP_NESTED_HOT_TEAMS
-
// -----------------------------------------------------------------------------
// KMP_HANDLE_SIGNALS
@@ -1678,6 +1682,11 @@ static void __kmp_stg_parse_align_alloc(char const *name, char const *value,
void *data) {
__kmp_stg_parse_size(name, value, CACHE_LINE, INT_MAX, NULL,
&__kmp_align_alloc, 1);
+ // Must be power of 2
+ if (__kmp_align_alloc == 0 || ((__kmp_align_alloc - 1) & __kmp_align_alloc)) {
+ KMP_WARNING(StgInvalidValue, name, value);
+ __kmp_align_alloc = CACHE_LINE;
+ }
} // __kmp_stg_parse_align_alloc
static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer, char const *name,
@@ -1710,15 +1719,16 @@ static void __kmp_stg_parse_barrier_branch_bit(char const *name,
} else {
__kmp_barrier_release_branch_bits[i] =
(kmp_uint32)__kmp_str_to_int(comma + 1, 0);
-
- if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
+ if (__kmp_barrier_release_branch_bits[i] == 0 ||
+ __kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
__kmp_msg(kmp_ms_warning,
KMP_MSG(BarrReleaseValueInvalid, name, comma + 1),
__kmp_msg_null);
__kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt;
}
}
- if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
+ if (__kmp_barrier_gather_branch_bits[i] == 0 ||
+ __kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS) {
KMP_WARNING(BarrGatherValueInvalid, name, value);
KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt);
__kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt;
@@ -2198,7 +2208,7 @@ static int __kmp_parse_affinity_proc_id_list(const char *var, const char *env,
{
ptrdiff_t len = next - env;
- char *retlist = (char *)__kmp_allocate((len + 1) * sizeof(char));
+ char *retlist = (char *)KMP_INTERNAL_MALLOC((len + 1) * sizeof(char));
KMP_MEMCPY_S(retlist, (len + 1) * sizeof(char), env, len * sizeof(char));
retlist[len] = '\0';
*proclist = retlist;
@@ -3016,7 +3026,7 @@ static int __kmp_parse_place_list(const char *var, const char *env,
{
ptrdiff_t len = scan - env;
- char *retlist = (char *)__kmp_allocate((len + 1) * sizeof(char));
+ char *retlist = (char *)KMP_INTERNAL_MALLOC((len + 1) * sizeof(char));
KMP_MEMCPY_S(retlist, (len + 1) * sizeof(char), env, len * sizeof(char));
retlist[len] = '\0';
*place_list = retlist;
@@ -3486,18 +3496,8 @@ static void __kmp_stg_parse_proc_bind(char const *name, char const *value,
const char *buf = value;
const char *next;
- int num;
+
SKIP_WS(buf);
- if ((*buf >= '0') && (*buf <= '9')) {
- next = buf;
- SKIP_DIGITS(next);
- num = __kmp_str_to_int(buf, *next);
- KMP_ASSERT(num >= 0);
- buf = next;
- SKIP_WS(buf);
- } else {
- num = -1;
- }
next = buf;
if (__kmp_match_str("disabled", buf, &next)) {
@@ -3508,8 +3508,7 @@ static void __kmp_stg_parse_proc_bind(char const *name, char const *value,
#endif /* KMP_AFFINITY_SUPPORTED */
__kmp_nested_proc_bind.used = 1;
__kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
- } else if ((num == (int)proc_bind_false) ||
- __kmp_match_str("false", buf, &next)) {
+ } else if (__kmp_match_str("false", buf, &next)) {
buf = next;
SKIP_WS(buf);
#if KMP_AFFINITY_SUPPORTED
@@ -3517,8 +3516,7 @@ static void __kmp_stg_parse_proc_bind(char const *name, char const *value,
#endif /* KMP_AFFINITY_SUPPORTED */
__kmp_nested_proc_bind.used = 1;
__kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
- } else if ((num == (int)proc_bind_true) ||
- __kmp_match_str("true", buf, &next)) {
+ } else if (__kmp_match_str("true", buf, &next)) {
buf = next;
SKIP_WS(buf);
__kmp_nested_proc_bind.used = 1;
@@ -3554,19 +3552,16 @@ static void __kmp_stg_parse_proc_bind(char const *name, char const *value,
for (;;) {
enum kmp_proc_bind_t bind;
- if ((num == (int)proc_bind_primary) ||
- __kmp_match_str("master", buf, &next) ||
+ if (__kmp_match_str("master", buf, &next) ||
__kmp_match_str("primary", buf, &next)) {
buf = next;
SKIP_WS(buf);
bind = proc_bind_primary;
- } else if ((num == (int)proc_bind_close) ||
- __kmp_match_str("close", buf, &next)) {
+ } else if (__kmp_match_str("close", buf, &next)) {
buf = next;
SKIP_WS(buf);
bind = proc_bind_close;
- } else if ((num == (int)proc_bind_spread) ||
- __kmp_match_str("spread", buf, &next)) {
+ } else if (__kmp_match_str("spread", buf, &next)) {
buf = next;
SKIP_WS(buf);
bind = proc_bind_spread;
@@ -3581,21 +3576,13 @@ static void __kmp_stg_parse_proc_bind(char const *name, char const *value,
if (i >= nelem) {
break;
}
- KMP_DEBUG_ASSERT(*buf == ',');
+ if (*buf != ',') {
+ KMP_WARNING(ParseExtraCharsWarn, name, buf);
+ while (*buf != ',')
+ buf++;
+ }
buf++;
SKIP_WS(buf);
-
- // Read next value if it was specified as an integer
- if ((*buf >= '0') && (*buf <= '9')) {
- next = buf;
- SKIP_DIGITS(next);
- num = __kmp_str_to_int(buf, *next);
- KMP_ASSERT(num >= 0);
- buf = next;
- SKIP_WS(buf);
- } else {
- num = -1;
- }
}
SKIP_WS(buf);
}
@@ -4536,6 +4523,10 @@ static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer, char const *name,
static void __kmp_stg_parse_consistency_check(char const *name,
char const *value, void *data) {
+ if (TCR_4(__kmp_init_serial)) {
+ KMP_WARNING(EnvSerialWarn, name);
+ return;
+ } // read value before serial initialization only
if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) {
// Note, this will not work from kmp_set_defaults because th_cons stack was
// not allocated
@@ -4902,7 +4893,6 @@ static void __kmp_stg_parse_spin_backoff_params(const char *name,
}
}
}
- KMP_DEBUG_ASSERT(total > 0);
if (total <= 0) {
KMP_WARNING(EnvSyntaxError, name, value);
return;
@@ -4998,7 +4988,6 @@ static void __kmp_stg_parse_adaptive_lock_props(const char *name,
}
}
}
- KMP_DEBUG_ASSERT(total > 0);
if (total <= 0) {
KMP_WARNING(EnvSyntaxError, name, value);
return;
@@ -5569,12 +5558,10 @@ static kmp_setting_t __kmp_stg_table[] = {
__kmp_stg_print_wait_policy, NULL, 0, 0},
{"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers,
__kmp_stg_print_disp_buffers, NULL, 0, 0},
-#if KMP_NESTED_HOT_TEAMS
{"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level,
__kmp_stg_print_hot_teams_level, NULL, 0, 0},
{"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode,
__kmp_stg_print_hot_teams_mode, NULL, 0, 0},
-#endif // KMP_NESTED_HOT_TEAMS
#if KMP_HANDLE_SIGNALS
{"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals,
@@ -5758,7 +5745,8 @@ static kmp_setting_t __kmp_stg_table[] = {
#if OMPX_TASKGRAPH
{"KMP_MAX_TDGS", __kmp_stg_parse_max_tdgs, __kmp_std_print_max_tdgs, NULL,
0, 0},
- {"KMP_TDG_DOT", __kmp_stg_parse_tdg_dot, __kmp_stg_print_tdg_dot, NULL, 0, 0},
+ {"KMP_TDG_DOT", __kmp_stg_parse_tdg_dot, __kmp_stg_print_tdg_dot, NULL, 0,
+ 0},
#endif
#if OMPT_SUPPORT
diff --git a/openmp/runtime/src/kmp_str.cpp b/openmp/runtime/src/kmp_str.cpp
index 6ee2df7..12cce53 100644
--- a/openmp/runtime/src/kmp_str.cpp
+++ b/openmp/runtime/src/kmp_str.cpp
@@ -628,6 +628,11 @@ int __kmp_basic_str_to_int(char const *str) {
for (t = str; *t != '\0'; ++t) {
if (*t < '0' || *t > '9')
break;
+ // Cap parsing to create largest integer
+ if (result >= (INT_MAX - (*t - '0')) / 10) {
+ result = INT_MAX;
+ break;
+ }
result = (result * 10) + (*t - '0');
}
@@ -643,9 +648,20 @@ int __kmp_str_to_int(char const *str, char sentinel) {
for (t = str; *t != '\0'; ++t) {
if (*t < '0' || *t > '9')
break;
+ // Cap parsing to create largest integer
+ if (result >= (INT_MAX - (*t - '0')) / 10) {
+ result = INT_MAX;
+ break;
+ }
result = (result * 10) + (*t - '0');
}
+ // Parse rest of large number by skipping the digits so t points to sentinel
+ if (result == INT_MAX)
+ for (t = str; *t != '\0'; ++t)
+ if (*t < '0' || *t > '9')
+ break;
+
switch (*t) {
case '\0': /* the current default for no suffix is bytes */
factor = 1;