@@ -24,15 +24,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc(
24
24
[[maybe_unused]] ur_usm_pool_handle_t pool, size_t size, void **ppMem) {
25
25
UR_ASSERT (ppMem, UR_RESULT_ERROR_INVALID_NULL_POINTER);
26
26
UR_ASSERT (hContext, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
27
-
28
- size_t DeviceMaxMemAllocSize = 0 ;
29
- UR_ASSERT (urDeviceGetInfo (hContext->getDevice (),
30
- UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE, sizeof (size_t ),
31
- static_cast <void *>(&DeviceMaxMemAllocSize),
32
- nullptr ) == UR_RESULT_SUCCESS,
33
- UR_RESULT_ERROR_INVALID_DEVICE);
34
- UR_ASSERT (size > 0 && size <= DeviceMaxMemAllocSize,
35
- UR_RESULT_ERROR_INVALID_USM_SIZE);
27
+ UR_ASSERT (!pUSMDesc || (pUSMDesc->align == 0 ||
28
+ ((pUSMDesc->align & (pUSMDesc->align - 1 )) == 0 )),
29
+ UR_RESULT_ERROR_INVALID_VALUE);
36
30
37
31
ur_result_t Result = UR_RESULT_SUCCESS;
38
32
try {
@@ -42,13 +36,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc(
42
36
Result = Err;
43
37
}
44
38
45
- UR_ASSERT (!pUSMDesc || (pUSMDesc->align == 0 ||
46
- ((pUSMDesc->align & (pUSMDesc->align - 1 )) == 0 )),
47
- UR_RESULT_ERROR_INVALID_VALUE);
48
-
49
- assert (Result == UR_RESULT_SUCCESS &&
50
- (!pUSMDesc || pUSMDesc->align == 0 ||
51
- reinterpret_cast <std::uintptr_t >(*ppMem) % pUSMDesc->align == 0 ));
39
+ if (Result == UR_RESULT_SUCCESS) {
40
+ assert ((!pUSMDesc || pUSMDesc->align == 0 ||
41
+ reinterpret_cast <std::uintptr_t >(*ppMem) % pUSMDesc->align == 0 ));
42
+ }
52
43
53
44
return Result;
54
45
}
@@ -66,15 +57,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc(
66
57
((pUSMDesc->align & (pUSMDesc->align - 1 )) == 0 )),
67
58
UR_RESULT_ERROR_INVALID_VALUE);
68
59
69
- size_t DeviceMaxMemAllocSize = 0 ;
70
- UR_ASSERT (urDeviceGetInfo (hDevice, UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE,
71
- sizeof (size_t ),
72
- static_cast <void *>(&DeviceMaxMemAllocSize),
73
- nullptr ) == UR_RESULT_SUCCESS,
74
- UR_RESULT_ERROR_INVALID_DEVICE);
75
- UR_ASSERT (size > 0 && size <= DeviceMaxMemAllocSize,
76
- UR_RESULT_ERROR_INVALID_USM_SIZE);
77
-
78
60
ur_result_t Result = UR_RESULT_SUCCESS;
79
61
try {
80
62
ScopedContext Active (hContext);
@@ -83,9 +65,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc(
83
65
return Err;
84
66
}
85
67
86
- assert (Result == UR_RESULT_SUCCESS &&
87
- (!pUSMDesc || pUSMDesc->align == 0 ||
88
- reinterpret_cast <std::uintptr_t >(*ppMem) % pUSMDesc->align == 0 ));
68
+ if (Result == UR_RESULT_SUCCESS) {
69
+ assert ((!pUSMDesc || pUSMDesc->align == 0 ||
70
+ reinterpret_cast <std::uintptr_t >(*ppMem) % pUSMDesc->align == 0 ));
71
+ }
89
72
90
73
return Result;
91
74
}
@@ -103,15 +86,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc(
103
86
((pUSMDesc->align & (pUSMDesc->align - 1 )) == 0 )),
104
87
UR_RESULT_ERROR_INVALID_VALUE);
105
88
106
- size_t DeviceMaxMemAllocSize = 0 ;
107
- UR_ASSERT (urDeviceGetInfo (hDevice, UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE,
108
- sizeof (size_t ),
109
- static_cast <void *>(&DeviceMaxMemAllocSize),
110
- nullptr ) == UR_RESULT_SUCCESS,
111
- UR_RESULT_ERROR_INVALID_DEVICE);
112
- UR_ASSERT (size > 0 && size <= DeviceMaxMemAllocSize,
113
- UR_RESULT_ERROR_INVALID_USM_SIZE);
114
-
115
89
ur_result_t Result = UR_RESULT_SUCCESS;
116
90
try {
117
91
ScopedContext Active (hContext);
@@ -121,9 +95,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc(
121
95
return Err;
122
96
}
123
97
124
- assert (Result == UR_RESULT_SUCCESS &&
125
- (!pUSMDesc || pUSMDesc->align == 0 ||
126
- reinterpret_cast <std::uintptr_t >(*ppMem) % pUSMDesc->align == 0 ));
98
+ if (Result == UR_RESULT_SUCCESS) {
99
+ assert ((!pUSMDesc || pUSMDesc->align == 0 ||
100
+ reinterpret_cast <std::uintptr_t >(*ppMem) % pUSMDesc->align == 0 ));
101
+ }
127
102
128
103
return Result;
129
104
}
0 commit comments