MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / time_loop

Function time_loop

src/targets/gpu/time_op.cpp:50–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50double
51time_loop(migraphx::gpu::context& gctx, int bundle, int nruns, const std::function<void()>& f)
52{
53 // check for manual overrides
54 bundle = value_of(MIGRAPHX_BENCHMARKING_BUNDLE{}, bundle);
55 nruns = value_of(MIGRAPHX_BENCHMARKING_NRUNS{}, nruns);
56
57 std::vector<std::pair<hip_event_ptr, hip_event_ptr>> events(nruns);
58 std::generate(events.begin(), events.end(), [] {
59 return std::make_pair(context::create_event_for_timing(),
60 context::create_event_for_timing());
61 });
62 std::vector<double> times;
63 // Warmup
64 f();
65 for(auto i : range(nruns))
66 {
67 gctx.get_stream().record(events[i].first.get());
68 for(auto j : range(bundle))
69 {
70 (void)j;
71 f();
72 }
73 gctx.get_stream().record(events[i].second.get());
74 }
75 gctx.finish();
76 std::transform(events.begin(), events.end(), std::back_inserter(times), [&](const auto& p) {
77 return context::get_elapsed_ms(p.first.get(), p.second.get()) / bundle;
78 });
79 std::sort(times.begin(), times.end());
80
81 // compute common average by removing top and bottom 25% of values
82 std::size_t quarters = times.size() / 4;
83 double total = std::accumulate(times.begin() + quarters, times.end() - quarters, 0.0);
84 return total / std::distance(times.begin() + quarters, times.end() - quarters);
85}
86
87double
88time_op(const context& ictx, operation op, const std::vector<shape>& inputs, int bundle, int nruns)

Callers 3

tuneMethod · 0.85
time_opFunction · 0.85
time_programFunction · 0.85

Calls 14

generateFunction · 0.85
accumulateFunction · 0.85
distanceFunction · 0.85
value_ofFunction · 0.50
rangeFunction · 0.50
transformFunction · 0.50
sortFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
recordMethod · 0.45
get_streamMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected