// Copyright Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include #include #include #include "SimpleFixture.hpp" using namespace rocRoller; class MetaObserverTest : public SimpleFixture { }; class TestFalseObserver { public: TestFalseObserver() {} TestFalseObserver(ContextPtr context) : m_context(context){ }; Scheduling::InstructionStatus peek(Instruction const& inst) const { return Scheduling::InstructionStatus(); }; void modify(Instruction& inst) const {} void observe(Instruction const& inst) {} constexpr static bool required(GPUArchitectureTarget const& target) { return false; } private: std::weak_ptr m_context; }; class TestTrueObserver { public: TestTrueObserver() {} TestTrueObserver(ContextPtr context) : m_context(context){ }; Scheduling::InstructionStatus peek(Instruction const& inst) const { return Scheduling::InstructionStatus(); }; void modify(Instruction& inst) const {} void observe(Instruction const& inst) {} constexpr static bool required(GPUArchitectureTarget const& target) { return true; } private: std::weak_ptr m_context; }; static_assert(Scheduling::CObserver); static_assert(Scheduling::CObserver); TEST_F(MetaObserverTest, MultipleObserverTest) { rocRoller::ContextPtr m_context = Context::ForTarget({rocRoller::GPUArchitectureGFX::GFX90A}, "kernel"); std::tuple constructedObservers = {Scheduling::AllocatingObserver(m_context), Scheduling::WaitcntObserver(m_context), Scheduling::AllocatingObserver(m_context), Scheduling::WaitcntObserver(m_context)}; using MyObserver = Scheduling::MetaObserver; m_context->observer() = std::make_shared(constructedObservers); }