aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src/kmp_affinity.cpp
diff options
context:
space:
mode:
authorgonglingqin <gonglingqin@loongson.cn>2022-12-13 19:44:06 +0800
committergonglingqin <gonglingqin@loongson.cn>2022-12-13 20:13:10 +0800
commit9a0831afa03a8e3181dccb3338fb804db80a96a3 (patch)
tree39b8625d7716535b7086b1d0a94aa2611ee87c6d /openmp/runtime/src/kmp_affinity.cpp
parent38386b4318e3ba54f450480ad49b237a9c357af4 (diff)
downloadllvm-9a0831afa03a8e3181dccb3338fb804db80a96a3.zip
llvm-9a0831afa03a8e3181dccb3338fb804db80a96a3.tar.gz
llvm-9a0831afa03a8e3181dccb3338fb804db80a96a3.tar.bz2
[OpenMP] Skip extra blank line when parsing /proc/cpuinfo on LoongArch64
This fixes the following test cases: * affinity/kmp-affinity.c * affinity/kmp-hw-subset.c * affinity/omp-places.c Differential Revision: https://reviews.llvm.org/D139802
Diffstat (limited to 'openmp/runtime/src/kmp_affinity.cpp')
-rw-r--r--openmp/runtime/src/kmp_affinity.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index 43bf794..fb3f0ed 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -2943,6 +2943,17 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line,
}
(*line)++;
+#if KMP_ARCH_LOONGARCH64
+ // The parsing logic of /proc/cpuinfo in this function highly depends on
+ // the blank lines between each processor info block. But on LoongArch a
+ // blank line exists before the first processor info block (i.e. after the
+ // "system type" line). This blank line was added because the "system
+ // type" line is unrelated to any of the CPUs. We must skip this line so
+ // that the original logic works on LoongArch.
+ if (*buf == '\n' && *line == 2)
+ continue;
+#endif
+
char s1[] = "processor";
if (strncmp(buf, s1, sizeof(s1) - 1) == 0) {
CHECK_LINE;