|
8 | 8 | #pragma once
|
9 | 9 |
|
10 | 10 | #include <set>
|
11 |
| -#include <unordered_map> |
12 | 11 |
|
13 | 12 | #include "common.hpp"
|
14 | 13 | #include "device.hpp"
|
@@ -104,57 +103,6 @@ struct ur_context_handle_t_ {
|
104 | 103 |
|
105 | 104 | ur_usm_pool_handle_t getOwningURPool(umf_memory_pool_t *UMFPool);
|
106 | 105 |
|
107 |
| - /// We need to keep track of USM mappings in AMD HIP, as certain extra |
108 |
| - /// synchronization *is* actually required for correctness. |
109 |
| - /// During kernel enqueue we must dispatch a prefetch for each kernel argument |
110 |
| - /// that points to a USM mapping to ensure the mapping is correctly |
111 |
| - /// populated on the device (https://github.com/intel/llvm/issues/7252). Thus, |
112 |
| - /// we keep track of mappings in the context, and then check against them just |
113 |
| - /// before the kernel is launched. The stream against which the kernel is |
114 |
| - /// launched is not known until enqueue time, but the USM mappings can happen |
115 |
| - /// at any time. Thus, they are tracked on the context used for the urUSM* |
116 |
| - /// mapping. |
117 |
| - /// |
118 |
| - /// The three utility function are simple wrappers around a mapping from a |
119 |
| - /// pointer to a size. |
120 |
| - void addUSMMapping(void *Ptr, size_t Size) { |
121 |
| - std::lock_guard<std::mutex> Guard(Mutex); |
122 |
| - assert(USMMappings.find(Ptr) == USMMappings.end() && |
123 |
| - "mapping already exists"); |
124 |
| - USMMappings[Ptr] = Size; |
125 |
| - } |
126 |
| - |
127 |
| - void removeUSMMapping(const void *Ptr) { |
128 |
| - std::lock_guard<std::mutex> guard(Mutex); |
129 |
| - auto It = USMMappings.find(Ptr); |
130 |
| - if (It != USMMappings.end()) |
131 |
| - USMMappings.erase(It); |
132 |
| - } |
133 |
| - |
134 |
| - std::pair<const void *, size_t> getUSMMapping(const void *Ptr) { |
135 |
| - std::lock_guard<std::mutex> Guard(Mutex); |
136 |
| - auto It = USMMappings.find(Ptr); |
137 |
| - // The simple case is the fast case... |
138 |
| - if (It != USMMappings.end()) |
139 |
| - return *It; |
140 |
| - |
141 |
| - // ... but in the failure case we have to fall back to a full scan to search |
142 |
| - // for "offset" pointers in case the user passes in the middle of an |
143 |
| - // allocation. We have to do some not-so-ordained-by-the-standard ordered |
144 |
| - // comparisons of pointers here, but it'll work on all platforms we support. |
145 |
| - uintptr_t PtrVal = (uintptr_t)Ptr; |
146 |
| - for (std::pair<const void *, size_t> Pair : USMMappings) { |
147 |
| - uintptr_t BaseAddr = (uintptr_t)Pair.first; |
148 |
| - uintptr_t EndAddr = BaseAddr + Pair.second; |
149 |
| - if (PtrVal > BaseAddr && PtrVal < EndAddr) { |
150 |
| - // If we've found something now, offset *must* be nonzero |
151 |
| - assert(Pair.second); |
152 |
| - return Pair; |
153 |
| - } |
154 |
| - } |
155 |
| - return {nullptr, 0}; |
156 |
| - } |
157 |
| - |
158 | 106 | private:
|
159 | 107 | std::mutex Mutex;
|
160 | 108 | std::vector<deleter_data> ExtendedDeleters;
|
|
0 commit comments