/******************************************************************************* * * MIT License * * Copyright 2024-2025 AMD ROCm(TM) Software * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * *******************************************************************************/ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace rocRoller { class GPUArchitecture { public: GPUArchitecture(); explicit GPUArchitecture(GPUArchitectureTarget const&); GPUArchitecture(GPUArchitectureTarget const&, std::map const&, std::map 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; template requires(std::is_pointer_v) 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 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 bool isSupportedConstantValue(T value) const; constexpr GPUArchitectureTarget const& target() const; template friend struct rocRoller::Serialization::MappingTraits; static std::string writeYaml(std::map const&); static std::map readYaml(std::string const&); static std::string writeMsgpack(std::map const&); static std::map readMsgpack(std::string const&); static std::map readEmbeddedMsgpack(); std::map const& getAllCapabilities() const; std::map const& getAllIntructionInfo() const; bool isSupportedScaleBlockSize(int size) const; bool isSupportedScaleType(DataType type) const; private: GPUArchitectureTarget m_archTarget; std::map m_capabilities; std::map m_instructionInfos; template // cppcheck-suppress functionStatic std::unordered_set supportedConstantValues() const; template // cppcheck-suppress functionStatic std::pair supportedConstantRange() const; }; //Used as a container for serialization. struct GPUArchitecturesStruct { std::map architectures; }; } #include