| 232 | } |
| 233 | |
| 234 | Error encode_dispatch(StreamImpl* s, const Op& o) { |
| 235 | MTL::ComputeCommandEncoder* e = encoder(s); |
| 236 | e->setComputePipelineState(o.pipe); |
| 237 | if (o.big_args.empty()) e->setBytes(o.args, o.arg_bytes, 0); |
| 238 | else e->setBytes(o.big_args.data(), o.big_args.size(), 0); |
| 239 | if (o.tg_bytes) e->setThreadgroupMemoryLength(o.tg_bytes, 0); |
| 240 | e->dispatchThreadgroups(MTL::Size(o.groups.x, o.groups.y, o.groups.z), MTL::Size(o.threads.x, o.threads.y, o.threads.z)); |
| 241 | ++rt().stats.dispatches; |
| 242 | if (++s->pending >= kFlushEvery) flush(s); |
| 243 | return kSuccess; |
| 244 | } |
| 245 | |
| 246 | Error record_event(EventImpl* e, StreamImpl* s) { |
| 247 | flush(s); // CUDA submits on launch: a recorded event must become complete without a further call |