[Openmp-commits] [openmp] 24d0ef0 - [OpenMP] Fixed a bug when displaying affinity
Shilei Tian via Openmp-commits
openmp-commits at lists.llvm.org
Thu Nov 12 19:27:40 PST 2020
Author: Shilei Tian
Date: 2020-11-12T22:27:32-05:00
New Revision: 24d0ef0f503f8230f115df049ee0ccd067f0881b
URL: https://github.com/llvm/llvm-project/commit/24d0ef0f503f8230f115df049ee0ccd067f0881b
DIFF: https://github.com/llvm/llvm-project/commit/24d0ef0f503f8230f115df049ee0ccd067f0881b.diff
LOG: [OpenMP] Fixed a bug when displaying affinity
Currently the affinity format string has initial value. When users set
the format via OMP_AFFINITY_FORMAT, it will overwrite the format string. However,
when copying the format, the tailing null is missing. As a result, if the user
format string is shorter than default value, the remaining part in the default
value still makes effort. This bug is not exposed because the test case doesn't
check the end of a string. It only checks whether given output "contains" the
check string.
Reviewed By: AndreyChurbanov
Differential Revision: https://reviews.llvm.org/D91309
Added:
Modified:
openmp/runtime/src/kmp_safe_c_api.h
openmp/runtime/test/affinity/format/simple_env.c
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_safe_c_api.h b/openmp/runtime/src/kmp_safe_c_api.h
index f839f734aa98..abc0a16f87cf 100644
--- a/openmp/runtime/src/kmp_safe_c_api.h
+++ b/openmp/runtime/src/kmp_safe_c_api.h
@@ -64,11 +64,9 @@ static inline void __kmp_strncpy_truncate(char *buffer, size_t buf_size,
char const *src, size_t src_size) {
if (src_size >= buf_size) {
src_size = buf_size - 1;
- KMP_STRNCPY_S(buffer, buf_size, src, src_size);
- buffer[buf_size - 1] = '\0';
- } else {
- KMP_STRNCPY_S(buffer, buf_size, src, src_size);
}
+ KMP_STRNCPY_S(buffer, buf_size, src, src_size);
+ buffer[src_size] = '\0';
}
#endif // KMP_SAFE_C_API_H
diff --git a/openmp/runtime/test/affinity/format/simple_env.c b/openmp/runtime/test/affinity/format/simple_env.c
index ad0a2651e364..f369e9f3704d 100644
--- a/openmp/runtime/test/affinity/format/simple_env.c
+++ b/openmp/runtime/test/affinity/format/simple_env.c
@@ -13,4 +13,4 @@ int main(int argc, char** argv) {
return 0;
}
-// CHECK-8: num_threads=8 TESTER-ENV: tl:1 tn:[0-7] nt:8
+// CHECK-8: num_threads=8 TESTER-ENV: tl:1 tn:[0-7] nt:8$
More information about the Openmp-commits
mailing list