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

Function pipeline

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

Source from the content-addressed store, hash-verified

575MTL::Device* device() { return rt().dev; }
576
577MTL::ComputePipelineState* pipeline(const char* source_name, const char* source, const char* function, std::string& err) {
578 Runtime& r = rt();
579 const std::string key = std::string(source_name) + "::" + function;
580 std::lock_guard<std::mutex> lk(r.mu);
581 if (auto it = r.pipes.find(key); it != r.pipes.end()) return it->second;
582 MTL::Library*& lib = r.libs[source_name];
583 NS::Error* e = nullptr;
584 if (!lib) {
585 MTL::CompileOptions* co = MTL::CompileOptions::alloc()->init();
586 co->setMathMode(MTL::MathModeSafe); // no fast-math reassociation: parity with the CUDA reference first
587 lib = r.dev->newLibrary(NS::String::string(source, NS::UTF8StringEncoding), co, &e);
588 co->release();
589 if (!lib) {
590 err = std::string("MSL compile of ") + source_name + ": " + (e ? e->localizedDescription()->utf8String() : "?");
591 return nullptr;
592 }
593 }
594 MTL::Function* f = lib->newFunction(NS::String::string(function, NS::UTF8StringEncoding));
595 if (!f) { err = std::string("no MSL function ") + function; return nullptr; }
596 MTL::ComputePipelineState* p = r.dev->newComputePipelineState(f, &e);
597 f->release();
598 if (!p) { err = std::string("pipeline ") + function + ": " + (e ? e->localizedDescription()->utf8String() : "?"); return nullptr; }
599 r.pipes[key] = p;
600 return p;
601}
602
603Error dispatch(Stream st, MTL::ComputePipelineState* p, const void* args, size_t arg_bytes, Grid groups, Grid threads,
604 size_t tg_bytes) {

Callers 3

mainFunction · 0.85
apiFunction · 0.85
installFunction · 0.85

Calls 6

allocFunction · 0.85
stringFunction · 0.50
findMethod · 0.45
endMethod · 0.45
initMethod · 0.45
releaseMethod · 0.45

Tested by 1

mainFunction · 0.68