Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge release code into development #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@

cmake_minimum_required(VERSION 3.8.0)

project(ROCM_DEBUG_AGENT VERSION 2.0.3)
project(rocm-debug-agent VERSION 2.0.3)

# The project command does not set the <PROJECT-NAME>_NAME variable so must set
# it explicitly.
set(ROCM_DEBUG_AGENT_NAME "${PROJECT_NAME}")
include(GNUInstallDirs)

file(GLOB SOURCES "src/*.cpp")
add_library(rocm-debug-agent SHARED ${SOURCES})
Expand All @@ -47,8 +45,8 @@ set_target_properties(rocm-debug-agent PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
VERSION ${ROCM_DEBUG_AGENT_VERSION}
SOVERSION ${ROCM_DEBUG_AGENT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
NO_SYSTEM_FROM_IMPORTED ON)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
Expand Down Expand Up @@ -122,11 +120,11 @@ target_compile_definitions(rocm-debug-agent
install(TARGETS rocm-debug-agent
LIBRARY
NAMELINK_SKIP
DESTINATION lib
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT runtime)

install(FILES LICENSE.txt README.md
DESTINATION share/doc/rocm-debug-agent
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT runtime)

enable_testing()
Expand All @@ -137,7 +135,7 @@ set(CPACK_PACKAGE_NAME rocm-debug-agent)
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc")
set(CPACK_PACKAGE_CONTACT "ROCm Debugger Support <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute Debug Agent (ROCdebug-agent)")
set(CPACK_PACKAGE_VERSION ${ROCM_DEBUG_AGENT_VERSION})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")

if(DEFINED ENV{ROCM_LIBPATCH_VERSION})
Expand Down
4 changes: 2 additions & 2 deletions src/code_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#ifndef _ROCM_DEBUG_AGENT_CODE_OBJECT_H
#define _ROCM_DEBUG_AGENT_CODE_OBJECT_H 1

#include <amd-dbgapi.h>
#include <amd-dbgapi/amd-dbgapi.h>

#include <cstddef>
#include <map>
Expand Down Expand Up @@ -98,4 +98,4 @@ class code_object_t

} /* namespace amd::debug_agent */

#endif /* _ROCM_DEBUG_AGENT_CODE_OBJECT_H */
#endif /* _ROCM_DEBUG_AGENT_CODE_OBJECT_H */
74 changes: 63 additions & 11 deletions src/debug_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "debug.h"
#include "logging.h"

#include <amd-dbgapi.h>
#include <amd-dbgapi/amd-dbgapi.h>
#include <hsa/hsa.h>
#include <hsa/hsa_api_trace.h>
#include <hsa/hsa_ext_amd.h>
Expand Down Expand Up @@ -365,19 +365,35 @@ stop_all_wavefronts (amd_dbgapi_process_id_t process_id)
if (event_id.handle == AMD_DBGAPI_EVENT_NONE.handle)
break;

if (kind == AMD_DBGAPI_EVENT_KIND_WAVE_STOP)
if (kind == AMD_DBGAPI_EVENT_KIND_WAVE_STOP
|| kind == AMD_DBGAPI_EVENT_KIND_WAVE_COMMAND_TERMINATED)
{
amd_dbgapi_wave_id_t wave_id;
DBGAPI_CHECK (amd_dbgapi_event_get_info (
event_id, AMD_DBGAPI_EVENT_INFO_WAVE, sizeof (wave_id),
&wave_id));

agent_assert (waiting_to_stop.find (wave_id.handle)
!= waiting_to_stop.end ());

waiting_to_stop.erase (wave_id.handle);
already_stopped.emplace (wave_id.handle);

agent_log (log_level_t::info, "wave_%ld is stopped",
wave_id.handle);
if (kind == AMD_DBGAPI_EVENT_KIND_WAVE_STOP)
{
already_stopped.emplace (wave_id.handle);

agent_log (log_level_t::info, "wave_%ld is stopped",
wave_id.handle);
}
else /* kind == AMD_DBGAPI_EVENT_KIND_COMMAND_TERMINATED */
{
agent_log (log_level_t::info,
"wave_%ld terminated while stopping",
wave_id.handle);
}
}

DBGAPI_CHECK (amd_dbgapi_event_processed (event_id));
}

amd_dbgapi_wave_id_t *wave_ids;
Expand All @@ -401,13 +417,47 @@ stop_all_wavefronts (amd_dbgapi_process_id_t process_id)
continue;
}

agent_log (log_level_t::info,
"wave_%ld is running, sending stop request",
wave_id.handle);
amd_dbgapi_wave_state_t state;
if (amd_dbgapi_status_t status = amd_dbgapi_wave_get_info (
wave_id, AMD_DBGAPI_WAVE_INFO_STATE, sizeof (state), &state);
status == AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID)
{
/* The wave could have terminated since it was reported in the
last wave list. Skip it. */
continue;
}
else if (status != AMD_DBGAPI_STATUS_SUCCESS)
agent_error ("amd_dbgapi_wave_get_info failed (rc=%d)", status);

if (state == AMD_DBGAPI_WAVE_STATE_STOP)
{
already_stopped.emplace (wave_ids[i].handle);

/* FIXME: The wave could be single-stepping, how are we going to
restore the state? */
DBGAPI_CHECK (amd_dbgapi_wave_stop (wave_id));
agent_log (log_level_t::info, "wave_%ld is already stopped",
wave_id.handle);
continue;
}
if (state == AMD_DBGAPI_WAVE_STATE_SINGLE_STEP)
{
/* The wave is single-stepping, it will stop and report an event
once the instruction execution is complete. */
agent_log (log_level_t::info, "wave_%ld is single-stepping",
wave_id.handle);
continue;
}

if (amd_dbgapi_status_t status = amd_dbgapi_wave_stop (wave_id);
status == AMD_DBGAPI_STATUS_ERROR_INVALID_WAVE_ID)
{
/* The wave could have terminated since it was reported in the
last wave list. Skip it. */
continue;
}
else if (status != AMD_DBGAPI_STATUS_SUCCESS)
agent_error ("amd_dbgapi_wave_stop failed (rc=%d)", status);

agent_log (log_level_t::info,
"wave_%ld is running, sent stop request", wave_id.handle);

waiting_to_stop.emplace (wave_id.handle);
}
Expand Down Expand Up @@ -473,6 +523,8 @@ print_wavefronts (bool all_wavefronts)
/* No more events. */
if (event_kind == AMD_DBGAPI_EVENT_KIND_NONE)
break;

DBGAPI_CHECK (amd_dbgapi_event_processed (event_id));
}

std::map<amd_dbgapi_global_address_t, code_object_t> code_object_map;
Expand Down
2 changes: 1 addition & 1 deletion src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "logging.h"

#include <amd-dbgapi.h>
#include <amd-dbgapi/amd-dbgapi.h>
#include <cstdio>
#include <stdarg.h>

Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

cmake_minimum_required(VERSION 3.8.0)

project(ROCM_DEBUG_AGENT_TEST VERSION ${ROCM_DEBUG_AGENT_VERSION})
project(rocm-debug-agent-test)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/opt/rocm/hip/cmake")
find_package(HIP REQUIRED MODULE)
Expand Down