From 883caf271923b705f4eb9140486f4a7d3c2df318 Mon Sep 17 00:00:00 2001 From: Kian Cossettini Date: Fri, 31 Oct 2025 09:59:23 -0400 Subject: [PATCH] [rocprofiler-systems] Overhaul skip condition of implicit_task and add ROCPD validation test (#1589) - Add rocpd validation check and fix implicit_task check - SWDEV-562896 --- .../rocprof-sys/library/rocprofiler-sdk.cpp | 26 ++++++++++++++----- .../rocpd-validation-rules/default-rules.json | 18 +++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/rocprof-sys/library/rocprofiler-sdk.cpp b/projects/rocprofiler-systems/source/lib/rocprof-sys/library/rocprofiler-sdk.cpp index 8ba498b2cd..df8ae1bf3f 100644 --- a/projects/rocprofiler-systems/source/lib/rocprof-sys/library/rocprofiler-sdk.cpp +++ b/projects/rocprofiler-systems/source/lib/rocprof-sys/library/rocprofiler-sdk.cpp @@ -1242,14 +1242,28 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record, }; #if(ROCPROFILER_VERSION >= 600) - static bool is_first_implicit_task = false; - if(!is_first_implicit_task && record.operation == ROCPROFILER_OMPT_ID_implicit_task) + // Skip implicit_task associated with an "initial-task-begin" occurrence + // as it is generated by our tool. + // Occurs after our tool initializes OMPT but before the first OpenMP + // region (user code) begins. + // Note: Can occur multiple times (Ex: MPI+OpenMP hybrid) + if(record.kind == ROCPROFILER_CALLBACK_TRACING_OMPT && + record.operation == ROCPROFILER_OMPT_ID_implicit_task) { - // We do not capture implicit task with flags = 1 on main thread - // For now, this is identified as the first implicit task call - is_first_implicit_task = true; - return; + auto* payload_data = + static_cast(record.payload); + int flag = payload_data->args.implicit_task.flags; + if(flag & ompt_task_initial) return; } + // TODO: Once ompt_callback_thread_begin is supported, we need to skip + // every occurrence of an "initial-thread-begin" for similar reasons. + // This callback is identified with thread_type == ompt_thread_initial. + + // Note: If the finalization issue is resolved, the corresponding ends of these + // callbacks (which should be discarded) can be identified with: + // - implicit_task: (flag & ompt_task_initial) && endpoint == ompt_scope_end + // - thread_end: The thread_data ptr from the thread_begin callback generated + // by the "initial-thread-begin" needs to match the thread_end's thread_data ptr #endif auto ts = rocprofiler_timestamp_t{}; diff --git a/projects/rocprofiler-systems/tests/rocpd-validation-rules/default-rules.json b/projects/rocprofiler-systems/tests/rocpd-validation-rules/default-rules.json index 5a8725c8fe..9cde528c3a 100644 --- a/projects/rocprofiler-systems/tests/rocpd-validation-rules/default-rules.json +++ b/projects/rocprofiler-systems/tests/rocpd-validation-rules/default-rules.json @@ -68,6 +68,24 @@ "end", "name" ] + }, + { + "name": "regions", + "required_columns": [ + "tid", + "start", + "end", + "name" + ], + "validation_queries": [ + { + "comparison": "equals", + "description": "Verify entries have non-zero start times", + "error_message": "Found entries with zero start times in table", + "expected_result": 0, + "query": "SELECT COUNT(*) as count FROM regions WHERE start = 0" + } + ] } ] }