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
This commit is contained in:
Jonathan R. Madsen authored and GitHub committed 2024-02-29 23:49:54 -06:00
1 parent 31dcfabe23
commit a1267e1fd2
27 files changed
+432 -23

No files matched your search

+1 -1
View File
@@ -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
+4 -1
View File
@@ -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>
+4 -1
View File
@@ -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>
+4 -1
View File
@@ -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>