CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
121 lines
3.4 KiB
C++
121 lines
3.4 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include <rocRoller/Scheduling/MetaObserver.hpp>
|
|
#include <rocRoller/Scheduling/Scheduling.hpp>
|
|
|
|
namespace rocRoller
|
|
{
|
|
namespace Scheduling
|
|
{
|
|
namespace Detail
|
|
{
|
|
template <typename TupType, size_t... Indices>
|
|
TupType ConstructMapping(ContextPtr ctx, std::index_sequence<Indices...>)
|
|
{
|
|
auto tup = TupType();
|
|
auto mapping = [&ctx]<CObserver T>(T head, auto... tail) { return T(ctx); };
|
|
|
|
return {mapping(std::get<Indices>(tup))...};
|
|
}
|
|
}
|
|
|
|
template <CObserver... Types>
|
|
MetaObserver<Types...>::MetaObserver() = default;
|
|
|
|
template <CObserver... Types>
|
|
MetaObserver<Types...>::MetaObserver(ContextPtr ctx)
|
|
: m_tuple(Detail::ConstructMapping<Tup>(ctx, std::make_index_sequence<Size>{}))
|
|
{
|
|
}
|
|
|
|
template <CObserver... Types>
|
|
MetaObserver<Types...>::MetaObserver(Tup const& tup)
|
|
: m_tuple(tup)
|
|
{
|
|
}
|
|
|
|
template <CObserver... Types>
|
|
MetaObserver<Types...>::~MetaObserver() = default;
|
|
|
|
namespace Detail
|
|
{
|
|
template <CObserver T, CObserver... Rest>
|
|
InstructionStatus Peek(Instruction const& inst, T const& obs, Rest const&... rest)
|
|
{
|
|
auto rv = obs.peek(inst);
|
|
if constexpr(sizeof...(rest) > 0)
|
|
{
|
|
rv.combine(Peek(inst, rest...));
|
|
}
|
|
return rv;
|
|
}
|
|
}
|
|
|
|
template <>
|
|
inline InstructionStatus MetaObserver<>::peek(Instruction const& inst) const
|
|
{
|
|
return {};
|
|
}
|
|
|
|
template <CObserver... Types>
|
|
InstructionStatus MetaObserver<Types...>::peek(Instruction const& inst) const
|
|
{
|
|
return std::apply([&inst](auto&&... args) { return Detail::Peek(inst, args...); },
|
|
m_tuple);
|
|
}
|
|
|
|
namespace Detail
|
|
{
|
|
template <CObserver T, CObserver... Rest>
|
|
void Modify(Instruction& inst, T const& obs, Rest const&... rest)
|
|
{
|
|
obs.modify(inst);
|
|
if constexpr(sizeof...(rest) > 0)
|
|
{
|
|
Modify(inst, rest...);
|
|
}
|
|
}
|
|
}
|
|
|
|
template <>
|
|
inline void MetaObserver<>::modify(Instruction& inst) const
|
|
{
|
|
return;
|
|
}
|
|
|
|
template <CObserver... Types>
|
|
void MetaObserver<Types...>::modify(Instruction& inst) const
|
|
{
|
|
std::apply([&inst](auto&&... args) { return Detail::Modify(inst, args...); }, m_tuple);
|
|
}
|
|
|
|
namespace Detail
|
|
{
|
|
template <CObserver T, CObserver... Rest>
|
|
void Observe(Instruction const& inst, T& obs, Rest&... rest)
|
|
{
|
|
obs.observe(inst);
|
|
if constexpr(sizeof...(rest) > 0)
|
|
{
|
|
Observe(inst, rest...);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
template <>
|
|
inline void MetaObserver<>::observe(Instruction const& inst)
|
|
{
|
|
}
|
|
|
|
template <CObserver... Types>
|
|
void MetaObserver<Types...>::observe(Instruction const& inst)
|
|
{
|
|
std::apply([&inst](auto&&... args) { Detail::Observe(inst, args...); }, m_tuple);
|
|
}
|
|
}
|
|
}
|