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

Method capture

engine/src/core/verify.cpp:3813–3982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3811}
3812
3813bool Verifier::capture(int T, std::string& err) {
3814 const auto cap_t0 = std::chrono::steady_clock::now();
3815 cudaGraphExec_t& exec_t = ar_off_ ? exec_nr_[sel_long_][T] : exec_[sel_long_][T];
3816 if (exec_t != nullptr) return true;
3817 { // said before the capture: a process that exits inside it (#1275: Windows, 313 MiB free) leaves this line as the trace
3818 size_t free_b = 0, total_b = 0;
3819 if (cudaMemGetInfo(&free_b, &total_b) == cudaSuccess)
3820 std::fprintf(stderr, "strata verify: capturing the %d-token window (%zu MiB of VRAM free)\n", T, free_b >> 20);
3821 else
3822 (void) cudaGetLastError();
3823 }
3824#if !defined(STRATA_USE_HIP) && !defined(STRATA_HIP_GFX906) && !defined(STRATA_GPU_METAL)
3825 // #5636: an error an earlier unchecked call left in the thread's slot is said and cleared here; otherwise the first launch check of the capture
3826 // (copy_i32_from_mapped: "invalid argument" on sm_70 / sm_75) reads it and ends the engine as if that launch had failed
3827 (void) strata::core::take_pending_cuda_error("the verify window's capture");
3828#endif
3829 if (cudaStreamBeginCapture(cs_, cudaStreamCaptureModeThreadLocal) != cudaSuccess) {
3830 err = "verify: begin capture failed";
3831 return false;
3832 }
3833#if !defined(STRATA_USE_HIP) && !defined(STRATA_HIP_GFX906) && !defined(STRATA_GPU_METAL)
3834 prio_forks_.clear();
3835 prio_tails_.clear();
3836#endif
3837 std::string rerr;
3838 const bool ok = record_window(T, cs_, rerr);
3839 cudaGraph_t graph = nullptr;
3840 const cudaError_t ce = cudaStreamEndCapture(cs_, &graph);
3841 if (!ok) {
3842 if (graph) cudaGraphDestroy(graph);
3843 err = rerr;
3844 return false;
3845 }
3846 if (ce != cudaSuccess) {
3847 err = std::string("verify: end capture: ") + cudaGetErrorString(ce);
3848 return false;
3849 }
3850#if defined(STRATA_USE_HIP) // 143-amdk: the same listing on HIP (kernel names by hipKernelNameRefByPtr); STRATA_VERIFY_NODES=2 also lists the first nodes in graph order
3851 if (std::getenv("STRATA_VERIFY_NODES") != nullptr) {
3852 size_t nn = 0;
3853 hipGraphGetNodes(graph, nullptr, &nn);
3854 std::vector<hipGraphNode_t> nodes(nn);
3855 hipGraphGetNodes(graph, nodes.data(), &nn);
3856 std::map<std::string, int> kinds;
3857 std::string seq;
3858 size_t shown = 0;
3859 for (hipGraphNode_t nd : nodes) {
3860 hipGraphNodeType ty;
3861 hipGraphNodeGetType(nd, &ty);
3862 std::string name = "type" + std::to_string((int) ty);
3863 if (ty == hipGraphNodeTypeKernel) {
3864 hipKernelNodeParams kp{};
3865 if (hipGraphKernelNodeGetParams(nd, &kp) == hipSuccess && kp.func != nullptr) {
3866#if defined(_WIN32)
3867 using Fn_hipKernelNameRefByPtr = const char* (*)(const void*, hipStream_t);
3868 static auto p_hipKernelNameRefByPtr = reinterpret_cast<Fn_hipKernelNameRefByPtr>(
3869 GetProcAddress(GetModuleHandleA("amdhip64_7.dll"), "hipKernelNameRefByPtr"));
3870 const char* fn = p_hipKernelNameRefByPtr ? p_hipKernelNameRefByPtr(kp.func, nullptr) : nullptr;

Callers 14

carry_user_argsFunction · 0.45
_startFunction · 0.45
engine_argsFunction · 0.45
engine_argsFunction · 0.45
strata_engine_argsFunction · 0.45
engine_argsFunction · 0.45
_configured_pool_workersFunction · 0.45
applyFunction · 0.45
engine_argsFunction · 0.45
apply_args_to_configFunction · 0.45
_hand_editsFunction · 0.45

Calls 15

take_pending_cuda_errorFunction · 0.85
sortFunction · 0.85
cudaGraphGetNodesFunction · 0.85
cudaFuncGetNameFunction · 0.85
graph_prio_onFunction · 0.85
cudaGraphUploadFunction · 0.85
push_backMethod · 0.80
env_onFunction · 0.70
nowFunction · 0.50
cudaMemGetInfoFunction · 0.50
cudaGetLastErrorFunction · 0.50
cudaStreamBeginCaptureFunction · 0.50