| 126 | } |
| 127 | |
| 128 | result ze_allocator::query_pointer(const void* ptr, pointer_info& out) const { |
| 129 | |
| 130 | ze_memory_allocation_properties_t props; |
| 131 | props.pNext = nullptr; |
| 132 | |
| 133 | ze_device_handle_t dev; |
| 134 | |
| 135 | ze_result_t err = zeMemGetAllocProperties(_ctx, ptr, &props, &dev); |
| 136 | |
| 137 | if(err != ZE_RESULT_SUCCESS) { |
| 138 | return make_error(__acpp_here(), |
| 139 | error_info{"ze_allocator: zeMemGetAllocProperties() failed", |
| 140 | error_code{"ze", static_cast<int>(err)}}); |
| 141 | } |
| 142 | |
| 143 | if(props.type == ZE_MEMORY_TYPE_UNKNOWN) { |
| 144 | return make_error( |
| 145 | __acpp_here(), |
| 146 | error_info{"ze_allocator: query_pointer(): pointer is unknown by backend", |
| 147 | error_code{"ze", static_cast<int>(err)}, |
| 148 | error_type::invalid_parameter_error}); |
| 149 | } |
| 150 | |
| 151 | out.is_optimized_host = props.type == ZE_MEMORY_TYPE_HOST; |
| 152 | out.is_usm = props.type == ZE_MEMORY_TYPE_SHARED; |
| 153 | |
| 154 | out.is_from_host_backend = false; |
| 155 | |
| 156 | // Lastly, fill out.dev with ze_device_handle_t converted |
| 157 | // to hipSYCL device_id. This might fail if the |
| 158 | // ze_device_handle_t is unknown, so return the result of this function |
| 159 | // for error handling. |
| 160 | // However, if the allocation is shared or it is a host allocation, |
| 161 | // no device might be associated, and the error is expected, so do |
| 162 | // not fail in that case. Only if we have a device allocation do |
| 163 | // we really need to enforce that we get a valid value. |
| 164 | auto dev_handle_err = _hw_manager->device_handle_to_device_id(dev, out.dev); |
| 165 | if(props.type == ZE_MEMORY_TYPE_DEVICE && !dev_handle_err.is_success()){ |
| 166 | return dev_handle_err; |
| 167 | } |
| 168 | |
| 169 | return make_success(); |
| 170 | } |
| 171 | |
| 172 | result ze_allocator::mem_advise(const void *addr, std::size_t num_bytes, |
| 173 | int advise) const { |
no test coverage detected