From 470f11dfaa5b9baddc5c7d5778cbd8111bb94883 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 29 Apr 2020 19:45:12 -0700 Subject: [PATCH 1/2] Create `msg` before sending it --- tests/test_send_recv.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_send_recv.py b/tests/test_send_recv.py index cd7accc20..ceb0a1e89 100644 --- a/tests/test_send_recv.py +++ b/tests/test_send_recv.py @@ -98,13 +98,14 @@ async def test_send_recv_cupy(size, dtype, blocking_progress_mode): ucp.init(blocking_progress_mode=blocking_progress_mode) cupy = pytest.importorskip("cupy") - msg = cupy.arange(size, dtype=dtype) - msg_size = np.array([msg.nbytes], dtype=np.uint64) - listener = ucp.create_listener( make_echo_server(lambda n: cupy.empty((n,), dtype=np.uint8)) ) client = await ucp.create_endpoint(ucp.get_address(), listener.port) + + msg = cupy.arange(size, dtype=dtype) + msg_size = np.array([msg.nbytes], dtype=np.uint64) + await client.send(msg_size) await client.send(msg) resp = cupy.empty_like(msg) From dd37692ffdfc4b50c6b765292656775f5168bba5 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 29 Apr 2020 19:47:13 -0700 Subject: [PATCH 2/2] Test concatenating a trivial array and sending it --- tests/test_send_recv.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_send_recv.py b/tests/test_send_recv.py index ceb0a1e89..c3e749072 100644 --- a/tests/test_send_recv.py +++ b/tests/test_send_recv.py @@ -112,6 +112,17 @@ async def test_send_recv_cupy(size, dtype, blocking_progress_mode): await client.recv(resp) np.testing.assert_array_equal(cupy.asnumpy(resp), cupy.asnumpy(msg)) + msg = cupy.concatenate( + [cupy.arange(0, dtype=dtype), cupy.arange(size, dtype=dtype)] + ) + msg_size = np.array([msg.nbytes], dtype=np.uint64) + + await client.send(msg_size) + await client.send(msg) + resp = cupy.empty_like(msg) + await client.recv(resp) + np.testing.assert_array_equal(cupy.asnumpy(resp), cupy.asnumpy(msg)) + @pytest.mark.asyncio @pytest.mark.parametrize("size", msg_sizes)