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

120 lines
4.7 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
#include <array>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <unordered_set>
#include <vector>
#include <rocRoller/DataTypes/DataTypes.hpp>
#include <rocRoller/GPUArchitecture/GPUArchitectureTarget.hpp>
#include <rocRoller/GPUArchitecture/GPUCapability.hpp>
#include <rocRoller/GPUArchitecture/GPUInstructionInfo.hpp>
#include <rocRoller/InstructionValues/Register_fwd.hpp>
#include <rocRoller/Serialization/Base_fwd.hpp>
namespace rocRoller
{
class GPUArchitecture
{
public:
GPUArchitecture();
explicit GPUArchitecture(GPUArchitectureTarget const&);
GPUArchitecture(GPUArchitectureTarget const&,
std::map<GPUCapability, int> const&,
std::map<std::string, GPUInstructionInfo> const&);
void AddCapability(GPUCapability const&, int);
void AddInstructionInfo(GPUInstructionInfo const&);
bool HasCapability(GPUCapability const&) const;
int GetCapability(GPUCapability const&) const;
bool HasCapability(std::string const&) const;
int GetCapability(std::string const&) const;
rocRoller::GPUInstructionInfo GetInstructionInfo(std::string const&) const;
bool HasInstructionInfo(std::string const&) const;
/**
* Returns true if `reg` is a Literal value that can be represented as a
* constant operand in an instruction. This is one of only a limited set of
* values that can be encoded directly in the instruction, as opposed to
* actual literals, which must be encoded as a separate 32-bit word in the
* instruction stream.
*
* Many instructions support constant values but not literal values.
*/
bool isSupportedConstantValue(Register::ValuePtr reg) const;
bool isSupportedConstantValue(Raw32 value) const;
bool isSupportedConstantValue(Buffer value) const;
bool isSupportedConstantValue(TDM value) const;
template <typename T>
requires(std::is_pointer_v<T>) bool isSupportedConstantValue(T value) const;
/**
* Returns true iff `value` can be represented as an iconst value in an
* instruction. For all supported architectures, currently this is -16..64
* inclusive
*/
template <std::integral T>
bool isSupportedConstantValue(T value) const;
/**
* Returns true iff `value` can be represented as an fconst value in an
* instruction. For all supported architectures, currently this includes:
*
* * 0, 0.5, 1.0, 2.0, 4.0
* * -0.5, -1.0, -2.0, -4.0
* * 1/(2*pi)
*/
template <std::floating_point T>
bool isSupportedConstantValue(T value) const;
constexpr GPUArchitectureTarget const& target() const;
template <typename T1, typename T2, typename T3>
friend struct rocRoller::Serialization::MappingTraits;
static std::string writeYaml(std::map<GPUArchitectureTarget, GPUArchitecture> const&);
static std::map<GPUArchitectureTarget, GPUArchitecture> readYaml(std::string const&);
static std::string writeMsgpack(std::map<GPUArchitectureTarget, GPUArchitecture> const&);
static std::map<GPUArchitectureTarget, GPUArchitecture> readMsgpack(std::string const&);
static std::map<GPUArchitectureTarget, GPUArchitecture> readEmbeddedMsgpack();
std::map<GPUCapability, int> const& getAllCapabilities() const;
std::map<std::string, GPUInstructionInfo> const& getAllIntructionInfo() const;
bool isSupportedScaleBlockSize(int size) const;
bool isSupportedScaleType(DataType type) const;
private:
GPUArchitectureTarget m_archTarget;
std::map<GPUCapability, int> m_capabilities;
std::map<std::string, GPUInstructionInfo> m_instructionInfos;
template <std::floating_point T>
// cppcheck-suppress functionStatic
std::unordered_set<T> supportedConstantValues() const;
template <std::integral T>
// cppcheck-suppress functionStatic
std::pair<T, T> supportedConstantRange() const;
};
//Used as a container for serialization.
struct GPUArchitecturesStruct
{
std::map<GPUArchitectureTarget, GPUArchitecture> architectures;
};
}
#include <rocRoller/GPUArchitecture/GPUArchitecture_impl.hpp>