Skip to content

Commit

Permalink
[GPU] Add extra flush() command for dynamic models and OOO queue (ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
sshlyapn authored Jul 27, 2023
1 parent 5f5df36 commit 2bd49cc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/plugins/intel_gpu/src/graph/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,14 @@ void network::execute_impl(const std::vector<event::ptr>& events) {
return std::to_string(iter) + "_";
};

// This extra flush command is needed for dynamic models in case of out_of_order operating mode since
// it reduces `bubbles` number in pipeline and GPU's idle time by timely flushing new kernels to device.
// The freqency of flushing (16) is selected empirically, see details in tickets 116365, 116287.
const bool is_out_of_order_queue = get_stream().get_queue_type() == QueueTypes::out_of_order;
const bool needs_flushing = _is_dynamic && is_out_of_order_queue;
const size_t flush_frequency = needs_flushing ? 16 : 0;
size_t executed_prims = 0;

for (auto& inst : _exec_order) {
// Load binary dump for input layers
GPU_DEBUG_IF(!debug_config->load_layers_raw_dump.empty()) {
Expand Down Expand Up @@ -1337,6 +1345,10 @@ void network::execute_impl(const std::vector<event::ptr>& events) {
}

execute_primitive(inst, events);
executed_prims++;

if (needs_flushing && executed_prims % flush_frequency == 0)
get_stream().flush();

// Dump output buffers of 'inst'
GPU_DEBUG_IF(debug_config->dump_layers_path.length() > 0) {
Expand Down Expand Up @@ -1378,7 +1390,7 @@ void network::execute_impl(const std::vector<event::ptr>& events) {
}

// Store events only in case of OOO queue or enabled Profiling
auto store_events = get_stream().get_queue_type() == QueueTypes::out_of_order || _enable_profiling;
auto store_events = is_out_of_order_queue || _enable_profiling;
if (store_events) {
if (_program != nullptr) {
for (auto& inst : _program->get_processing_order()) {
Expand Down

0 comments on commit 2bd49cc

Please sign in to comment.