diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp --- a/openmp/runtime/src/kmp_affinity.cpp +++ b/openmp/runtime/src/kmp_affinity.cpp @@ -2943,6 +2943,16 @@ } (*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 there is a + // disrupter on LoongArch that a blank line exists before the first + // processor info block (i.e. after the "system type" line). 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;