Files
TheRock/rocm-libraries/shared/rocroller/lib/source/GPUArchitecture.cpp
T
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

107 lines
3.3 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <rocRoller/GPUArchitecture/GPUArchitecture.hpp>
#include <rocRoller/InstructionValues/Register.hpp>
#ifdef ROCROLLER_USE_HIP
#include <hip/hip_runtime.h>
#endif
#include <rocRoller/Utilities/Error.hpp>
#include <rocRoller/Utilities/Utils.hpp>
#include <rocRoller/Serialization/GPUArchitecture.hpp>
#include <rocRoller/Serialization/YAML.hpp>
#include <rocRoller/Serialization/msgpack/Msgpack.hpp>
#ifdef ROCROLLER_EMBED_ARCH_DEF
#include <cmrc/cmrc.hpp>
CMRC_DECLARE(rocRoller);
#endif
namespace rocRoller
{
std::string
GPUArchitecture::writeYaml(std::map<GPUArchitectureTarget, GPUArchitecture> const& input)
{
rocRoller::GPUArchitecturesStruct tmp;
tmp.architectures = input;
return Serialization::toYAML(tmp);
}
std::map<GPUArchitectureTarget, GPUArchitecture>
GPUArchitecture::readYaml(std::string const& input)
{
auto archStruct = Serialization::readYAMLFile<GPUArchitecturesStruct>(input);
return archStruct.architectures;
}
std::string
GPUArchitecture::writeMsgpack(std::map<GPUArchitectureTarget, GPUArchitecture> const& input)
{
std::stringstream buffer;
msgpack::pack(buffer, input);
return buffer.str();
}
std::map<GPUArchitectureTarget, GPUArchitecture>
GPUArchitecture::readMsgpack(std::string const& input)
{
try
{
std::ifstream ifs(input);
std::string buffer((std::istreambuf_iterator<char>(ifs)),
std::istreambuf_iterator<char>());
msgpack::object_handle oh = msgpack::unpack(buffer.data(), buffer.size());
msgpack::object const& obj = oh.get();
auto rv = obj.as<std::map<GPUArchitectureTarget, GPUArchitecture>>();
return rv;
}
catch(const std::exception& e)
{
Throw<FatalError>("GPUArchitecture::readMsgpack(", input, ") failed: ", e.what());
}
}
std::map<GPUArchitectureTarget, GPUArchitecture> GPUArchitecture::readEmbeddedMsgpack()
{
#ifdef ROCROLLER_EMBED_ARCH_DEF
try
{
auto fs = cmrc::rocRoller::get_filesystem();
auto fd = fs.open("resources/GPUArchitecture_def.msgpack");
msgpack::object_handle oh = msgpack::unpack(
fd.begin(),
reinterpret_cast<uintptr_t>(fd.end()) - reinterpret_cast<uintptr_t>(fd.begin()));
msgpack::object const& obj = oh.get();
auto rv = obj.as<std::map<GPUArchitectureTarget, GPUArchitecture>>();
return rv;
}
catch(const std::exception& e)
{
Throw<FatalError>("GPUArchitecture::readEmbeddedMsgpack() failed: ", e.what());
}
#else
Throw<FatalError>(
"GPUArchitecture::readEmbeddedMsgpack() failed: no embedded architecture definitions");
#endif
}
bool GPUArchitecture::isSupportedConstantValue(Register::ValuePtr value) const
{
if(value->regType() != Register::Type::Literal)
return false;
return std::visit([this](auto val) -> bool { return this->isSupportedConstantValue(val); },
value->getLiteralValue());
}
}