Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Removed handler::codeplay_host_task #428

Merged
merged 3 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 9 additions & 25 deletions SYCL/Basic/host-task-dependency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace S = cl::sycl;

template <typename T, bool B> class NameGen;
template <typename T> class NameGen;

struct Context {
std::atomic_bool Flag;
Expand All @@ -31,7 +31,6 @@ struct Context {
std::condition_variable CV;
};

template <bool UseSYCL2020HostTask>
S::event HostTask_CopyBuf1ToBuf2(Context *Ctx) {
S::event Event = Ctx->Queue.submit([&](S::handler &CGH) {
S::accessor<int, 1, S::access::mode::read, S::access::target::host_buffer>
Expand All @@ -53,15 +52,12 @@ S::event HostTask_CopyBuf1ToBuf2(Context *Ctx) {
}
};

if constexpr (UseSYCL2020HostTask)
CGH.host_task(CopierHostTask);
else
CGH.codeplay_host_task(CopierHostTask);
CGH.host_task(CopierHostTask);
});
return Event;
}

template <bool UseSYCL2020HostTask> void Thread1Fn(Context *Ctx) {
void Thread1Fn(Context *Ctx) {
// 0. initialize resulting buffer with apriori wrong result
{
S::accessor<int, 1, S::access::mode::write, S::access::target::host_buffer>
Expand Down Expand Up @@ -98,11 +94,11 @@ template <bool UseSYCL2020HostTask> void Thread1Fn(Context *Ctx) {
GeneratorAcc[Idx] = Idx;
};

CGH.single_task<NameGen<class Gen, UseSYCL2020HostTask>>(GeneratorKernel);
CGH.single_task<NameGen<class Gen>>(GeneratorKernel);
});

// 2. submit host task writing from buf 1 to buf 2
S::event HostTaskEvent = HostTask_CopyBuf1ToBuf2<UseSYCL2020HostTask>(Ctx);
S::event HostTaskEvent = HostTask_CopyBuf1ToBuf2(Ctx);

// 3. submit simple task to move data between two buffers
Ctx->Queue.submit([&](S::handler &CGH) {
Expand All @@ -119,7 +115,7 @@ template <bool UseSYCL2020HostTask> void Thread1Fn(Context *Ctx) {
DstAcc[Idx] = SrcAcc[Idx];
};

CGH.single_task<NameGen<class Copier, UseSYCL2020HostTask>>(CopierKernel);
CGH.single_task<NameGen<class Copier>>(CopierKernel);
});

// 4. check data in buffer #3
Expand Down Expand Up @@ -148,7 +144,7 @@ void Thread2Fn(Context *Ctx) {
assert(Ctx->Flag.load());
}

template <bool UseSYCL2020HostTask> void test() {
void test() {
auto EH = [](S::exception_list EL) {
for (const std::exception_ptr &E : EL) {
throw E;
Expand All @@ -160,8 +156,7 @@ template <bool UseSYCL2020HostTask> void test() {
Context Ctx{{false}, Queue, {10}, {10}, {10}, {}, {}};

// 0. setup: thread 1 T1: exec smth; thread 2 T2: waits; init flag F = false
auto A1 =
std::async(std::launch::async, Thread1Fn<UseSYCL2020HostTask>, &Ctx);
auto A1 = std::async(std::launch::async, Thread1Fn, &Ctx);
auto A2 = std::async(std::launch::async, Thread2Fn, &Ctx);

A1.get();
Expand All @@ -186,8 +181,7 @@ template <bool UseSYCL2020HostTask> void test() {
}

int main() {
test<true>();
test<false>();
test();

return 0;
}
Expand All @@ -203,16 +197,6 @@ int main() {
// CHECK: Copier
// CHECK:---> piEnqueueKernelLaunch(

// CHECK:---> piKernelCreate(
// CHECK: NameGen
// CHECK:---> piEnqueueKernelLaunch(
// prepare for host task
// CHECK:---> piEnqueueMemBuffer{{Map|Read}}(
// launch of Copier kernel
// CHECK:---> piKernelCreate(
// CHECK: Copier
// CHECK:---> piEnqueueKernelLaunch(

// TODO need to check for piEventsWait as "wait on dependencies of host task".
// At the same time this piEventsWait may occur anywhere after
// piEnqueueMemBufferMap ("prepare for host task").
20 changes: 5 additions & 15 deletions SYCL/HostInteropTask/host-task-dependency2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static auto EH = [](exception_list EL) {

// Host-task depending on another host-task via handler::depends_on() only
// should not hang
template <bool UseSYCL2020HostTask> void test(queue &Q, size_t Count) {
void test(queue &Q, size_t Count) {
static constexpr size_t BufferSize = 10 * 1024;

buffer<int, 1> B0{range<1>{BufferSize}};
Expand All @@ -48,10 +48,7 @@ template <bool UseSYCL2020HostTask> void test(queue &Q, size_t Count) {
Acc1[0] = 2 * Idx;
Acc2[0] = 3 * Idx;
};
if constexpr (UseSYCL2020HostTask)
CGH.host_task(Func);
else
CGH.codeplay_host_task(Func);
CGH.host_task(Func);
});

// This host task is going to depend on blocked empty node of the first
Expand All @@ -66,10 +63,7 @@ template <bool UseSYCL2020HostTask> void test(queue &Q, size_t Count) {
Acc2[1] = 1 * Idx;
Acc3[1] = 2 * Idx;
};
if constexpr (UseSYCL2020HostTask)
CGH.host_task(Func);
else
CGH.codeplay_host_task(Func);
CGH.host_task(Func);
});

// This host-task only depends on the second host-task via
Expand All @@ -87,10 +81,7 @@ template <bool UseSYCL2020HostTask> void test(queue &Q, size_t Count) {
Acc4[2] = 1 * Idx;
Acc5[2] = 2 * Idx;
};
if constexpr (UseSYCL2020HostTask)
CGH.host_task(Func);
else
CGH.codeplay_host_task(Func);
CGH.host_task(Func);
});
}

Expand All @@ -103,7 +94,6 @@ int main(int Argc, const char *Argv[]) {
Count = std::stoi(Argv[1]);

queue Q(EH);
test<true>(Q, Count);
test<false>(Q, Count);
test(Q, Count);
return 0;
}
33 changes: 10 additions & 23 deletions SYCL/HostInteropTask/host-task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,27 @@ static auto EH = [](exception_list EL) {
template <typename T, bool B> class NameGen;

// Check that a single host-task with a buffer will work
template <bool UseSYCL2020HostTask> void test1(queue &Q) {
void test1(queue &Q) {
buffer<int, 1> Buffer{BUFFER_SIZE};

Q.submit([&](handler &CGH) {
auto Acc = Buffer.get_access<mode::write>(CGH);
if constexpr (UseSYCL2020HostTask)
CGH.host_task([=] { /* A no-op */ });
else
CGH.codeplay_host_task([=] { /* A no-op */ });
CGH.host_task([=] { /* A no-op */ });
});

Q.wait_and_throw();
}

// Check that a host task after the kernel (deps via buffer) will work
template <bool UseSYCL2020HostTask> void test2(queue &Q) {
void test2(queue &Q) {
buffer<int, 1> Buffer1{BUFFER_SIZE};
buffer<int, 1> Buffer2{BUFFER_SIZE};

Q.submit([&](handler &CGH) {
auto Acc = Buffer1.template get_access<mode::write>(CGH);

auto Kernel = [=](item<1> Id) { Acc[Id] = 123; };
CGH.parallel_for<NameGen<class Test6Init, UseSYCL2020HostTask>>(
Acc.get_count(), Kernel);
CGH.parallel_for<NameGen<class Test6Init, true>>(Acc.get_count(), Kernel);
});

Q.submit([&](handler &CGH) {
Expand All @@ -65,10 +61,7 @@ template <bool UseSYCL2020HostTask> void test2(queue &Q) {
for (size_t Idx = 0; Idx < AccDst.get_count(); ++Idx)
AccDst[Idx] = AccSrc[Idx];
};
if constexpr (UseSYCL2020HostTask)
CGH.host_task(Func);
else
CGH.codeplay_host_task(Func);
CGH.host_task(Func);
});

{
Expand All @@ -85,7 +78,7 @@ template <bool UseSYCL2020HostTask> void test2(queue &Q) {

// Host-task depending on another host-task via both buffers and
// handler::depends_on() should not hang
template <bool UseSYCL2020HostTask> void test3(queue &Q) {
void test3(queue &Q) {
static constexpr size_t BufferSize = 10 * 1024;

buffer<int, 1> B0{range<1>{BufferSize}};
Expand Down Expand Up @@ -134,10 +127,7 @@ template <bool UseSYCL2020HostTask> void test3(queue &Q) {
X ^= reinterpret_cast<uint64_t>(&Acc8[Idx + 8]);
X ^= reinterpret_cast<uint64_t>(&Acc9[Idx + 9]);
};
if constexpr (UseSYCL2020HostTask)
CGH.host_task(Func);
else
CGH.codeplay_host_task(Func);
CGH.host_task(Func);
});

Deps = {E};
Expand All @@ -161,16 +151,13 @@ int main(int Argc, const char *Argv[]) {
queue Q(EH);
switch (TestIdx) {
case 1:
test1<true>(Q);
test1<false>(Q);
test1(Q);
break;
case 2:
test2<true>(Q);
test2<false>(Q);
test2(Q);
break;
case 3:
test3<true>(Q);
test3<false>(Q);
test3(Q);
break;
default:
return 1;
Expand Down