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

Function encode_copy

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

Source from the content-addressed store, hash-verified

195}
196
197Error encode_copy(StreamImpl* s, void* dst, const void* src, size_t n) {
198 size_t od = 0, os = 0;
199 const Alloc* ad = find(dst, &od);
200 const Alloc* as = find(src, &os);
201 check_purged(ad, "copy");
202 check_purged(as, "copy");
203 if (ad && as) { // buffer to buffer: a blit, in stream order
204 end_encoder(s);
205 MTL::BlitCommandEncoder* b = open_cb(s)->blitCommandEncoder();
206 b->copyFromBuffer(as->buf, os, ad->buf, od, n);
207 b->endEncoding();
208 ++rt().stats.blits;
209 return kSuccess;
210 }
211 // ordinary host memory on one side: the stream's earlier work must be complete first (the conservative CUDA
212 // pageable-memory semantics: the call returns when the copy is done)
213 flush(s);
214 wait_value(s->tl, s->submitted);
215 uint8_t* d = ad ? ad->cpu + od : (uint8_t*) dst;
216 const uint8_t* sp = as ? as->cpu + os : (const uint8_t*) src;
217 std::memcpy(d, sp, n);
218 return kSuccess;
219}
220
221Error encode_fill(StreamImpl* s, void* p, int value, size_t n) {
222 size_t off = 0;

Callers 3

run_opFunction · 0.85
memcpy_syncFunction · 0.85
memcpy_asyncFunction · 0.85

Calls 7

check_purgedFunction · 0.85
end_encoderFunction · 0.85
open_cbFunction · 0.85
wait_valueFunction · 0.85
memcpyFunction · 0.85
findFunction · 0.70
flushFunction · 0.70

Tested by

no test coverage detected