From d8297bd56e0e4c88fbaa1b3fc6b6304a67eddbcf Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Fri, 3 Apr 2020 16:18:14 +0300 Subject: [PATCH 01/12] [SYCL] Fix linked AllocaCmd dependencies Signed-off-by: Sergey Kanaev --- sycl/source/detail/scheduler/graph_builder.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index 2105c22cf6af7..3d977560635ae 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -618,6 +618,15 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq( } else { LinkedAllocaCmd->MIsActive = false; Record->MCurContext = Queue->getContextImplPtr(); + + std::set 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); } } } From 5a4458028118fd6b9ea987c31a3ea11420873f30 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 8 Apr 2020 16:58:52 +0300 Subject: [PATCH 02/12] [SYCL] Add test Signed-off-by: Sergey Kanaev --- sycl/test/scheduler/LinkedAlloca.cpp | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 sycl/test/scheduler/LinkedAlloca.cpp diff --git a/sycl/test/scheduler/LinkedAlloca.cpp b/sycl/test/scheduler/LinkedAlloca.cpp new file mode 100644 index 0000000000000..059f5348ae547 --- /dev/null +++ b/sycl/test/scheduler/LinkedAlloca.cpp @@ -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 + +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 Buf{BSIZE}; + + // 0. submit kernel + Queue.submit([&](S::handler &CGH) { + S::accessor + GeneratorAcc(Buf, CGH); + + auto GeneratorKernel = [GeneratorAcc]() { + for (size_t Idx = 0; Idx < GeneratorAcc.get_count(); ++Idx) + GeneratorAcc[Idx] = BSIZE - Idx; + }; + + CGH.single_task(GeneratorKernel); + }); + // 1. create host-accessor + { + S::accessor + 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 + GeneratorAcc(Buf, CGH); + + auto GeneratorKernel = [GeneratorAcc]() { + for (size_t Idx = 0; Idx < GeneratorAcc.get_count(); ++Idx) + GeneratorAcc[Idx] = Idx; + }; + + CGH.single_task(GeneratorKernel); + }); + + // 3. create host-accessor + { + S::accessor + 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 CPU +// 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 From 49a89091cf5fada7eed6c30c678359a332704b13 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Thu, 9 Apr 2020 09:47:02 +0300 Subject: [PATCH 03/12] [SYCL] Fix test Signed-off-by: Sergey Kanaev --- sycl/test/scheduler/LinkedAlloca.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/scheduler/LinkedAlloca.cpp b/sycl/test/scheduler/LinkedAlloca.cpp index 059f5348ae547..d71b764c4bf57 100644 --- a/sycl/test/scheduler/LinkedAlloca.cpp +++ b/sycl/test/scheduler/LinkedAlloca.cpp @@ -78,7 +78,7 @@ int main(void) { return 0; } -// CHECK: "[[MAP_ON_CPU:0x[0-9a-fA-F]+]]"{{.*}} MAP ON CPU +// 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 From 462ee071742782cfb87f95d5e83d408778a965cd Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Thu, 9 Apr 2020 10:05:39 +0300 Subject: [PATCH 04/12] [SYCL] Fix test Signed-off-by: Sergey Kanaev --- sycl/test/scheduler/LinkedAlloca.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/scheduler/LinkedAlloca.cpp b/sycl/test/scheduler/LinkedAlloca.cpp index d71b764c4bf57..aebf9e2975144 100644 --- a/sycl/test/scheduler/LinkedAlloca.cpp +++ b/sycl/test/scheduler/LinkedAlloca.cpp @@ -78,7 +78,7 @@ int main(void) { return 0; } -// CHECK: "[[MAP_ON_CPU:0x[0-9a-fA-F]+]]"{{.*}} MAP ON +// 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 From 704fdb062424f5d1ae701238eec9b72c6b5e5611 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 17 Jun 2020 12:30:14 +0300 Subject: [PATCH 05/12] [SYCL] Add unit-test Signed-off-by: Sergey Kanaev --- sycl/source/detail/scheduler/scheduler.hpp | 5 + sycl/unittests/scheduler/CMakeLists.txt | 1 + .../scheduler/LinkedAllocaDependencies.cpp | 97 +++++++++++++++++++ .../scheduler/SchedulerTestUtils.hpp | 8 ++ 4 files changed, 111 insertions(+) create mode 100644 sycl/unittests/scheduler/LinkedAllocaDependencies.cpp diff --git a/sycl/source/detail/scheduler/scheduler.hpp b/sycl/source/detail/scheduler/scheduler.hpp index b7d580e5d1823..e985a8b123174 100644 --- a/sycl/source/detail/scheduler/scheduler.hpp +++ b/sycl/source/detail/scheduler/scheduler.hpp @@ -166,6 +166,9 @@ /// clReleaseContext(ContextCPU); /// \endcode +// For testing purposes +class MockScheduler; + __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { @@ -576,6 +579,8 @@ class Scheduler { friend class Command; private: + friend class ::MockScheduler; + /// Searches for suitable alloca in memory record. /// /// If none found, creates new one. diff --git a/sycl/unittests/scheduler/CMakeLists.txt b/sycl/unittests/scheduler/CMakeLists.txt index c0354882f851b..ea308fe1b60bb 100644 --- a/sycl/unittests/scheduler/CMakeLists.txt +++ b/sycl/unittests/scheduler/CMakeLists.txt @@ -6,5 +6,6 @@ add_sycl_unittest(SchedulerTests OBJECT MemObjCommandCleanup.cpp CommandsWaitForEvents.cpp WaitAfterCleanup.cpp + LinkedAllocaDependencies.cpp utils.cpp ) diff --git a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp new file mode 100644 index 0000000000000..3ce24fbaf5f39 --- /dev/null +++ b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp @@ -0,0 +1,97 @@ +//==------ LinkedAllocaDependencies.cpp --- Scheduler unit tests -----------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SchedulerTest.hpp" +#include "SchedulerTestUtils.hpp" + +using namespace cl::sycl; + +class MemObjMock : public cl::sycl::detail::SYCLMemObjI { +public: + using ContextImplPtr = std::shared_ptr; + + MemObjMock(const std::shared_ptr &Record) + : SYCLMemObjI() { MRecord = Record; } + + ~MemObjMock() {}; + + MemObjType getType() const override { return MemObjType::BUFFER; } + + void *allocateMem(ContextImplPtr Context, + bool InitFromUserData, void *HostPtr, + cl::sycl::detail::pi::PiEvent &InteropEvent) { + return nullptr; + } + + void *allocateHostMem() { return nullptr; } + void releaseMem(ContextImplPtr Context, void *Ptr) {} + void releaseHostMem(void *Ptr) {} + size_t getSize() const override { return 10; } +}; + +TEST_F(SchedulerTest, LinkedAllocaDependencies) { + default_selector Selector{}; + if (Selector.select_device().is_host()) { + std::cerr << "Not run due to host-only environment\n"; + return; + } + + // 1. create two commands: alloca + alloca and link them + // 2. call Scheduler::GraphBuilder::getOrCreateAllocaForReq + detail::Requirement Req = getMockRequirement(); + + cl::sycl::queue Queue1; + cl::sycl::detail::QueueImplPtr Q1 = cl::sycl::detail::getSyclObjImpl(Queue1); + + sycl::device HostDevice; + std::shared_ptr DefaultHostQueue(new detail::queue_impl( + detail::getSyclObjImpl(HostDevice), /*AsyncHandler=*/{}, + detail::QueueOrder::Ordered, /*PropList=*/{})); + + std::shared_ptr Record{ + new cl::sycl::detail::MemObjRecord( + DefaultHostQueue->getContextImplPtr(), 10)}; + + MemObjMock MemObj(Record); + Req.MSYCLMemObj = &MemObj; + + cl::sycl::detail::AllocaCommand AllocaCmd1(DefaultHostQueue, Req, false); + Record->MAllocaCommands.push_back(&AllocaCmd1); + + MockCommand DepCmd(DefaultHostQueue, Req); + MockCommand DepDepCmd(DefaultHostQueue, Req); + DepCmd.MDeps.push_back({ + &DepDepCmd, DepDepCmd.getRequirement(), &AllocaCmd1 }); + DepDepCmd.MUsers.insert(&DepCmd); + Record->MWriteLeaves.push_back(&DepCmd); + + MockScheduler MS; + cl::sycl::detail::Command *AllocaCmd2 = MS.getOrCreateAllocaForReq( + Record.get(), &Req, Q1); + + ASSERT_TRUE(!!AllocaCmd1.MLinkedAllocaCmd) + << "No link appeared in existing command"; + ASSERT_EQ(AllocaCmd1.MLinkedAllocaCmd, AllocaCmd2) + << "Invalid link appeared"; + ASSERT_GT(AllocaCmd1.MUsers.count(AllocaCmd2), 0u) + << "New alloca isn't in users of the old one"; + ASSERT_GT(AllocaCmd2->MDeps.size(), 1u) + << "No deps appeared in the new alloca"; + ASSERT_GT(DepCmd.MUsers.count(AllocaCmd2), 0u) + << "No deps appeared for leaves of record (i.e. deps of existing alloca)"; + ASSERT_TRUE(std::find_if(AllocaCmd2->MDeps.begin(), AllocaCmd2->MDeps.end(), + [&](const cl::sycl::detail::DepDesc &Dep) -> bool { + return Dep.MDepCommand == &AllocaCmd1; + }) != AllocaCmd2->MDeps.end()) + << "No deps for existing alloca appeared in new alloca"; + ASSERT_TRUE(std::find_if(AllocaCmd2->MDeps.begin(), AllocaCmd2->MDeps.end(), + [&](const cl::sycl::detail::DepDesc &Dep) -> bool { + return Dep.MDepCommand == &DepCmd; + }) != AllocaCmd2->MDeps.end()) + << "No deps for leaves (deps of existing alloca) appeared in new alloca"; +} diff --git a/sycl/unittests/scheduler/SchedulerTestUtils.hpp b/sycl/unittests/scheduler/SchedulerTestUtils.hpp index 594426b007ef6..afa3f9111dae5 100644 --- a/sycl/unittests/scheduler/SchedulerTestUtils.hpp +++ b/sycl/unittests/scheduler/SchedulerTestUtils.hpp @@ -91,6 +91,14 @@ class MockScheduler : public cl::sycl::detail::Scheduler { cl::sycl::detail::BlockingT Blocking) { return GraphProcessor::enqueueCommand(Cmd, EnqueueResult, Blocking); } + + cl::sycl::detail::AllocaCommandBase *getOrCreateAllocaForReq( + cl::sycl::detail::MemObjRecord *Record, + const cl::sycl::detail::Requirement *Req, + cl::sycl::detail::QueueImplPtr Queue + ) { + return MGraphBuilder.getOrCreateAllocaForReq(Record, Req, Queue); + } }; void addEdge(cl::sycl::detail::Command *User, cl::sycl::detail::Command *Dep, From 0abc9280dc21cf7d1a7124e3c091b2ea29b2ec3c Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 17 Jun 2020 13:04:40 +0300 Subject: [PATCH 06/12] [SYCL] Fix lit test Signed-off-by: Sergey Kanaev --- sycl/test/scheduler/LinkedAlloca.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/test/scheduler/LinkedAlloca.cpp b/sycl/test/scheduler/LinkedAlloca.cpp index aebf9e2975144..e61f88d571d59 100644 --- a/sycl/test/scheduler/LinkedAlloca.cpp +++ b/sycl/test/scheduler/LinkedAlloca.cpp @@ -78,8 +78,8 @@ int main(void) { 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 +// CHECK: {{^}}"[[MAP_OP:0x[0-9a-fA-F]+]]"{{.*}} MAP ON +// CHECK: "[[MAP_OP]]" -> "[[MAP_DEP_1:0x[0-9a-fA-F]+]]" +// CHECK: "[[MAP_OP]]" -> "[[MAP_DEP_2:0x[0-9a-fA-F]+]]" +// CHECK: {{^}}"[[MAP_DEP_2]]"{{.*}}\nEXEC CG ON +// CHECK: {{^}}"[[MAP_DEP_1]]"{{.*}}\nALLOCA ON HOST From e84cad7e14d703f30c7ceb62da26b4d11a2dcd90 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 17 Jun 2020 13:34:44 +0300 Subject: [PATCH 07/12] [SYCL] Fix style issue Signed-off-by: Sergey Kanaev --- .../scheduler/LinkedAllocaDependencies.cpp | 37 +++++++++---------- .../scheduler/SchedulerTestUtils.hpp | 9 ++--- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp index 3ce24fbaf5f39..1e6bc6641bf91 100644 --- a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp +++ b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp @@ -16,21 +16,22 @@ class MemObjMock : public cl::sycl::detail::SYCLMemObjI { using ContextImplPtr = std::shared_ptr; MemObjMock(const std::shared_ptr &Record) - : SYCLMemObjI() { MRecord = Record; } + : SYCLMemObjI() { + MRecord = Record; + } - ~MemObjMock() {}; + ~MemObjMock(){}; MemObjType getType() const override { return MemObjType::BUFFER; } - void *allocateMem(ContextImplPtr Context, - bool InitFromUserData, void *HostPtr, - cl::sycl::detail::pi::PiEvent &InteropEvent) { + void *allocateMem(ContextImplPtr, bool, void *, + cl::sycl::detail::pi::PiEvent &) { return nullptr; } void *allocateHostMem() { return nullptr; } - void releaseMem(ContextImplPtr Context, void *Ptr) {} - void releaseHostMem(void *Ptr) {} + void releaseMem(ContextImplPtr, void *) {} + void releaseHostMem(void *) {} size_t getSize() const override { return 10; } }; @@ -65,19 +66,17 @@ TEST_F(SchedulerTest, LinkedAllocaDependencies) { MockCommand DepCmd(DefaultHostQueue, Req); MockCommand DepDepCmd(DefaultHostQueue, Req); - DepCmd.MDeps.push_back({ - &DepDepCmd, DepDepCmd.getRequirement(), &AllocaCmd1 }); + DepCmd.MDeps.push_back({&DepDepCmd, DepDepCmd.getRequirement(), &AllocaCmd1}); DepDepCmd.MUsers.insert(&DepCmd); Record->MWriteLeaves.push_back(&DepCmd); MockScheduler MS; - cl::sycl::detail::Command *AllocaCmd2 = MS.getOrCreateAllocaForReq( - Record.get(), &Req, Q1); + cl::sycl::detail::Command *AllocaCmd2 = + MS.getOrCreateAllocaForReq(Record.get(), &Req, Q1); ASSERT_TRUE(!!AllocaCmd1.MLinkedAllocaCmd) << "No link appeared in existing command"; - ASSERT_EQ(AllocaCmd1.MLinkedAllocaCmd, AllocaCmd2) - << "Invalid link appeared"; + ASSERT_EQ(AllocaCmd1.MLinkedAllocaCmd, AllocaCmd2) << "Invalid link appeared"; ASSERT_GT(AllocaCmd1.MUsers.count(AllocaCmd2), 0u) << "New alloca isn't in users of the old one"; ASSERT_GT(AllocaCmd2->MDeps.size(), 1u) @@ -85,13 +84,13 @@ TEST_F(SchedulerTest, LinkedAllocaDependencies) { ASSERT_GT(DepCmd.MUsers.count(AllocaCmd2), 0u) << "No deps appeared for leaves of record (i.e. deps of existing alloca)"; ASSERT_TRUE(std::find_if(AllocaCmd2->MDeps.begin(), AllocaCmd2->MDeps.end(), - [&](const cl::sycl::detail::DepDesc &Dep) -> bool { - return Dep.MDepCommand == &AllocaCmd1; - }) != AllocaCmd2->MDeps.end()) + [&](const cl::sycl::detail::DepDesc &Dep) -> bool { + return Dep.MDepCommand == &AllocaCmd1; + }) != AllocaCmd2->MDeps.end()) << "No deps for existing alloca appeared in new alloca"; ASSERT_TRUE(std::find_if(AllocaCmd2->MDeps.begin(), AllocaCmd2->MDeps.end(), - [&](const cl::sycl::detail::DepDesc &Dep) -> bool { - return Dep.MDepCommand == &DepCmd; - }) != AllocaCmd2->MDeps.end()) + [&](const cl::sycl::detail::DepDesc &Dep) -> bool { + return Dep.MDepCommand == &DepCmd; + }) != AllocaCmd2->MDeps.end()) << "No deps for leaves (deps of existing alloca) appeared in new alloca"; } diff --git a/sycl/unittests/scheduler/SchedulerTestUtils.hpp b/sycl/unittests/scheduler/SchedulerTestUtils.hpp index afa3f9111dae5..8eeb3e0ed9008 100644 --- a/sycl/unittests/scheduler/SchedulerTestUtils.hpp +++ b/sycl/unittests/scheduler/SchedulerTestUtils.hpp @@ -92,11 +92,10 @@ class MockScheduler : public cl::sycl::detail::Scheduler { return GraphProcessor::enqueueCommand(Cmd, EnqueueResult, Blocking); } - cl::sycl::detail::AllocaCommandBase *getOrCreateAllocaForReq( - cl::sycl::detail::MemObjRecord *Record, - const cl::sycl::detail::Requirement *Req, - cl::sycl::detail::QueueImplPtr Queue - ) { + cl::sycl::detail::AllocaCommandBase * + getOrCreateAllocaForReq(cl::sycl::detail::MemObjRecord *Record, + const cl::sycl::detail::Requirement *Req, + cl::sycl::detail::QueueImplPtr Queue) { return MGraphBuilder.getOrCreateAllocaForReq(Record, Req, Queue); } }; From fa0dda47b6fc061db855eeb435729144122e13ec Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 17 Jun 2020 13:55:14 +0300 Subject: [PATCH 08/12] [SYCL] Fix style issue Signed-off-by: Sergey Kanaev --- sycl/unittests/scheduler/LinkedAllocaDependencies.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp index 1e6bc6641bf91..ce409a37918d1 100644 --- a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp +++ b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp @@ -55,8 +55,8 @@ TEST_F(SchedulerTest, LinkedAllocaDependencies) { detail::QueueOrder::Ordered, /*PropList=*/{})); std::shared_ptr Record{ - new cl::sycl::detail::MemObjRecord( - DefaultHostQueue->getContextImplPtr(), 10)}; + new cl::sycl::detail::MemObjRecord(DefaultHostQueue->getContextImplPtr(), + 10)}; MemObjMock MemObj(Record); Req.MSYCLMemObj = &MemObj; From 658b05798b39ed2d01ad49f9380032844c6bb853 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 17 Jun 2020 15:59:48 +0300 Subject: [PATCH 09/12] [SYCL] Fix lit test Signed-off-by: Sergey Kanaev --- sycl/test/scheduler/LinkedAlloca.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/test/scheduler/LinkedAlloca.cpp b/sycl/test/scheduler/LinkedAlloca.cpp index e61f88d571d59..3ed0a658392df 100644 --- a/sycl/test/scheduler/LinkedAlloca.cpp +++ b/sycl/test/scheduler/LinkedAlloca.cpp @@ -79,7 +79,7 @@ int main(void) { } // CHECK: {{^}}"[[MAP_OP:0x[0-9a-fA-F]+]]"{{.*}} MAP ON -// CHECK: "[[MAP_OP]]" -> "[[MAP_DEP_1:0x[0-9a-fA-F]+]]" -// CHECK: "[[MAP_OP]]" -> "[[MAP_DEP_2:0x[0-9a-fA-F]+]]" -// CHECK: {{^}}"[[MAP_DEP_2]]"{{.*}}\nEXEC CG ON -// CHECK: {{^}}"[[MAP_DEP_1]]"{{.*}}\nALLOCA ON HOST +// CHECK-DAG: "[[MAP_OP]]" -> "[[MAP_DEP_1:0x[0-9a-fA-F]+]]" +// CHECK-DAG: "[[MAP_OP]]" -> "[[MAP_DEP_2:0x[0-9a-fA-F]+]]" +// CHECK-DAG: {{^}}"[[MAP_DEP_1]]"{{.*}}\nEXEC CG ON +// CHECK-DAG: {{^}}"[[MAP_DEP_2]]"{{.*}}\nALLOCA ON HOST From 107fe7f7f0284d38f640a2c05a558636f6ae3187 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 17 Jun 2020 16:06:09 +0300 Subject: [PATCH 10/12] [SYCL] Apply suggestion Signed-off-by: Sergey Kanaev --- sycl/unittests/scheduler/LinkedAllocaDependencies.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp index ce409a37918d1..569d1d096dca5 100644 --- a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp +++ b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp @@ -20,7 +20,7 @@ class MemObjMock : public cl::sycl::detail::SYCLMemObjI { MRecord = Record; } - ~MemObjMock(){}; + ~MemObjMock() = default; MemObjType getType() const override { return MemObjType::BUFFER; } From 897b1b19dbee90294e0b4e01dbc116a59ade3c7d Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Thu, 30 Jul 2020 09:58:35 +0300 Subject: [PATCH 11/12] [SYCL] Remove redundant test Signed-off-by: Sergey Kanaev --- sycl/test/scheduler/LinkedAlloca.cpp | 85 ---------------------------- 1 file changed, 85 deletions(-) delete mode 100644 sycl/test/scheduler/LinkedAlloca.cpp diff --git a/sycl/test/scheduler/LinkedAlloca.cpp b/sycl/test/scheduler/LinkedAlloca.cpp deleted file mode 100644 index 3ed0a658392df..0000000000000 --- a/sycl/test/scheduler/LinkedAlloca.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// 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 - -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 Buf{BSIZE}; - - // 0. submit kernel - Queue.submit([&](S::handler &CGH) { - S::accessor - GeneratorAcc(Buf, CGH); - - auto GeneratorKernel = [GeneratorAcc]() { - for (size_t Idx = 0; Idx < GeneratorAcc.get_count(); ++Idx) - GeneratorAcc[Idx] = BSIZE - Idx; - }; - - CGH.single_task(GeneratorKernel); - }); - // 1. create host-accessor - { - S::accessor - 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 - GeneratorAcc(Buf, CGH); - - auto GeneratorKernel = [GeneratorAcc]() { - for (size_t Idx = 0; Idx < GeneratorAcc.get_count(); ++Idx) - GeneratorAcc[Idx] = Idx; - }; - - CGH.single_task(GeneratorKernel); - }); - - // 3. create host-accessor - { - S::accessor - 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_OP:0x[0-9a-fA-F]+]]"{{.*}} MAP ON -// CHECK-DAG: "[[MAP_OP]]" -> "[[MAP_DEP_1:0x[0-9a-fA-F]+]]" -// CHECK-DAG: "[[MAP_OP]]" -> "[[MAP_DEP_2:0x[0-9a-fA-F]+]]" -// CHECK-DAG: {{^}}"[[MAP_DEP_1]]"{{.*}}\nEXEC CG ON -// CHECK-DAG: {{^}}"[[MAP_DEP_2]]"{{.*}}\nALLOCA ON HOST From ba8a54d4145e831a82d38517b8419cf57c1b3851 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Thu, 30 Jul 2020 16:24:19 +0300 Subject: [PATCH 12/12] [SYCL] Fix testing Signed-off-by: Sergey Kanaev --- sycl/unittests/scheduler/LinkedAllocaDependencies.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp index 569d1d096dca5..3c967c0f60aad 100644 --- a/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp +++ b/sycl/unittests/scheduler/LinkedAllocaDependencies.cpp @@ -52,7 +52,7 @@ TEST_F(SchedulerTest, LinkedAllocaDependencies) { sycl::device HostDevice; std::shared_ptr DefaultHostQueue(new detail::queue_impl( detail::getSyclObjImpl(HostDevice), /*AsyncHandler=*/{}, - detail::QueueOrder::Ordered, /*PropList=*/{})); + /*PropList=*/{})); std::shared_ptr Record{ new cl::sycl::detail::MemObjRecord(DefaultHostQueue->getContextImplPtr(),