Check to force tools to initialize the ctx id to zero. (#1135)
* Check to force tool to initialize the ctx id to zero. * initialize rocprofiler_context_id_t with 0 in units tests * changelog --------- Co-authored-by: Gopesh Bhardwaj <gopesh.bhardwaj@amd.com>
This commit is contained in:
committad av
GitHub
förälder
a92fa8f071
incheckning
3f91d90bbc
@@ -266,7 +266,7 @@ is_targeted_kernel(uint64_t _kern_id)
|
||||
auto&
|
||||
get_client_ctx()
|
||||
{
|
||||
static rocprofiler_context_id_t context_id;
|
||||
static rocprofiler_context_id_t context_id{0};
|
||||
return context_id;
|
||||
}
|
||||
|
||||
@@ -1270,7 +1270,7 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&get_client_ctx()), "create context failed");
|
||||
|
||||
auto code_obj_ctx = rocprofiler_context_id_t{};
|
||||
auto code_obj_ctx = rocprofiler_context_id_t{0};
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&code_obj_ctx), "failed to create context");
|
||||
|
||||
ROCPROFILER_CALL(
|
||||
@@ -1294,7 +1294,7 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
nullptr),
|
||||
"callback tracing service failed to configure");
|
||||
|
||||
auto pause_resume_ctx = rocprofiler_context_id_t{};
|
||||
auto pause_resume_ctx = rocprofiler_context_id_t{0};
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&pause_resume_ctx), "failed to create context");
|
||||
|
||||
ROCPROFILER_CALL(rocprofiler_configure_callback_tracing_service(
|
||||
@@ -1465,7 +1465,7 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
|
||||
if(tool::get_config().kernel_rename)
|
||||
{
|
||||
auto rename_ctx = rocprofiler_context_id_t{};
|
||||
auto rename_ctx = rocprofiler_context_id_t{0};
|
||||
auto marker_core_api_kinds = std::array<rocprofiler_tracing_operation_t, 3>{
|
||||
ROCPROFILER_MARKER_CORE_API_ID_roctxMarkA,
|
||||
ROCPROFILER_MARKER_CORE_API_ID_roctxRangePushA,
|
||||
|
||||
@@ -41,6 +41,7 @@ extern "C" {
|
||||
rocprofiler_status_t
|
||||
rocprofiler_create_context(rocprofiler_context_id_t* context_id)
|
||||
{
|
||||
if(context_id->handle != 0) return ROCPROFILER_STATUS_ERROR_CONTEXT_ID_NOT_ZERO;
|
||||
// context already registered
|
||||
if(rocprofiler::context::get_registered_context(*context_id))
|
||||
return ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID;
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace
|
||||
rocprofiler_context_id_t&
|
||||
get_client_ctx()
|
||||
{
|
||||
static rocprofiler_context_id_t ctx;
|
||||
static rocprofiler_context_id_t ctx{0};
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t,
|
||||
rocprofiler_context_id_t&
|
||||
get_client_ctx()
|
||||
{
|
||||
static rocprofiler_context_id_t ctx;
|
||||
static rocprofiler_context_id_t ctx{0};
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ struct callback_data
|
||||
{
|
||||
rocprofiler_client_id_t* client_id = nullptr;
|
||||
rocprofiler_client_finalize_t client_fini_func = nullptr;
|
||||
rocprofiler_context_id_t client_ctx = {};
|
||||
rocprofiler_context_id_t client_ctx = {0};
|
||||
rocprofiler_buffer_id_t client_buffer = {};
|
||||
rocprofiler_callback_thread_t client_thread = {};
|
||||
uint64_t client_workflow_count = {};
|
||||
@@ -344,7 +344,7 @@ TEST(pc_sampling, rocprofiler_configure_pc_sampling_service)
|
||||
|
||||
// We will create another context and try configuring pc sampling inside it,
|
||||
// that is supposed to fail.
|
||||
rocprofiler_context_id_t another_ctx;
|
||||
rocprofiler_context_id_t another_ctx{0};
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&another_ctx), "failed to create context");
|
||||
rocprofiler_buffer_id_t another_buff;
|
||||
ROCPROFILER_CALL(rocprofiler_create_buffer(another_ctx,
|
||||
|
||||
@@ -50,7 +50,7 @@ struct callback_data
|
||||
{
|
||||
rocprofiler_client_id_t* client_id = nullptr;
|
||||
rocprofiler_client_finalize_t client_fini_func = nullptr;
|
||||
rocprofiler_context_id_t client_ctx = {};
|
||||
rocprofiler_context_id_t client_ctx = {0};
|
||||
rocprofiler_buffer_id_t client_buffer = {};
|
||||
rocprofiler_callback_thread_t client_thread = {};
|
||||
uint64_t client_workflow_count = {};
|
||||
|
||||
@@ -46,7 +46,7 @@ struct callback_data
|
||||
{
|
||||
rocprofiler_client_id_t* client_id = nullptr;
|
||||
rocprofiler_client_finalize_t client_fini_func = nullptr;
|
||||
rocprofiler_context_id_t client_ctx = {};
|
||||
rocprofiler_context_id_t client_ctx = {0};
|
||||
rocprofiler_buffer_id_t client_buffer = {};
|
||||
rocprofiler_callback_thread_t client_thread = {};
|
||||
uint64_t client_workflow_count = {};
|
||||
|
||||
@@ -58,7 +58,7 @@ struct callback_data
|
||||
{
|
||||
rocprofiler_client_id_t* client_id = nullptr;
|
||||
rocprofiler_client_finalize_t client_fini_func = nullptr;
|
||||
rocprofiler_context_id_t client_ctx = {};
|
||||
rocprofiler_context_id_t client_ctx = {0};
|
||||
rocprofiler_buffer_id_t client_buffer = {};
|
||||
rocprofiler_callback_thread_t client_thread = {};
|
||||
uint64_t client_workflow_count = {};
|
||||
|
||||
@@ -55,6 +55,8 @@ ROCPROFILER_STATUS_STRING(ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID,
|
||||
ROCPROFILER_STATUS_STRING(ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_STARTED, "Context failed to start")
|
||||
ROCPROFILER_STATUS_STRING(ROCPROFILER_STATUS_ERROR_CONTEXT_CONFLICT,
|
||||
"Context has a conflict with another context")
|
||||
ROCPROFILER_STATUS_STRING(ROCPROFILER_STATUS_ERROR_CONTEXT_ID_NOT_ZERO,
|
||||
"Context ID should be initialized to zero")
|
||||
ROCPROFILER_STATUS_STRING(
|
||||
ROCPROFILER_STATUS_ERROR_BUFFER_BUSY,
|
||||
"Buffer operation failed because it is currently busy handling another request")
|
||||
|
||||
@@ -56,7 +56,7 @@ struct callback_data
|
||||
{
|
||||
rocprofiler_client_id_t* client_id = nullptr;
|
||||
rocprofiler_client_finalize_t client_fini_func = nullptr;
|
||||
rocprofiler_context_id_t client_ctx = {};
|
||||
rocprofiler_context_id_t client_ctx = {0};
|
||||
rocprofiler_buffer_id_t client_buffer = {};
|
||||
rocprofiler_callback_thread_t client_thread = {};
|
||||
uint64_t client_workflow_count = {};
|
||||
@@ -73,7 +73,7 @@ struct callback_data_ext
|
||||
|
||||
rocprofiler_client_id_t* client_id = nullptr;
|
||||
rocprofiler_client_finalize_t client_fini_func = nullptr;
|
||||
rocprofiler_context_id_t client_hsa_ctx = {};
|
||||
rocprofiler_context_id_t client_hsa_ctx = {0};
|
||||
rocprofiler_context_id_t client_hip_ctx = {};
|
||||
rocprofiler_buffer_id_t client_buffer = {};
|
||||
rocprofiler_callback_thread_t client_thread = {};
|
||||
|
||||
@@ -60,7 +60,7 @@ struct callback_data
|
||||
{
|
||||
rocprofiler_client_id_t* client_id = nullptr;
|
||||
rocprofiler_client_finalize_t client_fini_func = nullptr;
|
||||
rocprofiler_context_id_t client_ctx = {};
|
||||
rocprofiler_context_id_t client_ctx = {0};
|
||||
rocprofiler_buffer_id_t client_buffer = {};
|
||||
rocprofiler_callback_thread_t client_thread = {};
|
||||
uint64_t client_workflow_count = {};
|
||||
@@ -472,7 +472,7 @@ TEST(rocprofiler_lib, buffered_external_correlation)
|
||||
return &cfg_result;
|
||||
};
|
||||
|
||||
auto ctx = rocprofiler_context_id_t{};
|
||||
auto ctx = rocprofiler_context_id_t{0};
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_EQ(rocprofiler_force_configure(rocp_init), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
|
||||
@@ -225,7 +225,7 @@ TEST(rocprofiler_lib, registration_lambda_no_result)
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
auto ctx = rocprofiler_context_id_t{};
|
||||
auto ctx = rocprofiler_context_id_t{0};
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_EQ(rocprofiler_force_configure(rocp_init), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
@@ -313,7 +313,7 @@ TEST(rocprofiler_lib, callback_registration_lambda_with_result)
|
||||
return std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
};
|
||||
|
||||
auto ctx = rocprofiler_context_id_t{};
|
||||
auto ctx = rocprofiler_context_id_t{0};
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_EQ(rocprofiler_force_configure(rocp_init), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
@@ -469,7 +469,7 @@ TEST(rocprofiler_lib, buffer_registration_lambda_with_result)
|
||||
return &cfg_result;
|
||||
};
|
||||
|
||||
auto ctx = rocprofiler_context_id_t{};
|
||||
auto ctx = rocprofiler_context_id_t{0};
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_EQ(rocprofiler_force_configure(rocp_init), ROCPROFILER_STATUS_SUCCESS);
|
||||
EXPECT_NE(rocprofiler_create_context(&ctx), ROCPROFILER_STATUS_SUCCESS);
|
||||
|
||||
@@ -309,7 +309,7 @@ TEST(rocprofiler_lib, roctx_callback_tracing)
|
||||
cb_data->client_workflow_count++;
|
||||
cb_data->client_fini_func = fini_func;
|
||||
|
||||
auto pause_resume_ctx = rocprofiler_context_id_t{};
|
||||
auto pause_resume_ctx = rocprofiler_context_id_t{0};
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&pause_resume_ctx), "failed to create context");
|
||||
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&cb_data->client_ctx),
|
||||
@@ -425,7 +425,7 @@ TEST(rocprofiler_lib, roctx_buffered_tracing)
|
||||
cb_data->client_workflow_count++;
|
||||
cb_data->client_fini_func = fini_func;
|
||||
|
||||
auto pause_resume_ctx = rocprofiler_context_id_t{};
|
||||
auto pause_resume_ctx = rocprofiler_context_id_t{0};
|
||||
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&pause_resume_ctx), "failed to create context");
|
||||
ROCPROFILER_CALL(rocprofiler_configure_callback_tracing_service(
|
||||
|
||||
@@ -134,7 +134,7 @@ TEST(thread_trace, configure_test)
|
||||
registration::init_logging();
|
||||
registration::set_init_status(-1);
|
||||
context::push_client(1);
|
||||
rocprofiler_context_id_t ctx;
|
||||
rocprofiler_context_id_t ctx{0};
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&ctx), "context creation failed");
|
||||
|
||||
std::vector<rocprofiler_att_parameter_t> params;
|
||||
@@ -171,7 +171,7 @@ TEST(thread_trace, perfcounters_configure_test)
|
||||
registration::init_logging();
|
||||
registration::set_init_status(-1);
|
||||
context::push_client(1);
|
||||
rocprofiler_context_id_t ctx;
|
||||
rocprofiler_context_id_t ctx{0};
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&ctx), "context creation failed");
|
||||
|
||||
// Only GFX9 SQ Block counters are supported
|
||||
@@ -299,7 +299,7 @@ TEST(thread_trace, agent_configure_test)
|
||||
registration::init_logging();
|
||||
registration::set_init_status(-1);
|
||||
context::push_client(1);
|
||||
rocprofiler_context_id_t ctx;
|
||||
rocprofiler_context_id_t ctx{0};
|
||||
ROCPROFILER_CALL(rocprofiler_create_context(&ctx), "context creation failed");
|
||||
|
||||
ROCPROFILER_CALL(rocprofiler_query_available_agents(ROCPROFILER_AGENT_INFO_VERSION_0,
|
||||
|
||||
Referens i nytt ärende
Block a user