Files
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

145 lines
4.9 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
#include <concepts>
#include <string>
#include <vector>
#include <rocRoller/CodeGen/Instruction_fwd.hpp>
#include <rocRoller/CodeGen/WaitCount.hpp>
#include <rocRoller/Context_fwd.hpp>
#include <rocRoller/Utilities/EnumArray.hpp>
#include <rocRoller/Utilities/EnumBitset.hpp>
namespace rocRoller
{
using DisallowedCycles = std::map<int, EnumBitset<CoexecCategory>>;
void combineCoexec(DisallowedCycles& dst, DisallowedCycles const& src, int offset);
std::string toString(DisallowedCycles const& cycles);
namespace Scheduling
{
/**
* Struct that describes modeled properties of an instruction if it were to be scheduled now.
*
* Note that any new members need to:
* 1. Have a neutral default value, either in the declaration or in the constructor
* 2. Be added to the combine() function which is used to merge values from different observers.
*/
struct InstructionStatus
{
unsigned int stallCycles = 0;
unsigned int additionalCycles = 0;
WaitCount waitCount;
unsigned int nops = 0;
unsigned int reusedOperands = 0;
/// The new length of each of the queues.
EnumArray<int, GPUWaitQueueType> waitLengths;
/// How many new registers of each type must be allocated?
EnumArray<int, Register::Type> allocatedRegisters;
/// How many free registers of each type will remain?
EnumArray<int, Register::Type> remainingRegisters;
/// How much does this instruction add to the high water mark of allocated registers?
EnumArray<int, Register::Type> highWaterMarkRegistersDelta;
/// Will this cause an out-of-registers error?
EnumBitset<Register::Type> outOfRegisters;
DisallowedCycles disallowedCoexec;
std::vector<std::string> errors;
static InstructionStatus StallCycles(unsigned int const value);
static InstructionStatus Wait(WaitCount const& value);
static InstructionStatus Nops(unsigned int const value);
static InstructionStatus Error(std::string const& msg);
/**
* Merge values of members from `other` into `this`.
*/
void combine(InstructionStatus const& other);
std::string coexecString() const;
InstructionStatus();
std::string toString() const;
};
template <typename T>
concept CObserver = requires(T a, Instruction inst)
{
//> Speculatively predict stalls if this instruction were scheduled now.
{
a.peek(inst)
} -> std::convertible_to<InstructionStatus>;
//> Add any waitcnt or nop instructions needed before `inst` if it were to be scheduled now.
//> Throw an exception if it can't be scheduled now.
{a.modify(inst)};
//> This instruction _will_ be scheduled now, record any side effects.
//> This is after all observers have had the opportunity to modify the instruction.
{a.observe(inst)};
};
template <typename T>
concept CObserverConst = requires(T a, GPUArchitectureTarget const& target)
{
requires CObserver<T>;
//> This observer is required in ctx, checking GPUArchitectureTarget if needed.
{
a.required(target)
} -> std::convertible_to<bool>;
};
template <typename T>
concept CObserverRuntime = requires(T a)
{
requires CObserver<T>;
//> This observer is required in ctx, determined at runtime.
{
a.runtimeRequired()
} -> std::convertible_to<bool>;
};
template <typename T>
concept CObserverRuntimeWithContext = requires(T a, ContextPtr const& ctx)
{
requires CObserver<T>;
//> This observer requires ctx to determine if it's required at runtime.
{
a.runtimeRequired(ctx)
} -> std::convertible_to<bool>;
};
struct IObserver
{
virtual ~IObserver();
//> Speculatively predict stalls if this instruction were scheduled now.
virtual InstructionStatus peek(Instruction const& inst) const = 0;
//> Add any waitcnt or nop instructions needed before `inst` if it were to be scheduled now.
//> Throw an exception if it can't be scheduled now.
virtual void modify(Instruction& inst) const = 0;
//> This instruction _will_ be scheduled now, record any side effects.
virtual void observe(Instruction const& inst) = 0;
};
}
}
#include <rocRoller/Scheduling/Scheduling_impl.hpp>