|
| 1 | +//==----------- RunOnHostIntelCG.cpp --- Scheduler unit tests --------------==// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// |
| 9 | + |
| 10 | +#include "SchedulerTest.hpp" |
| 11 | +#include "SchedulerTestUtils.hpp" |
| 12 | + |
| 13 | +#include <detail/event_impl.hpp> |
| 14 | + |
| 15 | +using namespace sycl; |
| 16 | + |
| 17 | +bool CGDeleted = false; |
| 18 | +class MockCGExecKernel : public detail::CGExecKernel { |
| 19 | +public: |
| 20 | + MockCGExecKernel(detail::NDRDescT NDRDesc, |
| 21 | + std::unique_ptr<detail::HostKernelBase> HostKernel) |
| 22 | + : CGExecKernel(NDRDesc, std::move(HostKernel), /*SyclKernel*/ nullptr, |
| 23 | + /*ArgsStorage*/ {}, /*AccStorage*/ {}, |
| 24 | + /*SharedPtrStorage*/ {}, /*Requirements*/ {}, |
| 25 | + /*Events*/ {}, /*Args*/ {}, /*KernelName*/ "", |
| 26 | + detail::OSUtil::ExeModuleHandle, /*Streams*/ {}, |
| 27 | + /*AuxilaryResources*/ {}, detail::CG::RunOnHostIntel) {} |
| 28 | + ~MockCGExecKernel() override { CGDeleted = true; } |
| 29 | +}; |
| 30 | + |
| 31 | +// Check that the command group associated with run_on_host_intel is properly |
| 32 | +// released on command destruction. |
| 33 | +TEST_F(SchedulerTest, RunOnHostIntelCG) { |
| 34 | + MockScheduler MS; |
| 35 | + detail::QueueImplPtr QueueImpl = detail::getSyclObjImpl(MQueue); |
| 36 | + |
| 37 | + detail::NDRDescT NDRDesc; |
| 38 | + NDRDesc.set(range<1>{1}, id<1>{0}); |
| 39 | + std::unique_ptr<detail::HostKernelBase> HostKernel{ |
| 40 | + new detail::HostKernel<std::function<void()>, void, 1>([]() {})}; |
| 41 | + std::unique_ptr<detail::CG> CommandGroup{ |
| 42 | + new MockCGExecKernel(std::move(NDRDesc), std::move(HostKernel))}; |
| 43 | + MS.addCG(std::move(CommandGroup), QueueImpl); |
| 44 | + EXPECT_TRUE(CGDeleted); |
| 45 | +} |
0 commit comments