Skip to content

Commit

Permalink
Reorganize thread trace codeobj headers (#1001)
Browse files Browse the repository at this point in the history
* include/rocprofiler-sdk/cxx/codeobj

- Relocated from include/rocprofiler-sdk/amd_detail/rocprofiler-sdk-codeobj

* Update include/rocprofiler-sdk/cxx

- cmake updates
- correct namespace rocprofiler::codeobj rocprofiler::sdk::codeobj

* Update codeobj tests and samples
  • Loading branch information
jrmadsen authored Aug 1, 2024
1 parent 94b5d9b commit 20e07ca
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 48 deletions.
8 changes: 4 additions & 4 deletions samples/advanced_thread_trace/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <rocprofiler-sdk/amd_detail/rocprofiler-sdk-codeobj/code_printing.hpp>
#include <rocprofiler-sdk/cxx/codeobj/code_printing.hpp>
#include <shared_mutex>

#include "common/defines.hpp"
Expand Down Expand Up @@ -106,9 +106,9 @@ namespace client
using code_obj_load_data_t = rocprofiler_callback_tracing_code_object_load_data_t;
using kernel_symbol_data_t = rocprofiler_callback_tracing_code_object_kernel_symbol_register_data_t;

using Instruction = rocprofiler::codeobj::disassembly::Instruction;
using CodeobjAddressTranslate = rocprofiler::codeobj::disassembly::CodeobjAddressTranslate;
using SymbolInfo = rocprofiler::codeobj::disassembly::SymbolInfo;
using Instruction = rocprofiler::sdk::codeobj::disassembly::Instruction;
using CodeobjAddressTranslate = rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate;
using SymbolInfo = rocprofiler::sdk::codeobj::disassembly::SymbolInfo;

rocprofiler_client_id_t* client_id = nullptr;
rocprofiler_context_id_t client_ctx = {};
Expand Down
6 changes: 3 additions & 3 deletions samples/code_object_isa_decode/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <rocprofiler-sdk/amd_detail/rocprofiler-sdk-codeobj/code_printing.hpp>
#include <rocprofiler-sdk/cxx/codeobj/code_printing.hpp>

#include "common/defines.hpp"
#include "common/filesystem.hpp"
Expand Down Expand Up @@ -90,8 +90,8 @@ using code_obj_load_data_t = rocprofiler_callback_tracing_code_object_load_data_
using kernel_symbol_data_t = rocprofiler_callback_tracing_code_object_kernel_symbol_register_data_t;
using kernel_symbol_map_t = std::unordered_map<std::string, std::pair<uint64_t, size_t>>;

using Instruction = rocprofiler::codeobj::disassembly::Instruction;
using CodeobjAddressTranslate = rocprofiler::codeobj::disassembly::CodeobjAddressTranslate;
using Instruction = rocprofiler::sdk::codeobj::disassembly::Instruction;
using CodeobjAddressTranslate = rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate;

rocprofiler_client_id_t* client_id = nullptr;
rocprofiler_client_finalize_t client_fini_func = nullptr;
Expand Down
2 changes: 0 additions & 2 deletions source/include/rocprofiler-sdk/amd_detail/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ install(
FILES ${ROCPROFILER_AMD_DETAIL_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/amd_detail/
COMPONENT development)

add_subdirectory(rocprofiler-sdk-codeobj)

This file was deleted.

1 change: 1 addition & 0 deletions source/include/rocprofiler-sdk/cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ install(
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/cxx
COMPONENT development)

add_subdirectory(codeobj)
add_subdirectory(details)
6 changes: 6 additions & 0 deletions source/include/rocprofiler-sdk/cxx/codeobj/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(ROCPROFILER_CXX_CODEOBJ_HEADERS code_printing.hpp disassembly.hpp segment.hpp)

install(
FILES ${ROCPROFILER_CXX_CODEOBJ_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/cxx/codeobj
COMPONENT development)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

namespace rocprofiler
{
namespace sdk
{
namespace codeobj
{
namespace disassembly
Expand Down Expand Up @@ -423,4 +425,5 @@ class CodeobjAddressTranslate : public CodeobjMap

} // namespace disassembly
} // namespace codeobj
} // namespace sdk
} // namespace rocprofiler
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@

namespace rocprofiler
{
namespace sdk
{
namespace codeobj
{
namespace disassembly
Expand Down Expand Up @@ -333,4 +335,5 @@ class DisassemblyInstance

} // namespace disassembly
} // namespace codeobj
} // namespace sdk
} // namespace rocprofiler
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

namespace rocprofiler
{
namespace sdk
{
namespace codeobj
{
namespace segment
Expand Down Expand Up @@ -89,4 +91,5 @@ class CodeobjTableTranslator : public std::set<address_range_t>

} // namespace segment
} // namespace codeobj
} // namespace sdk
} // namespace rocprofiler
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <fstream>
#include <rocprofiler-sdk/amd_detail/rocprofiler-sdk-codeobj/code_printing.hpp>
#include <rocprofiler-sdk/cxx/codeobj/code_printing.hpp>
#include <string_view>
#include <vector>

