ROCpd schema fetching from rocprofiler-sdk (#1501)
- Integrate rocprofiler-systems with rocprofiler-sdk-rocpd to fetch schema - If rocprofiler-sdk-rocpd is not availabe, use embedded schema files. With this we provide rocpd format support even if ROCm is not available - Include detection in CMake if rocprofiler-sdk-rocpd package is available (and valid), and build database class upon that - Update embedded schema that is used as a fallback. - Update some validation tests to account for schema changes.
Cette révision appartient à :
révisé par
GitHub
Parent
b299eece9b
révision
a9082a7158
@@ -10,6 +10,7 @@ Full documentation for ROCm Systems Profiler is available at [https://rocm.docs.
|
||||
|
||||
- Added a `ROCPROFSYS_PERFETTO_FLUSH_PERIOD_MS` configuration setting to set the flush period for Perfetto traces. The default value is 10000 ms (10 seconds).
|
||||
- Added tracing of VAAPI, MPI and host events inside `rocpd` output database.
|
||||
- Added fetching of the `rocpd` schema from rocprofiler-sdk-rocpd
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -232,6 +232,99 @@ if(ROCPROFSYS_USE_ROCM)
|
||||
target_link_libraries(rocprofiler-systems-rocm INTERFACE amd-smi::amd-smi)
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# ROCpd
|
||||
#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
function(ROCPROFSYS_CONFIGURE_ROCPD_SCHEMA_FILES)
|
||||
rocprofiler_systems_target_compile_definitions(
|
||||
rocprofiler-systems-rocm INTERFACE ROCPROFSYS_USE_ROCPD_LIBRARY=0
|
||||
)
|
||||
|
||||
set(SCHEMA_FILES
|
||||
"rocpd_tables.sql"
|
||||
"rocpd_views.sql"
|
||||
"data_views.sql"
|
||||
"marker_views.sql"
|
||||
"summary_views.sql"
|
||||
)
|
||||
|
||||
set(SCHEMA_SOURCE_DIR
|
||||
"${PROJECT_SOURCE_DIR}/source/lib/core/rocpd/data_storage/schema"
|
||||
)
|
||||
set(SCHEMA_BINARY_DIR
|
||||
"${PROJECT_BINARY_DIR}/source/lib/core/rocpd/data_storage/schema"
|
||||
)
|
||||
set(TEMPLATE_FILE "${PROJECT_SOURCE_DIR}/cmake/Templates/rocpd_schema.in")
|
||||
|
||||
file(MAKE_DIRECTORY ${SCHEMA_BINARY_DIR})
|
||||
|
||||
foreach(SCHEMA_FILE ${SCHEMA_FILES})
|
||||
file(READ "${SCHEMA_SOURCE_DIR}/${SCHEMA_FILE}" SQL_CONTENT)
|
||||
|
||||
string(REPLACE "\\" "\\\\" SQL_CONTENT "${SQL_CONTENT}")
|
||||
string(REPLACE "\"" "\\\"" SQL_CONTENT "${SQL_CONTENT}")
|
||||
string(REPLACE "\n" "\\n\"\n\"" SQL_CONTENT "${SQL_CONTENT}")
|
||||
|
||||
get_filename_component(SCHEMA_NAME ${SCHEMA_FILE} NAME_WE)
|
||||
string(TOUPPER ${SCHEMA_NAME} SCHEMA_NAME_UPPER)
|
||||
|
||||
configure_file("${TEMPLATE_FILE}" "${SCHEMA_BINARY_DIR}/${SCHEMA_NAME}.hpp" @ONLY)
|
||||
endforeach()
|
||||
|
||||
target_include_directories(
|
||||
rocprofiler-systems-headers
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/source/lib/core/rocpd/data_storage>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
set(ROCPROFSYS_USE_ROCPD_LIBRARY OFF CACHE BOOL "Use rocpd library" FORCE)
|
||||
find_package(rocprofiler-sdk-rocpd ${rocprofiler_systems_FIND_QUIETLY})
|
||||
|
||||
if(rocprofiler-sdk-rocpd_FOUND)
|
||||
set(ROCPROFSYS_ROCPD_HAS_SQL_H FALSE)
|
||||
|
||||
if(rocprofiler-sdk-rocpd_INCLUDE_DIR)
|
||||
set(_INCLUDE_PATH "${rocprofiler-sdk-rocpd_INCLUDE_DIR}/rocprofiler-sdk-rocpd")
|
||||
message(STATUS "${_INCLUDE_PATH}/sql.h")
|
||||
if(EXISTS "${_INCLUDE_PATH}/sql.h")
|
||||
set(ROCPROFSYS_ROCPD_HAS_SQL_H TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ROCPROFSYS_ROCPD_HAS_SQL_H)
|
||||
set(ROCPROFSYS_USE_ROCPD_LIBRARY ON CACHE BOOL "Use rocpd library" FORCE)
|
||||
|
||||
rocprofiler_systems_target_compile_definitions(
|
||||
rocprofiler-systems-rocm INTERFACE ROCPROFSYS_USE_ROCPD_LIBRARY=1
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
rocprofiler-systems-rocm
|
||||
INTERFACE rocprofiler-sdk-rocpd::rocprofiler-sdk-rocpd
|
||||
)
|
||||
|
||||
message(
|
||||
STATUS
|
||||
"rocprofiler-sdk-rocpd found with sql.h - using latest schema files"
|
||||
)
|
||||
else()
|
||||
message(
|
||||
STATUS
|
||||
"rocprofiler-sdk-rocpd found but sql.h missing - using local schema files"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "rocprofiler-sdk-rocpd not found - using local schema files")
|
||||
endif()
|
||||
|
||||
if(NOT ROCPROFSYS_USE_ROCPD_LIBRARY)
|
||||
rocprofsys_configure_rocpd_schema_files()
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# MPI
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Auto-generated from @SCHEMA_FILE@
|
||||
#pragma once
|
||||
|
||||
namespace rocprofsys {
|
||||
namespace rocpd {
|
||||
namespace data_storage {
|
||||
namespace schema {
|
||||
|
||||
constexpr const char* @SCHEMA_NAME_UPPER@_SQL = "@SQL_CONTENT@";
|
||||
|
||||
} // namespace schema
|
||||
} // namespace data_storage
|
||||
} // namespace rocpd
|
||||
} // namespace rocprofsys
|
||||
@@ -133,22 +133,6 @@ target_link_libraries(
|
||||
$<BUILD_INTERFACE:$<IF:$<BOOL:${ROCPROFSYS_BUILD_LTO}>,rocprofiler-systems::rocprofiler-systems-lto,>>
|
||||
)
|
||||
|
||||
file(GLOB ROCPD_SCHEMA_FILES "${CMAKE_CURRENT_LIST_DIR}/rocpd/data_storage/schema/*.sql")
|
||||
|
||||
foreach(_SRC ${ROCPD_SCHEMA_FILES})
|
||||
cmake_path(GET _SRC FILENAME _BASE)
|
||||
configure_file(
|
||||
${_SRC}
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/${_BASE}
|
||||
COPYONLY
|
||||
)
|
||||
install(
|
||||
FILES ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/${_BASE}
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
|
||||
COMPONENT core
|
||||
)
|
||||
endforeach()
|
||||
|
||||
set_target_properties(
|
||||
rocprofiler-systems-core-library
|
||||
PROPERTIES OUTPUT_NAME ${BINARY_NAME_PREFIX}-core
|
||||
|
||||
+125
-46
@@ -26,13 +26,39 @@
|
||||
#include "node_info.hpp"
|
||||
|
||||
#include <config.hpp>
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <timemory/environment/types.hpp>
|
||||
#include <timemory/utility/filepath.hpp>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCPD_LIBRARY) && ROCPROFSYS_USE_ROCPD_LIBRARY > 0
|
||||
# include <rocprofiler-sdk-rocpd/rocpd.h>
|
||||
# include <rocprofiler-sdk-rocpd/types.h>
|
||||
#else
|
||||
# include "core/rocpd/data_storage/schema/data_views.hpp"
|
||||
# include "core/rocpd/data_storage/schema/marker_views.hpp"
|
||||
# include "core/rocpd/data_storage/schema/rocpd_tables.hpp"
|
||||
# include "core/rocpd/data_storage/schema/rocpd_views.hpp"
|
||||
# include "core/rocpd/data_storage/schema/summary_views.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
enum rocpd_sql_schema_kind_t
|
||||
{
|
||||
ROCPD_SQL_SCHEMA_NONE = 0,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_TABLES,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_INDEXES,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_VIEWS,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_DATA_VIEWS,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_SUMMARY_VIEWS,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_MARKER_VIEWS,
|
||||
ROCPD_SQL_SCHEMA_LAST,
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
void
|
||||
@@ -44,7 +70,89 @@ create_directory_for_database_file(const std::string& db_file)
|
||||
tim::filepath::makedir(_db_dirname);
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
process_schema_template(std::string_view schema_content, const std::string& upid)
|
||||
{
|
||||
std::string query = std::string(schema_content);
|
||||
|
||||
std::regex upid_pattern("\\{\\{uuid\\}\\}");
|
||||
std::regex guid_pattern("\\{\\{guid\\}\\}");
|
||||
std::regex view_upid_pattern("\\{\\{view_upid\\}\\}");
|
||||
|
||||
query = std::regex_replace(query, upid_pattern, "_" + upid);
|
||||
query = std::regex_replace(query, guid_pattern, upid);
|
||||
query = std::regex_replace(query, view_upid_pattern, "");
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
#if defined(ROCPROFSYS_USE_ROCPD_LIBRARY) && ROCPROFSYS_USE_ROCPD_LIBRARY > 0
|
||||
void
|
||||
load_schema_cb(rocpd_sql_engine_t, rocpd_sql_schema_kind_t, rocpd_sql_options_t,
|
||||
const rocpd_sql_schema_jinja_variables_t*, const char*,
|
||||
const char* schema_content, void* user_data)
|
||||
{
|
||||
if(user_data == nullptr || schema_content == nullptr)
|
||||
{
|
||||
ROCPROFSYS_WARNING(1, "Invalid user data or schema content pointer");
|
||||
return;
|
||||
}
|
||||
auto* query = static_cast<std::string*>(user_data);
|
||||
if(query == nullptr)
|
||||
{
|
||||
ROCPROFSYS_WARNING(1, "Invalid query pointer");
|
||||
return;
|
||||
}
|
||||
*query = std::string(schema_content);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string
|
||||
get_schema_query(rocpd_sql_schema_kind_t schema_kind, const std::string& upid)
|
||||
{
|
||||
#if defined(ROCPROFSYS_USE_ROCPD_LIBRARY) && ROCPROFSYS_USE_ROCPD_LIBRARY > 0
|
||||
const auto jinja_size = 2 * upid.size();
|
||||
rocpd_sql_schema_jinja_variables_t info{ jinja_size, upid.c_str(), upid.c_str() };
|
||||
|
||||
std::string query;
|
||||
auto status = rocpd_sql_load_schema(ROCPD_SQL_ENGINE_SQLITE3, schema_kind,
|
||||
ROCPD_SQL_OPTIONS_NONE, &info, load_schema_cb,
|
||||
nullptr, 0, &query);
|
||||
if(status != ROCPD_STATUS_SUCCESS)
|
||||
{
|
||||
ROCPROFSYS_WARNING(0, "Unable to load rocpd schema. Error code: %d", status);
|
||||
}
|
||||
return query;
|
||||
#else
|
||||
std::string_view schema_content;
|
||||
|
||||
switch(schema_kind)
|
||||
{
|
||||
case ROCPD_SQL_SCHEMA_ROCPD_TABLES:
|
||||
schema_content = rocprofsys::rocpd::data_storage::schema::ROCPD_TABLES_SQL;
|
||||
break;
|
||||
case ROCPD_SQL_SCHEMA_ROCPD_VIEWS:
|
||||
schema_content = rocprofsys::rocpd::data_storage::schema::ROCPD_VIEWS_SQL;
|
||||
break;
|
||||
case ROCPD_SQL_SCHEMA_ROCPD_DATA_VIEWS:
|
||||
schema_content = rocprofsys::rocpd::data_storage::schema::DATA_VIEWS_SQL;
|
||||
break;
|
||||
case ROCPD_SQL_SCHEMA_ROCPD_MARKER_VIEWS:
|
||||
schema_content = rocprofsys::rocpd::data_storage::schema::MARKER_VIEWS_SQL;
|
||||
break;
|
||||
case ROCPD_SQL_SCHEMA_ROCPD_SUMMARY_VIEWS:
|
||||
schema_content = rocprofsys::rocpd::data_storage::schema::SUMMARY_VIEWS_SQL;
|
||||
break;
|
||||
default: ROCPROFSYS_WARNING(0, "Unknown schema kind: %d", schema_kind); return "";
|
||||
}
|
||||
|
||||
return process_schema_template(schema_content, upid);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace rocprofsys
|
||||
{
|
||||
namespace rocpd
|
||||
@@ -75,57 +183,28 @@ database::~database()
|
||||
void
|
||||
database::initialize_schema()
|
||||
{
|
||||
auto get_file_path = [](const std::string_view filename) {
|
||||
auto _rocprofsys_root = tim::get_env<std::string>(
|
||||
"rocprofiler_systems_ROOT", tim::get_env<std::string>("ROCPROFSYS_ROOT", ""));
|
||||
if(!_rocprofsys_root.empty() &&
|
||||
tim::filepath::direxists(std::string(_rocprofsys_root)))
|
||||
{
|
||||
auto new_file_path = std::string(_rocprofsys_root)
|
||||
.append("/share/rocprofiler-systems/")
|
||||
.append(filename);
|
||||
if(tim::filepath::exists(new_file_path))
|
||||
{
|
||||
return new_file_path;
|
||||
}
|
||||
}
|
||||
// TODO: Update to look for the system's rocpd schema
|
||||
return std::string("source/lib/core/rocpd/data_storage/schema/").append(filename);
|
||||
const auto upid = get_upid();
|
||||
|
||||
const std::vector<rocpd_sql_schema_kind_t> schema_kinds = {
|
||||
ROCPD_SQL_SCHEMA_ROCPD_TABLES, ROCPD_SQL_SCHEMA_ROCPD_VIEWS,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_DATA_VIEWS, ROCPD_SQL_SCHEMA_ROCPD_MARKER_VIEWS,
|
||||
ROCPD_SQL_SCHEMA_ROCPD_SUMMARY_VIEWS
|
||||
};
|
||||
|
||||
std::vector<std::string_view> schema_files = { "rocpd_tables.sql", "rocpd_views.sql",
|
||||
"data_views.sql", "marker_views.sql",
|
||||
"summary_views.sql" };
|
||||
|
||||
// Process each schema file
|
||||
for(const auto& schema_file : schema_files)
|
||||
for(const auto& schema_kind : schema_kinds)
|
||||
{
|
||||
auto file_path = get_file_path(schema_file);
|
||||
std::ifstream file(file_path);
|
||||
if(!file.is_open())
|
||||
const std::string query = get_schema_query(schema_kind, upid);
|
||||
|
||||
if(query.empty())
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string("Failed to open schema file ").append(file_path));
|
||||
ROCPROFSYS_WARNING(0, "Failed to get schema query for schema kind: %d",
|
||||
schema_kind);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::stringstream ss_query;
|
||||
ss_query << file.rdbuf();
|
||||
std::string query = ss_query.str();
|
||||
|
||||
std::regex upid_pattern("\\{\\{uuid\\}\\}");
|
||||
std::regex guid_pattern("\\{\\{guid\\}\\}");
|
||||
std::regex view_upid_pattern("\\{\\{view_upid\\}\\}");
|
||||
|
||||
auto upid = get_upid();
|
||||
|
||||
query = std::regex_replace(query, upid_pattern, "_" + upid);
|
||||
query = std::regex_replace(query, guid_pattern, upid);
|
||||
query = std::regex_replace(query, view_upid_pattern, "");
|
||||
|
||||
validate_sqlite3_result(
|
||||
sqlite3_exec(_sqlite3_db_temp, query.c_str(), 0, 0, 0), query.c_str(),
|
||||
std::string("Invalid schema file, init database failed!").append(file_path));
|
||||
file.close();
|
||||
validate_sqlite3_result(sqlite3_exec(_sqlite3_db_temp, query.c_str(), 0, 0, 0),
|
||||
query.c_str(),
|
||||
std::string("Invalid schema, init database failed!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -315,6 +315,9 @@ SELECT
|
||||
K.workgroup_size_z AS workgroup_z,
|
||||
K.group_segment_size AS lds_size,
|
||||
K.private_segment_size AS scratch_size,
|
||||
S.arch_vgpr_count AS vgpr_count,
|
||||
S.accum_vgpr_count,
|
||||
S.sgpr_count,
|
||||
S.group_segment_size AS static_lds_size,
|
||||
S.private_segment_size AS static_scratch_size,
|
||||
E.stack_id,
|
||||
@@ -596,6 +599,7 @@ SELECT
|
||||
JSON_EXTRACT(M.extdata, '$.flags') AS alloc_flags,
|
||||
M.start,
|
||||
M.end,
|
||||
(M.end - M.start) AS duration,
|
||||
M.size,
|
||||
M.address,
|
||||
E.correlation_id,
|
||||
|
||||
-223
@@ -151,226 +151,3 @@ GROUP BY
|
||||
name
|
||||
ORDER BY
|
||||
total_duration DESC;
|
||||
|
||||
-- Kernel summary by name
|
||||
CREATE VIEW
|
||||
`kernel_summary` AS
|
||||
WITH
|
||||
avg_data AS (
|
||||
SELECT
|
||||
name,
|
||||
AVG(duration) AS avg_duration
|
||||
FROM
|
||||
`kernels`
|
||||
GROUP BY
|
||||
name
|
||||
),
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
K.name,
|
||||
COUNT(*) AS calls,
|
||||
SUM(K.duration) AS total_duration,
|
||||
SUM(CAST(K.duration AS REAL) * CAST(K.duration AS REAL)) AS sqr_duration,
|
||||
A.avg_duration AS average_duration,
|
||||
MIN(K.duration) AS min_duration,
|
||||
MAX(K.duration) AS max_duration,
|
||||
SUM(CAST((K.duration - A.avg_duration) AS REAL) * CAST((K.duration - A.avg_duration) AS REAL)) / (COUNT(*) - 1) AS variance_duration,
|
||||
SQRT(
|
||||
SUM(CAST((K.duration - A.avg_duration) AS REAL) * CAST((K.duration - A.avg_duration) AS REAL)) / (COUNT(*) - 1)
|
||||
) AS std_dev_duration
|
||||
FROM
|
||||
`kernels` K
|
||||
JOIN avg_data A ON K.name = A.name
|
||||
GROUP BY
|
||||
K.name
|
||||
),
|
||||
total_duration AS (
|
||||
SELECT
|
||||
SUM(total_duration) AS grand_total_duration
|
||||
FROM
|
||||
aggregated_data
|
||||
)
|
||||
SELECT
|
||||
AD.name AS name,
|
||||
AD.calls,
|
||||
AD.total_duration AS "DURATION (nsec)",
|
||||
AD.sqr_duration AS "SQR (nsec)",
|
||||
AD.average_duration AS "AVERAGE (nsec)",
|
||||
(CAST(AD.total_duration AS REAL) / TD.grand_total_duration) * 100 AS "PERCENT (INC)",
|
||||
AD.min_duration AS "MIN (nsec)",
|
||||
AD.max_duration AS "MAX (nsec)",
|
||||
AD.variance_duration AS "VARIANCE",
|
||||
AD.std_dev_duration AS "STD_DEV"
|
||||
FROM
|
||||
aggregated_data AD
|
||||
CROSS JOIN total_duration TD;
|
||||
|
||||
--
|
||||
-- Kernel summary by region name
|
||||
CREATE VIEW
|
||||
`kernel_summary_region` AS
|
||||
WITH
|
||||
avg_data AS (
|
||||
SELECT
|
||||
region,
|
||||
AVG(duration) AS avg_duration
|
||||
FROM
|
||||
`kernels`
|
||||
GROUP BY
|
||||
region
|
||||
),
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
K.region AS name,
|
||||
COUNT(*) AS calls,
|
||||
SUM(K.duration) AS total_duration,
|
||||
SUM(CAST(K.duration AS REAL) * CAST(K.duration AS REAL)) AS sqr_duration,
|
||||
A.avg_duration AS average_duration,
|
||||
MIN(K.duration) AS min_duration,
|
||||
MAX(K.duration) AS max_duration,
|
||||
SUM(CAST((K.duration - A.avg_duration) AS REAL) * CAST((K.duration - A.avg_duration) AS REAL)) / (COUNT(*) - 1) AS variance_duration,
|
||||
SQRT(
|
||||
SUM(CAST((K.duration - A.avg_duration) AS REAL) * CAST((K.duration - A.avg_duration) AS REAL)) / (COUNT(*) - 1)
|
||||
) AS std_dev_duration
|
||||
FROM
|
||||
`kernels` K
|
||||
JOIN avg_data A ON K.region = A.region
|
||||
GROUP BY
|
||||
K.region
|
||||
),
|
||||
total_duration AS (
|
||||
SELECT
|
||||
SUM(total_duration) AS grand_total_duration
|
||||
FROM
|
||||
aggregated_data
|
||||
)
|
||||
SELECT
|
||||
AD.name AS name,
|
||||
AD.calls,
|
||||
AD.total_duration AS "DURATION (nsec)",
|
||||
AD.sqr_duration AS "SQR (nsec)",
|
||||
AD.average_duration AS "AVERAGE (nsec)",
|
||||
(CAST(AD.total_duration AS REAL) / TD.grand_total_duration) * 100 AS "PERCENT (INC)",
|
||||
AD.min_duration AS "MIN (nsec)",
|
||||
AD.max_duration AS "MAX (nsec)",
|
||||
AD.variance_duration AS "VARIANCE",
|
||||
AD.std_dev_duration AS "STD_DEV"
|
||||
FROM
|
||||
aggregated_data AD
|
||||
CROSS JOIN total_duration TD;
|
||||
|
||||
--
|
||||
-- Memory copy summary
|
||||
CREATE VIEW
|
||||
`memory_copy_summary` AS
|
||||
WITH
|
||||
avg_data AS (
|
||||
SELECT
|
||||
name,
|
||||
AVG(duration) AS avg_duration
|
||||
FROM
|
||||
`memory_copies`
|
||||
GROUP BY
|
||||
name
|
||||
),
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
MC.name,
|
||||
COUNT(*) AS calls,
|
||||
SUM(MC.duration) AS total_duration,
|
||||
SUM(CAST(MC.duration AS REAL) * CAST(MC.duration AS REAL)) AS sqr_duration,
|
||||
A.avg_duration AS average_duration,
|
||||
MIN(MC.duration) AS min_duration,
|
||||
MAX(MC.duration) AS max_duration,
|
||||
SUM(
|
||||
CAST((MC.duration - A.avg_duration) AS REAL) * CAST((MC.duration - A.avg_duration) AS REAL)
|
||||
) / (COUNT(*) - 1) AS variance_duration,
|
||||
SQRT(
|
||||
SUM(
|
||||
CAST((MC.duration - A.avg_duration) AS REAL) * CAST((MC.duration - A.avg_duration) AS REAL)
|
||||
) / (COUNT(*) - 1)
|
||||
) AS std_dev_duration
|
||||
FROM
|
||||
`memory_copies` MC
|
||||
JOIN avg_data A ON MC.name = A.name
|
||||
GROUP BY
|
||||
MC.name
|
||||
),
|
||||
total_duration AS (
|
||||
SELECT
|
||||
SUM(total_duration) AS grand_total_duration
|
||||
FROM
|
||||
aggregated_data
|
||||
)
|
||||
SELECT
|
||||
AD.name AS name,
|
||||
AD.calls,
|
||||
AD.total_duration AS "DURATION (nsec)",
|
||||
AD.sqr_duration AS "SQR (nsec)",
|
||||
AD.average_duration AS "AVERAGE (nsec)",
|
||||
(CAST(AD.total_duration AS REAL) / TD.grand_total_duration) * 100 AS "PERCENT (INC)",
|
||||
AD.min_duration AS "MIN (nsec)",
|
||||
AD.max_duration AS "MAX (nsec)",
|
||||
AD.variance_duration AS "VARIANCE",
|
||||
AD.std_dev_duration AS "STD_DEV"
|
||||
FROM
|
||||
aggregated_data AD
|
||||
CROSS JOIN total_duration TD;
|
||||
|
||||
--
|
||||
-- Memory allocation summary
|
||||
CREATE VIEW
|
||||
`memory_allocation_summary` AS
|
||||
WITH
|
||||
avg_data AS (
|
||||
SELECT
|
||||
type AS name,
|
||||
AVG(duration) AS avg_duration
|
||||
FROM
|
||||
`memory_allocations`
|
||||
GROUP BY
|
||||
type
|
||||
),
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
MA.type AS name,
|
||||
COUNT(*) AS calls,
|
||||
SUM(MA.duration) AS total_duration,
|
||||
SUM(CAST(MA.duration AS REAL) * CAST(MA.duration AS REAL)) AS sqr_duration,
|
||||
A.avg_duration AS average_duration,
|
||||
MIN(MA.duration) AS min_duration,
|
||||
MAX(MA.duration) AS max_duration,
|
||||
SUM(
|
||||
CAST((MA.duration - A.avg_duration) AS REAL) * CAST((MA.duration - A.avg_duration) AS REAL)
|
||||
) / (COUNT(*) - 1) AS variance_duration,
|
||||
SQRT(
|
||||
SUM(
|
||||
CAST((MA.duration - A.avg_duration) AS REAL) * CAST((MA.duration - A.avg_duration) AS REAL)
|
||||
) / (COUNT(*) - 1)
|
||||
) AS std_dev_duration
|
||||
FROM
|
||||
`memory_allocations` MA
|
||||
JOIN avg_data A ON MA.type = A.name
|
||||
GROUP BY
|
||||
MA.type
|
||||
),
|
||||
total_duration AS (
|
||||
SELECT
|
||||
SUM(total_duration) AS grand_total_duration
|
||||
FROM
|
||||
aggregated_data
|
||||
)
|
||||
SELECT
|
||||
'MEMORY_ALLOCATION_' || AD.name AS name,
|
||||
AD.calls,
|
||||
AD.total_duration AS "DURATION (nsec)",
|
||||
AD.sqr_duration AS "SQR (nsec)",
|
||||
AD.average_duration AS "AVERAGE (nsec)",
|
||||
(CAST(AD.total_duration AS REAL) / TD.grand_total_duration) * 100 AS "PERCENT (INC)",
|
||||
AD.min_duration AS "MIN (nsec)",
|
||||
AD.max_duration AS "MAX (nsec)",
|
||||
AD.variance_duration AS "VARIANCE",
|
||||
AD.std_dev_duration AS "STD_DEV"
|
||||
FROM
|
||||
aggregated_data AD
|
||||
CROSS JOIN total_duration TD;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"required_tables": [
|
||||
{
|
||||
"name": "kernel_summary",
|
||||
"name": "top_kernels",
|
||||
"required_columns": [
|
||||
"name",
|
||||
"calls",
|
||||
"DURATION (nsec)"
|
||||
"total_calls",
|
||||
"total_duration",
|
||||
"average",
|
||||
"percentage"
|
||||
],
|
||||
"validation_queries": [
|
||||
{
|
||||
@@ -13,14 +15,7 @@
|
||||
"description": "Check for null function names",
|
||||
"error_message": "Found API calls with null function names",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary WHERE name IS NULL"
|
||||
},
|
||||
{
|
||||
"comparison": "greater_than",
|
||||
"description": "Check that we have some kernel calls",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels WHERE name IS NULL"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -43,13 +38,6 @@
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernels WHERE name IS NULL"
|
||||
},
|
||||
{
|
||||
"comparison": "greater_than",
|
||||
"description": "Check that we have kernel entries",
|
||||
"error_message": "No kernel entries found",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernels"
|
||||
},
|
||||
{
|
||||
"comparison": "equals",
|
||||
"description": "Check for kernels with no active time",
|
||||
|
||||
+7
-5
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"required_tables": [
|
||||
{
|
||||
"name": "kernel_summary",
|
||||
"name": "top_kernels",
|
||||
"required_columns": [
|
||||
"name",
|
||||
"calls",
|
||||
"DURATION (nsec)"
|
||||
"total_calls",
|
||||
"total_duration",
|
||||
"average",
|
||||
"percentage"
|
||||
],
|
||||
"validation_queries": [
|
||||
{
|
||||
@@ -13,14 +15,14 @@
|
||||
"description": "Check for null function names",
|
||||
"error_message": "Found API calls with null function names",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary WHERE name IS NULL"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels WHERE name IS NULL"
|
||||
},
|
||||
{
|
||||
"comparison": "greater_than",
|
||||
"description": "Check that we have some kernel calls",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
+7
-5
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"required_tables": [
|
||||
{
|
||||
"name": "kernel_summary",
|
||||
"name": "top_kernels",
|
||||
"required_columns": [
|
||||
"name",
|
||||
"calls",
|
||||
"DURATION (nsec)"
|
||||
"total_calls",
|
||||
"total_duration",
|
||||
"average",
|
||||
"percentage"
|
||||
],
|
||||
"validation_queries": [
|
||||
{
|
||||
@@ -13,14 +15,14 @@
|
||||
"description": "Check for null function names",
|
||||
"error_message": "Found API calls with null function names",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary WHERE name IS NULL"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels WHERE name IS NULL"
|
||||
},
|
||||
{
|
||||
"comparison": "equals",
|
||||
"description": "Check for 3 unique kernels",
|
||||
"error_message": "Expecting 3 unique kernels",
|
||||
"expected_result": 3,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
+10
-8
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"required_tables": [
|
||||
{
|
||||
"name": "kernel_summary",
|
||||
"name": "top_kernels",
|
||||
"required_columns": [
|
||||
"name",
|
||||
"calls",
|
||||
"DURATION (nsec)"
|
||||
"total_calls",
|
||||
"total_duration",
|
||||
"average",
|
||||
"percentage"
|
||||
],
|
||||
"validation_queries": [
|
||||
{
|
||||
@@ -13,28 +15,28 @@
|
||||
"description": "Check for null function names",
|
||||
"error_message": "Found API calls with null function names",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary WHERE name IS NULL"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels WHERE name IS NULL"
|
||||
},
|
||||
{
|
||||
"comparison": "greater_than",
|
||||
"description": "Check that we have some kernel calls",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels"
|
||||
},
|
||||
{
|
||||
"comparison": "equals",
|
||||
"description": "Check that we have 'hipKernelLaunch' kernel captured",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"error_message": "'hipKernelLaunch' not found in top_kernels",
|
||||
"expected_result": 1,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary WHERE name LIKE 'hipKernelLaunch%'"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels WHERE name LIKE 'hipKernelLaunch%'"
|
||||
},
|
||||
{
|
||||
"comparison": "equals",
|
||||
"description": "Check that we have predefined number of kernel calls",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"expected_result": 2,
|
||||
"query": "SELECT calls as num_calls FROM kernel_summary WHERE name LIKE 'hipKernelLaunch%'"
|
||||
"query": "SELECT total_calls FROM top_kernels WHERE name LIKE 'hipKernelLaunch%'"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
+10
-8
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"required_tables": [
|
||||
{
|
||||
"name": "kernel_summary",
|
||||
"name": "top_kernels",
|
||||
"required_columns": [
|
||||
"name",
|
||||
"calls",
|
||||
"DURATION (nsec)"
|
||||
"total_calls",
|
||||
"total_duration",
|
||||
"average",
|
||||
"percentage"
|
||||
],
|
||||
"validation_queries": [
|
||||
{
|
||||
@@ -13,28 +15,28 @@
|
||||
"description": "Check for null function names",
|
||||
"error_message": "Found API calls with null function names",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary WHERE name IS NULL"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels WHERE name IS NULL"
|
||||
},
|
||||
{
|
||||
"comparison": "greater_than",
|
||||
"description": "Check that we have some kernel calls",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"expected_result": 0,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels"
|
||||
},
|
||||
{
|
||||
"comparison": "equals",
|
||||
"description": "Check that we have transpose kernel captured",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"error_message": "transpose kernel not found in top_kernels",
|
||||
"expected_result": 1,
|
||||
"query": "SELECT COUNT(*) as count FROM kernel_summary WHERE name LIKE 'transpose%'"
|
||||
"query": "SELECT COUNT(*) FROM top_kernels WHERE name LIKE 'transpose%'"
|
||||
},
|
||||
{
|
||||
"comparison": "equals",
|
||||
"description": "Check that we have predefined number of kernel calls",
|
||||
"error_message": "No kernel calls found in summary",
|
||||
"expected_result": 1000,
|
||||
"query": "SELECT calls as num_calls FROM kernel_summary WHERE name LIKE 'transpose%'"
|
||||
"query": "SELECT total_calls FROM top_kernels WHERE name LIKE 'transpose%'"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur