Skip to content

[SYCL][ESIMD] Support accessors for ESIMD kernels in SYCL RT. #1870

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 1 commit into from
Jul 7, 2020

Conversation

kbobrovs
Copy link
Contributor

Main changes:

  1. Handle 1d accessors differently - wrap in image1d buffer object to work with ESIMD back-end.
  2. Introduce new OpenCL image1d buffer type in device code - to represent accessor's wrapped memory object.
  3. Add "private proxy" classes to access accessor's memory object in the simd library.

Specific tests will be added once other parts get merged (simd library specifically) which are used by the tests.

@kbobrovs kbobrovs requested a review from romanovvlad June 10, 2020 18:49
@kbobrovs kbobrovs requested a review from a team as a code owner June 10, 2020 18:49
IMAGE_BUFFER_TY_DEFINE(read_write, rw);

template <> struct opencl_image1d_buffer_type<access::mode::atomic> {
// static_assert(false && "atomic access not supported for image1d
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably you can have this static assert in the "default" definition of opencl_image1d_buffer_type on line 184 which should be instantiated if there is no matching specialization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not work unfortunately, as there is instantiation in stream_impl.hpp - GlobalOffsetAccessorT.

@@ -1617,6 +1620,30 @@ static void ReverseRangeDimensionsForKernel(NDRDescT &NDR) {
}
}

// Creates an image1d buffer wrapper object to enable surface index-based
// access for ESIMD.
static pi_mem createImage1dBufferWrapper(const context_impl &Ctx, size_t Size,
Copy link
Contributor

Choose a reason for hiding this comment

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

Conceptually this function should be in program_manager.cpp. Could you please move it there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean memory manager?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I meant memory manager

@DenisBakhvalov DenisBakhvalov added the esimd Explicit SIMD feature label Jun 11, 2020
if (IsESIMDAcc) {
// Create additional wrapper object for an ESIMD accessor and record
// it for subsequent de-allocation.
size_t AllocSize = Req->MMemoryRange.size() * Req->MElemSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move image allocation to AllocaCmd::enqueueImp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, good catch

// compiler option enabling the macro below. Eventually ESIMD kernels and usual
// kernels must co-exist and there must be a mechanism for distinguishing usual
// and ESIMD accessors.
#ifndef __SYCL_EXPLICIT_SIMD__
Copy link
Contributor

Choose a reason for hiding this comment

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

This macro won't work because this file is a part of libsycl.so. Suggest adding ESIMD flag to AccessorImplHost and check it dynamically where needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, thanks. This was a last-minute change for the open-source variant, could not really test it at this point.

// Create additional wrapper object for an ESIMD accessor and record
// it for subsequent de-allocation.
size_t AllocSize = Req->MMemoryRange.size() * Req->MElemSize;
MemArg = createImage1dBufferWrapper(*getSyclObjImpl(Context),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, make sure that such combined alloca(buffer + image) works correctly in cases when we move memory between contexts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As agreed, I will add a TODO - ESIMD interop will need to be addressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@s-kanaev, please review. I think I addressed all @romanovvlad's comments, except the dummy opencl_image1d_buffer_type specialization for atomic mode, which I can't find simple solution for at this point, and added a TODO.

Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

The code looks good to me, but some one else should take a look at that.
@sergey-semenov will you take a look?

@@ -37,6 +37,7 @@ void addHostAccessorAndWait(Requirement *Req) {
detail::Scheduler::getInstance().addHostAccessor(Req);
Event->wait(Event);
}

Copy link
Contributor

@s-kanaev s-kanaev Jun 24, 2020

Choose a reason for hiding this comment

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

Minor. Unneeded change.

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 requested a review from s-kanaev July 1, 2020 22:02
s-kanaev
s-kanaev previously approved these changes Jul 2, 2020
@kbobrovs
Copy link
Contributor Author

kbobrovs commented Jul 3, 2020

@bader, please take a look/merge. Change requested by @romanovvlad was implemented.

@bader
Copy link
Contributor

bader commented Jul 3, 2020

@kbobrovs, please, resolve merge conflicts.

1. Handle 1d accessors differently - wrap in image1d buffer object to
work with ESIMD back-end.
2. Introduce new OpenCL image1d buffer type in device code - to represent
accessor's wrapped memory object.
3. Add "private proxy" classes to access accessor's memory object in the
simd library.

Co-authored-by: Vlad Romanov <[email protected]>

Signed-off-by: Konstantin S Bobrovsky <[email protected]>
@kbobrovs
Copy link
Contributor Author

kbobrovs commented Jul 4, 2020

@bader, done. Had to squash (and rebase) to avoid to-be-thrown-away resolution of conflicts on early commits.

@bader
Copy link
Contributor

bader commented Jul 5, 2020

Had to squash (and rebase) to avoid to-be-thrown-away resolution of conflicts on early commits.

If I understand the explanation correctly, early commits could be reverted to avoid conflicts during the merge.

@romanovvlad, please, approve.

@bader bader requested a review from s-kanaev July 5, 2020 15:23
@kbobrovs
Copy link
Contributor Author

kbobrovs commented Jul 6, 2020

If I understand the explanation correctly, early commits could be reverted to avoid conflicts during the merge.

Some of the changes from early commits remained. So reverting would require more work on conflict resolution, potentially they could happen with all newer commits.

@bader
Copy link
Contributor

bader commented Jul 6, 2020

If I understand the explanation correctly, early commits could be reverted to avoid conflicts during the merge.

Some of the changes from early commits remained. So reverting would require more work on conflict resolution, potentially they could happen with all newer commits.

I don't get this, but there is a way to avoid rebase in any case: revert all commits, merge, apply rebased/squashed commits on top of that.

@bader bader merged commit 05e6755 into intel:sycl Jul 7, 2020
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Jul 20, 2020
intel#1870 broke ABI by adding new field to
AccessorImplHost. This patch improves ABI testing to catch this type of
problems in future.

Signed-off-by: Alexander Batashev <[email protected]>
romanovvlad pushed a commit that referenced this pull request Jul 21, 2020
#1870 broke ABI by adding new field to
AccessorImplHost. This patch improves ABI testing to catch this type of
problems in future.

Signed-off-by: Alexander Batashev <[email protected]>
@kbobrovs kbobrovs deleted the esimd-rt branch July 30, 2020 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esimd Explicit SIMD feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants