MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / TEST

Function TEST

src/core/test/graph/defrag.cpp:78–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76} // anonymous namespace
77
78TEST(TestGraph, Defragment) {
79 REQUIRE_GPU(1);
80 CompNode::load("gpux").activate();
81 size_t reserve;
82 {
83 size_t free, tot;
84 MGB_CUDA_CHECK(cudaMemGetInfo(&free, &tot));
85 reserve = free * 0.92;
86 }
87 auto reserve_setting = ssprintf("b:%zu", reserve);
88
89 auto do_run = [reserve]() {
90 ASSERT_THROW(run_graph(reserve, false), MemAllocError);
91 run_graph(reserve, true);
92 };
93
94 // reserve memory explicitly to avoid uncontrollable factors
95 constexpr const char* KEY = "MGB_CUDA_RESERVE_MEMORY";
96 auto old_value = getenv(KEY);
97 setenv(KEY, reserve_setting.c_str(), 1);
98 MGB_TRY { do_run(); }
99 MGB_FINALLY(
100 if (old_value) { setenv(KEY, old_value, 1); } else {
101 unsetenv(KEY);

Callers

nothing calls this directly

Calls 3

run_graphFunction · 0.70
loadFunction · 0.50
activateMethod · 0.45

Tested by

no test coverage detected