You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like there have been some changes to OpenMP # threads, so the only thing that stands out to me in that test is
#ifdefUSE_OPENMPnthreads_omp=omp_get_max_threads();
// Run with half the max OMP threads, the max threads and twice thatfor(i= (nthreads_omp+1) / 2; i <= nthreads_omp*2; i *= 2) {
omp_set_num_threads(i);
#endif
i.e. calling omp_set_num_threads with double the number of threads reported available by omp_get_max_threads.
Interesting. Requests for more than omp_get_max_threads() would get (silently) clamped to that limit until recently. Not sure why that would lead to failures on power9 specifically, and sadly our Travis CI seems to have gone dead again while
still displaying the "all good" badge. (This may have masked the problem - though I'm fairly sure I tested this change manually in the gcc compile farm)
Not reproducible with gcc 10.1 on power9, but will probably have to build my own if I want a newer compiler on that machine. Are there other architectures where the openblas_utest hangs for you ?
Hm, maybe the issue is just related to the build job using more cores than requested (it builds with -j1, probably omp_get_max_threads() returns something big inside the tests). I'll close for now.
@martin-frbg sorry for wasting your time (again 😆). I think the issue had to do with a small CI job getting scheduled to a large CPU, and although the build used -j1, the tests started to use nproc / 2, nproc, and 2 * nproc threads. Potentially cgroups were used to tame the build's CPU usage.
Now I'm running make ... all -j1 with the environment variable OMP_NUM_THREADS=1 (which feels wrong, but well) and things are looking better.
I'm observing this as well with an old Xeon machine with 4 cores/8threads. And some user on the arch forum as well. https://aur.archlinux.org/packages/openblas-lapack. I've bisected it to your changes here: 9f9d001
I can pass the test if I run it individually (with ./openblas_utest fork) which is a bit puzzling. I also get the test suite to pass if I run it with OPENBLAS_NUM_THREADS=8 openblas_utest. This could potentially make sense given your changes.
Strange - declaring 8 threads should be no different from letting openblas figure it out . "Old Xeon" probably means Haswell target so nothing exotic (and the user report seems to be from quad-core Zen2, pretty much the same setup as far as openblas is concerned)
#ifdef USE_OPENMP
nthreads_omp = omp_get_max_threads();
printf("\nomp_threads:%d\topenblas_threads:%d\n", nthreads_omp, openblas_get_num_threads());
// Run with half the max OMP threads, the max threads and twice that
for(i = (nthreads_omp + 1) / 2; i <= nthreads_omp * 2; i *= 2) {
printf("setting omp threads to: %d\n", i);
omp_set_num_threads(i);
#endif
printf("omp_threads:%d\topenblas_threads:%d\n", nthreads_omp, openblas_get_num_threads());
fork_pid = fork();
if (fork_pid == -1) {
CTEST_ERR("Failed to fork process.");
} else if (fork_pid == 0) {
// Just pretend to do something, e.g. call `uname`, then exit
exit(0);
} else {
// Wait for the child to finish and check the exit code.
int child_status = 0;
pid_t wait_pid = wait(&child_status);
ASSERT_EQUAL(wait_pid, fork_pid);
ASSERT_EQUAL(0, WEXITSTATUS (child_status));
// Now OpenBLAS has to work
printf("after fork\n");
printf("omp_threads:%d\topenblas_threads:%d\n", nthreads_omp, openblas_get_num_threads());
check_dgemm(a, b, d, c, n);
printf("after gemm\n");
printf("omp_threads:%d\topenblas_threads:%d\n", nthreads_omp, openblas_get_num_threads());
}
TEST 37/37 fork:safety_after_fork_in_parent
omp_threads:8 openblas_threads:8
setting omp threads to: 4
omp_threads:8 openblas_threads:8
after fork
omp_threads:8 openblas_threads:8
after gemm
omp_threads:8 openblas_threads:4
setting omp threads to: 8
omp_threads:8 openblas_threads:4
after fork
omp_threads:8 openblas_threads:4
after gemm
omp_threads:8 openblas_threads:8
setting omp threads to: 16
omp_threads:8 openblas_threads:8
after fork
omp_threads:8 openblas_threads:8
after gemm
omp_threads:8 openblas_threads:16
[OK]
and after:
TEST 1/1 fork:safety_after_fork_in_parent
omp_threads:8 openblas_threads:16
setting omp threads to: 4
omp_threads:8 openblas_threads:16
after fork
omp_threads:8 openblas_threads:16
after gemm
omp_threads:8 openblas_threads:4
setting omp threads to: 8
omp_threads:8 openblas_threads:4
after fork
omp_threads:8 openblas_threads:4
after gemm
omp_threads:8 openblas_threads:4
setting omp threads to: 16
omp_threads:8 openblas_threads:4
after fork
omp_threads:8 openblas_threads:4
after gemm
omp_threads:8 openblas_threads:4
[OK]
or if I try to run the whole test suite:
omp_threads:8 openblas_threads:8
setting omp threads to: 4
omp_threads:8 openblas_threads:8
after fork
omp_threads:8 openblas_threads:8
and then it gets stuck.
So even when I can make it run, I think the behavior changed since setting omp num threads will permanently set openblas threads to a low number, which I'm not sure is a desired feature.
I'm still trying to understand why would the test get stuck.
This might be two separate issues - openblas thread count no longer getting unconditionally initialized to the omp num threads (note both "old" and "new" behavior have the omp num threads permanently affecting openblas thread count); and a race condition somewhere that may have been aggravated by the changed thread ratio.
I still cannot reproduce the hang, I can let my 6-core laptop run openblas_utest in a loop for hours, and I can also run it repeatedly on a 12-core Xeon in the gcc compile farm (though ofc I won't let it loop there for hours).
The clang assertion appears to be triggered by running out of shared memory segments - there is some fallback code in the LLVM OpenMP that would try to use a temporary file instead, but the assert has been placed right before that.
I have most likely the same issue that test_post_fork gets stuck when trying to build new version 0.3.23 for Fedora, but only on s390x and ppl64le architectures. Works fine for x86_64, i386 and aarch64.
I had the same issue with version 0.3.22, but the test passes with current version 0.3.21 of openblas on Fedora
For ppc64le it gets stuck here:
TEST 35/37 potrf:bug_695 [OK]
TEST 36/37 kernel_regress:skx_avx [OK]
for succesfull x86_64 build I see that these fork tests follow
TEST 36/38 kernel_regress:skx_avx [OK]
TEST 37/38 fork:safety [OK]
TEST 38/38 fork:safety_after_fork_in_parent [OK]
...
I can trigger the lock with this simple test: https://gist.github.com/thrasibule/394425dee40b2b852513c47f1b737ad6. So just changing the number of omp threads between two calls of dgemm is enough to get a lock. I don't think it's a race issue, but something very basic with the number of treads that are different in two places in the code.
I've identified what's different with my machine that triggers this vs my other machines. It's a Intel(R) Core(TM) i7-3820 CPU with 4 cores/8 threads. However sysconf(_SC_NPROCESSORS_CONF) returns 16 (sysconf(_SC_NPROCESSORS_ONLN) correctly returns 8). Because of this, just running dgemm is enough for blas_num_threads_set to be 1 (I've checked this), even without actually calling openblas_set_num_threads.
Thank you. It appeared to do so on my 6-core AMD system as well, but a largish power10 system in the gcc compile farm (24 cores/192 threads) failed to reproduce the hang with or without the patch (though with the patch, the actual thread counts after openblas_set_num_threads make more sense)
Activity
martin-frbg commentedon Apr 21, 2023
Interesting. Requests for more than omp_get_max_threads() would get (silently) clamped to that limit until recently. Not sure why that would lead to failures on power9 specifically, and sadly our Travis CI seems to have gone dead again while
still displaying the "all good" badge. (This may have masked the problem - though I'm fairly sure I tested this change manually in the gcc compile farm)
martin-frbg commentedon Apr 21, 2023
Not reproducible with gcc 10.1 on power9, but will probably have to build my own if I want a newer compiler on that machine. Are there other architectures where the openblas_utest hangs for you ?
haampie commentedon Apr 21, 2023
Hm, maybe the issue is just related to the build job using more cores than requested (it builds with -j1, probably omp_get_max_threads() returns something big inside the tests). I'll close for now.
haampie commentedon Apr 21, 2023
@martin-frbg sorry for wasting your time (again 😆). I think the issue had to do with a small CI job getting scheduled to a large CPU, and although the build used
-j1, the tests started to usenproc / 2,nproc, and2 * nprocthreads. Potentially cgroups were used to tame the build's CPU usage.Now I'm running
make ... all -j1with the environment variableOMP_NUM_THREADS=1(which feels wrong, but well) and things are looking better.thrasibule commentedon May 3, 2023
I'm observing this as well with an old Xeon machine with 4 cores/8threads. And some user on the arch forum as well. https://aur.archlinux.org/packages/openblas-lapack. I've bisected it to your changes here: 9f9d001
I can pass the test if I run it individually (with ./openblas_utest fork) which is a bit puzzling. I also get the test suite to pass if I run it with OPENBLAS_NUM_THREADS=8 openblas_utest. This could potentially make sense given your changes.
martin-frbg commentedon May 3, 2023
Strange - declaring 8 threads should be no different from letting openblas figure it out . "Old Xeon" probably means Haswell target so nothing exotic (and the user report seems to be from quad-core Zen2, pretty much the same setup as far as openblas is concerned)
thrasibule commentedon May 3, 2023
I've instrumented the test as follows:
This is how it looks before 9f9d001:
and after:
or if I try to run the whole test suite:
martin-frbg commentedon May 3, 2023
This might be two separate issues - openblas thread count no longer getting unconditionally initialized to the omp num threads (note both "old" and "new" behavior have the omp num threads permanently affecting openblas thread count); and a race condition somewhere that may have been aggravated by the changed thread ratio.
orlitzky commentedon Jul 17, 2023
Another data point: this hits an assertion with clang-16: llvm/llvm-project#63908
martin-frbg commentedon Jul 19, 2023
I still cannot reproduce the hang, I can let my 6-core laptop run openblas_utest in a loop for hours, and I can also run it repeatedly on a 12-core Xeon in the gcc compile farm (though ofc I won't let it loop there for hours).
The clang assertion appears to be triggered by running out of shared memory segments - there is some fallback code in the LLVM OpenMP that would try to use a temporary file instead, but the assert has been placed right before that.
thrasibule commentedon Jul 19, 2023
The bug doesn't happen if I add
openblas_set_num_threads(-1)here: https://github.com/xianyi/OpenBLAS/blob/develop/utest/test_post_fork.c#L102 (ie reset blas_num_threads_set to 0).I can consistently reproduce on a machine with 4 cores/8 threads.
psimovec commentedon Jul 20, 2023
I have most likely the same issue that test_post_fork gets stuck when trying to build new version 0.3.23 for Fedora, but only on s390x and ppl64le architectures. Works fine for x86_64, i386 and aarch64.
I had the same issue with version 0.3.22, but the test passes with current version 0.3.21 of openblas on Fedora
For ppc64le it gets stuck here:
for succesfull x86_64 build I see that these fork tests follow
martin-frbg commentedon Jul 20, 2023
Still trying to reproduce this (builds without issue on pwr9 and z14 in CI too) but I think your successful x86_64 build is not using OpenMP...
thrasibule commentedon Jul 20, 2023
I can trigger the lock with this simple test: https://gist.github.com/thrasibule/394425dee40b2b852513c47f1b737ad6. So just changing the number of omp threads between two calls of dgemm is enough to get a lock. I don't think it's a race issue, but something very basic with the number of treads that are different in two places in the code.
I've identified what's different with my machine that triggers this vs my other machines. It's a Intel(R) Core(TM) i7-3820 CPU with 4 cores/8 threads. However
sysconf(_SC_NPROCESSORS_CONF)returns 16 (sysconf(_SC_NPROCESSORS_ONLN)correctly returns 8). Because of this, just running dgemm is enough for blas_num_threads_set to be 1 (I've checked this), even without actually calling openblas_set_num_threads.thrasibule commentedon Jul 31, 2023
I can confirm that the above PR fixes the issue.
martin-frbg commentedon Jul 31, 2023
Thank you. It appeared to do so on my 6-core AMD system as well, but a largish power10 system in the gcc compile farm (24 cores/192 threads) failed to reproduce the hang with or without the patch (though with the patch, the actual thread counts after openblas_set_num_threads make more sense)