Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions projects/rocprofiler-systems/source/lib/core/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
} \
} // namespace ::tim::cereal

#include "common/defines.h"

#if !defined(ROCPROFSYS_USE_ROCM)
# define ROCPROFSYS_USE_ROCM 0
#endif
Expand All @@ -40,7 +42,6 @@

#include <timemory/manager.hpp>

#include <dlfcn.h>
#include <string>

#include "core/agent_manager.hpp"
Expand Down Expand Up @@ -92,17 +93,6 @@ _amdsmi_is_initialized()
return initialized;
}

void
prevent_amdsmi_library_unload()
{
static bool _initialized = false;
if(_initialized) return;
_initialized = true;

dlopen("libamd_smi.so", RTLD_NOW | RTLD_NOLOAD | RTLD_NODELETE);
dlopen("librocm_smi64.so", RTLD_NOW | RTLD_NOLOAD | RTLD_NODELETE);
}

bool
amdsmi_init()
{
Expand All @@ -113,8 +103,6 @@ amdsmi_init()
ROCPROFSYS_AMD_SMI_CALL(::amdsmi_init(AMDSMI_INIT_AMD_GPUS));
get_processor_handles();
_amdsmi_is_initialized() = true; // Mark as initialized

prevent_amdsmi_library_unload();
} catch(std::exception& _e)
{
LOG_ERROR("Exception thrown initializing amd-smi: {}", _e.what());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,10 @@ shutdown()

try
{
data::shutdown();
if(data::shutdown())
{
ROCPROFSYS_AMD_SMI_CALL(amdsmi_shut_down());
}
} catch(std::runtime_error& _e)
{
LOG_WARNING("Exception thrown when shutting down amd-smi: {}", _e.what());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "core/common.hpp"
#include "core/config.hpp"
#include "core/state.hpp"
#include "core/timemory.hpp"
#include "library/runtime.hpp"

#include <timemory/backends/threading.hpp>
Expand All @@ -33,9 +34,7 @@
#include "logger/debug.hpp"

#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>

namespace rocprofsys
{
Expand Down Expand Up @@ -89,26 +88,6 @@ void
exit_gotcha::operator()(const gotcha_data& _data, exit_func_t _func, int _ec) const
{
_exit_info = { true, _data.tool_id.find("quick") != std::string::npos, _ec };

if(config::get_use_amd_smi())
{
threading::clear_callbacks();

if(get_state() < ::rocprofsys::State::Finalized && !is_child_process())
{
LOG_DEBUG("Finalizing {} before calling {}({})...", get_exe_name(),
_data.tool_id, _ec);

rocprofsys_finalize();
}

LOG_DEBUG("Calling _exit({}) in {} to avoid AMD SMI cleanup issues...", _ec,
get_exe_name().c_str());

std::fflush(nullptr);
_exit(_ec);
}

invoke_exit_gotcha(_data, _func, _ec);
}

Expand Down