[WIP][xpu][fix] improve XPU host time in tuning by creating less events #1230
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.
I found XPU host is slow on host when creating too many events. It may stuck ~60s after some iteration. I optimize it by using less events. i.e. when I bench rms_norm, the first shape is [2048, 1024], it will bench ~150 kernels with repeat=1000. It will create 300k events. We can reuse events instead of maintaining so many.
Before change:

maintain #kernels * #repeat * 2 events, use 1 synchronize
Example of host time of each iteration when benchmark 200 kernels with repeat = 100:
After change:

maintain #kernels * 2 events, use #repeat synchronizes
cc: @EikanWang