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

Method record

engine/src/core/graph.cpp:104–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104bool GraphRegistry::record(LayerType type, int n_tokens, const std::function<void()>& body, std::string& err) {
105 const Key k{(int) type, n_tokens};
106 if (graphs_.count(k)) return true; // already recorded: the point of a registry
107
108 CapturedGraph g;
109 if (!g.begin(stream_, err)) return false;
110 body(); // the caller launches into the captured stream
111 // The body must not have failed silently. An error state left on the stream would make EndCapture
112 // succeed with a broken graph, so it is checked and cleared first.
113 const cudaError_t body_err = cudaGetLastError();
114 if (body_err != cudaSuccess) {
115 // Abandon the capture without instantiating anything.
116 cudaGraph_t junk = nullptr;
117 cudaStreamEndCapture((cudaStream_t) stream_, &junk);
118 if (junk) cudaGraphDestroy(junk);
119 return fail(err, "the capture body left a CUDA error", body_err);
120 }
121 if (!g.end(stream_, err)) return false;
122
123 graphs_.emplace(k, std::move(g));
124 ++captures_;
125 return true;
126}
127
128const CapturedGraph* GraphRegistry::find(LayerType type, int n_tokens) const {
129 const auto it = graphs_.find(Key{(int) type, n_tokens});

Callers 1

mainFunction · 0.45

Calls 9

moveFunction · 0.85
failFunction · 0.70
bodyFunction · 0.50
cudaGetLastErrorFunction · 0.50
cudaStreamEndCaptureFunction · 0.50
cudaGraphDestroyFunction · 0.50
countMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

mainFunction · 0.36