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

146 lines
5.0 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
#include "../catch/TestContext.hpp"
#include "../catch/TestKernels.hpp"
#include <rocRoller/AssemblyKernel.hpp>
#include <rocRoller/CodeGen/Instruction.hpp>
#include <rocRoller/Expression.hpp>
#include <rocRoller/InstructionValues/Register.hpp>
#include <rocRoller/KernelOptions.hpp>
#include <rocRoller/KernelOptions_detail.hpp>
#include <rocRoller/Scheduling/LDSModel.hpp>
#include <rocRoller/Scheduling/Observers/FunctionalUnit/MEMObserver.hpp>
#include <rocRoller/Utilities/Generator.hpp>
#include <functional>
#include <string>
#include <tuple>
#include <vector>
namespace rocRoller
{
/**
* @brief Results from kernel profiling and latency collection
*/
struct KernelLatencyResults
{
std::vector<Instruction> filteredInstructions;
std::vector<std::tuple<std::string, size_t>> medianLatencies;
std::string infoStr;
};
/**
* @brief Results from latency delta analysis
*/
struct LatencyAnalysisResult
{
int totalDelta;
int totalAbsoluteDelta;
int incorrectPredictionCount;
};
/**
* @brief Base class for LDS test kernels with shared functionality
*/
class LDSTestKernelBase : public AssemblyTestKernel
{
public:
LDSTestKernelBase(ContextPtr context,
uint32_t workgroupSize,
size_t instrDwords,
size_t strideMultiplier,
const std::vector<size_t>& baseAddresses,
bool write);
void operator()();
const std::vector<Instruction>& getInstructions() const;
std::string getSectionName() const;
protected:
virtual void generate() override;
virtual Generator<Instruction> generateKernelBody() = 0;
protected:
uint32_t m_workgroupSize;
size_t m_instrDwords;
size_t m_strideMultiplier;
std::vector<size_t> m_baseAddresses;
bool m_write;
std::vector<Instruction> m_instructions;
std::shared_ptr<Register::Value> m_ldsDst;
std::shared_ptr<Register::Value> m_ldsWithOffset;
std::shared_ptr<Register::Value> m_workitemIndex;
};
/**
* @brief Helper function for profiling and collecting median latencies
*/
KernelLatencyResults runKernelAndCollectLatencies(TestContext& context,
LDSTestKernelBase& kernel);
/**
* @brief Analyzes latency deltas between model predictions and profiler measurements
*
* @param filteredInstructions The list of instructions to analyze
* @param medianLatencies The measured latencies for each instruction
* @return Structure containing total delta, absolute delta, and incorrect prediction count
*/
LatencyAnalysisResult
analyzeLatencyDeltas(const std::vector<Instruction>& filteredInstructions,
const std::vector<std::tuple<std::string, size_t>>& medianLatencies);
/**
* @brief Generic parameterized kernel class for LDS tests
*/
class ParameterizedLDSKernel : public LDSTestKernelBase
{
public:
using BodyGenerator = std::function<Generator<Instruction>(ParameterizedLDSKernel*)>;
ParameterizedLDSKernel(ContextPtr context,
uint32_t workgroupSize,
size_t instrDwords,
size_t strideMultiplier,
const std::vector<size_t>& baseAddresses,
bool write,
BodyGenerator bodyGen);
Generator<Instruction> scheduleLdsInstruction(int& counter);
ContextPtr getContext() const;
protected:
Generator<Instruction> generateKernelBody() override;
private:
BodyGenerator m_bodyGenerator;
};
/**
* @brief Configuration for LDS test cases
*/
struct LDSTestConfig
{
bool useMultipleWorkgroupSizes;
std::function<Generator<Instruction>(ParameterizedLDSKernel*)> kernelBodyGen;
std::function<void(
const KernelLatencyResults&, const LatencyAnalysisResult&, int, int, bool, uint32_t)>
validationFunc;
};
/**
* @brief Common test harness function for LDS tests
* Handles workgroup/item set up, kernel generation, profiling, latency collection, and validation based on the provided configuration
* Test need only implement the kernel body generation and validation logic
*/
void runLDSTest(const LDSTestConfig& config);
} // namespace rocRoller