Commit ad13912
committed
Add USMAllocationError exception, use it for USM allocation failures
This PR addresses concern about use of non-descriptive RuntimeError
exception in earlier versions raised in issue gh-1158
```
In [1]: import dpctl
In [2]: import dpctl.memory as dpm
In [3]: dpm.MemoryUSMDevice( 1024 * 1024 * 1024 * 8)
---------------------------------------------------------------------------
USMAllocationError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 dpm.MemoryUSMDevice( 1024 * 1024 * 1024 * 8)
File ~/repos/dpctl/dpctl/memory/_memory.pyx:783, in dpctl.memory._memory.MemoryUSMDevice.__cinit__()
781 SyclQueue queue=None, int copy=False):
782 if (isinstance(other, numbers.Integral)):
--> 783 self._cinit_alloc(alignment, <Py_ssize_t>other, b"device", queue)
784 else:
785 self._cinit_other(other)
File ~/repos/dpctl/dpctl/memory/_memory.pyx:201, in dpctl.memory._memory._Memory._cinit_alloc()
199 self.queue = queue
200 else:
--> 201 raise USMAllocationError(
202 "USM allocation failed"
203 )
USMAllocationError: USM allocation failed
In [4]: quit
```1 parent 7bbfce1 commit ad13912
2 files changed
+21
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
| |||
177 | 188 | | |
178 | 189 | | |
179 | 190 | | |
180 | | - | |
| 191 | + | |
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
| |||
187 | 198 | | |
188 | 199 | | |
189 | 200 | | |
190 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
191 | 204 | | |
192 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
193 | 208 | | |
194 | 209 | | |
195 | 210 | | |
| |||
0 commit comments