unifying unittests
Change-Id: Icc47229fa4eb88fa40be7ae179e5dc5693659cfd
[ROCm/rocprofiler commit: 377748d2f8]
This commit is contained in:
@@ -6,8 +6,7 @@ CURRENT_DIR="$( dirname -- "$0"; )";
|
||||
echo -e "Running Profiler Tests"
|
||||
|
||||
echo -e "Running Unit tests for rocprofiler"
|
||||
eval ${CURRENT_DIR}/tests/unittests/core/runCoreUnitTests
|
||||
eval ${CURRENT_DIR}/tests/unittests/profiler/runProfilerUnitTests
|
||||
eval ${CURRENT_DIR}/tests/unittests/runUnitTests
|
||||
|
||||
echo -e "Running Feature Tests for diff Applicaitons;i.e: HSA,HIP,OpenMP,MPI"
|
||||
eval ${CURRENT_DIR}/tests/featuretests/profiler/runFeatureTests
|
||||
|
||||
@@ -1,2 +1,97 @@
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(profiler)
|
||||
# Setup unit testing env
|
||||
|
||||
find_library(PCIACCESS_LIBRARIES pciaccess REQUIRED)
|
||||
|
||||
enable_testing()
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
# Getting Source files for ROCProfiler, Hardware, HSA, Memory, Session, Counters, Utils
|
||||
set(CORE_MEMORY_DIR ${PROJECT_SOURCE_DIR}/src/core/memory)
|
||||
file(GLOB CORE_MEMORY_SRC_FILES ${CORE_MEMORY_DIR}/*.cpp)
|
||||
|
||||
set(CORE_SESSION_DIR ${PROJECT_SOURCE_DIR}/src/core/session)
|
||||
file(GLOB CORE_SESSION_SRC_FILES ${CORE_SESSION_DIR}/session.cpp)
|
||||
file(GLOB CORE_FILTER_SRC_FILES ${CORE_SESSION_DIR}/filter.cpp)
|
||||
file(GLOB CORE_DEVICE_PROFILING_SRC_FILES ${CORE_SESSION_DIR}/device_profiling.cpp)
|
||||
file(GLOB CORE_COUNTERS_SAMPLER_SRC_FILES ${CORE_SESSION_DIR}/counters_sampler.cpp)
|
||||
|
||||
set(CORE_HW_DIR ${PROJECT_SOURCE_DIR}/src/core/hardware)
|
||||
file(GLOB CORE_HW_SRC_FILES ${CORE_HW_DIR}/hsa_info.cpp)
|
||||
|
||||
set(CORE_HW_DIR ${PROJECT_SOURCE_DIR}/src/core/hardware)
|
||||
file(GLOB CORE_HW_SRC_FILES ${CORE_HW_DIR}/hsa_info.cpp)
|
||||
|
||||
set(CORE_UTILS_DIR ${PROJECT_SOURCE_DIR}/src/utils)
|
||||
file(GLOB CORE_UTILS_SRC_FILES ${CORE_UTILS_DIR}/*.cpp)
|
||||
|
||||
set(CORE_HSA_PACKETS_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa/packets)
|
||||
file(GLOB CORE_HSA_PACKETS_SRC_FILES ${CORE_HSA_PACKETS_DIR}/packets_generator.cpp)
|
||||
|
||||
file(GLOB CORE_COUNTERS_SRC_FILES ${PROJECT_BINARY_DIR}/src/api/*_counter.cpp)
|
||||
|
||||
file(GLOB ROCPROFILER_SRC_PROFILER_FILES ${PROJECT_SOURCE_DIR}/src/core/session/profiler/profiler.cpp)
|
||||
file(GLOB ROCPROFILER_TRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/*.cpp)
|
||||
file(GLOB ROCPROFILER_ROCTRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/src/*.cpp)
|
||||
file(GLOB ROCPROFILER_ATT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/att/att.cpp)
|
||||
file(GLOB ROCPROFILER_SRC_CLASS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocmtool.cpp)
|
||||
file(GLOB ROCPROFILER_SPM_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/spm/spm.cpp)
|
||||
file(GLOB ROCPROFILER_SRC_API_FILES ${PROJECT_SOURCE_DIR}/src/api/*.cpp)
|
||||
|
||||
set(ROCPROFILER_SRC_FILES ${ROCPROFILER_SRC_API_FILES} ${ROCPROFILER_SRC_CLASS_FILES} ${ROCPROFILER_SRC_PROFILER_FILES} ${ROCPROFILER_ATT_SRC_FILES})
|
||||
|
||||
set(CORE_HSA_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa)
|
||||
file(GLOB CORE_HSA_SRC_FILES ${CORE_HSA_DIR}/*.cpp)
|
||||
|
||||
set(CORE_HSA_QUEUES_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa/queues)
|
||||
file(GLOB CORE_HSA_QUEUES_SRC_FILES ${CORE_HSA_QUEUES_DIR}/*.cpp)
|
||||
|
||||
set(CORE_PC_SAMPLING_DIR ${PROJECT_SOURCE_DIR}/src/pcsampler)
|
||||
file(GLOB CORE_PC_SAMPLING_FILES ${CORE_PC_SAMPLING_DIR}/core/*.cpp ${CORE_PC_SAMPLING_DIR}/gfxip/*.cpp ${CORE_PC_SAMPLING_DIR}/session/*.cpp)
|
||||
|
||||
# Compiling gtests
|
||||
file(GLOB ROCPROFILER_TOOL_SRC_FILES ${PROJECT_SOURCE_DIR}/src/rocmtools/tools/tool.cpp)
|
||||
|
||||
file(GLOB CORE_COUNTERS_PARENT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/*.cpp)
|
||||
file(GLOB CORE_COUNTERS_METRICS_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/metrics/*.cpp)
|
||||
file(GLOB CORE_COUNTERS_MMIO_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/mmio/*.cpp)
|
||||
|
||||
add_executable(runUnitTests ${CMAKE_CURRENT_SOURCE_DIR}/profiler_gtest.cpp
|
||||
${CORE_MEMORY_SRC_FILES}
|
||||
${CORE_SESSION_SRC_FILES}
|
||||
${CORE_FILTER_SRC_FILES}
|
||||
${CORE_DEVICE_PROFILING_SRC_FILES}
|
||||
${CORE_COUNTERS_SAMPLER_SRC_FILES}
|
||||
${CORE_HW_SRC_FILES}
|
||||
${CORE_UTILS_SRC_FILES}
|
||||
${ROCPROFILER_SPM_SRC_FILES}
|
||||
${ROCPROFILER_SRC_FILES}
|
||||
${CORE_HSA_SRC_FILES}
|
||||
${CORE_HSA_PACKETS_SRC_FILES}
|
||||
${CORE_COUNTERS_SRC_FILES}
|
||||
${CORE_HSA_QUEUES_SRC_FILES}
|
||||
${ROCPROFILER_TRACER_SRC_FILES}
|
||||
${ROCPROFILER_ROCTRACER_SRC_FILES}
|
||||
${CORE_COUNTERS_METRICS_SRC_FILES}
|
||||
${CORE_COUNTERS_MMIO_SRC_FILES}
|
||||
${CORE_COUNTERS_PARENT_SRC_FILES}
|
||||
${CORE_PC_SAMPLING_FILES})
|
||||
|
||||
target_include_directories(runUnitTests PRIVATE ${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/inc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_BINARY_DIR}/rocprofiler)
|
||||
|
||||
target_compile_definitions(runUnitTests
|
||||
PUBLIC AMD_INTERNAL_BUILD
|
||||
PRIVATE PROF_API_IMPL HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_AMD__=1)
|
||||
|
||||
target_link_libraries(runUnitTests PRIVATE rocprofiler_tool ${AQLPROFILE_LIB}
|
||||
hsa-runtime64::hsa-runtime64
|
||||
GTest::gtest GTest::gtest_main stdc++fs
|
||||
${PCIACCESS_LIBRARIES})
|
||||
|
||||
add_dependencies(tests runUnitTests)
|
||||
install(TARGETS runUnitTests RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests COMPONENT tests)
|
||||
add_test(AllTests runUnitTests)
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
set (OLD_LIB_SRC
|
||||
${LIB_DIR}/core/rocprofiler.cpp
|
||||
${LIB_DIR}/core/gpu_command.cpp
|
||||
${LIB_DIR}/core/proxy_queue.cpp
|
||||
${LIB_DIR}/core/simple_proxy_queue.cpp
|
||||
${LIB_DIR}/core/intercept_queue.cpp
|
||||
${LIB_DIR}/core/metrics.cpp
|
||||
${LIB_DIR}/core/activity.cpp
|
||||
${LIB_DIR}/util/hsa_rsrc_factory.cpp
|
||||
)
|
||||
|
||||
# Setup unit testing env
|
||||
find_library(PCIACCESS_LIBRARIES pciaccess REQUIRED)
|
||||
|
||||
enable_testing()
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
# Getting Source files for ROCProfiler, Hardware, HSA, Memory, Session, Counters, Utils
|
||||
set(CORE_MEMORY_DIR ${PROJECT_SOURCE_DIR}/src/core/memory)
|
||||
file(GLOB CORE_MEMORY_SRC_FILES ${CORE_MEMORY_DIR}/*.cpp)
|
||||
|
||||
set(CORE_SESSION_DIR ${PROJECT_SOURCE_DIR}/src/core/session)
|
||||
file(GLOB CORE_SESSION_SRC_FILES ${CORE_SESSION_DIR}/session.cpp)
|
||||
file(GLOB CORE_FILTER_SRC_FILES ${CORE_SESSION_DIR}/filter.cpp)
|
||||
file(GLOB CORE_DEVICE_PROFILING_SRC_FILES ${CORE_SESSION_DIR}/device_profiling.cpp)
|
||||
file(GLOB CORE_COUNTERS_SAMPLER_SRC_FILES ${CORE_SESSION_DIR}/counters_sampler.cpp)
|
||||
|
||||
set(CORE_HW_DIR ${PROJECT_SOURCE_DIR}/src/core/hardware)
|
||||
file(GLOB CORE_HW_SRC_FILES ${CORE_HW_DIR}/hsa_info.cpp)
|
||||
|
||||
set(CORE_HW_DIR ${PROJECT_SOURCE_DIR}/src/core/hardware)
|
||||
file(GLOB CORE_HW_SRC_FILES ${CORE_HW_DIR}/hsa_info.cpp)
|
||||
|
||||
set(CORE_UTILS_DIR ${PROJECT_SOURCE_DIR}/src/utils)
|
||||
file(GLOB CORE_UTILS_SRC_FILES ${CORE_UTILS_DIR}/*.cpp)
|
||||
|
||||
set(CORE_HSA_PACKETS_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa/packets)
|
||||
file(GLOB CORE_HSA_PACKETS_SRC_FILES ${CORE_HSA_PACKETS_DIR}/packets_generator.cpp)
|
||||
|
||||
file(GLOB CORE_COUNTERS_SRC_FILES ${PROJECT_BINARY_DIR}/src/api/*_counter.cpp)
|
||||
|
||||
file(GLOB ROCPROFILER_SRC_API_FILES ${PROJECT_SOURCE_DIR}/src/api/*.cpp)
|
||||
|
||||
file(GLOB ROCPROFILER_SRC_PROFILER_FILES ${PROJECT_SOURCE_DIR}/src/core/session/profiler/profiler.cpp)
|
||||
file(GLOB ROCPROFILER_TRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/*.cpp)
|
||||
file(GLOB ROCPROFILER_ROCTRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/src/*.cpp)
|
||||
file(GLOB ROCPROFILER_ATT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/att/att.cpp)
|
||||
file(GLOB ROCPROFILER_SRC_CLASS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocmtool.cpp)
|
||||
file(GLOB ROCPROFILER_SPM_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/spm/spm.cpp)
|
||||
|
||||
set(ROCPROFILER_SRC_FILES ${ROCPROFILER_SRC_API_FILES} ${ROCPROFILER_SRC_CLASS_FILES} ${ROCPROFILER_SRC_PROFILER_FILES} ${ROCPROFILER_ATT_SRC_FILES})
|
||||
|
||||
set(CORE_HSA_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa)
|
||||
file(GLOB CORE_HSA_SRC_FILES ${CORE_HSA_DIR}/*.cpp)
|
||||
|
||||
set(CORE_HSA_QUEUES_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa/queues)
|
||||
file(GLOB CORE_HSA_QUEUES_SRC_FILES ${CORE_HSA_QUEUES_DIR}/*.cpp)
|
||||
|
||||
file(GLOB CORE_COUNTERS_PARENT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/*.cpp)
|
||||
file(GLOB CORE_COUNTERS_METRICS_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/metrics/*.cpp)
|
||||
file(GLOB CORE_COUNTERS_MMIO_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/mmio/*.cpp)
|
||||
|
||||
set(CORE_PC_SAMPLING_DIR ${PROJECT_SOURCE_DIR}/src/pcsampler)
|
||||
file(GLOB CORE_PC_SAMPLING_FILES ${CORE_PC_SAMPLING_DIR}/core/*.cpp ${CORE_PC_SAMPLING_DIR}/gfxip/*.cpp ${CORE_PC_SAMPLING_DIR}/session/*.cpp)
|
||||
|
||||
# Compiling gtests
|
||||
add_executable(runCoreUnitTests ${CMAKE_CURRENT_SOURCE_DIR}/gtests_main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/session/session_gtest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory/memory_gtest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hsa_info_gtest.cpp
|
||||
${CORE_MEMORY_SRC_FILES}
|
||||
${CORE_SESSION_SRC_FILES}
|
||||
${CORE_FILTER_SRC_FILES}
|
||||
${CORE_DEVICE_PROFILING_SRC_FILES}
|
||||
${CORE_COUNTERS_SAMPLER_SRC_FILES}
|
||||
${CORE_HW_SRC_FILES}
|
||||
${CORE_UTILS_SRC_FILES}
|
||||
${ROCPROFILER_SRC_FILES}
|
||||
${CORE_HSA_SRC_FILES}
|
||||
${ROCPROFILER_SPM_SRC_FILES}
|
||||
${CORE_HSA_PACKETS_SRC_FILES}
|
||||
${CORE_COUNTERS_SRC_FILES}
|
||||
${CORE_HSA_QUEUES_SRC_FILES}
|
||||
${ROCPROFILER_TRACER_SRC_FILES}
|
||||
${ROCPROFILER_ROCTRACER_SRC_FILES}
|
||||
${CORE_COUNTERS_METRICS_SRC_FILES}
|
||||
${CORE_COUNTERS_MMIO_SRC_FILES}
|
||||
${CORE_COUNTERS_PARENT_SRC_FILES}
|
||||
${CORE_PC_SAMPLING_FILES}
|
||||
${OLD_LIB_SRC})
|
||||
|
||||
target_include_directories(runCoreUnitTests PRIVATE ${PROJECT_SOURCE_DIR}
|
||||
${LIB_DIR} ${ROOT_DIR}
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/inc
|
||||
${PROJECT_SOURCE_DIR}/tests/unittests/profiler
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_BINARY_DIR}/rocprofiler)
|
||||
|
||||
target_compile_definitions(runCoreUnitTests
|
||||
PUBLIC AMD_INTERNAL_BUILD
|
||||
PRIVATE PROF_API_IMPL HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_AMD__=1)
|
||||
|
||||
# Link test executable against gtest & gtest_main
|
||||
target_link_libraries(runCoreUnitTests PRIVATE ${ROCPROFILER_TARGET} ${AQLPROFILE_LIB}
|
||||
hsa-runtime64::hsa-runtime64 c stdc++
|
||||
GTest::gtest GTest::gtest_main stdc++fs dl ${PCIACCESS_LIBRARIES})
|
||||
|
||||
add_dependencies(tests runCoreUnitTests)
|
||||
install(TARGETS runCoreUnitTests RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests COMPONENT tests)
|
||||
add_test(AllTests runCoreUnitTests)
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// Entry Point for Gtests Infra
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
testing::FLAGS_gtest_death_test_style = "threadsafe";
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/* Copyright (c) 2022 Advanced Micro Devices, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <vector>
|
||||
#include "core/hardware/hsa_info.h"
|
||||
|
||||
TEST(WhenTestingAgentInfoGetterSetters, TestRunsSuccessfully) {
|
||||
Agent::AgentInfo agent_info = Agent::AgentInfo();
|
||||
char gpu_name[] = "gfx10";
|
||||
agent_info.setName(gpu_name);
|
||||
agent_info.setIndex(0);
|
||||
agent_info.setType(hsa_device_type_t::HSA_DEVICE_TYPE_GPU);
|
||||
|
||||
EXPECT_EQ(agent_info.getName(), gpu_name);
|
||||
EXPECT_EQ(agent_info.getIndex(), 0);
|
||||
EXPECT_EQ(agent_info.getType(), hsa_device_type_t::HSA_DEVICE_TYPE_GPU);
|
||||
|
||||
Agent::CounterHardwareInfo hw_info(0, "GRBM");
|
||||
EXPECT_TRUE(getHardwareInfo(0, "GRBM", &hw_info));
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/* Copyright (c) 2022 Advanced Micro Devices, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "core/memory/generic_buffer.h"
|
||||
|
||||
void buffer_callback_fun(const rocprofiler_record_header_t* begin,
|
||||
const rocprofiler_record_header_t* end, rocprofiler_session_id_t session_id,
|
||||
rocprofiler_buffer_id_t buffer_id) {
|
||||
std::cout << "buffer callback" << std::endl;
|
||||
}
|
||||
// A lot have changed in the class, since this test was written
|
||||
// Need to rewrite all the test cases again.
|
||||
TEST(WhenAddingARecordToBuffer, DISABLED_RecordGetsAddedSuccefully) {
|
||||
Memory::GenericBuffer* buffer = new Memory::GenericBuffer(
|
||||
rocprofiler_session_id_t{0}, rocprofiler_buffer_id_t{0}, 0x8000, buffer_callback_fun);
|
||||
|
||||
uint64_t start_time = 0;
|
||||
uint64_t end_time = 10;
|
||||
|
||||
uint64_t kernel_object = 123456789;
|
||||
uint64_t gpu_name_descriptor = 1234565789;
|
||||
rocprofiler_record_profiler_t record = rocprofiler_record_profiler_t{
|
||||
rocprofiler_record_header_t{ROCPROFILER_PROFILER_RECORD, rocprofiler_record_id_t{0}},
|
||||
rocprofiler_kernel_id_t{kernel_object},
|
||||
rocprofiler_agent_id_t{gpu_name_descriptor},
|
||||
rocprofiler_queue_id_t{0},
|
||||
rocprofiler_record_header_timestamp_t{start_time, end_time},
|
||||
nullptr,
|
||||
0};
|
||||
|
||||
EXPECT_TRUE(buffer->AddRecord(record));
|
||||
delete buffer;
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
# Setup unit testing env
|
||||
|
||||
find_library(PCIACCESS_LIBRARIES pciaccess REQUIRED)
|
||||
|
||||
enable_testing()
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
# Getting Source files for ROCProfiler, Hardware, HSA, Memory, Session, Counters, Utils
|
||||
set(CORE_MEMORY_DIR ${PROJECT_SOURCE_DIR}/src/core/memory)
|
||||
file(GLOB CORE_MEMORY_SRC_FILES ${CORE_MEMORY_DIR}/*.cpp)
|
||||
|
||||
set(CORE_SESSION_DIR ${PROJECT_SOURCE_DIR}/src/core/session)
|
||||
file(GLOB CORE_SESSION_SRC_FILES ${CORE_SESSION_DIR}/session.cpp)
|
||||
file(GLOB CORE_FILTER_SRC_FILES ${CORE_SESSION_DIR}/filter.cpp)
|
||||
file(GLOB CORE_DEVICE_PROFILING_SRC_FILES ${CORE_SESSION_DIR}/device_profiling.cpp)
|
||||
file(GLOB CORE_COUNTERS_SAMPLER_SRC_FILES ${CORE_SESSION_DIR}/counters_sampler.cpp)
|
||||
|
||||
set(CORE_HW_DIR ${PROJECT_SOURCE_DIR}/src/core/hardware)
|
||||
file(GLOB CORE_HW_SRC_FILES ${CORE_HW_DIR}/hsa_info.cpp)
|
||||
|
||||
set(CORE_HW_DIR ${PROJECT_SOURCE_DIR}/src/core/hardware)
|
||||
file(GLOB CORE_HW_SRC_FILES ${CORE_HW_DIR}/hsa_info.cpp)
|
||||
|
||||
set(CORE_UTILS_DIR ${PROJECT_SOURCE_DIR}/src/utils)
|
||||
file(GLOB CORE_UTILS_SRC_FILES ${CORE_UTILS_DIR}/*.cpp)
|
||||
|
||||
set(CORE_HSA_PACKETS_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa/packets)
|
||||
file(GLOB CORE_HSA_PACKETS_SRC_FILES ${CORE_HSA_PACKETS_DIR}/packets_generator.cpp)
|
||||
|
||||
file(GLOB CORE_COUNTERS_SRC_FILES ${PROJECT_BINARY_DIR}/src/api/*_counter.cpp)
|
||||
|
||||
file(GLOB ROCPROFILER_SRC_PROFILER_FILES ${PROJECT_SOURCE_DIR}/src/core/session/profiler/profiler.cpp)
|
||||
file(GLOB ROCPROFILER_TRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/*.cpp)
|
||||
file(GLOB ROCPROFILER_ROCTRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/src/*.cpp)
|
||||
file(GLOB ROCPROFILER_ATT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/att/att.cpp)
|
||||
file(GLOB ROCPROFILER_SRC_CLASS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocmtool.cpp)
|
||||
file(GLOB ROCPROFILER_SPM_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/spm/spm.cpp)
|
||||
file(GLOB ROCPROFILER_SRC_API_FILES ${PROJECT_SOURCE_DIR}/src/api/*.cpp)
|
||||
|
||||
set(ROCPROFILER_SRC_FILES ${ROCPROFILER_SRC_API_FILES} ${ROCPROFILER_SRC_CLASS_FILES} ${ROCPROFILER_SRC_PROFILER_FILES} ${ROCPROFILER_ATT_SRC_FILES})
|
||||
|
||||
set(CORE_HSA_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa)
|
||||
file(GLOB CORE_HSA_SRC_FILES ${CORE_HSA_DIR}/*.cpp)
|
||||
|
||||
set(CORE_HSA_QUEUES_DIR ${PROJECT_SOURCE_DIR}/src/core/hsa/queues)
|
||||
file(GLOB CORE_HSA_QUEUES_SRC_FILES ${CORE_HSA_QUEUES_DIR}/*.cpp)
|
||||
|
||||
set(CORE_PC_SAMPLING_DIR ${PROJECT_SOURCE_DIR}/src/pcsampler)
|
||||
file(GLOB CORE_PC_SAMPLING_FILES ${CORE_PC_SAMPLING_DIR}/core/*.cpp ${CORE_PC_SAMPLING_DIR}/gfxip/*.cpp ${CORE_PC_SAMPLING_DIR}/session/*.cpp)
|
||||
|
||||
# Compiling gtests
|
||||
file(GLOB ROCPROFILER_TOOL_SRC_FILES ${PROJECT_SOURCE_DIR}/src/rocmtools/tools/tool.cpp)
|
||||
|
||||
file(GLOB CORE_COUNTERS_PARENT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/*.cpp)
|
||||
file(GLOB CORE_COUNTERS_METRICS_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/metrics/*.cpp)
|
||||
file(GLOB CORE_COUNTERS_MMIO_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/counters/mmio/*.cpp)
|
||||
|
||||
add_executable(runProfilerUnitTests ${CMAKE_CURRENT_SOURCE_DIR}/tools/tool_gtest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api/rocmtool_gtest.cpp
|
||||
${CORE_MEMORY_SRC_FILES}
|
||||
${CORE_SESSION_SRC_FILES}
|
||||
${CORE_FILTER_SRC_FILES}
|
||||
${CORE_DEVICE_PROFILING_SRC_FILES}
|
||||
${CORE_COUNTERS_SAMPLER_SRC_FILES}
|
||||
${CORE_HW_SRC_FILES}
|
||||
${CORE_UTILS_SRC_FILES}
|
||||
${ROCPROFILER_SPM_SRC_FILES}
|
||||
${ROCPROFILER_SRC_FILES}
|
||||
${CORE_HSA_SRC_FILES}
|
||||
${CORE_HSA_PACKETS_SRC_FILES}
|
||||
${CORE_COUNTERS_SRC_FILES}
|
||||
${CORE_HSA_QUEUES_SRC_FILES}
|
||||
${ROCPROFILER_TRACER_SRC_FILES}
|
||||
${ROCPROFILER_ROCTRACER_SRC_FILES}
|
||||
${CORE_COUNTERS_METRICS_SRC_FILES}
|
||||
${CORE_COUNTERS_MMIO_SRC_FILES}
|
||||
${CORE_COUNTERS_PARENT_SRC_FILES}
|
||||
${CORE_PC_SAMPLING_FILES})
|
||||
|
||||
target_include_directories(runProfilerUnitTests PRIVATE ${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/inc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_BINARY_DIR}/rocprofiler)
|
||||
|
||||
target_compile_definitions(runProfilerUnitTests
|
||||
PUBLIC AMD_INTERNAL_BUILD
|
||||
PRIVATE PROF_API_IMPL HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_AMD__=1)
|
||||
|
||||
target_link_libraries(runProfilerUnitTests PRIVATE rocprofiler_tool ${AQLPROFILE_LIB}
|
||||
hsa-runtime64::hsa-runtime64
|
||||
GTest::gtest GTest::gtest_main stdc++fs
|
||||
${PCIACCESS_LIBRARIES})
|
||||
|
||||
add_dependencies(tests runProfilerUnitTests)
|
||||
install(TARGETS runProfilerUnitTests RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests COMPONENT tests)
|
||||
add_test(AllTests runProfilerUnitTests)
|
||||
@@ -1,91 +0,0 @@
|
||||
/* Copyright (c) 2022 Advanced Micro Devices, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "core/session/session.h"
|
||||
#include "api/rocmtool.h"
|
||||
|
||||
void (*callback_fun)(const rocprofiler_record_header_t* begin, const rocprofiler_record_header_t* end,
|
||||
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id);
|
||||
|
||||
TEST(WhenTestingCounterCollectionMode, TestSucceeds) {
|
||||
rocprofiler_session_id_t session_id;
|
||||
|
||||
rocmtools::rocmtool toolobj;
|
||||
session_id = toolobj.CreateSession(ROCPROFILER_NONE_REPLAY_MODE);
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
toolobj.GetSession(session_id)
|
||||
->CreateFilter(ROCPROFILER_COUNTERS_COLLECTION, rocprofiler_filter_data_t{}, 0,
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
toolobj.GetSession(session_id)->CreateBuffer(callback_fun, 0x9999);
|
||||
toolobj.GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
|
||||
|
||||
rocmtools::Session* session = toolobj.GetSession(session_id);
|
||||
EXPECT_TRUE(session->FindFilterWithKind(ROCPROFILER_COUNTERS_COLLECTION));
|
||||
toolobj.DestroySession(session_id);
|
||||
}
|
||||
|
||||
TEST(WhenTestingTimeStampCollectionMode, TestSucceeds) {
|
||||
rocprofiler_session_id_t session_id;
|
||||
|
||||
rocmtools::rocmtool toolobj;
|
||||
session_id = toolobj.CreateSession(ROCPROFILER_NONE_REPLAY_MODE);
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
toolobj.GetSession(session_id)
|
||||
->CreateFilter(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION, rocprofiler_filter_data_t{}, 0,
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
toolobj.GetSession(session_id)->CreateBuffer(callback_fun, 0x9999);
|
||||
toolobj.GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
|
||||
|
||||
rocmtools::Session* session = toolobj.GetSession(session_id);
|
||||
|
||||
EXPECT_TRUE(session->FindFilterWithKind(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION));
|
||||
toolobj.DestroySession(session_id);
|
||||
}
|
||||
|
||||
TEST(WhenTestingApplicationReplayMode, TestSucceeds) {
|
||||
std::vector<const char*> counters;
|
||||
counters.emplace_back("SQ_WAVES");
|
||||
rocprofiler_session_id_t session_id;
|
||||
|
||||
rocmtools::rocmtool toolobj;
|
||||
session_id = toolobj.CreateSession(ROCPROFILER_APPLICATION_REPLAY_MODE);
|
||||
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
toolobj.GetSession(session_id)
|
||||
->CreateFilter(ROCPROFILER_COUNTERS_COLLECTION,
|
||||
rocprofiler_filter_data_t{.counters_names = &counters[0]}, counters.size(),
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
toolobj.GetSession(session_id)->CreateBuffer(callback_fun, 0x8000);
|
||||
toolobj.GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
|
||||
rocmtools::Session* session = toolobj.GetSession(session_id);
|
||||
|
||||
EXPECT_TRUE(session->FindFilterWithKind(ROCPROFILER_COUNTERS_COLLECTION));
|
||||
toolobj.DestroySession(session_id);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/* Copyright (c) 2022 Advanced Micro Devices, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "utils/helper.h"
|
||||
|
||||
TEST(WhenTrucatingLongKernelNames, KernelNameGetsTruncatedProperly) {
|
||||
std::string long_kernel_name =
|
||||
"void kernel_7r_3d_pml<32, 8, 4>(long long, long long, long long, int, "
|
||||
"int, int, long long, long long, long long, long long, long long, long "
|
||||
"long, long long, long long, long long, float, float, float, float "
|
||||
"const*, float*, float const*, float*, float const*) [clone .kd]";
|
||||
|
||||
std::string trunkated_name = rocmtools::truncate_name(long_kernel_name);
|
||||
|
||||
EXPECT_EQ("kernel_7r_3d_pml", trunkated_name);
|
||||
}
|
||||
+166
-16
@@ -20,19 +20,82 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
#include "api/rocmtool.h"
|
||||
#include "core/memory/generic_buffer.h"
|
||||
#include "core/hardware/hsa_info.h"
|
||||
#include "core/session/session.h"
|
||||
#include "utils/helper.h"
|
||||
|
||||
void (*buffer_callback_fun)(const rocprofiler_record_header_t* begin,
|
||||
const rocprofiler_record_header_t* end, rocprofiler_session_id_t session_id,
|
||||
rocprofiler_buffer_id_t buffer_id);
|
||||
|
||||
/*
|
||||
* ###############################################
|
||||
* ################TESTING HSA_INFO###############
|
||||
* ###############################################
|
||||
*/
|
||||
|
||||
TEST(WhenTestingAgentInfoGetterSetters, TestRunsSuccessfully) {
|
||||
Agent::AgentInfo agent_info = Agent::AgentInfo();
|
||||
char gpu_name[] = "gfx10";
|
||||
agent_info.setName(gpu_name);
|
||||
agent_info.setIndex(0);
|
||||
agent_info.setType(hsa_device_type_t::HSA_DEVICE_TYPE_GPU);
|
||||
|
||||
EXPECT_EQ(agent_info.getName(), gpu_name);
|
||||
EXPECT_EQ(agent_info.getIndex(), 0);
|
||||
EXPECT_EQ(agent_info.getType(), hsa_device_type_t::HSA_DEVICE_TYPE_GPU);
|
||||
|
||||
Agent::CounterHardwareInfo hw_info(0, "GRBM");
|
||||
EXPECT_TRUE(getHardwareInfo(0, "GRBM", &hw_info));
|
||||
}
|
||||
|
||||
void buffer_callback_fun(const rocprofiler_record_header_t* begin,
|
||||
const rocprofiler_record_header_t* end,
|
||||
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id) {
|
||||
std::cout << "buffer callback" << std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
* ###############################################
|
||||
* ################TESTING BUFFERS###############
|
||||
* ###############################################
|
||||
*/
|
||||
|
||||
// A lot have changed in the class, since this test was written
|
||||
// Need to rewrite all the test cases again.
|
||||
TEST(WhenAddingARecordToBuffer, DISABLED_RecordGetsAddedSuccefully) {
|
||||
Memory::GenericBuffer* buffer = new Memory::GenericBuffer(
|
||||
rocprofiler_session_id_t{0}, rocprofiler_buffer_id_t{0}, 0x8000, buffer_callback_fun);
|
||||
|
||||
uint64_t start_time = 0;
|
||||
uint64_t end_time = 10;
|
||||
|
||||
uint64_t kernel_object = 123456789;
|
||||
uint64_t gpu_name_descriptor = 1234565789;
|
||||
rocprofiler_record_profiler_t record = rocprofiler_record_profiler_t{
|
||||
rocprofiler_record_header_t{ROCPROFILER_PROFILER_RECORD, rocprofiler_record_id_t{0}},
|
||||
rocprofiler_kernel_id_t{kernel_object},
|
||||
rocprofiler_agent_id_t{gpu_name_descriptor},
|
||||
rocprofiler_queue_id_t{0},
|
||||
rocprofiler_record_header_timestamp_t{start_time, end_time},
|
||||
nullptr,
|
||||
0};
|
||||
|
||||
EXPECT_TRUE(buffer->AddRecord(record));
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* ###############################################
|
||||
* ################TESTING SESSIONS###############
|
||||
* ###############################################
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This class creates a single timestamp session
|
||||
*
|
||||
* This class creates a single timestamp session
|
||||
*/
|
||||
|
||||
class TimeStampSession : public ::testing::Test {
|
||||
@@ -91,9 +154,9 @@ TEST_F(TimeStampSession, ForANewlyCreatedSessionValidSessionIdIsReturned) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This class creates multiple time stamp sessions
|
||||
*
|
||||
* This class creates multiple time stamp sessions
|
||||
*/
|
||||
|
||||
class TestingMultipleSessions : public ::testing::Test {
|
||||
protected:
|
||||
std::vector<std::unique_ptr<rocmtools::Session>> session_list;
|
||||
@@ -160,6 +223,13 @@ TEST_F(TestingMultipleSessions, DeactivatingAnActivatedSessionPasses) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ###############################################
|
||||
* ################TESTING ROCMTOOLS##############
|
||||
* ###############################################
|
||||
*/
|
||||
|
||||
|
||||
// Createing sessions with 2 different profiling mode
|
||||
TEST(WhenCreatingTwoSessionsWithDiffProfilingMode, BothSessionsAreCreated) {
|
||||
std::map<uint64_t, std::unique_ptr<rocmtools::Session>> sessions;
|
||||
@@ -172,14 +242,15 @@ TEST(WhenCreatingTwoSessionsWithDiffProfilingMode, BothSessionsAreCreated) {
|
||||
std::vector<const char*> counters;
|
||||
counters.emplace_back("SQ_WAVES");
|
||||
counters.emplace_back("GRBM_COUNT");
|
||||
sessions.emplace(session_id.handle,
|
||||
std::make_unique<rocmtools::Session>(ROCPROFILER_NONE_REPLAY_MODE, session_id));
|
||||
sessions.emplace(
|
||||
session_id.handle,
|
||||
std::make_unique<rocmtools::Session>(ROCPROFILER_NONE_REPLAY_MODE, session_id));
|
||||
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
sessions.at(session_id.handle)
|
||||
->CreateFilter(ROCPROFILER_COUNTERS_COLLECTION,
|
||||
rocprofiler_filter_data_t{.counters_names = &counters[0]}, counters.size(),
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_filter_data_t{.counters_names = &counters[0]},
|
||||
counters.size(), rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
sessions.at(session_id.handle)->CreateBuffer(buffer_callback_fun, 0x9999);
|
||||
sessions.at(session_id.handle)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
@@ -187,12 +258,13 @@ TEST(WhenCreatingTwoSessionsWithDiffProfilingMode, BothSessionsAreCreated) {
|
||||
{
|
||||
// create a timestamp collection session
|
||||
rocprofiler_session_id_t session_id{2};
|
||||
sessions.emplace(session_id.handle,
|
||||
std::make_unique<rocmtools::Session>(ROCPROFILER_NONE_REPLAY_MODE, session_id));
|
||||
sessions.emplace(
|
||||
session_id.handle,
|
||||
std::make_unique<rocmtools::Session>(ROCPROFILER_NONE_REPLAY_MODE, session_id));
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
sessions.at(session_id.handle)
|
||||
->CreateFilter(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION, rocprofiler_filter_data_t{}, 0,
|
||||
rocprofiler_filter_property_t{});
|
||||
->CreateFilter(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION, rocprofiler_filter_data_t{},
|
||||
0, rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
sessions.at(session_id.handle)->CreateBuffer(buffer_callback_fun, 0x9999);
|
||||
sessions.at(session_id.handle)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
@@ -203,4 +275,82 @@ TEST(WhenCreatingTwoSessionsWithDiffProfilingMode, BothSessionsAreCreated) {
|
||||
EXPECT_TRUE(sessions.at(2)->FindFilterWithKind(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION));
|
||||
|
||||
sessions.clear();
|
||||
}
|
||||
|
||||
void (*callback_fun)(const rocprofiler_record_header_t* begin,
|
||||
const rocprofiler_record_header_t* end, rocprofiler_session_id_t session_id,
|
||||
rocprofiler_buffer_id_t buffer_id);
|
||||
|
||||
TEST(WhenTestingCounterCollectionMode, TestSucceeds) {
|
||||
rocprofiler_session_id_t session_id;
|
||||
|
||||
rocmtools::rocmtool toolobj;
|
||||
session_id = toolobj.CreateSession(ROCPROFILER_NONE_REPLAY_MODE);
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
toolobj.GetSession(session_id)
|
||||
->CreateFilter(ROCPROFILER_COUNTERS_COLLECTION, rocprofiler_filter_data_t{}, 0,
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
toolobj.GetSession(session_id)->CreateBuffer(callback_fun, 0x9999);
|
||||
toolobj.GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
|
||||
|
||||
rocmtools::Session* session = toolobj.GetSession(session_id);
|
||||
EXPECT_TRUE(session->FindFilterWithKind(ROCPROFILER_COUNTERS_COLLECTION));
|
||||
toolobj.DestroySession(session_id);
|
||||
}
|
||||
|
||||
TEST(WhenTestingTimeStampCollectionMode, TestSucceeds) {
|
||||
rocprofiler_session_id_t session_id;
|
||||
|
||||
rocmtools::rocmtool toolobj;
|
||||
session_id = toolobj.CreateSession(ROCPROFILER_NONE_REPLAY_MODE);
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
toolobj.GetSession(session_id)
|
||||
->CreateFilter(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION, rocprofiler_filter_data_t{}, 0,
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
toolobj.GetSession(session_id)->CreateBuffer(callback_fun, 0x9999);
|
||||
toolobj.GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
|
||||
|
||||
rocmtools::Session* session = toolobj.GetSession(session_id);
|
||||
|
||||
EXPECT_TRUE(session->FindFilterWithKind(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION));
|
||||
toolobj.DestroySession(session_id);
|
||||
}
|
||||
|
||||
TEST(WhenTestingApplicationReplayMode, TestSucceeds) {
|
||||
std::vector<const char*> counters;
|
||||
counters.emplace_back("SQ_WAVES");
|
||||
rocprofiler_session_id_t session_id;
|
||||
|
||||
rocmtools::rocmtool toolobj;
|
||||
session_id = toolobj.CreateSession(ROCPROFILER_APPLICATION_REPLAY_MODE);
|
||||
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
toolobj.GetSession(session_id)
|
||||
->CreateFilter(ROCPROFILER_COUNTERS_COLLECTION,
|
||||
rocprofiler_filter_data_t{.counters_names = &counters[0]}, counters.size(),
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
toolobj.GetSession(session_id)->CreateBuffer(callback_fun, 0x8000);
|
||||
toolobj.GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
|
||||
rocmtools::Session* session = toolobj.GetSession(session_id);
|
||||
|
||||
EXPECT_TRUE(session->FindFilterWithKind(ROCPROFILER_COUNTERS_COLLECTION));
|
||||
toolobj.DestroySession(session_id);
|
||||
}
|
||||
|
||||
TEST(WhenTrucatingLongKernelNames, KernelNameGetsTruncatedProperly) {
|
||||
std::string long_kernel_name =
|
||||
"void kernel_7r_3d_pml<32, 8, 4>(long long, long long, long long, int, "
|
||||
"int, int, long long, long long, long long, long long, long long, long "
|
||||
"long, long long, long long, long long, float, float, float, float "
|
||||
"const*, float*, float const*, float*, float const*) [clone .kd]";
|
||||
|
||||
std::string trunkated_name = rocmtools::truncate_name(long_kernel_name);
|
||||
|
||||
EXPECT_EQ("kernel_7r_3d_pml", trunkated_name);
|
||||
}
|
||||
Reference in New Issue
Block a user