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

Function free_alloc

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

Source from the content-addressed store, hash-verified

294}
295
296Error free_alloc(void* p) {
297 if (!p) return kSuccess;
298 Runtime& r = rt();
299 size_t off = 0;
300 const Alloc* a = find(p, &off);
301 if (!a || off != 0) return fail(kErrorInvalidValue);
302 device_synchronize(); // as cudaFree: the GPU is done with it
303 std::lock_guard<std::mutex> lk(r.mu);
304 MTL::Buffer* b = a->buf;
305 const uint64_t g = a->gpu;
306 r.by_cpu.erase((uintptr_t) a->cpu);
307 r.by_gpu.erase(g);
308 r.rs->removeAllocation(b);
309 r.rs->commit();
310 b->release();
311 return kSuccess;
312}
313
314} // namespace
315

Callers 3

free_deviceFunction · 0.85
free_hostFunction · 0.85
host_unregisterFunction · 0.85

Calls 6

device_synchronizeFunction · 0.85
eraseMethod · 0.80
findFunction · 0.70
failFunction · 0.70
commitMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected