Skip to content

[SYCL] Fix working with subbuffers with non-nil offset #957

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

Conversation

s-kanaev
Copy link
Contributor

No description provided.

@@ -320,11 +320,13 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req) {

AllocaCommandBase *SrcAllocaCmd = nullptr;

if (Record->MAllocaCommands.empty())
if (Record->MAllocaCommands.empty() || IsSuitableSubReq(Req))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

getOrCreateAllocaForReq() method contains a proper procedure to create/find alloca cmd for subbuffer. That is why there is this kind of hack: regardless of whether alloca commands collection is non-empty go on and getOrCreate it. The method will lookup for it in first place, though. It'll not find the correct alloca command 'cause there is no equality of MOffsetInBytes. After that the method will create a proper alloca cmd for subbuffer.

@@ -320,11 +320,13 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req) {

AllocaCommandBase *SrcAllocaCmd = nullptr;

if (Record->MAllocaCommands.empty())
if (Record->MAllocaCommands.empty() || IsSuitableSubReq(Req))
Copy link
Contributor Author

@s-kanaev s-kanaev Dec 20, 2019

Choose a reason for hiding this comment

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

Another approach here might be to check if SrcAllocaCmd is null and create it the same way getOrCreateAllocaForReq does if IsSuitableSubReq(Req) returns true. Thing is, this approach would violate code reuse. Although after refactoring there will be more places to edit in case of logic change.

Copy link
Contributor Author

@s-kanaev s-kanaev Dec 20, 2019

Choose a reason for hiding this comment

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

The second commit implements this second approach. And fixes faults on GPU which were added with first commit.

Copy link
Contributor

@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

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

Suggest doing something like this instead:

  diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp
  index b150f66..6c5b682 100644
  --- a/sycl/source/detail/scheduler/graph_builder.cpp
  +++ b/sycl/source/detail/scheduler/graph_builder.cpp
  @@ -320,14 +320,21 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req) {
  ·
     AllocaCommandBase *SrcAllocaCmd = nullptr;
  ·
  -  if (Record->MAllocaCommands.empty())
  -    SrcAllocaCmd = getOrCreateAllocaForReq(Record, Req, HostQueue);
  -  else
  -    SrcAllocaCmd = findAllocaForReq(Record, Req, Record->MCurContext);
  +  AllocaCommandBase *HostAllocaCmd =
  +      getOrCreateAllocaForReq(Record, Req, HostQueue);
  ·
  -  if (!SrcAllocaCmd->getQueue()->is_host())
  +  if (!sameCtx(HostAllocaCmd->getQueue()->get_context_impl(),
  +               Record->MCurContext))
       insertMemoryMove(Record, Req, HostQueue);
  ·
  +  //if (Record->MAllocaCommands.empty())
  +    //SrcAllocaCmd = getOrCreateAllocaForReq(Record, Req, HostQueue);
  +  //else
  +    //SrcAllocaCmd = findAllocaForReq(Record, Req, Record->MCurContext);
  +
  +  //if (!SrcAllocaCmd->getQueue()->is_host())
  +    //insertMemoryMove(Record, Req, HostQueue);
  +
     Command *UpdateHostAccCmd = insertUpdateHostReqCmd(Record, Req, HostQueue);
  ·
     // Need empty command to be blocked until host accessor is destructed

@s-kanaev s-kanaev force-pushed the private/s-kanaev/fix-subbuffer-with-nonzero-offset branch from da2df9c to c4247a8 Compare December 25, 2019 08:51
@s-kanaev s-kanaev requested a review from romanovvlad December 25, 2019 08:52
@s-kanaev
Copy link
Contributor Author

Suggest doing something like this instead:

Done

@s-kanaev s-kanaev force-pushed the private/s-kanaev/fix-subbuffer-with-nonzero-offset branch 2 times, most recently from b1d0924 to 809318e Compare December 25, 2019 09:59
Copy link
Contributor

@KarachunIvan KarachunIvan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@alexbatashev alexbatashev left a comment

Choose a reason for hiding this comment

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

LGTM

romanovvlad
romanovvlad previously approved these changes Dec 25, 2019
romanovvlad and others added 4 commits December 26, 2019 11:34
Signed-off-by: Sergey Kanaev <[email protected]>
Signed-off-by: Sergey Kanaev <[email protected]>
Signed-off-by: Sergey Kanaev <[email protected]>
@s-kanaev s-kanaev force-pushed the private/s-kanaev/fix-subbuffer-with-nonzero-offset branch from 809318e to ed0b812 Compare December 26, 2019 15:26
@romanovvlad romanovvlad merged commit f607520 into intel:sycl Dec 27, 2019
@s-kanaev s-kanaev deleted the private/s-kanaev/fix-subbuffer-with-nonzero-offset branch March 12, 2020 13:13
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Feb 23, 2023
This change fixes the following problem:
`/usr/bin/ld: cannot find -lsycl`
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.

4 participants