[Openmp-commits] [PATCH] D105929: [OpenMP] Fix a small few issues
Jonathan Peyton via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jul 13 12:39:38 PDT 2021
jlpeyton created this revision.
jlpeyton added reviewers: hbae, AndreyChurbanov, tlwilmar, Nawrin.
jlpeyton added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
jlpeyton requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
- Add comment to help ensure new construct data are added in two places
- Check for division by zero in the loop worksharing code
- Check for syntax errors in par-range parsing
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105929
Files:
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_dispatch.cpp
openmp/runtime/src/kmp_settings.cpp
Index: openmp/runtime/src/kmp_settings.cpp
===================================================================
--- openmp/runtime/src/kmp_settings.cpp
+++ openmp/runtime/src/kmp_settings.cpp
@@ -426,6 +426,7 @@
int *out_range, char *out_routine,
char *out_file, int *out_lb,
int *out_ub) {
+ const char *par_range_value;
size_t len = KMP_STRLEN(value) + 1;
par_range_to_print = (char *)KMP_INTERNAL_MALLOC(len + 1);
KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
@@ -434,11 +435,14 @@
__kmp_par_range_ub = INT_MAX;
for (;;) {
unsigned int len;
- if (*value == '\0') {
+ if (!value || *value == '\0') {
break;
}
if (!__kmp_strcasecmp_with_sentinel("routine", value, '=')) {
- value = strchr(value, '=') + 1;
+ par_range_value = strchr(value, '=') + 1;
+ if (!par_range_value)
+ goto par_range_error;
+ value = par_range_value;
len = __kmp_readstr_with_sentinel(out_routine, value,
KMP_PAR_RANGE_ROUTINE_LEN - 1, ',');
if (len == 0) {
@@ -451,7 +455,10 @@
continue;
}
if (!__kmp_strcasecmp_with_sentinel("filename", value, '=')) {
- value = strchr(value, '=') + 1;
+ par_range_value = strchr(value, '=') + 1;
+ if (!par_range_value)
+ goto par_range_error;
+ value = par_range_value;
len = __kmp_readstr_with_sentinel(out_file, value,
KMP_PAR_RANGE_FILENAME_LEN - 1, ',');
if (len == 0) {
@@ -465,7 +472,10 @@
}
if ((!__kmp_strcasecmp_with_sentinel("range", value, '=')) ||
(!__kmp_strcasecmp_with_sentinel("incl_range", value, '='))) {
- value = strchr(value, '=') + 1;
+ par_range_value = strchr(value, '=') + 1;
+ if (!par_range_value)
+ goto par_range_error;
+ value = par_range_value;
if (KMP_SSCANF(value, "%d:%d", out_lb, out_ub) != 2) {
goto par_range_error;
}
@@ -477,7 +487,10 @@
continue;
}
if (!__kmp_strcasecmp_with_sentinel("excl_range", value, '=')) {
- value = strchr(value, '=') + 1;
+ par_range_value = strchr(value, '=') + 1;
+ if (!par_range_value)
+ goto par_range_error;
+ value = par_range_value;
if (KMP_SSCANF(value, "%d:%d", out_lb, out_ub) != 2) {
goto par_range_error;
}
Index: openmp/runtime/src/kmp_dispatch.cpp
===================================================================
--- openmp/runtime/src/kmp_dispatch.cpp
+++ openmp/runtime/src/kmp_dispatch.cpp
@@ -561,6 +561,7 @@
_control87(_PC_64, _MCW_PC); // 0,0x30000
#endif
/* value used for comparison in solver for cross-over point */
+ KMP_ASSERT(tc > 0);
long double target = ((long double)chunk * 2 + 1) * nproc / tc;
/* crossover point--chunk indexes equal to or greater than
@@ -1713,7 +1714,7 @@
status = 0; // nothing to do, don't try atomic op
break;
}
- KMP_DEBUG_ASSERT(init % chunk == 0);
+ KMP_DEBUG_ASSERT(chunk && init % chunk == 0);
// compare with K*nproc*(chunk+1), K=2 by default
if ((T)remaining < pr->u.p.parm2) {
// use dynamic-style schedule
Index: openmp/runtime/src/kmp.h
===================================================================
--- openmp/runtime/src/kmp.h
+++ openmp/runtime/src/kmp.h
@@ -1437,6 +1437,8 @@
/* Support datatypes for the orphaned construct nesting checks. */
/* ------------------------------------------------------------------------ */
+/* When adding to this enum, add its corresponding string in cons_text_c[]
+ * array in kmp_error.cpp */
enum cons_type {
ct_none,
ct_parallel,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105929.358368.patch
Type: text/x-patch
Size: 3838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210713/238f6e9f/attachment.bin>
More information about the Openmp-commits
mailing list