|
14 | 14 | #include <CL/sycl/usm.hpp>
|
15 | 15 | #include <detail/queue_impl.hpp>
|
16 | 16 |
|
| 17 | +#include <array> |
| 18 | +#include <cassert> |
17 | 19 | #include <cstdlib>
|
18 | 20 | #include <memory>
|
19 | 21 |
|
@@ -150,16 +152,32 @@ void *alignedAlloc(size_t Alignment, size_t Size, const context &Ctxt,
|
150 | 152 | }
|
151 | 153 | case alloc::shared: {
|
152 | 154 | Id = detail::getSyclObjImpl(Dev)->getHandleRef();
|
| 155 | + |
| 156 | + std::array<pi_usm_mem_properties, 5> Props; |
| 157 | + auto PropsIter = Props.begin(); |
| 158 | + |
153 | 159 | if (PropList.has_property<
|
154 | 160 | cl::sycl::ext::oneapi::property::usm::device_read_only>()) {
|
155 |
| - pi_usm_mem_properties Props[3] = {PI_MEM_ALLOC_FLAGS, |
156 |
| - PI_MEM_ALLOC_DEVICE_READ_ONLY, 0}; |
157 |
| - Error = Plugin.call_nocheck<PiApiKind::piextUSMSharedAlloc>( |
158 |
| - &RetVal, C, Id, Props, Size, Alignment); |
159 |
| - } else { |
160 |
| - Error = Plugin.call_nocheck<PiApiKind::piextUSMSharedAlloc>( |
161 |
| - &RetVal, C, Id, nullptr, Size, Alignment); |
| 161 | + *PropsIter++ = PI_MEM_ALLOC_FLAGS; |
| 162 | + *PropsIter++ = PI_MEM_ALLOC_DEVICE_READ_ONLY; |
162 | 163 | }
|
| 164 | + |
| 165 | + if (Dev.has_extension("cl_intel_mem_alloc_buffer_location") && |
| 166 | + PropList.has_property<cl::sycl::ext::intel::experimental::property:: |
| 167 | + usm::buffer_location>()) { |
| 168 | + *PropsIter++ = PI_MEM_USM_ALLOC_BUFFER_LOCATION; |
| 169 | + *PropsIter++ = PropList |
| 170 | + .get_property<cl::sycl::ext::intel::experimental:: |
| 171 | + property::usm::buffer_location>() |
| 172 | + .get_buffer_location(); |
| 173 | + } |
| 174 | + |
| 175 | + assert(PropsIter >= Props.begin() && PropsIter < Props.end()); |
| 176 | + *PropsIter++ = 0; // null-terminate property list |
| 177 | + |
| 178 | + Error = Plugin.call_nocheck<PiApiKind::piextUSMSharedAlloc>( |
| 179 | + &RetVal, C, Id, Props.data(), Size, Alignment); |
| 180 | + |
163 | 181 | break;
|
164 | 182 | }
|
165 | 183 | case alloc::host:
|
|
0 commit comments