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
110 lines
3.1 KiB
C++
110 lines
3.1 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <rocRoller/GPUArchitecture/GPUArchitecture.hpp>
|
|
#include <rocRoller/GPUArchitecture/GPUArchitectureLibrary.hpp>
|
|
#include <rocRoller/Utilities/Settings.hpp>
|
|
|
|
#ifdef ROCROLLER_USE_HIP
|
|
#include <hip/hip_runtime.h>
|
|
#include <rocRoller/Utilities/HipUtils.hpp>
|
|
#endif
|
|
|
|
namespace rocRoller
|
|
{
|
|
|
|
void GPUArchitectureLibrary::GetCurrentDevices(std::vector<GPUArchitecture>& retval,
|
|
int& default_device)
|
|
{
|
|
retval.clear();
|
|
default_device = -1;
|
|
#ifdef ROCROLLER_USE_HIP
|
|
int count;
|
|
hipError_t error = hipGetDeviceCount(&count);
|
|
if(error != hipSuccess)
|
|
{
|
|
count = 0;
|
|
}
|
|
|
|
for(int i = 0; i < count; i++)
|
|
{
|
|
hipDeviceProp_t deviceProps;
|
|
|
|
HIP_CHECK(hipGetDeviceProperties(&deviceProps, i));
|
|
|
|
retval.push_back(
|
|
m_gpuArchitectures.at(GPUArchitectureTarget::fromString(deviceProps.gcnArchName)));
|
|
}
|
|
|
|
if(count > 0)
|
|
{
|
|
HIP_CHECK(hipGetDevice(&default_device));
|
|
}
|
|
#else
|
|
//TODO: Add a way to get specific GPUs. Maybe through env vars.
|
|
Throw<FatalError>("Non-HIP Path Not Implemented");
|
|
#endif
|
|
}
|
|
|
|
GPUArchitecture GPUArchitectureLibrary::GetArch(GPUArchitectureTarget const& target)
|
|
{
|
|
auto iter = m_gpuArchitectures.find(target);
|
|
|
|
AssertFatal(iter != m_gpuArchitectures.end(),
|
|
concatenate("Could not find info for GPU target ", target));
|
|
|
|
return iter->second;
|
|
}
|
|
|
|
GPUArchitecture GPUArchitectureLibrary::GetHipDeviceArch(int deviceIdx)
|
|
{
|
|
hipDeviceProp_t deviceProps;
|
|
|
|
HIP_CHECK(hipGetDeviceProperties(&deviceProps, deviceIdx));
|
|
|
|
return GetArch(
|
|
GPUArchitectureTarget::fromString(deviceProps.gcnArchName, deviceProps.asicRevision));
|
|
}
|
|
|
|
GPUArchitecture GPUArchitectureLibrary::GetDefaultHipDeviceArch(int& deviceIdx)
|
|
{
|
|
HIP_CHECK(hipGetDevice(&deviceIdx));
|
|
return GetHipDeviceArch(deviceIdx);
|
|
}
|
|
|
|
GPUArchitecture GPUArchitectureLibrary::GetDefaultHipDeviceArch()
|
|
{
|
|
int idx;
|
|
return GetDefaultHipDeviceArch(idx);
|
|
}
|
|
|
|
bool GPUArchitectureLibrary::HasHipDevice()
|
|
{
|
|
int idx;
|
|
return hipGetDevice(&idx) == hipSuccess;
|
|
}
|
|
|
|
std::map<GPUArchitectureTarget, GPUArchitecture> GPUArchitectureLibrary::LoadLibrary()
|
|
{
|
|
TIMER(t, "GPUArchitectureLibrary::LoadLibrary");
|
|
|
|
auto envPath
|
|
= std::filesystem::path(Settings::getInstance()->get(Settings::ArchitectureFile));
|
|
|
|
if(!envPath.empty() && std::filesystem::exists(envPath))
|
|
{
|
|
if(envPath.extension() == ".yaml" || envPath.extension() == ".yml")
|
|
{
|
|
return GPUArchitecture::readYaml(envPath);
|
|
}
|
|
else if(envPath.extension() == ".msgpack")
|
|
{
|
|
return GPUArchitecture::readMsgpack(envPath);
|
|
}
|
|
// ignore otherwise
|
|
}
|
|
|
|
return GPUArchitecture::readEmbeddedMsgpack();
|
|
}
|
|
}
|