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/08/19 18:46:31 UTC

[GitHub] [tvm] farshidsp opened a new pull request, #12504: [Hexagon] Add support to run on multiple devices

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

   This PR enables running on multiple devices .  `Hexagon_luncher_process` will create a a single server on each device and  assigns a worker to a test whenever a new device becomes available where `pytest-xdist` will transfer to the subprocess.
   
   To run on multiple devices, set the `ANDROID_SERIAL_NUMBER` to devices separated by a comma. E.g: ` export ANDROID_SERIAL_NUMBER="xxx.xxx.xx.xxx:xxxx,yyy.yyy.yy.yyy:yyyy,zzz.zzz.zz.zzz:zzzz"`.
   
   And run the test using the following command:
   `py.test --tx {number_of_devices}*popen --dist=load  test_file`
   
   The `number_of_devices` cab be less or equal to the actually number of devices set in the `ANDROID_SERIAL_NUMBER`.
   
   Tests can still be run on a single device or simulator as before. E.g:
   
   ` export ANDROID_SERIAL_NUMBER="xxx.xxx.xx.xxx:xxxx"`
   `pytest test_file`
   
   @mehrdadh @Lunderberg @csullivan 
   
   
   


-- 
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] kparzysz-quic merged pull request #12504: [Hexagon] Add support to run on multiple devices

Posted by GitBox <gi...@apache.org>.
kparzysz-quic merged PR #12504:
URL: https://github.com/apache/tvm/pull/12504


-- 
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] farshidsp commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

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


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,14 +56,19 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
 def android_serial_number() -> Optional[str]:
+    """Return the android serial number or simulator"""
     serial = os.getenv(ANDROID_SERIAL_NUMBER, default="")
     # Setting ANDROID_SERIAL_NUMBER to an empty string should be
     # equivalent to having it unset.
     if not serial.strip():
         serial = None
-    return serial
+    if serial == "simulator":
+        return serial
+    else:
+        # Split android serial numbers into a list
+        serial = serial.split(",")

Review Comment:
   So in the new pr, I have changed this that if the android serial number is set to empty string, it would skip the test with an error of "ANDROID_SERIAL_NUMBER is not set".  



-- 
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] farshidsp commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

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


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,13 +56,16 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
-def android_serial_number() -> Optional[str]:

Review Comment:
   Since `pytest_configure(config)` is a pytest hook, there were no easy way to have it use a pytest fixtures. 
   Maybe I'm missing the point, but I did not see the usefulness of having the android_serial_number as a` pytest.fixture` and by removing it, it solved the previous error. 



-- 
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] kparzysz-quic commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

Posted by GitBox <gi...@apache.org>.
kparzysz-quic commented on code in PR #12504:
URL: https://github.com/apache/tvm/pull/12504#discussion_r950614799


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,14 +56,19 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
 def android_serial_number() -> Optional[str]:

Review Comment:
   This function no longer returns `Optional[str]`.  Please make it return `list[str]` for all cases, for consistency (including `[]` if there is no device of any kind).



##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,14 +56,19 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
 def android_serial_number() -> Optional[str]:
+    """Return the android serial number or simulator"""
     serial = os.getenv(ANDROID_SERIAL_NUMBER, default="")
     # Setting ANDROID_SERIAL_NUMBER to an empty string should be
     # equivalent to having it unset.
     if not serial.strip():
         serial = None
-    return serial
+    if serial == "simulator":
+        return serial
+    else:
+        # Split android serial numbers into a list
+        serial = serial.split(",")

Review Comment:
   This will fail if serial was set to `None` at L65.



-- 
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] kparzysz-quic commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

Posted by GitBox <gi...@apache.org>.
kparzysz-quic commented on code in PR #12504:
URL: https://github.com/apache/tvm/pull/12504#discussion_r1042559184


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -175,31 +182,50 @@ def hexagon_server_process(
             "rpc_server_port": rpc_server_port_for_session,
             "adb_server_socket": adb_server_socket,
         }
-        launcher = HexagonLauncher(serial_number=android_serial_number, rpc_info=rpc_info)
+        workerinput = getattr(request.config, "workerinput", None)
+        if workerinput is None:  # single-process execution
+            device_adr = read_device_list()[0]
+        else:  # running in a subprocess here
+            device_adr = workerinput["device_adr"]
+        launcher = HexagonLauncher(serial_number=device_adr, rpc_info=rpc_info)
         try:
             if not skip_rpc:
                 launcher.start_server()
