From 399f2cc660ca884867b1cc16decc8c488491ba60 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Mon, 22 Apr 2024 22:26:01 -0500 Subject: [PATCH] Remove -Wno-missing-field-initializers from build flags (#810) * Remove -Wno-missing-field-initializers - Compiler errors if missing field initializers * Update lib/rocprofiler-sdk/counters/evaluate_ast.cpp - copy over dispatch ID in perform_reduction/evaluate [ROCm/rocprofiler-sdk commit: 48273d6a65574c6ce5b385092d26b029f01542fb] --- .../cmake/rocprofiler_build_settings.cmake | 5 +- .../lib/rocprofiler-sdk/aql/helpers.cpp | 4 +- .../lib/rocprofiler-sdk/aql/tests/helpers.cpp | 15 ++++- .../rocprofiler-sdk/counters/evaluate_ast.cpp | 61 +++++++++++-------- .../counters/tests/evaluate_ast_test.cpp | 50 ++++++++------- .../source/lib/rocprofiler-sdk/hsa/queue.cpp | 7 ++- .../rocprofiler-sdk/hsa/queue_controller.cpp | 59 +++++++++++++++++- .../page_migration/page_migration.cpp | 5 +- 8 files changed, 145 insertions(+), 61 deletions(-) diff --git a/projects/rocprofiler-sdk/cmake/rocprofiler_build_settings.cmake b/projects/rocprofiler-sdk/cmake/rocprofiler_build_settings.cmake index 8b6b16716a..2e3e0d0e35 100644 --- a/projects/rocprofiler-sdk/cmake/rocprofiler_build_settings.cmake +++ b/projects/rocprofiler-sdk/cmake/rocprofiler_build_settings.cmake @@ -63,9 +63,8 @@ target_link_libraries(rocprofiler-build-flags INTERFACE rocprofiler::rocprofiler # ----------------------------------------------------------------------------------------# # set the compiler flags # -rocprofiler_target_compile_options( - rocprofiler-build-flags INTERFACE "-W" "-Wall" "-Wno-unknown-pragmas" - "-Wno-missing-field-initializers") +rocprofiler_target_compile_options(rocprofiler-build-flags + INTERFACE "-W" "-Wall" "-Wno-unknown-pragmas") # ----------------------------------------------------------------------------------------# # extra flags for debug information in debug or optimized binaries diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/helpers.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/helpers.cpp index 12080ca56d..cc6813d78f 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/helpers.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/helpers.cpp @@ -39,7 +39,7 @@ hsa_ven_amd_aqlprofile_id_query_t get_query_info(rocprofiler_agent_id_t agent, const counters::Metric& metric) { auto aql_agent = *CHECK_NOTNULL(rocprofiler::agent::get_aql_agent(agent)); - aqlprofile_pmc_profile_t profile = {.agent = aql_agent}; + aqlprofile_pmc_profile_t profile = {.agent = aql_agent, .events = nullptr, .event_count = 0}; hsa_ven_amd_aqlprofile_id_query_t query = {metric.block().c_str(), 0, 0}; if(aqlprofile_get_pmc_info(&profile, AQLPROFILE_INFO_BLOCK_ID, &query) != HSA_STATUS_SUCCESS) { @@ -113,4 +113,4 @@ get_dim_info(rocprofiler_agent_id_t agent, return ROCPROFILER_STATUS_SUCCESS; } } // namespace aql -} // namespace rocprofiler \ No newline at end of file +} // namespace rocprofiler diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/tests/helpers.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/tests/helpers.cpp index 9219faa3c2..c3dc8a46ce 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/tests/helpers.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/aql/tests/helpers.cpp @@ -103,7 +103,14 @@ findDeviceMetrics(const rocprofiler_agent_t& agent, const std::unordered_set* perform_reduction(ReduceOperation reduce_op, std::vector* input_array) { - rocprofiler_record_counter_t result{.id = 0, .counter_value = 0}; + rocprofiler_record_counter_t result{.id = 0, .counter_value = 0, .dispatch_id = 0}; if(input_array->empty()) return input_array; switch(reduce_op) { @@ -81,26 +81,30 @@ perform_reduction(ReduceOperation reduce_op, std::vectorbegin(), - input_array->end(), - rocprofiler_record_counter_t{.id = 0, .counter_value = 0}, - [](auto& a, auto& b) { - return rocprofiler_record_counter_t{ - .id = a.id, - .counter_value = a.counter_value + b.counter_value}; - }); + result = std::accumulate( + input_array->begin(), + input_array->end(), + rocprofiler_record_counter_t{.id = 0, .counter_value = 0, .dispatch_id = 0}, + [](auto& a, auto& b) { + return rocprofiler_record_counter_t{ + .id = a.id, + .counter_value = a.counter_value + b.counter_value, + .dispatch_id = a.dispatch_id}; + }); break; } case REDUCE_AVG: { - result = std::accumulate(input_array->begin(), - input_array->end(), - rocprofiler_record_counter_t{.id = 0, .counter_value = 0}, - [](auto& a, auto& b) { - return rocprofiler_record_counter_t{ - .id = a.id, - .counter_value = a.counter_value + b.counter_value}; - }); + result = std::accumulate( + input_array->begin(), + input_array->end(), + rocprofiler_record_counter_t{.id = 0, .counter_value = 0, .dispatch_id = 0}, + [](auto& a, auto& b) { + return rocprofiler_record_counter_t{ + .id = a.id, + .counter_value = a.counter_value + b.counter_value, + .dispatch_id = a.dispatch_id}; + }); result.counter_value /= input_array->size(); break; } @@ -214,8 +218,9 @@ EvaluateAST::EvaluateAST(rocprofiler_counter_id_t out_id, if(_type == NodeType::NUMBER_NODE) { _raw_value = std::get(ast.value); - _static_value.push_back( - {.id = 0, .counter_value = static_cast(std::get(ast.value))}); + _static_value.push_back({.id = 0, + .counter_value = static_cast(std::get(ast.value)), + .dispatch_id = 0}); } for(const auto& nextAst : ast.counter_set) @@ -590,24 +595,30 @@ EvaluateAST::evaluate( case ADDITION_NODE: return perform_op([](auto& a, auto& b) { return rocprofiler_record_counter_t{ - .id = a.id, .counter_value = a.counter_value + b.counter_value}; + .id = a.id, + .counter_value = a.counter_value + b.counter_value, + .dispatch_id = a.dispatch_id}; }); case SUBTRACTION_NODE: return perform_op([](auto& a, auto& b) { return rocprofiler_record_counter_t{ - .id = a.id, .counter_value = a.counter_value - b.counter_value}; + .id = a.id, + .counter_value = a.counter_value - b.counter_value, + .dispatch_id = a.dispatch_id}; }); case MULTIPLY_NODE: return perform_op([](auto& a, auto& b) { return rocprofiler_record_counter_t{ - .id = a.id, .counter_value = a.counter_value * b.counter_value}; + .id = a.id, + .counter_value = a.counter_value * b.counter_value, + .dispatch_id = a.dispatch_id}; }); case DIVIDE_NODE: return perform_op([](auto& a, auto& b) { return rocprofiler_record_counter_t{ - .id = a.id, - .counter_value = - (b.counter_value == 0 ? 0 : a.counter_value / b.counter_value)}; + .id = a.id, + .counter_value = (b.counter_value == 0 ? 0 : a.counter_value / b.counter_value), + .dispatch_id = a.dispatch_id}; }); case REFERENCE_NODE: { diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/evaluate_ast_test.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/evaluate_ast_test.cpp index 089897f5c3..0839dbf525 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/evaluate_ast_test.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/evaluate_ast_test.cpp @@ -646,16 +646,17 @@ TEST(evaluate_ast, counter_reduction_sum) sum_vec(base_counter_data["KRUEGER"])), 2}, {"KRAMER", - plus_vec(times_vec(std::vector{{.id = 0, - .counter_value = 5.0}}, - sum_vec(base_counter_data["VOORHEES"])), + plus_vec(times_vec( + std::vector{ + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}}, + sum_vec(base_counter_data["VOORHEES"])), sum_vec(base_counter_data["KRUEGER"])), 2}, {"GHOSTFACE", plus_vec(sum_vec(base_counter_data["VOORHEES"]), divide_vec(sum_vec(base_counter_data["KRUEGER"]), std::vector{ - {.id = 0, .counter_value = 5.0}})), + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}})), 2}, }; @@ -726,16 +727,17 @@ TEST(evaluate_ast, counter_reduction_min) min_vec(base_counter_data["KRUEGER"])), 2}, {"KRAMER", - plus_vec(times_vec(std::vector{{.id = 0, - .counter_value = 5.0}}, - min_vec(base_counter_data["VOORHEES"])), + plus_vec(times_vec( + std::vector{ + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}}, + min_vec(base_counter_data["VOORHEES"])), min_vec(base_counter_data["KRUEGER"])), 2}, {"GHOSTFACE", plus_vec(min_vec(base_counter_data["VOORHEES"]), divide_vec(min_vec(base_counter_data["KRUEGER"]), std::vector{ - {.id = 0, .counter_value = 5.0}})), + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}})), 2}, }; @@ -806,16 +808,17 @@ TEST(evaluate_ast, counter_reduction_max) max_vec(base_counter_data["KRUEGER"])), 2}, {"KRAMER", - plus_vec(times_vec(std::vector{{.id = 0, - .counter_value = 5.0}}, - max_vec(base_counter_data["VOORHEES"])), + plus_vec(times_vec( + std::vector{ + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}}, + max_vec(base_counter_data["VOORHEES"])), max_vec(base_counter_data["KRUEGER"])), 2}, {"GHOSTFACE", plus_vec(max_vec(base_counter_data["VOORHEES"]), divide_vec(max_vec(base_counter_data["KRUEGER"]), std::vector{ - {.id = 0, .counter_value = 5.0}})), + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}})), 2}, }; @@ -888,16 +891,17 @@ TEST(evaluate_ast, counter_reduction_avg) avg_vec(base_counter_data["KRUEGER"])), 2}, {"KRAMER", - plus_vec(times_vec(std::vector{{.id = 0, - .counter_value = 5.0}}, - avg_vec(base_counter_data["VOORHEES"])), + plus_vec(times_vec( + std::vector{ + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}}, + avg_vec(base_counter_data["VOORHEES"])), avg_vec(base_counter_data["KRUEGER"])), 2}, {"GHOSTFACE", plus_vec(avg_vec(base_counter_data["VOORHEES"]), divide_vec(avg_vec(base_counter_data["KRUEGER"]), std::vector{ - {.id = 0, .counter_value = 5.0}})), + {.id = 0, .counter_value = 5.0, .dispatch_id = 0}})), 2}, }; @@ -956,18 +960,20 @@ TEST(evaluate_ast, evaluate_mixed_counters) std::vector, int64_t>> derived_counters = { {"BATES", - times_vec(std::vector{{.id = 0, .counter_value = 32}}, - sum_vec(base_counter_data["VOORHEES"])), + times_vec( + std::vector{ + {.id = 0, .counter_value = 32, .dispatch_id = 0}}, + sum_vec(base_counter_data["VOORHEES"])), 2}, {"KRAMER", - times_vec( - sum_vec(base_counter_data["KRUEGER"]), - std::vector{{.id = 0, .counter_value = 8.0 / 5.0}}), + times_vec(sum_vec(base_counter_data["KRUEGER"]), + std::vector{ + {.id = 0, .counter_value = 8.0 / 5.0, .dispatch_id = 0}}), 3}, {"TORRANCE", times_vec(sum_vec(base_counter_data["KRUEGER"]), std::vector{ - {.id = 0, .counter_value = 104.0 / (156.0 * 8.0)}}), + {.id = 0, .counter_value = 104.0 / (156.0 * 8.0), .dispatch_id = 0}}), 4}, }; diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue.cpp index 004abc1f4c..a329ee6925 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue.cpp @@ -301,12 +301,13 @@ WriteInterceptor(const void* packets, .dispatch_id = dispatch_id, .private_segment_size = kernel_pkt.kernel_dispatch.private_segment_size, .group_segment_size = kernel_pkt.kernel_dispatch.group_segment_size, - .workgroup_size = rocprofiler_dim3_t{kernel_pkt.kernel_dispatch.workgroup_size_x, + .workgroup_size = rocprofiler_dim3_t{kernel_pkt.kernel_dispatch.workgroup_size_x, kernel_pkt.kernel_dispatch.workgroup_size_y, kernel_pkt.kernel_dispatch.workgroup_size_z}, - .grid_size = rocprofiler_dim3_t{kernel_pkt.kernel_dispatch.grid_size_x, + .grid_size = rocprofiler_dim3_t{kernel_pkt.kernel_dispatch.grid_size_x, kernel_pkt.kernel_dispatch.grid_size_y, - kernel_pkt.kernel_dispatch.grid_size_z}}}; + kernel_pkt.kernel_dispatch.grid_size_z}, + .reserved_padding = {0}}}; { auto tracer_data = callback_record; diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp index c9cfab1acc..282e3fa37e 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp @@ -84,7 +84,64 @@ destroy_queue(hsa_queue_t* hsa_queue) constexpr rocprofiler_agent_t default_agent = rocprofiler_agent_t{.size = sizeof(rocprofiler_agent_t), - .id = rocprofiler_agent_id_t{std::numeric_limits::max()}}; + .id = rocprofiler_agent_id_t{std::numeric_limits::max()}, + .type = ROCPROFILER_AGENT_TYPE_NONE, + .cpu_cores_count = 0, + .simd_count = 0, + .mem_banks_count = 0, + .caches_count = 0, + .io_links_count = 0, + .cpu_core_id_base = 0, + .simd_id_base = 0, + .max_waves_per_simd = 0, + .lds_size_in_kb = 0, + .gds_size_in_kb = 0, + .num_gws = 0, + .wave_front_size = 0, + .num_xcc = 0, + .cu_count = 0, + .array_count = 0, + .num_shader_banks = 0, + .simd_arrays_per_engine = 0, + .cu_per_simd_array = 0, + .simd_per_cu = 0, + .max_slots_scratch_cu = 0, + .gfx_target_version = 0, + .vendor_id = 0, + .device_id = 0, + .location_id = 0, + .domain = 0, + .drm_render_minor = 0, + .num_sdma_engines = 0, + .num_sdma_xgmi_engines = 0, + .num_sdma_queues_per_engine = 0, + .num_cp_queues = 0, + .max_engine_clk_ccompute = 0, + .max_engine_clk_fcompute = 0, + .sdma_fw_version = {}, + .fw_version = {}, + .capability = {}, + .cu_per_engine = 0, + .max_waves_per_cu = 0, + .family_id = 0, + .workgroup_max_size = 0, + .grid_max_size = 0, + .local_mem_size = 0, + .hive_id = 0, + .gpu_id = 0, + .workgroup_max_dim = {0, 0, 0}, + .grid_max_dim = {0, 0, 0}, + .mem_banks = nullptr, + .caches = nullptr, + .io_links = nullptr, + .name = nullptr, + .vendor_name = nullptr, + .product_name = nullptr, + .model_name = nullptr, + .num_pc_sampling_configs = 0, + .pc_sampling_configs = nullptr, + .node_id = 0, + .logical_node_id = 0}; } // namespace void diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/page_migration/page_migration.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/page_migration/page_migration.cpp index 4fd0433b3e..536cca361a 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/page_migration/page_migration.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/page_migration/page_migration.cpp @@ -848,9 +848,8 @@ struct poll_kfd_t // Create fd for notifying thread when we want to wake it up, and an eventfd for any events // to this thread - file_handles.emplace_back(pollfd{ - .fd = eventfd(0, DEFAULT_FLAGS), - }); + file_handles.emplace_back( + pollfd{.fd = eventfd(0, DEFAULT_FLAGS), .events = 0, .revents = 0}); fd_t thread_pipes[2]{};