| 195 | } |
| 196 | |
| 197 | Error 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 | |
| 221 | Error encode_fill(StreamImpl* s, void* p, int value, size_t n) { |
| 222 | size_t off = 0; |
no test coverage detected