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:52:56 UTC

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

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


##########
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:
   Changed the test to check if the reported number is `os.cpu_count()` or `os.cpu_count()/2`. That sound reasonable?



-- 
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