Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] [NPU] Using global command queue #28745

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

pereanub
Copy link
Contributor

@pereanub pereanub commented Jan 30, 2025

Details:

  • Another option for PR#28661
  • Using a global command queue per core and not creating different queues for each compiled model. The plugin will create a different queue only if the properties for using them are different from a compiled model to another or if the properties(workload type) are changing at runtime

Tickets:

  • E#154336

Signed-off-by: Bogdan Pereanu <[email protected]>
Signed-off-by: Bogdan Pereanu <[email protected]>
Signed-off-by: Bogdan Pereanu <[email protected]>
Signed-off-by: Bogdan Pereanu <[email protected]>
Signed-off-by: Bogdan Pereanu <[email protected]>
@pereanub pereanub force-pushed the global_command_queue_graph branch from e0df99b to 6d4ab81 Compare January 30, 2025 14:50
@pereanub pereanub marked this pull request as ready for review January 30, 2025 14:53
@pereanub pereanub requested review from a team as code owners January 30, 2025 14:53
Signed-off-by: Bogdan Pereanu <[email protected]>
@pereanub pereanub force-pushed the global_command_queue_graph branch from 81f15a6 to acb0b4f Compare January 30, 2025 17:02
Copy link
Contributor

@razvanapetroaie razvanapetroaie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't found any major issue regarding the design nor the code, but please don't rely on my review alone - I don't have much experience with the driver API.


CommandQueuePool::CommandQueuePool() : _log("CommandQueue", Logger::global().level()) {}
int CommandQueuePool::computeHash(CommandQueueDesc desc) {
return (static_cast<size_t>(desc.priority) & 0xFF) | (static_cast<size_t>(desc.workload) & 0xFF) << 8 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several things to note here:

  • Both priority and workload type can take the value of "0x7fffffff" (ZE_WORKLOAD_TYPE_FORCE_UINT32) which exceeds the 1 byte range. So we might have an issue if another value > 255 is defined in any of those enums. Perhaps not a problem since this scenario is unlikely, but worth taking into consideration.
  • int doesn't have a stable byte size and it seems you're using only 3 bytes so maybe we should use uint32_t.
  • C++ has a dedicated hash functionality, you may consider overriding its operator() instead. Example here, OV also has several in its implementation.

}
std::shared_ptr<CommandQueue> CommandQueuePool::getCommandQueue(
const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
const ze_command_queue_priority_t& priority,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const ze_command_queue_priority_t& priority,
const ze_command_queue_priority_t priority,

Primitive type, cheaper to pass by value.

const ze_command_queue_workload_type_t& workload_type,
const uint32_t& group_ordinal,
bool turbo) {
CommandQueueDesc desc = {priority, workload_type, turbo};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth asking: are we certain these three are all attributes that should be used for determining command queue sharing? Just making sure, I don't know how to answer that. I see there's also some group_ordinal (whatever that is) and multiple fields inside init_structs.

@@ -50,6 +52,34 @@ namespace zeroUtils {
ze_result_to_description(result)); \
}

static inline size_t toPriorityVal(const ze_command_queue_priority_t& val) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used? Same about toWorkloadVal.

}
}

void PluginGraph::create_new_command_queue() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name a bit misleading since we're not always creating a new one depending on whether or not we find one using the same stats in the pool.

if (config.has<TURBO>()) {
turbo = config.get<TURBO>();
_turbo = config.get<TURBO>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Will Config::get() return the default value if no value was explicitly set? If so, you could allow the default value to do its job by not setting _turbo to false (in the header file) and not checking config.has<TURBO>().

@@ -147,9 +180,30 @@ Pipeline::Pipeline(const Config& config,
_logger.debug("Pipeline - initialize completed");
}

void Pipeline::getCommandQueue() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: a bit weird to call a function a "getter" without returning anything.

@@ -206,6 +208,60 @@ TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadTypeUpdateAfterCompilation
}
}

TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadTypeUpdateAfterCompilationWithMultipleInfers) {
if (isCommandQueueExtSupported()) {
OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also change execNet old API naming with the new compiledModel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants