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