forked from OSchip/llvm-project
[OpenMP] Add a few small fixes
* 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 parrange parsing Differential Revision: https://reviews.llvm.org/D105929
This commit is contained in:
parent
6eeb4c1f32
commit
b4a1f441d9
|
@ -1439,6 +1439,8 @@ __kmp_mm_mwait(unsigned extensions, unsigned hints) {
|
||||||
/* Support datatypes for the orphaned construct nesting checks. */
|
/* 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 {
|
enum cons_type {
|
||||||
ct_none,
|
ct_none,
|
||||||
ct_parallel,
|
ct_parallel,
|
||||||
|
|
|
@ -561,6 +561,7 @@ void __kmp_dispatch_init_algorithm(ident_t *loc, int gtid,
|
||||||
_control87(_PC_64, _MCW_PC); // 0,0x30000
|
_control87(_PC_64, _MCW_PC); // 0,0x30000
|
||||||
#endif
|
#endif
|
||||||
/* value used for comparison in solver for cross-over point */
|
/* value used for comparison in solver for cross-over point */
|
||||||
|
KMP_ASSERT(tc > 0);
|
||||||
long double target = ((long double)chunk * 2 + 1) * nproc / tc;
|
long double target = ((long double)chunk * 2 + 1) * nproc / tc;
|
||||||
|
|
||||||
/* crossover point--chunk indexes equal to or greater than
|
/* crossover point--chunk indexes equal to or greater than
|
||||||
|
@ -1715,7 +1716,7 @@ int __kmp_dispatch_next_algorithm(int gtid,
|
||||||
status = 0; // nothing to do, don't try atomic op
|
status = 0; // nothing to do, don't try atomic op
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
KMP_DEBUG_ASSERT(init % chunk == 0);
|
KMP_DEBUG_ASSERT(chunk && init % chunk == 0);
|
||||||
// compare with K*nproc*(chunk+1), K=2 by default
|
// compare with K*nproc*(chunk+1), K=2 by default
|
||||||
if ((T)remaining < pr->u.p.parm2) {
|
if ((T)remaining < pr->u.p.parm2) {
|
||||||
// use dynamic-style schedule
|
// use dynamic-style schedule
|
||||||
|
|
|
@ -431,6 +431,7 @@ static void __kmp_stg_parse_par_range(char const *name, char const *value,
|
||||||
int *out_range, char *out_routine,
|
int *out_range, char *out_routine,
|
||||||
char *out_file, int *out_lb,
|
char *out_file, int *out_lb,
|
||||||
int *out_ub) {
|
int *out_ub) {
|
||||||
|
const char *par_range_value;
|
||||||
size_t len = KMP_STRLEN(value) + 1;
|
size_t len = KMP_STRLEN(value) + 1;
|
||||||
par_range_to_print = (char *)KMP_INTERNAL_MALLOC(len + 1);
|
par_range_to_print = (char *)KMP_INTERNAL_MALLOC(len + 1);
|
||||||
KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
|
KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1);
|
||||||
|
@ -439,11 +440,14 @@ static void __kmp_stg_parse_par_range(char const *name, char const *value,
|
||||||
__kmp_par_range_ub = INT_MAX;
|
__kmp_par_range_ub = INT_MAX;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
if (*value == '\0') {
|
if (!value || *value == '\0') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!__kmp_strcasecmp_with_sentinel("routine", value, '=')) {
|
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,
|
len = __kmp_readstr_with_sentinel(out_routine, value,
|
||||||
KMP_PAR_RANGE_ROUTINE_LEN - 1, ',');
|
KMP_PAR_RANGE_ROUTINE_LEN - 1, ',');
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
@ -456,7 +460,10 @@ static void __kmp_stg_parse_par_range(char const *name, char const *value,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!__kmp_strcasecmp_with_sentinel("filename", value, '=')) {
|
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,
|
len = __kmp_readstr_with_sentinel(out_file, value,
|
||||||
KMP_PAR_RANGE_FILENAME_LEN - 1, ',');
|
KMP_PAR_RANGE_FILENAME_LEN - 1, ',');
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
@ -470,7 +477,10 @@ static void __kmp_stg_parse_par_range(char const *name, char const *value,
|
||||||
}
|
}
|
||||||
if ((!__kmp_strcasecmp_with_sentinel("range", value, '=')) ||
|
if ((!__kmp_strcasecmp_with_sentinel("range", value, '=')) ||
|
||||||
(!__kmp_strcasecmp_with_sentinel("incl_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) {
|
if (KMP_SSCANF(value, "%d:%d", out_lb, out_ub) != 2) {
|
||||||
goto par_range_error;
|
goto par_range_error;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +492,10 @@ static void __kmp_stg_parse_par_range(char const *name, char const *value,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!__kmp_strcasecmp_with_sentinel("excl_range", value, '=')) {
|
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) {
|
if (KMP_SSCANF(value, "%d:%d", out_lb, out_ub) != 2) {
|
||||||
goto par_range_error;
|
goto par_range_error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue