Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions projects/rocprofiler-sdk/source/lib/python/rocpd/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ def build_agent_id_string(agent_index_value, prefix=""):
return ""


def write_kernel_csv(importData, config) -> None:

def get_kernel_csv_query(config) -> str:
agent_id = build_agent_id_string(config.agent_index_value)

if config.kernel_rename:
Expand All @@ -235,6 +234,7 @@ def write_kernel_csv(importData, config) -> None:
"stack_id AS Correlation_Id",
"start AS Start_Timestamp",
"end AS End_Timestamp",
"(end - start) AS Duration",
"lds_size AS Lds_Block_Size",
"scratch_size",
"vgpr_count",
Expand All @@ -248,19 +248,19 @@ def write_kernel_csv(importData, config) -> None:
"grid_z AS Grid_Size_Z",
]

aliased_headers = []
for column in select_columns:
aliased_headers.append(column)
select_clause = ",\n".join(select_columns)

select_clause = ",\n".join(aliased_headers)

query = f"""
return f"""
SELECT
{select_clause}
FROM "kernels"
ORDER BY
guid ASC, start ASC, end DESC
"""


def write_kernel_csv(importData, config) -> None:
query = get_kernel_csv_query(config)
write_sql_query_to_csv(importData, config, query, "kernel")


Expand Down
1 change: 1 addition & 0 deletions projects/rocprofiler-sdk/tests/rocprofv3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ add_subdirectory(conversion-script)
add_subdirectory(python-bindings)
add_subdirectory(rocpd)
add_subdirectory(rocpd-kernel-rename)
add_subdirectory(kernel-trace-duration)
add_subdirectory(attachment)
add_subdirectory(rocpd-scratch)
add_subdirectory(att-consecutive-kernels)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
# rocprofv3 tool tests for kernel duration
#
cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR)

project(
rocprofiler-sdk-tests-rocprofv3-kernel-trace-duration
LANGUAGES CXX
VERSION 0.0.0)

find_package(rocprofiler-sdk REQUIRED)
find_package(Python3 REQUIRED)

set(rocprofv3-generate-env
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}"
"PYTHONPATH=${rocprofiler-sdk_LIB_DIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages"
"ROCPROF_OUTPUT_FORMAT=json,rocpd")

set(rocprofv3-validate-env
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}"
"PYTHONPATH=${rocprofiler-sdk_LIB_DIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages"
)

rocprofiler_configure_pytest_files(CONFIG pytest.ini COPY conftest.py validate.py)

# Generate BOTH JSON and rocpd in a SINGLE execution using environment variable
add_test(
NAME rocprofv3-test-kernel-trace-duration-generate
COMMAND
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -d
${CMAKE_CURRENT_BINARY_DIR}/kernel-trace-duration -o out_combined --kernel-trace
-- $<TARGET_FILE:simple-transpose>)

set_tests_properties(
rocprofv3-test-kernel-trace-duration-generate
PROPERTIES TIMEOUT
120
LABELS
"integration-tests;kernel-trace-duration"
ENVIRONMENT
"${rocprofv3-generate-env}"
FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}"
FIXTURES_SETUP
rocprofv3-test-kernel-trace-duration-data)

# Validate: compare rocpd kernel query output with JSON
add_test(
NAME rocprofv3-test-kernel-trace-duration-validation
COMMAND
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --json-input
${CMAKE_CURRENT_BINARY_DIR}/kernel-trace-duration/out_combined_results.json
--db-input
${CMAKE_CURRENT_BINARY_DIR}/kernel-trace-duration/out_combined_results.db)

set_tests_properties(
rocprofv3-test-kernel-trace-duration-validation
PROPERTIES TIMEOUT
120
LABELS
"integration-tests;kernel-trace-duration"
ENVIRONMENT
"${rocprofv3-validate-env}"
FIXTURES_REQUIRED
rocprofv3-test-kernel-trace-duration-data
FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# MIT License
#
# Copyright (c) 2024-2025 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.

import json
import os

import pytest


def pytest_addoption(parser):
parser.addoption("--json-input", action="store", required=True, help="Input JSON")
parser.addoption("--db-input", action="store", required=True, help="Input rocpd DB")


@pytest.fixture
def json_data(request):
path = request.config.getoption("--json-input")
assert os.path.isfile(path), f"missing JSON input: {path}"
with open(path, "r", encoding="utf-8") as f:
return json.load(f)


@pytest.fixture
def db_path(request):
path = request.config.getoption("--db-input")
assert os.path.isfile(path), f"missing rocpd DB input: {path}"
return path
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
addopts = --durations=20 -rA -s
testpaths = validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
Loading
Loading