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
86 lines
2.3 KiB
C++
86 lines
2.3 KiB
C++
/*
|
|
* Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: NCSA
|
|
*/
|
|
|
|
/// \file
|
|
/// Implementation of centralized environment variable management
|
|
|
|
#include "common/env_config.h"
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
|
|
namespace rocrtst {
|
|
|
|
EnvironmentConfig::EnvironmentConfig()
|
|
: initialized_(false),
|
|
pool_size_limit_(0) {
|
|
}
|
|
|
|
EnvironmentConfig& EnvironmentConfig::getInstance() {
|
|
static EnvironmentConfig instance;
|
|
return instance;
|
|
}
|
|
|
|
void EnvironmentConfig::initialize() {
|
|
if (initialized_) {
|
|
return; // Already initialized
|
|
}
|
|
|
|
// Read all environment variables
|
|
hsa_model_topology_ = readEnvString("HSA_MODEL_TOPOLOGY");
|
|
platform_override_ = readEnvString("ROCRTST_PLATFORM_OVERRIDE");
|
|
platform_config_path_ = readEnvString("ROCRTST_PLATFORM_CONFIG");
|
|
test_groups_ = readEnvString("ROCRTST_TEST_GROUPS");
|
|
pool_size_limit_ = readEnvSize("ROCRTST_LIMIT_POOL_SIZE");
|
|
|
|
initialized_ = true;
|
|
|
|
// Optional: Print configuration for debugging
|
|
#ifdef ROCRTST_DEBUG_ENV
|
|
std::cout << "=== Environment Configuration ===" << std::endl;
|
|
if (!hsa_model_topology_.empty()) {
|
|
std::cout << "HSA_MODEL_TOPOLOGY: " << hsa_model_topology_ << std::endl;
|
|
}
|
|
if (!platform_override_.empty()) {
|
|
std::cout << "ROCRTST_PLATFORM_OVERRIDE: " << platform_override_ << std::endl;
|
|
}
|
|
if (!platform_config_path_.empty()) {
|
|
std::cout << "ROCRTST_PLATFORM_CONFIG: " << platform_config_path_ << std::endl;
|
|
}
|
|
if (!test_groups_.empty()) {
|
|
std::cout << "ROCRTST_TEST_GROUPS: " << test_groups_ << std::endl;
|
|
}
|
|
if (pool_size_limit_ > 0) {
|
|
std::cout << "ROCRTST_LIMIT_POOL_SIZE: " << pool_size_limit_ << std::endl;
|
|
}
|
|
std::cout << "=================================" << std::endl;
|
|
#endif
|
|
}
|
|
|
|
std::string EnvironmentConfig::readEnvString(const char* name) {
|
|
const char* value = std::getenv(name);
|
|
return value ? std::string(value) : std::string();
|
|
}
|
|
|
|
size_t EnvironmentConfig::readEnvSize(const char* name) {
|
|
const char* value = std::getenv(name);
|
|
if (!value) {
|
|
return 0;
|
|
}
|
|
|
|
char* end = nullptr;
|
|
unsigned long result = std::strtoul(value, &end, 10);
|
|
|
|
// Check for conversion errors
|
|
if (end == value || *end != '\0') {
|
|
std::cerr << "Warning: Invalid value for " << name << ": " << value << std::endl;
|
|
return 0;
|
|
}
|
|
|
|
return static_cast<size_t>(result);
|
|
}
|
|
|
|
} // namespace rocrtst
|