Skip to content

Conversation

kbsmith-intel
Copy link
Contributor

These changes add code to implement dynamic command list batch
size adjustment. This adds code that adjusts the batch size based
on how often the command list batch is closed and executed when
full versus how often it is closed and executed only partially full.
This also adds a new environment variable
SYCL_PI_LEVEL_ZERO_DISABLE_DYNAMIC_BATCH, and its accompanying
documentation.

kbsmith-intel and others added 8 commits October 6, 2020 14:39
Pull to update my local fork
updating fork from main
update fork to sycl head
Updating fork to head of sycl.
Update to sycl head.
update my fork to sycl head
These changes add code to implement dynamic command list batch
size adjustment.  This adds code that adjusts the batch size based
on how often the command list batch is closed and executed when
full versus how often it is closed and executed only partially full.
This also adds a new environment variable
SYCL_PI_LEVEL_ZERO_DISABLE_DYNAMIC_BATCH, and its accompanying
documentation.
| SYCL_PI_LEVEL_ZERO_DISABLE_USM_ALLOCATOR | Any(\*) | Disable USM allocator in Level Zero plugin (each memory request will go directly to Level Zero runtime) |
| SYCL_PI_LEVEL_ZERO_BATCH_SIZE | Positive integer | Sets a preferred number of commands to batch into a command list before executing the command list. Values 0 and 1 turn off batching. Default is 4. |
| SYCL_PI_LEVEL_ZERO_BATCH_SIZE | Positive integer | Sets a preferred number of commands to batch into a command list before executing the command list. Value of 0 turns off batching. Default is 4. |
| SYCL_PI_LEVEL_ZERO_DISABLE_DYNAMIC_BATCH | Any(\*) | Disable dyanmic command list batch size adjustment. |
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
| SYCL_PI_LEVEL_ZERO_DISABLE_DYNAMIC_BATCH | Any(\*) | Disable dyanmic command list batch size adjustment. |
| SYCL_PI_LEVEL_ZERO_DISABLE_DYNAMIC_BATCH | Any(\*) | Disable dynamic command list batch size adjustment. |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

kbobrovs
kbobrovs previously approved these changes Nov 19, 2020
@kbsmith-intel
Copy link
Contributor Author

Please only review this pull request. Please do not merge it quite yet.

@kbsmith-intel
Copy link
Contributor Author

/summary:run

This changes the level zero plug-in command list batching unit
test to turn off new dyanmic batching feature.  The test was intended
to test basic batching functionality with a fixed batch size,
and these changes make that continue to be true.
This change adds a new unit test which tests the dynamic batch size
adjustment feature.  This test is likely to need to be updated if the
batch size adjustment algorithm changes.
This removes some extra en-of-line whitespace that was found during
clang-format run on new level_zero_dynamic_batch_test.cpp test.
pvchupin
pvchupin previously approved these changes Nov 19, 2020
Copy link
Contributor

@pvchupin pvchupin left a comment

Choose a reason for hiding this comment

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

doc ok

@pvchupin pvchupin changed the title [SYCL][PI][L0] Add dynamic batch size adjustment [DO NOT MERGE][SYCL][PI][L0] Add dynamic batch size adjustment Nov 19, 2020
@pvchupin
Copy link
Contributor

pvchupin commented Nov 19, 2020

Please only review this pull request. Please do not merge it quite yet.

Updated PR title with tag so it's not merged accidentally.

Copy link
Contributor

@smaslov-intel smaslov-intel left a comment

Choose a reason for hiding this comment

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

see comments

This commit updates the dynamic batching code, documentation,
and test cases to address review comments.  This deletes the
newly added environment variable
SYCL_PI_LEVEL_ZERO_DISABLE_DYNAMIC_BATCH. Instead, this uses
the SYCL_PI_LEVEL_ZERO_BATCH_SIZE=0 to mean use dyanmic batching
and retains all the positive values above zero for menaing use
fixed size batching of that exact value.  the default is changed
to use dyanmic batching.  This also slightly updates the interface
to update the dynamic batch size in a way I thought was a little
cleaner.
This change lowers the maximum dynamic batch size to 16 from 32,
and starts the batch size for dynamic batching at 2.  It updates
the dynamic batch test output as needed because of the start
batch size change.
Copy link
Contributor

@smaslov-intel smaslov-intel left a comment

Choose a reason for hiding this comment

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

LGTM

}

void _pi_queue::adjustBatchSizeForFullBatch() {
// QueueBatchSize of 0 means never allow batching.
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: I think it can't happen in today's code the QueueBatchSize is equal to 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is incorrect. In the queue itself, QueueBatchSize of 0 means - No Batching. Because I need to allow QueueBatchSize to be 1 when dynamic batching is being used, because the possibility is that dynamic batching can adjust QueueBatchSize down to as low as 1 if we are still doing too many partial batches. So, in the queue itself, QueueBatchSize == 0 means no batching, QueueBatchSize > 0 is just the current bacthing size, and the queue bool UseDynamicBatching controls whether dynamic batch adjustment ever changes QueueBatchSize up or down.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, in the queue itself, QueueBatchSize == 0 means no batching

I realized this, yeah. But the code (in _pi_queue constructor) seems to never set it to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On looking at the code in pi_level_zero.hpp, I see that you are correct. Batching turned off is now really
represented as QueueBatchSize == 1 and UseDynamicBatching== false, or to say it another way, batching is turned off by using a fixed batch size of 1. Thank you for pointing that out.

@kbsmith-intel kbsmith-intel changed the title [DO NOT MERGE][SYCL][PI][L0] Add dynamic batch size adjustment [SYCL][PI][L0] Add dynamic batch size adjustment Nov 20, 2020
@kbsmith-intel
Copy link
Contributor Author

I changed the title as I think this is now ready to be merged after all reviews have completed.

@pvchupin
Copy link
Contributor

@kbsmith-intel, I'd like to squash and merge, could you please post a new commit message you'd like me to capture for a squashed commit? There've been changes done during code review and I'd like to capture summary of this change as accurate as possible.

@kbsmith-intel
Copy link
Contributor Author

OK, here's the commit log message I would like:
Add dynamic batch size adjustment

These changes add code to implement dynamic command list batch
size adjustment, change the documentation of the environment
variable that can be used to control command list batching,
and updates and adds tests for the batching feature.

@pvchupin pvchupin merged commit c70b047 into intel:sycl Nov 20, 2020
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.

5 participants