Skip to content

Commit 3f0f935

Browse files
Adds clear method to SequentialOrderManager
1 parent a5a481e commit 3f0f935

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

dpctl/utils/_order_manager.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __copy__(self):
6363
return res
6464

6565

66-
class OrderManagerMap:
66+
class SyclQueueToOrderManagerMap:
6767
"""Utility class to ensure sequential ordering of offloaded
6868
tasks issued by dpctl.tensor functions"""
6969

@@ -74,14 +74,21 @@ def __init__(self):
7474
)
7575

7676
def __getitem__(self, q: SyclQueue) -> _SequentialOrderManager:
77+
"""Get order manager for given SyclQueue"""
7778
_local = self._map.get()
78-
print(_local)
79+
if not isinstance(q, SyclQueue):
80+
raise TypeError(f"Expected `dpctl.SyclQueue`, got {type(q)}")
7981
if q in _local:
8082
return _local[q]
8183
else:
8284
v = _local[q]
8385
_local[q] = v
8486
return v
8587

88+
def clear(self):
89+
"""Clear content of internal dictionary"""
90+
_local = self._map.get()
91+
_local.clear()
92+
8693

87-
SequentialOrderManager = OrderManagerMap()
94+
SequentialOrderManager = SyclQueueToOrderManagerMap()

0 commit comments

Comments
 (0)