Recursive @threadpool_limits.wrap() calls do not behave as expected when recursing
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- performance
Hướng nghiên cứu
The failing case is the test test_recursive_wrap_releases_the_shared_pool_claim, which needs a non-OpenMP OpenBLAS build with at least two threads. Start by running it with recurse(1) and reading how threadpool_limits.wrap restores limits and releases the controlling thread on return. Done when the test passes with recurse(1) and the existing recursion behaviour still holds.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Returning from a wrapped function should return to the previous level of thread limits at the time they were called, even in the face of recursion. That's not what happens in practice, though.
The following test fails on both master and 3.7 (i.e. it's not due to the controlling thread changes), but passes if recurse(1) is switched to recurse(0).
from threading import Thread
from threadpoolctl import threadpool_limits, ThreadpoolController
import numpy
import pytest
def run_in_thread(f, *args, **kwargs):
thread = Thread(target=lambda: f(*args, **kwargs))
thread.start()
thread.join()
return thread
def _non_openmp_openblas():
openblas = ThreadpoolController().select(internal_api="openblas")
if not openblas:
pytest.skip("requires OpenBLAS.")
libs = []
seen = set()
for lib in openblas.lib_controllers:
if lib.threading_layer == "openmp" or lib.filepath in seen:
continue
seen.add(lib.filepath)
libs.append(lib)
if not libs:
pytest.skip("require non-OpenMP OpenBLAS.")
return libs
def _require_resizable_non_openmp_openblas():
libs = _non_openmp_openblas()
lib = libs[0]
orig = lib.get_num_threads()
if orig is None or orig < 2:
pytest.skip("Test requires a non-OpenMP OpenBLAS with at least 2 threads")
return lib, orig
def test_recursive_wrap_releases_the_shared_pool_claim():
# One wrapped function calling itself must keep the limit between the inner
# return and the outer return, then restore the original count and drop the
# controlling thread. Another thread can then set the count.
lib, orig = _require_resizable_non_openmp_openblas()
@threadpool_limits.wrap(limits=1, user_api="blas")
def recurse(depth):
assert lib.get_num_threads() == 1
if depth:
recurse(depth - 1)
assert lib.get_num_threads() == 1
recurse(1)
assert lib.get_num_threads() == orig
observed = {}
def other_thread():
lib.set_num_threads(1)
observed["threads"] = lib.get_num_threads()
worker = run_in_thread(other_thread)
assert observed["threads"] == 1
- Ngôn ngữ chính
- Python
- Star
- 434
- Fork
- 38
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của joblib/threadpoolctl
-
Drop 3.10Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
joblib/threadpoolctl#295 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
joblib/threadpoolctl#291 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Follow-up fixes for OpenBLAS-pthreads controlling thread featureCó thể đã có người làm @itamarst đã nhận 2 ngày trước. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 25/100
joblib/threadpoolctl#292 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
joblib/threadpoolctl#276 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Make it possible to set active/spin wait behavior of LLVM/Intel OpenMP via `kmp_set_blocktime`Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
joblib/threadpoolctl#271 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của joblib/threadpoolctl
Issue tương tự
-
fuzz fuzz-unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
neilsh/stunt-reel#220 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Issue]: use_fp4_cache is accepted but ignored; the launcher always writes FP8 recordsCó thể đã có người làm @0z5a đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: cli priority: p3 size: S type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
finos/open-resource-broker#757 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 6 ngày