A way to specify policies for a specific backend
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
調査の方向性
Read the existing controller API and the OpenBLASController implementation, then review how set_num_threads applies limits. The issue presents alternative policy hooks but does not choose a design; first determine which extension point fits the stated backend policies. Done means a selected design supports the intended policies, with tests covering the behavior.
索引モデルが issue の本文から書いたものです。
説明
We have discussed multiple potential examples of having specific policies for specific libraries' backends, mostly OpenBLAS+pthreads:
- Limit to just 1 core (i.e. inline in current thread) or all cores, don't set any other limits but those two. These are really the most common ones you'd want for a shared process-level thread pool. "All cores" is a concept outside of threadpoolctl's scope, though!
- Only allow setting limits on the main thread, basically: https://github.com/joblib/joblib/pull/1871#discussion_r4340880131
The current API doesn't have great ergonomics for this though.
One approach is to push policies down into threadpoolctl. But that seems difficult, e.g. "all cores" example above (until Python grows a cpu count API that knows about cgroups, at least).
Another approach is to allow libraries (really, joblib) to hook in and define their own policies.
Potential designs
Replace default controller class with custom controller class
from joblib import cpu_count
from threadpoolctl import OpenBLASController, replace_controller
class JoblibOpenBLASController(OpenBLASController):
def set_num_threads(self, num_cores):
if self.threading_layer == "openmp":
return super().set_num_threads(num_cores)
cpus = cpu_count()
if num_cores >= 0.75 * cpus:
num_cores = cpus
else
num_cores = 1
return super().set_num_threads(num_cores)
replace_controller(OpenBLASController, JoblibOpenBLASController)
Register custom policy just for set_num_threads
from joblib import cpu_count
from threadpoolctl import OpenBLASController
def transform_num_threads(controller, num_cores):
if controller.threading_layer == "openmp":
return num_cores
cpus = cpu_count()
if num_cores >= 0.75 * cpus:
return cpus
else
return 1
return super().set_num_threads(num_cores)
OpenBLASController.set_transform_num_threads_before_setting_hook(transform_num_threads)
... other ideas?
- 主要言語
- Python
- スター
- 434
- フォーク
- 38
- 平均マージ
- 2日 14時間
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
joblib/threadpoolctl のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
joblib/threadpoolctl#271 ·
メンテナーはふだん 1 日以内に返信
-
Make it possible to inspect active/spin wait behavior of LLVM/Intel OpenMP via `kmp_get_blocktime`オープン
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
joblib/threadpoolctl#270 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
joblib/threadpoolctl#261 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Opt-in API that has a cached `ThreadpoolController`対応中かも @itamarst が 29 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
joblib/threadpoolctl#254 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Speed up usage of threadpoolctl対応中かも @itamarst が 37 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 18/100
joblib/threadpoolctl#246 ·
メンテナーはふだん 1 日以内に返信
joblib/threadpoolctl の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
MISP/misp-workbench#496 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
fossasia/visdom-dev#69 ·
メンテナーはふだん 3 日以内に返信
-
[Bug] Parameters named like a property break to_xcal()対応中かも @atharvasalunke1267 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
collective/icalendar#2018 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信