test: enable async RPC tests

This commit is contained in:
Sébastien Bourdeauducq 2024-09-30 17:47:05 +08:00
parent 5dcdeb6e0d
commit 3473440534
3 changed files with 7 additions and 11 deletions

View File

@ -348,7 +348,7 @@ class _Async(EnvExperiment):
def build(self): def build(self):
self.setattr_device("core") self.setattr_device("core")
@rpc # NAC3TODO (flags={"async"}) @rpc(flags={"async"})
def recv_async(self, data: list[int32]): def recv_async(self, data: list[int32]):
pass pass

View File

@ -77,20 +77,18 @@ class _Transfer(EnvExperiment):
def sink_array(self, data: ndarray[int32, Literal[1]]): def sink_array(self, data: ndarray[int32, Literal[1]]):
pass pass
@rpc # NAC3TODO (flags={"async"}) @rpc(flags={"async"})
def sink_async(self, data: list[int32]): def sink_async(self, data: list[int32]):
global received_bytes, time_start, time_end global received_bytes, time_start, time_end
if received_bytes == 0: if received_bytes == 0:
time_start = time.time() time_start = time.time()
received_bytes += len(data) received_bytes += 4*len(data)
if received_bytes == (1024 ** 2)*128: if received_bytes == (1024 ** 2)*128:
time_end = time.time() time_end = time.time()
@rpc
def get_async_throughput(self) -> float: def get_async_throughput(self) -> float:
return 128.0 / (time_end - time_start) return 128.0 / (time_end - time_start)
@kernel @kernel
def test_bool_list(self, large: bool): def test_bool_list(self, large: bool):
for i in range(self.count): for i in range(self.count):
@ -125,11 +123,10 @@ class _Transfer(EnvExperiment):
self.d2h[i] = self.core.mu_to_seconds(t2 - t1) self.d2h[i] = self.core.mu_to_seconds(t2 - t1)
@kernel @kernel
def test_async(self) -> float: def test_async(self):
data = self.get_list(True) data = self.get_list(True)
for _ in range(128): for _ in range(128):
self.sink_async(data) self.sink_async(data)
return self.get_async_throughput()
class TransferTest(ExperimentCase): class TransferTest(ExperimentCase):
@ -225,10 +222,10 @@ class TransferTest(ExperimentCase):
self.results.append(["I32 Array (1KB) D2H", device_to_host.mean(), self.results.append(["I32 Array (1KB) D2H", device_to_host.mean(),
device_to_host.std()]) device_to_host.std()])
@unittest.skip("NAC3TODO https://git.m-labs.hk/M-Labs/nac3/issues/182")
def test_async_throughput(self): def test_async_throughput(self):
exp = self.create(_Transfer) exp = self.create(_Transfer)
results = exp.test_async() exp.test_async()
results = exp.get_async_throughput()
print("Async throughput: {:>6.2f}MiB/s".format(results)) print("Async throughput: {:>6.2f}MiB/s".format(results))

View File

@ -13,8 +13,7 @@ class _Stress(EnvExperiment):
def build(self): def build(self):
self.setattr_device("core") self.setattr_device("core")
# NAC3TODO https://git.m-labs.hk/M-Labs/nac3/issues/182 @rpc(flags={"async"})
@rpc #(flags={"async"})
def sink(self, data: int32): def sink(self, data: int32):
pass pass