MCPcopy Create free account
hub / github.com/Niko1221/Strata / find

Function find

engine/metal/src/gpu/runtime.cpp:139–155  ·  view source on GitHub ↗

The allocation that holds GPU address `p` (or CPU address `p` of a host allocation), with the offset into it.

Source from the content-addressed store, hash-verified

137
138/// The allocation that holds GPU address `p` (or CPU address `p` of a host allocation), with the offset into it.
139const Alloc* find(const void* p, size_t* off) {
140 Runtime& r = rt();
141 std::lock_guard<std::mutex> lk(r.mu);
142 const uint64_t a = (uint64_t) (uintptr_t) p;
143 auto it = r.by_gpu.upper_bound(a);
144 if (it != r.by_gpu.begin()) {
145 --it;
146 if (a < it->first + it->second.bytes) { *off = a - it->first; return &it->second; }
147 }
148 auto ic = r.by_cpu.upper_bound((uintptr_t) p);
149 if (ic != r.by_cpu.begin()) {
150 --ic;
151 const Alloc& al = r.by_gpu[ic->second];
152 if ((uintptr_t) p < ic->first + al.bytes) { *off = (uintptr_t) p - ic->first; return &al; }
153 }
154 return nullptr;
155}
156
157MTL::CommandBuffer* open_cb(StreamImpl* s) {
158 if (!s->cb) {

Callers 14

encode_copyFunction · 0.70
encode_fillFunction · 0.70
free_allocFunction · 0.70
host_viewFunction · 0.70
host_device_pointer_rawFunction · 0.70
load_denseMethod · 0.50
pendingMethod · 0.50
begin_layerMethod · 0.50
hold_regionMethod · 0.50
gemv16_tileFunction · 0.50
mtp_loadMethod · 0.50
mainFunction · 0.50

Calls 1

beginMethod · 0.45

Tested by 1

mainFunction · 0.40