Avoid calling OMP functions directly. #12679
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/dmlc/xgboost/pull/12679?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- recent_review_start -->
No actionable comments were generated in the recent review. 🎉
<details>
<summary><strong>ℹ️ Recent review info</strong></summary>
<dl>
<dd>
<details>
<summary><strong>⚙️ Run configuration</strong></summary>
<dl>
<dd>
266969c5-488c-49ae-b6da-d2ac1fe68738<hr>
</dd>
</dl>
</details>
<details>
<summary><strong>📥 Commits</strong></summary>
<dl>
<dd>
Reviewing files that changed from the base of the PR and between 72282fa4235a77231448e328f913da6936da7f7d and 445ee61076a4661e525bf205e63ab7169287f31f.
<hr>
</dd>
</dl>
</details>
<details>
<summary><strong>📒 Files selected for processing (4)</strong></summary>
<dl>
<dd>
src/common/threading_utils.h
src/data/data.cc
src/metric/auc.cc
tests/cpp/common/test_threading_utils.cc
<hr>
</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
<hr>
</dd>
</dl>
</details>
---
<!-- recent_review_end -->
<!-- walkthrough_start -->
Walkthrough
The change updates sparse-page transpose and sortedness calculations, replaces per-thread gradient accumulations with transform-reductions, and uses explicit worker IDs to select thread-local state in CPU parallel callbacks. Ranking metrics now share a cached base implementation. Grouped AUC and AUCPR tests cover how invalid and zero-AUC groups contribute.
Suggested reviewers: ramitchell
<!-- walkthrough_end -->
<!-- change_assessment_start -->
Priority: ➖ Normal
<!-- change_assessment_commit:"445ee61076a4661e525bf205e63ab7169287f31f" -->
<!-- change_assessment_end -->
<!-- final_review_risk_start -->
Merge Risk: ⚪ Minimal · up to 445ee
<!-- final_review_risk_coverage:{"sourceCommitId":"445ee61076a4661e525bf205e63ab7169287f31f","coveredCommitId":"445ee61076a4661e525bf205e63ab7169287f31f","kind":"reviewed"} -->
No identified issue prevents merging after normal checks.
<!-- final_review_risk_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- This is an auto-generated comment: all tool run failures by coderabbit.ai -->
[!WARNING]
Some tools did not complete. Review the errors below.
> <details>
<summary><strong>🔧 Cppcheck (2.22.0)</strong></summary>
<dl>
<dd>
> <details>
<summary><strong>src/data/data.cc</strong></summary>
<dl>
<dd>
> Cppcheck timed out; analysis of this file is incomplete
> </dd>
</dl>
</details>
>
<hr>
> </dd>
</dl>
</details>
<!-- end of auto-generated comment: all tool run failures by coderabbit.ai -->
<!-- tips_start -->
---
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary><strong>❤️ Share</strong></summary>
<dl>
<dd>
<hr>
</dd>
</dl>
</details>
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
Curious why need common::Worker? Why not just an overload. Only tid is used. What about:
common::ParallelFor(n, n_threads, [&](auto idx, std::int32_t tid) {
// Use stemp_[tid].
});
Might be good to do some small perf checks for these functions. There is risk of regression.
Curious why need common::Worker?
I don't enjoy lots of integers as parameters, I always have concerns that I get the parameter ordering wrong.
Might be good to do some small perf checks for these functions. There is risk of regression.
It's just a plain struct, with one less global function call. I can do some simple checks.
Reverted the single-element-per-thread loops, which cause regression. Rest should be the same. Also, cleaned up the Worker type to be an alias of integer.
Approved these changes.
RAMitchell
trivialfis
Avoid calling omp-related functions like
omp_get_thread_num.