Skip to content

[SYCL] Drop the old post-wait graph cleanup mechanism #7727

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

Merged
merged 11 commits into from
Dec 15, 2022

Conversation

sergey-semenov
Copy link
Contributor

@sergey-semenov sergey-semenov commented Dec 9, 2022

This patch updates the remaining cases that still used the old
post-wait graph cleanup:

  • Kernels with streams are now cleaned up after enqueue. The lifetime
    of internal buffers allocated for them is now handled like any other
    buffer with deferred release.
  • Kernels with auxiliary resources are also cleaned up after enqueue.
    Since their resources are not limited to buffers, we now regularly check
    the status of such kernels alongside regular graph cleanup, and release
    the resources when we're able to.
  • Host tasks are still cleaned up after completion, but they are now
    sent to the new cleanup mechanism instead of relying on the old one.

@sergey-semenov sergey-semenov changed the title [NOT FOR REVIEW][WIP] Test cleanup changes [WIP][SYCL] Drop the old post-wait graph cleanup mechanism Dec 12, 2022
@sergey-semenov sergey-semenov changed the title [WIP][SYCL] Drop the old post-wait graph cleanup mechanism [SYCL] Drop the old post-wait graph cleanup mechanism Dec 12, 2022
@sergey-semenov sergey-semenov marked this pull request as ready for review December 12, 2022 16:51
@sergey-semenov sergey-semenov requested a review from a team as a code owner December 12, 2022 16:51
@sergey-semenov
Copy link
Contributor Author

Still need to add tests, but the runtime changes should be ready for review.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

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

Not familiar with the area, so stylistic only review from me.

@@ -1036,22 +1033,17 @@ void Scheduler::GraphBuilder::decrementLeafCountersForRecord(
MemObjRecord *Record) {
for (Command *Cmd : Record->MReadLeaves) {
--(Cmd->MLeafCounter);
if (Cmd->MLeafCounter == 0 && Cmd->isSuccessfullyEnqueued() &&
Cmd->supportsPostEnqueueCleanup())
if (Cmd->readyForCleanup())
Copy link
Contributor

Choose a reason for hiding this comment

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

Not being familiar with the codebase, so possibly nonsense...

Any chance that having cleanupCommandIfReady would be a better interface now after the refactoring has happened?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather keep it as is. One of the places where readyForCleanup() check is currently made is in updateLeaves, which cannot clean up commands on the spot (since some of its potential callers don't hold the graph lock), so we would need to keep that check regardless. In the other three cases we could go with cleanupCommandIfReady(), but I don't think the current version is overly verbose to warrant introducing an additional function.

Comment on lines +50 to +51
return Buf_.get_access<sycl::access::mode::read_write>(
CGH, range<1>(BufferSize_), id<1>(OffsetSize));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use accessor's CTAD here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm having trouble using these in our library code, getting a CTAD compilation error with gcc (clang works just fine, we don't see any issues in SYCL applications after all). Not sure why, I'll look into it and address the stylistic accessor changes in this file separately, if you don't mind.

Comment on lines +79 to +80
auto FlushBufAcc = FlushBuf_.get_access<access::mode::discard_write,
access::target::host_buffer>(
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
auto FlushBufAcc = FlushBuf_.get_access<access::mode::discard_write,
access::target::host_buffer>(
host_accessor FlushBufAcc{sycl::write, sycl::no_init};

Comment on lines -91 to +104
.StreamBuffersPool.find(this)
->second->FlushBuf
FlushBuf_
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: host_accessor

// and associates it with the provided Data.
template <class T> inline T createDummyHandleWithData(unsigned char *Data) {
DummyHandlePtrT DummyHandlePtr = new DummyHandleT(Data);
return reinterpret_cast<T>(DummyHandlePtr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't it violate ANSI-alias rules?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a helper function for creating underlying data structure for native handles in the mock plugin (e.g. pi_mem). Like with proper plugins, these handles are never dereferenced directly and only used inside mock plugin's PI functions after reinterpret casting back to DummyHandlePtrT.

@sergey-semenov
Copy link
Contributor Author

@romanovvlad Could you please take a look at the added tests as well?

@romanovvlad romanovvlad merged commit 7181b4c into intel:sycl Dec 15, 2022
@sergey-semenov
Copy link
Contributor Author

The test changes introduced shared libs compilation failure, I'll open a PR with the fix.

@sergey-semenov
Copy link
Contributor Author

Opened #7794

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