You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/04 20:33:59 UTC

[GitHub] [tvm] masahi commented on a diff in pull request #10896: [RUNTIME] Api to get number of runtime threads

masahi commented on code in PR #10896:
URL: https://github.com/apache/tvm/pull/10896#discussion_r842117517


##########
tests/python/unittest/test_runtime_module_based_interface.py:
##########
@@ -674,6 +675,19 @@ def make_module(mod):
     module_main.get_function("func_b", query_imports=True)
 
 
+def test_num_threads():
+    reported = tvm.runtime.num_threads()
+    env_threads = os.getenv("TVM_NUM_THREADS")
+    omp_env_threads = os.getenv("OMP_NUM_THREADS")
+    if env_threads is not None:
+        assert reported == env_threads
+    elif omp_env_threads is not None:
+        assert reported == omp_env_threads
+    else:
+        hardware_threads = os.cpu_count() / 2
+        assert reported == hardware_threads

Review Comment:
   I think this is only true on x64 https://github.com/apache/tvm/blob/6ad7638be249fef0b2ce3f1112dd857e850949f1/src/runtime/threading_backend.cc#L304-L305



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org