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:23:24 UTC

[GitHub] [tvm] tkonolige opened a new pull request, #10896: [RUNTIME] Api to get number of runtime threads

tkonolige opened a new pull request, #10896:
URL: https://github.com/apache/tvm/pull/10896

   Add `tvm::runtime::threading::NumThreads` and `tvm.runtime.num_threads` as a way to get the number of threads in use by the TVM runtime.
   
   @jwfromm @masahi 
   


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


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

Posted by GitBox <gi...@apache.org>.
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


[GitHub] [tvm] masahi merged pull request #10896: [RUNTIME] Api to get number of runtime threads

Posted by GitBox <gi...@apache.org>.
masahi merged PR #10896:
URL: https://github.com/apache/tvm/pull/10896


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


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

Posted by GitBox <gi...@apache.org>.
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 true only 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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
masahi commented on code in PR #10896:
URL: https://github.com/apache/tvm/pull/10896#discussion_r842141244


##########
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:
   yeah as long as it doesn't fail on CI I think it's ok.



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