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

109 lines
3.6 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
#include <memory>
#include <rocRoller/Context.hpp>
#include <rocRoller/InstructionValues/Register_fwd.hpp>
class TestContext;
/**
* Helper to create a Context during a test.
*
* Will by default name the kernel for the current test name. Since catch2 does not
* include the test parameterization in the name, the helper functions all can take any
* number of arguments that will be stringified into the kernel name.
*
* Because TestContext restores settings in its destructor, the lifetime of the
* TestContext object should be at least the lifetime of the Context it
* contains.
*/
class TestContext
{
public:
/**
* Resets Settings.
*/
~TestContext();
/**
* Use this when creating a kernel for the current (physically present) GPU, to
* enable running the kernel.
*/
template <typename... Params>
static TestContext ForTestDevice(rocRoller::KernelOptions const& kernelOpts = {},
Params const&... params);
/**
* Use this when creating a kernel for a default GPU target (currently gfx90a), when
* testing features that are not target-specific.
*/
template <typename... Params>
static TestContext ForDefaultTarget(rocRoller::KernelOptions const& kernelOpts = {},
Params const&... params);
/**
* Use this when creating a kernel for a specific GPU target.
*/
template <typename... Params>
static TestContext ForTarget(rocRoller::GPUArchitectureTarget const& arch,
rocRoller::KernelOptions const& kernelOpts = {},
Params const&... params);
/**
* Use this when creating a kernel for a specific GPU target.
*/
template <typename... Params>
static TestContext ForTarget(std::string const& arch,
rocRoller::KernelOptions const& kernelOpts = {},
Params const&... params);
/**
* Use this when creating a kernel for a specific GPU target.
*/
template <typename... Params>
static TestContext ForTarget(rocRoller::GPUArchitecture const& arch,
rocRoller::KernelOptions const& kernelOpts = {},
Params const&... params);
/**
* Creates a valid kernel name which includes the name of the currently running test
* as well as stringified versions of all the provided parameters.
*/
template <typename... Params>
static std::string KernelName(Params const&... params);
/**
* Returns `name` (which may contain spaces or other special characters) converted
* into a valid C identifier name
*/
static std::string EscapeKernelName(std::string name);
rocRoller::ContextPtr get();
rocRoller::Context& operator*();
rocRoller::Context* operator->();
/**
* Returns the assembly code generated so far as a string.
*/
std::string output();
std::vector<rocRoller::Register::ValuePtr>
createRegisters(rocRoller::Register::Type const regType,
rocRoller::DataType const dataType,
size_t const amount,
int const regCount = 1,
rocRoller::Register::AllocationOptions allocOptions = {});
protected:
TestContext(rocRoller::ContextPtr context);
rocRoller::ContextPtr m_context;
};
#include "TestContext_impl.hpp"