C compatibility for public headers (#566)
* C compatibility for public headers
- add tests/tools/c-tool.c
- builds a tool (which does nothing) with C language
- ensures that tool can be compiled in C
- add tests/c-tool/CMakeLists.txt
- ensures that tool library build from C is a valid tool
- rocprofiler_counter_info_v0_t is_derived is int instead of bool
- C does not have bool unless <stdbool.h> is included
- add `include/rocprofiler-sdk/hsa/api_trace_version.h
- handles providing HSA_*_TABLE_(MAJOR|STEP)_VERSION values if compiled from C
- cmake define in version.h.in for ROCPROFILER_HSA_*_TABLE_(MAJOR|STEP)_VERSION
- HSA table versions compiled with
- use rocprofiler_(hsa|hip|marker)_api_no_args struct to handle incompatibility b/t empty structs in C vs. C++ (size of 0 vs. size of 1)
- extern "C" in include/rocprofiler-sdk/{hsa,hip,marker}/api_args.h
- fixed spelling error: derrived -> derived
- scope YY_NO_INPUT compile definition to lib/rocprofiler-sdk/counters/parser/*
* Revert CDash dashboard
Este commit está contenido en:
cometido por
GitHub
padre
31dcfabe23
commit
a1267e1fd2
@@ -176,8 +176,6 @@ if(ROCPROFILER_UNSAFE_NO_VERSION_CHECK)
|
||||
INTERFACE ROCPROFILER_UNSAFE_NO_VERSION_CHECK)
|
||||
endif()
|
||||
|
||||
rocprofiler_target_compile_definitions(rocprofiler-build-flags INTERFACE YY_NO_INPUT)
|
||||
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# user customization
|
||||
#
|
||||
|
||||
@@ -138,6 +138,8 @@ target_link_libraries(rocprofiler-hsa-runtime INTERFACE hsa-runtime64::hsa-runti
|
||||
rocprofiler_config_nolink_target(rocprofiler-hsa-runtime-nolink
|
||||
hsa-runtime64::hsa-runtime64)
|
||||
|
||||
rocprofiler_parse_hsa_api_table_versions(rocprofiler-hsa-runtime-nolink)
|
||||
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# amd comgr
|
||||
|
||||
@@ -945,4 +945,57 @@ function(COMPUTE_POW2_CEIL _OUTPUT _VALUE)
|
||||
|
||||
endfunction()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Parses headers in hsa/hsa_api_trace*.h for API table version numbers
|
||||
#
|
||||
function(rocprofiler_parse_hsa_api_table_versions _TARGET)
|
||||
get_target_property(HSA_API_TRACE_HEADER_PATH ${_TARGET}
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
|
||||
|
||||
if(HSA_API_TRACE_HEADER AND NOT EXISTS "${HSA_API_TRACE_HEADER}")
|
||||
unset(HSA_API_TRACE_HEADER CACHE)
|
||||
endif()
|
||||
|
||||
find_file(
|
||||
HSA_API_TRACE_HEADER
|
||||
NAMES hsa_api_trace_version.h hsa_api_trace.h
|
||||
HINTS ${HSA_API_TRACE_HEADER_PATH}
|
||||
PATHS ${HSA_API_TRACE_HEADER_PATH}
|
||||
PATH_SUFFIXES hsa
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
if(EXISTS "${HSA_API_TRACE_HEADER}")
|
||||
file(READ "${HSA_API_TRACE_HEADER}" HSA_API_TRACE_HEADER_CONTENTS)
|
||||
string(REPLACE "\n" ";" HSA_API_TRACE_HEADER_CONTENTS
|
||||
"${HSA_API_TRACE_HEADER_CONTENTS}")
|
||||
|
||||
foreach(_LINE ${HSA_API_TRACE_HEADER_CONTENTS})
|
||||
if("${_LINE}" MATCHES ".*define HSA_.*_(MAJOR|STEP)_VERSION .*")
|
||||
# message(STATUS "LINE: ${_LINE}")
|
||||
string(
|
||||
REGEX
|
||||
REPLACE
|
||||
"#[ ]*define HSA_([A-Z_]*)API_TABLE_(MAJOR|STEP)_VERSION [ ]*(0x[0-9A-Fa-f]+)"
|
||||
"HSA_\\1API_TABLE_\\2_VERSION"
|
||||
_VAR
|
||||
"${_LINE}")
|
||||
string(
|
||||
REGEX
|
||||
REPLACE
|
||||
"#[ ]*define HSA_([A-Z_]*)API_TABLE_(MAJOR|STEP)_VERSION [ ]*(0x[0-9A-Fa-f]+)"
|
||||
"\\3"
|
||||
_VAL
|
||||
"${_LINE}")
|
||||
|
||||
# used with cmakedefine in source/include/rocprofiler-sdk/version.h.in
|
||||
if(_VAR AND _VAL)
|
||||
set(ROCPROFILER_${_VAR}
|
||||
"${_VAL}"
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
cmake_policy(POP)
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "common/defines.hpp"
|
||||
#include "common/filesystem.hpp"
|
||||
|
||||
#include <hsa/hsa_api_trace.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
@@ -55,8 +57,6 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include "common/defines.hpp"
|
||||
#include "common/filesystem.hpp"
|
||||
|
||||
namespace client
|
||||
{
|
||||
|
||||
@@ -531,11 +531,11 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int is_derived; ///< If this counter is a derived counter
|
||||
const char* name; ///< Name of the counter
|
||||
const char* description; ///< Description of the counter
|
||||
bool is_derived; ///< If this counter is a derrived counter
|
||||
const char* block; ///< Block of the counter (non-derrived only)
|
||||
const char* expression; ///< Counter expression (derrived counters only)
|
||||
const char* block; ///< Block of the counter (non-derived only)
|
||||
const char* expression; ///< Counter expression (derived counters only)
|
||||
} rocprofiler_counter_info_v0_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/defines.h>
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
@@ -30,6 +31,18 @@
|
||||
// must be included after
|
||||
#include <hip/hip_deprecated.h>
|
||||
|
||||
#include <hip/amd_detail/amd_hip_gl_interop.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// This struct is added to the union members which represent
|
||||
// functions with no arguments to ensure ABI compatibility
|
||||
typedef struct rocprofiler_hip_api_no_args
|
||||
{
|
||||
char empty;
|
||||
} rocprofiler_hip_api_no_args;
|
||||
|
||||
typedef union rocprofiler_hip_api_retval_u
|
||||
{
|
||||
int int_retval;
|
||||
@@ -277,6 +290,9 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipCtxSetSharedMemConfig;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hip_api_no_args struct to fix this
|
||||
rocprofiler_hip_api_no_args no_args;
|
||||
} hipCtxSynchronize;
|
||||
struct
|
||||
{
|
||||
@@ -419,6 +435,9 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipDevicePrimaryCtxSetFlags;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hip_api_no_args struct to fix this
|
||||
rocprofiler_hip_api_no_args no_args;
|
||||
} hipDeviceReset;
|
||||
struct
|
||||
{
|
||||
@@ -446,6 +465,9 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipDeviceSetSharedMemConfig;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hip_api_no_args struct to fix this
|
||||
rocprofiler_hip_api_no_args no_args;
|
||||
} hipDeviceSynchronize;
|
||||
struct
|
||||
{
|
||||
@@ -668,6 +690,9 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipGetErrorString;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hip_api_no_args struct to fix this
|
||||
rocprofiler_hip_api_no_args no_args;
|
||||
} hipGetLastError;
|
||||
struct
|
||||
{
|
||||
@@ -2045,6 +2070,9 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipOccupancyMaxPotentialBlockSize;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hip_api_no_args struct to fix this
|
||||
rocprofiler_hip_api_no_args no_args;
|
||||
} hipPeekAtLastError;
|
||||
struct
|
||||
{
|
||||
@@ -2065,9 +2093,15 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipPointerSetAttribute;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hip_api_no_args struct to fix this
|
||||
rocprofiler_hip_api_no_args no_args;
|
||||
} hipProfilerStart;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hip_api_no_args struct to fix this
|
||||
rocprofiler_hip_api_no_args no_args;
|
||||
} hipProfilerStop;
|
||||
struct
|
||||
{
|
||||
@@ -2736,3 +2770,5 @@ typedef union rocprofiler_hip_api_args_u
|
||||
// hipCtx_t ctx;
|
||||
// } hipDrvGraphAddMemsetNode;
|
||||
} rocprofiler_hip_api_args_t;
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
|
||||
@@ -32,12 +32,14 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <hsa/hsa.h>
|
||||
|
||||
#include <rocprofiler-sdk/hsa/api_trace_version.h>
|
||||
|
||||
#include <rocprofiler-sdk/hsa/api_args.h>
|
||||
#include <rocprofiler-sdk/hsa/api_id.h>
|
||||
#include <rocprofiler-sdk/hsa/table_id.h>
|
||||
|
||||
#include <hsa/hsa.h>
|
||||
|
||||
#if defined(ROCPROFILER_DEFINED_AMD_INTERNAL_BUILD) && ROCPROFILER_DEFINED_AMD_INTERNAL_BUILD > 0
|
||||
# undef AMD_INTERNAL_BUILD
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
# Installation of public HSA headers
|
||||
#
|
||||
#
|
||||
set(ROCPROFILER_HSA_HEADER_FILES amd_ext_api_id.h api_args.h api_id.h core_api_id.h
|
||||
finalize_ext_api_id.h image_ext_api_id.h table_id.h)
|
||||
set(ROCPROFILER_HSA_HEADER_FILES
|
||||
amd_ext_api_id.h api_args.h api_id.h api_trace_version.h core_api_id.h
|
||||
finalize_ext_api_id.h image_ext_api_id.h table_id.h)
|
||||
|
||||
install(
|
||||
FILES ${ROCPROFILER_HSA_HEADER_FILES}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/hsa/api_trace_version.h>
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,14 +22,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/defines.h>
|
||||
#include <rocprofiler-sdk/hsa/api_trace_version.h>
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#include <hsa/hsa.h>
|
||||
#include <hsa/hsa_api_trace.h>
|
||||
#include <hsa/hsa_ext_amd.h>
|
||||
#include <hsa/hsa_ext_finalize.h>
|
||||
#include <hsa/hsa_ext_image.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// This struct is added to the union members which represent
|
||||
// functions with no arguments to ensure ABI compatibility
|
||||
typedef struct rocprofiler_hsa_api_no_args
|
||||
{
|
||||
char empty;
|
||||
} rocprofiler_hsa_api_no_args;
|
||||
|
||||
typedef union rocprofiler_hsa_api_retval_u
|
||||
{
|
||||
uint64_t uint64_t_retval;
|
||||
@@ -38,18 +49,38 @@ typedef union rocprofiler_hsa_api_retval_u
|
||||
hsa_status_t hsa_status_t_retval;
|
||||
} rocprofiler_hsa_api_retval_t;
|
||||
|
||||
// the following hsa_* typedefs are only in hsa/hsa_api_trace.h but we cannot include that file here
|
||||
// because it is not C-compatible
|
||||
typedef hsa_status_t (*hsa_ext_program_iterate_modules_cb_t)(hsa_ext_program_t program,
|
||||
hsa_ext_module_t module,
|
||||
void* data);
|
||||
|
||||
typedef void (*hsa_amd_queue_intercept_packet_writer)(const void* pkts, uint64_t pkt_count);
|
||||
|
||||
typedef void (*hsa_amd_queue_intercept_handler)(const void* pkts,
|
||||
uint64_t pkt_count,
|
||||
uint64_t user_pkt_index,
|
||||
void* data,
|
||||
hsa_amd_queue_intercept_packet_writer writer);
|
||||
|
||||
typedef void (*hsa_amd_runtime_queue_notifier)(const hsa_queue_t* queue,
|
||||
hsa_agent_t agent,
|
||||
void* data);
|
||||
|
||||
typedef union rocprofiler_hsa_api_args_u
|
||||
{
|
||||
// block: CoreApi API
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hsa_api_no_args struct to fix this
|
||||
rocprofiler_hsa_api_no_args no_args;
|
||||
} hsa_init;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_hsa_api_no_args struct to fix this
|
||||
rocprofiler_hsa_api_no_args no_args;
|
||||
} hsa_shut_down;
|
||||
struct
|
||||
{
|
||||
@@ -1360,3 +1391,5 @@ typedef union rocprofiler_hsa_api_args_u
|
||||
# endif
|
||||
#endif
|
||||
} rocprofiler_hsa_api_args_t;
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
# include <hsa/hsa_api_trace.h> // safe to include from C++
|
||||
#elif defined(__has_include)
|
||||
# if __has_include(<hsa/hsa_api_trace_version.h>)
|
||||
# include <hsa/hsa_api_trace_version.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_API_TABLE_MAJOR_VERSION
|
||||
# ifdef ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION
|
||||
# define HSA_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_CORE_API_TABLE_MAJOR_VERSION
|
||||
# ifdef ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION
|
||||
# define HSA_CORE_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_AMD_EXT_API_TABLE_MAJOR_VERSION
|
||||
# ifdef ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION
|
||||
# define HSA_AMD_EXT_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_FINALIZER_API_TABLE_MAJOR_VERSION
|
||||
# ifdef ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION
|
||||
# define HSA_FINALIZER_API_TABLE_MAJOR_VERSION \
|
||||
ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_IMAGE_API_TABLE_MAJOR_VERSION
|
||||
# ifdef ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION
|
||||
# define HSA_IMAGE_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION
|
||||
# ifdef ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION
|
||||
# define HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION \
|
||||
ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_TOOLS_API_TABLE_MAJOR_VERSION
|
||||
# ifdef ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION
|
||||
# define HSA_TOOLS_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_API_TABLE_STEP_VERSION
|
||||
# ifdef ROCPROFILER_HSA_API_TABLE_STEP_VERSION
|
||||
# define HSA_API_TABLE_STEP_VERSION ROCPROFILER_HSA_API_TABLE_STEP_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_CORE_API_TABLE_STEP_VERSION
|
||||
# ifdef ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION
|
||||
# define HSA_CORE_API_TABLE_STEP_VERSION ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_AMD_EXT_API_TABLE_STEP_VERSION
|
||||
# ifdef ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION
|
||||
# define HSA_AMD_EXT_API_TABLE_STEP_VERSION ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_FINALIZER_API_TABLE_STEP_VERSION
|
||||
# ifdef ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION
|
||||
# define HSA_FINALIZER_API_TABLE_STEP_VERSION \
|
||||
ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_IMAGE_API_TABLE_STEP_VERSION
|
||||
# ifdef ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION
|
||||
# define HSA_IMAGE_API_TABLE_STEP_VERSION ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_AQLPROFILE_API_TABLE_STEP_VERSION
|
||||
# ifdef ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION
|
||||
# define HSA_AQLPROFILE_API_TABLE_STEP_VERSION \
|
||||
ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HSA_TOOLS_API_TABLE_STEP_VERSION
|
||||
# ifdef ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION
|
||||
# define HSA_TOOLS_API_TABLE_STEP_VERSION ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION
|
||||
# endif
|
||||
#endif
|
||||
@@ -22,11 +22,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/defines.h>
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#include <rocprofiler-sdk-roctx/api_trace.h>
|
||||
#include <rocprofiler-sdk-roctx/types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// This struct is added to the union members which represent
|
||||
// functions with no arguments to ensure ABI compatibility
|
||||
typedef struct rocprofiler_marker_api_no_args
|
||||
{
|
||||
char empty;
|
||||
} rocprofiler_marker_api_no_args;
|
||||
|
||||
typedef union rocprofiler_marker_api_retval_u
|
||||
{
|
||||
int32_t int32_t_retval;
|
||||
@@ -46,6 +59,9 @@ typedef union rocprofiler_marker_api_args_u
|
||||
} roctxRangePushA;
|
||||
struct
|
||||
{
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// Add the rocprofiler_marker_api_no_args struct to fix this
|
||||
rocprofiler_marker_api_no_args no_args;
|
||||
} roctxRangePop;
|
||||
struct
|
||||
{
|
||||
@@ -87,3 +103,5 @@ typedef union rocprofiler_marker_api_args_u
|
||||
const struct ihipStream_t* stream;
|
||||
} roctxNameHipStream;
|
||||
} rocprofiler_marker_api_args_t;
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
|
||||
@@ -105,6 +105,22 @@
|
||||
|
||||
#define ROCPROFILER_HSA_RUNTIME_VERSION_MAJOR @HSA_RUNTIME_VERSION_MAJOR@
|
||||
#define ROCPROFILER_HSA_RUNTIME_VERSION_MINOR @HSA_RUNTIME_VERSION_MINOR@
|
||||
|
||||
#cmakedefine ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION@
|
||||
|
||||
#cmakedefine ROCPROFILER_HSA_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_API_TABLE_STEP_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION@
|
||||
#cmakedefine ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION@
|
||||
// clang-format on
|
||||
|
||||
#define ROCPROFILER_VERSION \
|
||||
|
||||
@@ -64,9 +64,9 @@ rocprofiler_query_counter_info(rocprofiler_counter_id_t counter_id,
|
||||
|
||||
if(const auto* metric_ptr = rocprofiler::common::get_val(id_map, counter_id.handle))
|
||||
{
|
||||
out_struct.is_derived = (metric_ptr->expression().empty()) ? 0 : 1;
|
||||
out_struct.name = metric_ptr->name().c_str();
|
||||
out_struct.description = metric_ptr->description().c_str();
|
||||
out_struct.is_derived = !metric_ptr->expression().empty();
|
||||
out_struct.block = metric_ptr->block().c_str();
|
||||
out_struct.expression = metric_ptr->expression().c_str();
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
|
||||
@@ -121,7 +121,7 @@ get_ast_map()
|
||||
const auto& metric_map = *CHECK_NOTNULL(counters::getMetricMap());
|
||||
for(const auto& [gfx, metrics] : metric_map)
|
||||
{
|
||||
// TODO: Remove global XML from derrived counters...
|
||||
// TODO: Remove global XML from derived counters...
|
||||
if(gfx == "global") continue;
|
||||
|
||||
std::unordered_map<std::string, Metric> by_name;
|
||||
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
using EvaluateASTMap = std::unordered_map<std::string, EvaluateAST>;
|
||||
|
||||
/**
|
||||
* Construct the ASTs for all counters appearing in basic/derrived counter
|
||||
* Construct the ASTs for all counters appearing in basic/derived counter
|
||||
* definition files.
|
||||
*/
|
||||
const std::unordered_map<std::string, EvaluateASTMap>&
|
||||
@@ -193,7 +193,7 @@ get_ast_map();
|
||||
|
||||
/**
|
||||
* Get the required basic/hardware counters needed to evaluate a
|
||||
* specific metric (may be multiple HW counters if a derrived metric).
|
||||
* specific metric (may be multiple HW counters if a derived metric).
|
||||
*/
|
||||
std::optional<std::set<Metric>>
|
||||
get_required_hardware_counters(const std::unordered_map<std::string, EvaluateASTMap>& asts,
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace rocprofiler
|
||||
{
|
||||
namespace counters
|
||||
{
|
||||
// Base metrics (w/o instance information) defined in gfx_metrics/derrived.xml
|
||||
// Base metrics (w/o instance information) defined in gfx_metrics/derived.xml
|
||||
class Metric
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -40,6 +40,7 @@ endif()
|
||||
|
||||
target_sources(rocprofiler-expr-parser PRIVATE ${expr_parser_sources})
|
||||
target_include_directories(rocprofiler-expr-parser PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_compile_definitions(rocprofiler-expr-parser PRIVATE YY_NO_INPUT)
|
||||
target_link_libraries(rocprofiler-expr-parser
|
||||
PRIVATE rocprofiler::rocprofiler-common-library)
|
||||
target_sources(rocprofiler-object-library
|
||||
|
||||
@@ -130,7 +130,10 @@ template <typename DataArgsT, typename... Args>
|
||||
auto
|
||||
hip_api_impl<TableIdx, OpIdx>::set_data_args(DataArgsT& _data_args, Args... args)
|
||||
{
|
||||
_data_args = DataArgsT{args...};
|
||||
if constexpr(sizeof...(Args) == 0)
|
||||
_data_args.no_args.empty = '\0';
|
||||
else
|
||||
_data_args = DataArgsT{args...};
|
||||
}
|
||||
|
||||
template <size_t TableIdx, size_t OpIdx>
|
||||
|
||||
@@ -176,7 +176,10 @@ template <typename DataArgsT, typename... Args>
|
||||
auto
|
||||
hsa_api_impl<TableIdx, OpIdx>::set_data_args(DataArgsT& _data_args, Args... args)
|
||||
{
|
||||
_data_args = DataArgsT{args...};
|
||||
if constexpr(sizeof...(Args) == 0)
|
||||
_data_args.no_args.empty = '\0';
|
||||
else
|
||||
_data_args = DataArgsT{args...};
|
||||
}
|
||||
|
||||
template <size_t TableIdx, size_t OpIdx>
|
||||
|
||||
@@ -93,7 +93,10 @@ template <typename DataArgsT, typename... Args>
|
||||
auto
|
||||
roctx_api_impl<TableIdx, OpIdx>::set_data_args(DataArgsT& _data_args, Args... args)
|
||||
{
|
||||
_data_args = DataArgsT{args...};
|
||||
if constexpr(sizeof...(Args) == 0)
|
||||
_data_args.no_args.empty = '\0';
|
||||
else
|
||||
_data_args = DataArgsT{args...};
|
||||
}
|
||||
|
||||
template <size_t TableIdx, size_t OpIdx>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hsa/hsa.h>
|
||||
#include <hsa/hsa_api_trace.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -12,8 +12,8 @@ import multiprocessing
|
||||
|
||||
# this constant is used to define CTEST_PROJECT_NAME
|
||||
# and default value for CTEST_SUBMIT_URL
|
||||
_PROJECT_NAME = "rocprofiler-sdk-internal"
|
||||
_BASE_URL = "rocprofiler0.amd.com:30915"
|
||||
_PROJECT_NAME = "rocprofiler-v2-internal"
|
||||
_BASE_URL = "10.194.116.31/cdash"
|
||||
_GCOVR_GENERATE_CMD = None
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ add_subdirectory(apps)
|
||||
# validation tests
|
||||
add_subdirectory(kernel-tracing)
|
||||
add_subdirectory(async-copy-tracing)
|
||||
add_subdirectory(c-tool)
|
||||
|
||||
# rocprofv3 validation tests
|
||||
add_subdirectory(rocprofv3)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR)
|
||||
|
||||
project(
|
||||
rocprofiler-tests-c-tool
|
||||
LANGUAGES CXX
|
||||
VERSION 0.0.0)
|
||||
|
||||
find_package(rocprofiler-sdk REQUIRED)
|
||||
|
||||
if(ROCPROFILER_MEMCHECK_PRELOAD_ENV)
|
||||
set(PRELOAD_ENV
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}:$<TARGET_FILE:rocprofiler-sdk-c-tool>")
|
||||
else()
|
||||
set(PRELOAD_ENV "LD_PRELOAD=$<TARGET_FILE:rocprofiler-sdk-c-tool>")
|
||||
endif()
|
||||
|
||||
add_test(NAME test-c-tool-execute COMMAND $<TARGET_FILE:transpose> 1)
|
||||
|
||||
set(c-tool-env
|
||||
"${PRELOAD_ENV}"
|
||||
"LD_LIBRARY_PATH=$<TARGET_FILE_DIR:rocprofiler::rocprofiler-shared-library>:$ENV{LD_LIBRARY_PATH}"
|
||||
)
|
||||
|
||||
set_tests_properties(
|
||||
test-c-tool-execute
|
||||
PROPERTIES TIMEOUT
|
||||
45
|
||||
LABELS
|
||||
"integration-tests"
|
||||
ENVIRONMENT
|
||||
"${c-tool-env}"
|
||||
PASS_REGULAR_EXPRESSION
|
||||
"Test C tool is using rocprofiler-sdk v([0-9]+\\.[0-9]+\\.[0-9]+)"
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"threw an exception")
|
||||
@@ -5,11 +5,12 @@ cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR)
|
||||
|
||||
project(
|
||||
rocprofiler-tests-json-tool
|
||||
LANGUAGES CXX
|
||||
LANGUAGES C CXX
|
||||
VERSION 0.0.0)
|
||||
|
||||
find_package(rocprofiler-sdk REQUIRED)
|
||||
|
||||
# tool library supporting JSON and perfetto output
|
||||
add_library(rocprofiler-sdk-json-tool SHARED)
|
||||
target_sources(rocprofiler-sdk-json-tool PRIVATE json-tool.cpp)
|
||||
target_link_libraries(
|
||||
@@ -28,3 +29,16 @@ install(
|
||||
TARGETS rocprofiler-sdk-json-tool
|
||||
DESTINATION lib/rocprofiler-sdk
|
||||
COMPONENT tests)
|
||||
|
||||
# tool library which just checks that tools can be compiled with C language
|
||||
add_library(rocprofiler-sdk-c-tool SHARED)
|
||||
target_sources(rocprofiler-sdk-c-tool PRIVATE c-tool.c)
|
||||
target_link_libraries(rocprofiler-sdk-c-tool PRIVATE rocprofiler::rocprofiler
|
||||
rocprofiler::tests-build-flags)
|
||||
set_target_properties(
|
||||
rocprofiler-sdk-c-tool
|
||||
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/rocprofiler-sdk"
|
||||
SOVERSION ${PROJECT_VERSION_MINOR}
|
||||
VERSION
|
||||
${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
||||
INSTALL_RPATH "\$ORIGIN:\$ORIGIN/..")
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// undefine NDEBUG so asserts are implemented
|
||||
#ifdef NDEBUG
|
||||
# undef NDEBUG
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file samples/c_tool/client.cpp
|
||||
*
|
||||
* @brief Example rocprofiler client (tool) written in C
|
||||
*/
|
||||
|
||||
#include <rocprofiler-sdk/registration.h>
|
||||
#include <rocprofiler-sdk/rocprofiler.h>
|
||||
|
||||
rocprofiler_tool_configure_result_t*
|
||||
rocprofiler_configure(uint32_t version,
|
||||
const char* runtime_version,
|
||||
uint32_t priority,
|
||||
rocprofiler_client_id_t* id)
|
||||
{
|
||||
// only activate if main tool
|
||||
if(priority > 0) return NULL;
|
||||
|
||||
// set the client name
|
||||
id->name = "Test C tool";
|
||||
|
||||
// compute major/minor/patch version info
|
||||
uint32_t major = version / 10000;
|
||||
uint32_t minor = (version % 10000) / 100;
|
||||
uint32_t patch = version % 100;
|
||||
|
||||
// generate info string
|
||||
printf("%s is using rocprofiler-sdk v%i.%i.%i (%s)\n",
|
||||
id->name,
|
||||
major,
|
||||
minor,
|
||||
patch,
|
||||
runtime_version);
|
||||
|
||||
// return pointer to configure data
|
||||
return NULL;
|
||||
}
|
||||
Referencia en una nueva incidencia
Block a user