Files
TheRock/rocm-systems/projects/rocprofiler-systems/source/bin/rocprof-sys-exe/rocprof-sys.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

145 lines
7.1 KiB
C++

// Copyright (c) Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT
#include "common/env_vars.hpp"
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <future>
#include <iomanip>
#include <iostream>
#include <map>
#include <pthread.h>
#include <regex>
#include <signal.h>
#include <sstream>
#include <string_view>
#include <thread>
#include <unistd.h>
int
main(int argc, char** argv)
{
static const char* _warning = R"warning(
WWWWWWWW WWWWWWWW iiii !!!
W::::::W W::::::W i::::i !!:!!
W::::::W W::::::W iiii !:::!
W::::::W W::::::W !:::!
W:::::W WWWWW W:::::Waaaaaaaaaaaaa rrrrr rrrrrrrrr nnnn nnnnnnnn iiiiiiinnnn nnnnnnnn ggggggggg ggggg!:::!
W:::::W W:::::W W:::::W a::::::::::::a r::::rrr:::::::::r n:::nn::::::::nn i:::::in:::nn::::::::nn g:::::::::ggg::::g!:::!
W:::::W W:::::::W W:::::W aaaaaaaaa:::::ar:::::::::::::::::r n::::::::::::::nn i::::in::::::::::::::nn g:::::::::::::::::g!:::!
W:::::W W:::::::::W W:::::W a::::arr::::::rrrrr::::::rnn:::::::::::::::n i::::inn:::::::::::::::ng::::::ggggg::::::gg!:::!
W:::::W W:::::W:::::W W:::::W aaaaaaa:::::a r:::::r r:::::r n:::::nnnn:::::n i::::i n:::::nnnn:::::ng:::::g g:::::g !:::!
W:::::W W:::::W W:::::W W:::::W aa::::::::::::a r:::::r rrrrrrr n::::n n::::n i::::i n::::n n::::ng:::::g g:::::g !:::!
W:::::W:::::W W:::::W:::::W a::::aaaa::::::a r:::::r n::::n n::::n i::::i n::::n n::::ng:::::g g:::::g !!:!!
W:::::::::W W:::::::::W a::::a a:::::a r:::::r n::::n n::::n i::::i n::::n n::::ng::::::g g:::::g !!!
W:::::::W W:::::::W a::::a a:::::a r:::::r n::::n n::::ni::::::i n::::n n::::ng:::::::ggggg:::::g
W:::::W W:::::W a:::::aaaa::::::a r:::::r n::::n n::::ni::::::i n::::n n::::n g::::::::::::::::g !!!
W:::W W:::W a::::::::::aa:::ar:::::r n::::n n::::ni::::::i n::::n n::::n gg::::::::::::::g !!:!!
WWW WWW aaaaaaaaaa aaaarrrrrrr nnnnnn nnnnnniiiiiiii nnnnnn nnnnnn gggggggg::::::g !!!
g:::::g
gggggg g:::::g
g:::::gg gg:::::g
g::::::ggg:::::::g
gg:::::::::::::g
ggg::::::ggg
gggggg
ROCm Systems Profiler has renamed the "rocprof-sys" executable to "rocprof-sys-instrument".
This executable only exists to provide this deprecation warning and maintain backwards compatibility for a few releases.
This executable will soon invoke "rocprof-sys-instrument" with the arguments you just provided after we've given you
a chance to read this message.
If you are running this job interactively, please acknowledge that you've read this message and whether you want to continue.
If you are running this job non-interactively, we will resume executing after ~1 minute unless CI or ROCPROFSYS_CI is defined
in the environment, in which case, we will throw an error.
Thanks for using ROCm Systems Profiler and happy optimizing!
)warning";
auto _completed = std::promise<void>{};
bool _acknowledged = false;
auto _emit_warning = []() {
// emit warning
std::cerr << _warning << std::endl;
};
auto _get_env = [](const char* _var) {
auto* _val = getenv(_var);
if(_val == nullptr) return false;
return !std::regex_match(
_val, std::regex{ "0|false|off|no", std::regex_constants::icase });
};
auto _env_failure = [_emit_warning, argv](std::string_view _env_var) {
// emit warning
_emit_warning();
std::cerr
<< "[" << argv[0] << "] Detected " << _env_var
<< " environment variable. Exiting to prevent consuming CI resources. "
"Use \"rocprof-sys-instrument\" executable instead of \"rocprof-sys\" "
"to prevent this error."
<< std::endl;
std::exit(EXIT_FAILURE);
};
auto _wait_for_input = [&_completed, &_acknowledged, _emit_warning]() {
// emit warning and wait for input
_emit_warning();
std::cerr << "Do you want to continue? [Y/n] " << std::flush;
auto _input = char{};
std::cin.get(_input);
_input = tolower(_input);
if(_input == 'n') std::exit(EXIT_SUCCESS);
_acknowledged = true;
_completed.set_value();
};
for(const auto* itr : { "CI", rocprofsys::env_vars::CI })
{
if(_get_env(itr)) _env_failure(itr);
}
{
auto _thr = std::thread{ _wait_for_input };
_completed.get_future().wait_for(std::chrono::seconds{ 60 });
if(!_acknowledged)
{
std::cerr << "[" << argv[0]
<< "] No acknowledgement after 1 minute. Continuing..."
<< std::endl;
_thr.detach();
}
else
_thr.join();
}
// generate the new command
auto _argv = std::vector<char*>{};
_argv.emplace_back(
strdup(std::string{ std::string{ argv[0] } + "-instrument" }.c_str()));
for(int i = 1; i < argc; ++i)
_argv.emplace_back(argv[i]);
// echo the new command for diagnostic purposes
auto _cmdss = std::stringstream{};
for(const auto& itr : _argv)
if(itr) _cmdss << " " << itr;
auto _cmd = _cmdss.str();
if(!_cmd.empty())
std::cerr << "[" << argv[0] << "] Executing: \"" << _cmd.substr(1) << "\"...\n"
<< std::endl;
// make sure command ends with nullptr
_argv.emplace_back(nullptr);
return execvp(_argv.front(), _argv.data());
}