omp_pause_resource() warning on every SparseArray.Call() with the clang/libomp toolchain (Windows arm64)
まだ誰も着手していません。
評価
調査の方向性
Start with .pause_resource() in R/thread-control.R, which warns on a non-zero return, and its C counterpart in src/thread_control.c, which calls omp_pause_resource(). Check where SparseArray.Call() invokes it in its on.exit(). Reproduce by running the NaArray-Arith-methods example, which should warn on a clang/libomp build. Done means the example and the test suite run without the warning, and the choice between the four proposed fixes is agreed on in the thread.
索引モデルが issue の本文から書いたものです。
説明
On the Windows arm64 builder at R-Universe, SparseArray 1.13.4 emits the following warning on almost every call into its C code (see log here):
Warning in .pause_resource() :
omp_pause_resource() failed to relinquish resources on device 0
The x86_64 Windows build of the same version is silent. The results themselves are correct and only the warnings differ. However, the warnings reach downstream packages. For example, GSVA's unit tests for version 2.7.23 failed on Windows arm64 because one test was turning such a warning into an error. I have tweaked the test in GSVA to make it pass, but other packages may run into it too.
Minimal reproducible example
I don't have a Windows machine, so this is more of a guess based on the outputs of the logs from R-Universe and suggestions by Claude Code, taking SparseArray's own NaArray-Arith-methods example, which warns in the arm64 example log:
library(SparseArray)
nam1 <- NaArray(dim=c(15, 6), type="integer")
nam1[cbind(1:15, 2)] <- 100:114
## Warning in .pause_resource() :
## omp_pause_resource() failed to relinquish resources on device 0
nam1[cbind(1:15, 5)] <- -(114:100)
## Warning in .pause_resource() : ...
nam1
## Warning in .pause_resource() : ...
Calling the internal wrapper directly should isolate the cause:
SparseArray:::.pause_resource() # expected to return 0
SparseArray:::.pause_resource() # expected to warn: runtime already paused
Possible cause
SparseArray.Call() always runs .pause_resource() in its on.exit(). That calls omp_pause_resource(omp_pause_soft, omp_get_initial_device()) (src/thread_control.c) and warns whenever the return value is non-zero (R/thread-control.R).
The return value depends on the OpenMP runtime:
- libgomp (GCC): pausing the host always succeeds and returns 0, unless it's called inside a parallel region. That's why Linux and Windows x86_64 builds are silent. macOS builds without OpenMP are unaffected.
- LLVM libomp (clang): as far as Claude can tell from the libomp sources (
__kmp_pause_resource()inkmp_runtime.cpp), a pause request returns non-zero if the runtime is already paused. A soft pause is only lifted when the next parallel region starts (__kmp_resume_if_soft_paused()).
Only a few C files contain #pragma omp parallel regions (SparseMatrix_mult.c, SparseArray_subassignment.c, SparseArray_matrixStats.c, SparseArray_subsetting.c). Most SparseArray.Call()s never open one, so after the first soft pause the runtime stays paused. Every later omp_pause_resource() call then fails as "already paused" and triggers the warning. This should affect any clang + libomp build, such as Linux with clang or macOS with OpenMP enabled, not only Windows arm64.
Possible fixes
- Treat the pause as best-effort: ignore the return value of
omp_pause_resource(), or report it only once or when a verbose/debug option is set. - Only call
.pause_resource()after C routines that actually ran a parallel region, or keep a flag in C that is set when a parallel region is entered. - Skip the pause when
nthread <= 1, since no worker threads were created. - Check the pause state before pausing again, so an already-paused runtime isn't treated as an error.
Unrelated, minor
Both Windows builders also report an install WARNING for -Wformat at OPBufTree.c:320 (%lu) and SVT_SparseArray_class.c:677-679 (%ld). Both print an R_xlen_t (long long), but long is 32-bit on Windows, so large values could be printed wrong. Casting to (long long) with %lld, or to (double) with %.0f, would fix it.
This issue has been written with the assistance of Claude Code (Anthropic).
- 主要言語
- C
- スター
- 13
- フォーク
- 3
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Bioconductor/SparseArray のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
Bioconductor/SparseArray#20 · コメント 3 件 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
Bioconductor/SparseArray#5 · コメント 7 件 · リアクション 1 件 ·
Bioconductor/SparseArray の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ChupathingyCE/chupathingyce#1550 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] SWAPDB sends no invalidation to CLIENT TRACKING clients対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
redis/redis#16302 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
slice
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
Life-Framework/Life-Framework#3878 ·
メンテナーはふだん 1 日以内に返信
-
`sha256()` returns a wrong hash when libsql-ffi is built with gcc 11 or later対応中かも @colinhacks が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tursodatabase/libsql#2333 ·
メンテナーはふだん 11 日以内に返信