Expand Down Expand Up @@ -84,7 +84,7 @@ GetCodeobjContents()

TEST(codeobj_library, segment_test)
{
using CodeobjTableTranslator = rocprofiler::codeobj::segment::CodeobjTableTranslator;
using CodeobjTableTranslator = rocprofiler::sdk::codeobj::segment::CodeobjTableTranslator;

CodeobjTableTranslator table;
std::unordered_set<size_t> used_addr{};
Expand Down Expand Up @@ -122,10 +122,10 @@ TEST(codeobj_library, segment_test)
}
}

namespace disassembly = rocprofiler::codeobj::disassembly;
namespace disassembly = rocprofiler::sdk::codeobj::disassembly;
namespace codeobjhelper = rocprofiler::testing::codeobjhelper;
using CodeobjDecoderComponent = rocprofiler::codeobj::disassembly::CodeobjDecoderComponent;
using LoadedCodeobjDecoder = rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder;
using CodeobjDecoderComponent = rocprofiler::sdk::codeobj::disassembly::CodeobjDecoderComponent;
using LoadedCodeobjDecoder = rocprofiler::sdk::codeobj::disassembly::LoadedCodeobjDecoder;

TEST(codeobj_library, file_opens)
{
Expand Down Expand Up @@ -192,7 +192,7 @@ TEST(codeobj_library, loaded_codeobj_component)

TEST(codeobj_library, codeobj_map_test)
{
using marker_id_t = rocprofiler::codeobj::segment::marker_id_t;
using marker_id_t = rocprofiler::sdk::codeobj::segment::marker_id_t;

const std::vector<char>& objdata = rocprofiler::testing::codeobjhelper::GetCodeobjContents();
constexpr size_t laddr1 = 0x1000;
Expand Down Expand Up @@ -221,7 +221,7 @@ TEST(codeobj_library, codeobj_map_test)

TEST(codeobj_library, codeobj_table_test)
{
using marker_id_t = rocprofiler::codeobj::segment::marker_id_t;
using marker_id_t = rocprofiler::sdk::codeobj::segment::marker_id_t;

const std::vector<std::string>& hiplines = codeobjhelper::GetHipccOutput();
const std::vector<char>& objdata = codeobjhelper::GetCodeobjContents();
Expand Down
8 changes: 4 additions & 4 deletions tests/pc_sampling/address_translation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#pragma once

#include <rocprofiler-sdk/amd_detail/rocprofiler-sdk-codeobj/code_printing.hpp>
#include <rocprofiler-sdk/cxx/codeobj/code_printing.hpp>

#include <algorithm>
#include <cassert>
Expand All @@ -38,9 +38,9 @@ namespace client
{
namespace address_translation
{
using Instruction = rocprofiler::codeobj::disassembly::Instruction;
using CodeobjAddressTranslate = rocprofiler::codeobj::disassembly::CodeobjAddressTranslate;
using marker_id_t = rocprofiler::codeobj::disassembly::marker_id_t;
using Instruction = rocprofiler::sdk::codeobj::disassembly::Instruction;
using CodeobjAddressTranslate = rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate;
using marker_id_t = rocprofiler::sdk::codeobj::disassembly::marker_id_t;

/**
* @brief Pair (code_object_id, pc_addr) uniquely identifies an instruction.
Expand Down
6 changes: 3 additions & 3 deletions tests/thread-trace/trace_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <rocprofiler-sdk/amd_detail/rocprofiler-sdk-codeobj/code_printing.hpp>
#include <rocprofiler-sdk/cxx/codeobj/code_printing.hpp>
#include "common.hpp"

#include <atomic>
Expand All @@ -50,8 +50,8 @@ namespace Callbacks
{
using code_obj_load_data_t = rocprofiler_callback_tracing_code_object_load_data_t;
using kernel_symbol_data_t = rocprofiler_callback_tracing_code_object_kernel_symbol_register_data_t;
using CodeobjAddressTranslate = rocprofiler::codeobj::disassembly::CodeobjAddressTranslate;
using Instruction = rocprofiler::codeobj::disassembly::Instruction;
using CodeobjAddressTranslate = rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate;
using Instruction = rocprofiler::sdk::codeobj::disassembly::Instruction;

CodeobjAddressTranslate* codeobjTranslate = nullptr;

Expand Down

0 comments on commit 20e07ca

Please sign in to comment.