Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sycl/source/detail/scheduler/graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,15 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
} else {
LinkedAllocaCmd->MIsActive = false;
Record->MCurContext = Queue->getContextImplPtr();

std::set<Command *> Deps =
findDepsForReq(Record, Req, Queue->getContextImplPtr());
for (Command *Dep : Deps) {
AllocaCmd->addDep(DepDesc{Dep, Req, AllocaCmd});
Dep->addUser(AllocaCmd);
}
updateLeaves(Deps, Record, Req->MAccessMode);
addNodeToLeaves(Record, AllocaCmd, Req->MAccessMode);
}
}
}
Expand Down
85 changes: 85 additions & 0 deletions sycl/test/scheduler/LinkedAlloca.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out
// RUN: env SYCL_PRINT_EXECUTION_GRAPH=always %t.out
// RUN: cat graph_7after_addHostAccessor.dot
// RUN: cat graph_7after_addHostAccessor.dot | FileCheck %s

#include <CL/sycl.hpp>

namespace S = cl::sycl;

void test() {
auto EH = [](S::exception_list EL) {
for (const std::exception_ptr &E : EL) {
throw E;
}
};

S::queue Queue(EH);

static const size_t BSIZE = 10;
S::buffer<int, 1> Buf{BSIZE};

// 0. submit kernel
Queue.submit([&](S::handler &CGH) {
S::accessor<int, 1, S::access::mode::write,
S::access::target::global_buffer>
GeneratorAcc(Buf, CGH);

auto GeneratorKernel = [GeneratorAcc]() {
for (size_t Idx = 0; Idx < GeneratorAcc.get_count(); ++Idx)
GeneratorAcc[Idx] = BSIZE - Idx;
};

CGH.single_task<class GeneratorTask0>(GeneratorKernel);
});
// 1. create host-accessor
{
S::accessor<int, 1, S::access::mode::write,
S::access::target::host_buffer>
Acc(Buf);

for (size_t Idx = 0; Idx < Acc.get_count(); ++Idx)
Acc[Idx] = -1;
}

// 2. submit kernel
Queue.submit([&](S::handler &CGH) {
S::accessor<int, 1, S::access::mode::write,
S::access::target::global_buffer>
GeneratorAcc(Buf, CGH);

auto GeneratorKernel = [GeneratorAcc]() {
for (size_t Idx = 0; Idx < GeneratorAcc.get_count(); ++Idx)
GeneratorAcc[Idx] = Idx;
};

CGH.single_task<class GeneratorTask>(GeneratorKernel);
});

// 3. create host-accessor
{
S::accessor<int, 1, S::access::mode::write,
S::access::target::host_buffer>
Acc(Buf);

bool Failure = false;
for (size_t Idx = 0; Idx < Acc.get_count(); ++Idx) {
fprintf(stderr, "Buffer [%03zu] = %i\n", Idx, Acc[Idx]);
Failure |= (Acc[Idx] != Idx);
}

assert(!Failure || "Invalid data in buffer");
}
}

int main(void) {
test();

return 0;
}

// CHECK: "[[MAP_ON_CPU:0x[0-9a-fA-F]+]]"{{.*}} MAP ON
// CHECK: "[[MAP_ON_CPU]]" -> "[[MAP_DEP_1:0x[0-9a-fA-F]+]]"
// CHECK: "[[MAP_ON_CPU]]" -> "[[MAP_DEP_2:0x[0-9a-fA-F]+]]"
// CHECK: "[[MAP_DEP_2]]"{{.*}}\nEXEC CG ON
// CHECK: "[[MAP_DEP_1]]"{{.*}}\nALLOCA ON HOST