-
Notifications
You must be signed in to change notification settings - Fork 615
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
Synchronize CUDA stream once in operator benchmark #3525
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
JanuszL
reviewed
Nov 23, 2021
Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
jantonguirao
approved these changes
Dec 2, 2021
awolant
approved these changes
Dec 6, 2021
!build |
CI MESSAGE: [3544555]: BUILD STARTED |
CI MESSAGE: [3544555]: BUILD PASSED |
23 tasks
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jan 23, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Feb 21, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
May 13, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
cyyever
pushed a commit
to cyyever/DALI
that referenced
this pull request
Jun 7, 2022
* Synchronize CUDA stream once in operator benchmark CUDA stream was synchronized after each iteration in operator benchmark, which introduced an error to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operation. This commit moves the synchronization out of the loop, synchronizing the stream only once in a benchmark. Added sync_each_n parameter. Signed-off-by: Szymon Karpiński <hugo@staszic.waw.pl>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
What happened in this PR
CUDA stream was synchronized after each iteration in an operator benchmark, which introduced an overhead to the measurements, especially for small data and small batch sizes. In a real pipeline the synchronization would not happen after each operator but only at the end, so the introduced overhead was benchmark-specific and would not occur in real life.
This overhead was quite significant, when the operator execution was fast: the throughput of Copy measured on Titan V with
copy_bench.cc
for batch_size=1 and 3MiB images was decreased by 25% when synchronizing the stream after each iteration. The main source of the overhead was that the synchronization made it impossible to schedule copy with cudaMemcpyAsync while another copy was still in progress.This PR moves the stream synchronization out of the loop, synchronizing the stream only once in a benchmark, so that the measured operator performance is closer to the actual one.
Additional information
Key points relevant for the review:
As synchronizing each loop introduces a benchmark-specific overhead, I consider it a bug that should be fixed. I am assuming that:
If any of the above is false, making synchronization behaviour configurable with some optional parameter to
RunGPU
would be a better solution.Checklist
Tests
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A