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

[hip][cuda] Merged pending_queue_actions implementations. #18220

Merged
merged 9 commits into from
Aug 15, 2024

Conversation

AWoloszyn
Copy link
Contributor

This creates a single deferred work queue that merges the almost identical implementations of pending_queue_actions.

This leaves the actual underlying implementation unchanged, and simply moves the work into a shared location. There are some future cleanups that can be made in order to improve this even further.

This creates a single deferred work queue that merges
the almost identical implementations of pending_queue_actions.

This leaves the actual underlying implementation unchanged,
and simply moves the work into a shared location. There
are some future cleanups that can be made in order to
improve this even further.

Signed-off-by: Andrew Woloszyn <[email protected]>
Copy link
Collaborator

@benvanik benvanik left a comment

Choose a reason for hiding this comment

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

Nice!

I only reviewed the hip side - same comments apply to cuda

} iree_hal_deferred_work_queue_device_interface_t;

typedef struct iree_hal_deferred_work_queue_device_interface_vtable_t {
void (*destroy)(iree_hal_deferred_work_queue_device_interface_t*);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
void (*destroy)(iree_hal_deferred_work_queue_device_interface_t*);
void(IREE_API_PTR* destroy)(iree_hal_deferred_work_queue_device_interface_t*);

(as in other files)

Copy link
Collaborator

Choose a reason for hiding this comment

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

(still need the IREE_API_PTR and arg name on destroy)

runtime/src/iree/hal/utils/deferred_work_queue.h Outdated Show resolved Hide resolved
runtime/src/iree/hal/utils/deferred_work_queue.h Outdated Show resolved Hide resolved
runtime/src/iree/hal/utils/deferred_work_queue.h Outdated Show resolved Hide resolved
runtime/src/iree/hal/drivers/hip/hip_device.c Outdated Show resolved Hide resolved
runtime/src/iree/hal/drivers/hip/hip_device.c Outdated Show resolved Hide resolved
runtime/src/iree/hal/drivers/hip/hip_device.c Outdated Show resolved Hide resolved
runtime/src/iree/hal/drivers/hip/hip_device.c Outdated Show resolved Hide resolved
runtime/src/iree/hal/drivers/hip/hip_device.c Outdated Show resolved Hide resolved
Signed-off-by: Andrew Woloszyn <[email protected]>
Signed-off-by: Andrew Woloszyn <[email protected]>
Signed-off-by: Andrew Woloszyn <[email protected]>
Signed-off-by: Andrew Woloszyn <[email protected]>
Signed-off-by: Andrew Woloszyn <[email protected]>
Signed-off-by: Andrew Woloszyn <[email protected]>
Signed-off-by: Andrew Woloszyn <[email protected]>
@AWoloszyn AWoloszyn requested a review from benvanik August 15, 2024 15:11
@AWoloszyn AWoloszyn enabled auto-merge (squash) August 15, 2024 15:12
Copy link
Collaborator

@benvanik benvanik left a comment

Choose a reason for hiding this comment

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

A few loose bits bit otherwise LGTM!

@@ -77,7 +77,7 @@ typedef struct iree_hal_hip_device_t {
// are met. It buffers submissions and allocations internally before they
// are ready. This queue couples with HAL semaphores backed by iree_event_t
// and hipEvent_t objects.
iree_hal_hip_pending_queue_actions_t* pending_queue_actions;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is how it was and not something done in this PR, but something to think about is how we'll extend this for multiple queues (hopefully just making this an array and selecting the right one on the queue operations) - the nice thing about all the logic being wrapped up in the work queue is that we can move anything queue specific that's bled out (hip_dispatch_stream, tracing_context, etc) into the work queue and stamp them out as multiple per physical device or one or more per physical device.

} iree_hal_deferred_work_queue_device_interface_t;

typedef struct iree_hal_deferred_work_queue_device_interface_vtable_t {
void (*destroy)(iree_hal_deferred_work_queue_device_interface_t*);
Copy link
Collaborator

Choose a reason for hiding this comment

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

(still need the IREE_API_PTR and arg name on destroy)

typedef void(IREE_API_PTR* iree_hal_deferred_work_queue_cleanup_callback_t)(
void* user_data);

// Enques command buffer submissions into the work queue to be executed
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Enques command buffer submissions into the work queue to be executed
// Enqueues command buffer submissions into the work queue to be executed


// Enques command buffer submissions into the work queue to be executed
// once all semaphores have been satisfied.
iree_status_t iree_hal_deferred_work_queue_enque(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
iree_status_t iree_hal_deferred_work_queue_enque(
iree_status_t iree_hal_deferred_work_queue_enqueue(

@AWoloszyn AWoloszyn merged commit 75ad937 into iree-org:main Aug 15, 2024
36 checks passed
@benvanik
Copy link
Collaborator

ah, didn't realize you had that on auto-submit - please do a follow up with the required fixes

@AWoloszyn
Copy link
Contributor Author

ah, didn't realize you had that on auto-submit - please do a follow up with the required fixes
Will do!

Comment on lines +241 to +258
iree_cc_library(
NAME
deferred_work_queue
HDRS
"deferred_work_queue.h"
SRCS
"deferred_work_queue.c"
DEPS
::deferred_command_buffer
::resource_set
::semaphore_base
iree::base
iree::base::internal::arena
iree::base::internal::synchronization
iree::base::internal::threading
iree::hal
PUBLIC
)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be wrapped in:

if (IREE_ENABLE_THREADING)

My builds is now failing as iree::base::internal::threading does not exist, presumably because IREE_ENABLE_THREADING is not set:

if(NOT IREE_ENABLE_THREADING)
return()
endif()
iree_cc_library(
NAME
event_pool
HDRS
"event_pool.h"
SRCS
"event_pool.c"
DEPS
::internal
::synchronization
::wait_handle
iree::base
iree::base::core_headers
PUBLIC
)
iree_cc_library(
NAME
threading
HDRS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Successfully merging this pull request may close these issues.

3 participants