-            yield launcher
+            yield {"launcher": launcher, "device_adr": device_adr}
         finally:
             if not skip_rpc:
                 launcher.stop_server()
 
 
+def read_device_list():
+    return android_serial_number()
+
+
+def pytest_configure(config):
+    # read device list if we are on the master
+    if not hasattr(config, "workerinput"):
+        config.iplist = read_device_list()
+
+
+def pytest_configure_node(node):
+    # the master for each node fills slaveinput dictionary
+    # which pytest-xdist will transfer to the subprocess
+    node.workerinput["device_adr"] = node.config.iplist.pop()

Review Comment:
   This causes an error when we try to run these tests in parallel on simulator:
   
   ```IINTERNALERROR> Traceback (most recent call last):
   INTERNALERROR>   File "/usr2/kparzysz/.local/lib/python3.6/site-packages/_pytest/main.py", line 266, in wrap_session
   INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
   [...]
   INTERNALERROR>   File "/usr2/kparzysz/.local/lib/python3.6/site-packages/pluggy/_callers.py", line 39, in _multicall
   INTERNALERROR>     res = hook_impl.function(*args)
   INTERNALERROR>   File "/local/mnt/workspace/kparzysz/aitools/tvm-upstream/python/tvm/contrib/hexagon/pytest_plugin.py", line 242, in pytest_configure_node
   INTERNALERROR>     node.workerinput["device_adr"] = node.config.iplist.pop()
   INTERNALERROR> IndexError: pop from empty list
   ```
   @farshidsp 



-- 
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] farshidsp commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

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


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,14 +56,19 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
 def android_serial_number() -> Optional[str]:
+    """Return the android serial number or simulator"""
     serial = os.getenv(ANDROID_SERIAL_NUMBER, default="")
     # Setting ANDROID_SERIAL_NUMBER to an empty string should be
     # equivalent to having it unset.
     if not serial.strip():
         serial = None
-    return serial
+    if serial == "simulator":
+        return serial
+    else:
+        # Split android serial numbers into a list
+        serial = serial.split(",")

Review Comment:
   If the serial was set to None, we skip the test with a message that says android serial number is not set.



-- 
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] kparzysz-quic commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

Posted by GitBox <gi...@apache.org>.
kparzysz-quic commented on code in PR #12504:
URL: https://github.com/apache/tvm/pull/12504#discussion_r953040326


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,14 +56,19 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
 def android_serial_number() -> Optional[str]:
+    """Return the android serial number or simulator"""
     serial = os.getenv(ANDROID_SERIAL_NUMBER, default="")
     # Setting ANDROID_SERIAL_NUMBER to an empty string should be
     # equivalent to having it unset.
     if not serial.strip():
         serial = None
-    return serial
+    if serial == "simulator":
+        return serial
+    else:
+        # Split android serial numbers into a list
+        serial = serial.split(",")

Review Comment:
   Ah, you're right, I was looking at the old sources.



-- 
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] mehrdadh commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

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


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,13 +56,16 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
-def android_serial_number() -> Optional[str]:

Review Comment:
   can you explain why is it not a fixture anymore?



-- 
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] farshidsp commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

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


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,14 +56,19 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
 def android_serial_number() -> Optional[str]:

Review Comment:
   Thanks for you recommendation. This function now returns only a list of string. 



-- 
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] kparzysz-quic commented on a diff in pull request #12504: [Hexagon] Add support to run on multiple devices

Posted by GitBox <gi...@apache.org>.
kparzysz-quic commented on code in PR #12504:
URL: https://github.com/apache/tvm/pull/12504#discussion_r953005947


##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -56,14 +56,19 @@ def _compose(args, decs):
 requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
 
 
-@pytest.fixture(scope="session")
 def android_serial_number() -> Optional[str]:
+    """Return the android serial number or simulator"""
     serial = os.getenv(ANDROID_SERIAL_NUMBER, default="")
     # Setting ANDROID_SERIAL_NUMBER to an empty string should be
     # equivalent to having it unset.
     if not serial.strip():
         serial = None
-    return serial
+    if serial == "simulator":
+        return serial
+    else:
+        # Split android serial numbers into a list
+        serial = serial.split(",")

Review Comment:
   Line 61 gets the serial number from an environment variable, then if it's an empty string, it's set to `None` at line 65.  This `None` can get to line 70...



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