Repository navigation
Report OpenMP blocktime in milliseconds - #302
Aschenbath wants to merge 1 commit into
Conversation
ogrisel
left a comment
There was a problem hiding this comment.
Thanks for the PR. Here is a first pass of feedback.
| from ``kmp_get_blocktime`` (LLVM/Intel OpenMP), or None when unavailable. | ||
| Its units are milliseconds by default, or microseconds when configured | ||
| through ``KMP_BLOCKTIME`` on runtimes supporting that unit. This value is | ||
| queried on every call, including when reusing a controller. |
There was a problem hiding this comment.
I would rather always report "ms" to avoid any ambiguity on how to correctly leverage this value. Is it possible to programmatically inspect the runtime and do the conversion in get_blocktime itself so that it always returns ms values?
| 'user_api': 'blas', | ||
| 'version': '2019.0.4'}, | ||
| {'filepath': '/home/ogrisel/miniconda3/envs/tmp/lib/libiomp5.so', | ||
| {'blocktime': 200, |
There was a problem hiding this comment.
We could even rename 'blocktime' to 'blocktime_ms' if we ensure that we always report this value in miliseconds.
| assert get_blocktime() == 7 | ||
| assert kmp_controller.info()["blocktime"] == 7 | ||
| finally: | ||
| set_blocktime(original) |
There was a problem hiding this comment.
I think we should include a test that imports openmp in a Python subprocess and the verbose env variable set and then check that the value reported by threadpool_info is consistent with the value parsed from stdout (including when manually set to non-ms units).
6a2e9fd to
3e86126
Compare
Expose
blocktime_msin OpenMP information fromthreadpool_info(), controllerinfo(), and the CLI. LLVM/Intel OpenMP values are read fromkmp_get_blocktimeon every query and converted to milliseconds, preserving fractional milliseconds. Runtimes without that symbol, including GNU OpenMP, reportNone(nullin JSON).The dynamic property and
OpenMPController.get_blocktime()reflect the calling thread's current value afterkmp_set_blocktime, including when a controller is reused. The unit is cached per loaded runtime so later environment changes do not change the conversion.Unit-detection limitation: the common LLVM/Intel kmp API does not export a unit getter. Conversion therefore uses a valid
KMP_BLOCKTIMEstartup setting, which must remain available until the runtime is first inspected. Microsecond settings require a runtime that supports them. Changing units throughkmp_set_defaultsis unsupported. These conditions are documented in the README and API docstrings; this implementation does not provide unconditional native unit introspection.Validation on this revision:
OMP_DISPLAY_ENV=VERBOSEandKMP_SETTINGS=1, parse the effective runtime setting, and compare it withthreadpool_info(). Cases cover the default,37,37ms,35001us, and35 us, then change the environment and callkmp_set_blocktimeto check cached units with a fresh value. The two microsecond cases failed before conversion on Intel OpenMP.test_get_original_num_threadswarning expectations with this NumPy/SciPy setup, and both also fail against unchanged master13b1a129901f353ee4820a3fb7e9a6f7d5fcf4f4in the same environment.PYTHON_CPU_COUNT=4. The initial unrestricted run reached 82 passed and 35 skipped but timed out in the existing 10-second controller concurrency stress test, which creates four threads per reported CPU. No Linux baseline run is claimed.git diff --checkpassed.macOS and hosted CI results are not claimed here. AI assistance was used for investigation, implementation, testing, and this description.
Closes #270.