Adding rocprofilerv2
Change-Id: Ic0cc280ba207d2b8f6ccae1cd4ac3184152fc1ad
Bu işleme şunda yer alıyor:
@@ -0,0 +1,2 @@
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(profiler)
|
||||
@@ -0,0 +1,106 @@
|
||||
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)
|
||||
|
||||
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_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})
|
||||
|
||||
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)
|
||||
|
||||
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_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_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)
|
||||
@@ -0,0 +1,9 @@
|
||||
#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();
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/* 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));
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/* 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;
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/* 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 <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "core/memory/generic_buffer.h"
|
||||
#include "core/session/session.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);
|
||||
|
||||
/**
|
||||
* @brief This class creates a single timestamp session
|
||||
*
|
||||
*/
|
||||
|
||||
class TimeStampSession : public ::testing::Test {
|
||||
protected:
|
||||
rocprofiler_session_id_t session_id{1234};
|
||||
std::unique_ptr<rocmtools::Session> session_ptr =
|
||||
std::make_unique<rocmtools::Session>(ROCPROFILER_NONE_REPLAY_MODE, session_id);
|
||||
|
||||
void SetUp() {
|
||||
rocprofiler_filter_id_t filter_id =
|
||||
session_ptr->CreateFilter(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION,
|
||||
rocprofiler_filter_data_t{}, 0, rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id = session_ptr->CreateBuffer(buffer_callback_fun, 0x9999);
|
||||
session_ptr->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
session_ptr->Start();
|
||||
}
|
||||
void TearDown() { session_ptr->Terminate(); }
|
||||
};
|
||||
|
||||
TEST_F(TimeStampSession, NewlyActivatedSessionIsActive) {
|
||||
// check if session is inactive
|
||||
EXPECT_TRUE(session_ptr->IsActive());
|
||||
}
|
||||
|
||||
TEST_F(TimeStampSession, DeactivatingNewlyCreatedSessionPasses) {
|
||||
// check if session is inactive
|
||||
EXPECT_TRUE(session_ptr->IsActive());
|
||||
|
||||
// Activate session
|
||||
session_ptr->Terminate();
|
||||
|
||||
// check if session is active
|
||||
EXPECT_FALSE(session_ptr->IsActive());
|
||||
}
|
||||
|
||||
TEST_F(TimeStampSession, DeactivatingAnActivatedSessionPasses) {
|
||||
// activate the session
|
||||
session_ptr->Start();
|
||||
|
||||
// check if session is active
|
||||
EXPECT_TRUE(session_ptr->IsActive());
|
||||
|
||||
// deactivate the session
|
||||
session_ptr->Terminate();
|
||||
|
||||
// check if session is inactive
|
||||
EXPECT_FALSE(session_ptr->IsActive());
|
||||
}
|
||||
|
||||
TEST_F(TimeStampSession, ForANewlyCreatedSessionValidSessionIdIsReturned) {
|
||||
// get session id
|
||||
rocprofiler_session_id_t session_id = session_ptr->GetId();
|
||||
|
||||
// check for the valid id
|
||||
EXPECT_EQ(1234, session_id.handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This class creates multiple time stamp sessions
|
||||
*
|
||||
*/
|
||||
class TestingMultipleSessions : public ::testing::Test {
|
||||
protected:
|
||||
std::vector<std::unique_ptr<rocmtools::Session>> session_list;
|
||||
uint64_t number_of_sessions = 5;
|
||||
void SetUp() {
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
std::unique_ptr<rocmtools::Session> timestamp_session = std::make_unique<rocmtools::Session>(
|
||||
ROCPROFILER_NONE_REPLAY_MODE, rocprofiler_session_id_t{id});
|
||||
|
||||
rocprofiler_filter_id_t filter_id = timestamp_session->CreateFilter(
|
||||
ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION, rocprofiler_filter_data_t{}, 0,
|
||||
rocprofiler_filter_property_t{});
|
||||
rocprofiler_buffer_id_t buffer_id =
|
||||
timestamp_session->CreateBuffer(buffer_callback_fun, 0x9999);
|
||||
timestamp_session->GetFilter(filter_id)->SetBufferId(buffer_id);
|
||||
timestamp_session->Start();
|
||||
session_list.push_back(std::move(timestamp_session));
|
||||
}
|
||||
}
|
||||
void TearDown() {
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
session_list[id]->Terminate();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TestingMultipleSessions, AllSessionsAreCreatedSuccessfully) {
|
||||
// check if sessions are inactive
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
EXPECT_TRUE(session_list[id]->IsActive());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestingMultipleSessions, AllSessionsAreActivatedSuccessfully) {
|
||||
// Activate all sessions
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
session_list[id]->Start();
|
||||
}
|
||||
// Check if sessions are activated
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
EXPECT_TRUE(session_list[id]->IsActive());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestingMultipleSessions, DeactivatingAnActivatedSessionPasses) {
|
||||
// Activate all sessions
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
session_list[id]->Start();
|
||||
}
|
||||
|
||||
// Check if sessions are activated
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
EXPECT_TRUE(session_list[id]->IsActive());
|
||||
}
|
||||
|
||||
// deactivate the sessions
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
session_list[id]->Terminate();
|
||||
}
|
||||
|
||||
// check if all sessions are deactivated
|
||||
for (uint64_t id = 0; id < number_of_sessions; id++) {
|
||||
EXPECT_FALSE(session_list[id]->IsActive());
|
||||
}
|
||||
}
|
||||
|
||||
// Createing sessions with 2 different profiling mode
|
||||
TEST(WhenCreatingTwoSessionsWithDiffProfilingMode, BothSessionsAreCreated) {
|
||||
std::map<uint64_t, std::unique_ptr<rocmtools::Session>> sessions;
|
||||
|
||||
sessions = std::map<uint64_t, std::unique_ptr<rocmtools::Session>>();
|
||||
|
||||
{
|
||||
// create a counter collection session
|
||||
rocprofiler_session_id_t session_id{1};
|
||||
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));
|
||||
|
||||
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_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);
|
||||
}
|
||||
{
|
||||
// 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));
|
||||
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{});
|
||||
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);
|
||||
}
|
||||
|
||||
// check for correct profiling mode
|
||||
EXPECT_TRUE(sessions.at(1)->FindFilterWithKind(ROCPROFILER_COUNTERS_COLLECTION));
|
||||
EXPECT_TRUE(sessions.at(2)->FindFilterWithKind(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION));
|
||||
|
||||
sessions.clear();
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
# 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)
|
||||
|
||||
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_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})
|
||||
|
||||
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)
|
||||
|
||||
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_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_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)
|
||||
@@ -0,0 +1,91 @@
|
||||
/* 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);
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
// TODO(aelwazir): To be checked
|
||||
|
||||
#include "hip/hip_runtime.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
#include <hip/hip_profile.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#define N 2560
|
||||
//change here to run this app longer
|
||||
#define num_iters 1
|
||||
|
||||
|
||||
template<int n, int m>
|
||||
__global__ void kernel(double* x) {
|
||||
for (int idx = threadIdx.x + blockIdx.x * blockDim.x; idx < N; idx += gridDim.x * blockDim.x)
|
||||
{
|
||||
#pragma unroll
|
||||
for (int i = 0; i < n; ++i)
|
||||
x[idx] += i * m;
|
||||
}
|
||||
}
|
||||
|
||||
void cpuWork() {
|
||||
// Do some CPU "work".
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
inline void hip_assert(hipError_t err, const char *file, int line)
|
||||
{
|
||||
if (err != hipSuccess)
|
||||
{
|
||||
fprintf(stderr,"HIP error: %s %s %d\n", hipGetErrorString(err), file, line);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
#define hipErrorCheck(f) { hip_assert((f), __FILE__, __LINE__); }
|
||||
#define kernelErrorCheck() { hipErrorCheck(hipPeekAtLastError()); }
|
||||
|
||||
int main() {
|
||||
|
||||
double* x;
|
||||
double* x_h;
|
||||
|
||||
size_t sz = N * sizeof(double);
|
||||
std::cout << "running app....." << std::endl;
|
||||
hipErrorCheck(hipHostMalloc(&x_h, sz));
|
||||
|
||||
memset(x_h, 0, sz);
|
||||
hipErrorCheck(hipMallocManaged(&x, sz));
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
|
||||
hipStream_t stream;
|
||||
hipErrorCheck(hipStreamCreate(&stream));
|
||||
|
||||
hipFuncAttributes attr;
|
||||
|
||||
int blocks = 80;
|
||||
int threads = 32;
|
||||
int fact = 100;
|
||||
for (int j = 0; j < num_iters; ++j) {
|
||||
for (int n = 0; n < 25*fact; ++n) {
|
||||
hipErrorCheck(hipMemcpyAsync(x, x_h, sz, hipMemcpyHostToDevice));
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,1>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,2>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,3>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,4>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,5>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,6>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,7>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,8>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,9>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,10>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,11>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,12>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,13>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,14>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,15>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,16>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,17>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,18>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,19>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,20>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,20>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,21>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,22>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,23>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,24>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,25>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,26>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,27>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,28>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,29>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,30>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,30>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,31>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,32>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,33>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,34>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,35>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,36>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,37>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,38>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,39>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<1,40>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipErrorCheck(hipMemcpyAsync(x_h, x, sz, hipMemcpyDeviceToHost));
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
for (int n = 0; n < 200*fact; ++n) {
|
||||
hipErrorCheck(hipFuncGetAttributes(&attr, reinterpret_cast<const void*>(kernel<10,1>)));
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<10,1>), dim3(blocks), dim3(threads), 0, stream, x);
|
||||
kernelErrorCheck();
|
||||
hipErrorCheck(hipStreamSynchronize(stream));
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
for (int n = 0; n < 30*fact; ++n) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
hipErrorCheck(hipFuncGetAttributes(&attr, reinterpret_cast<const void*>(kernel<8,1>)));
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<8,1>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
}
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
for (int n = 0; n < 100*fact; ++n) {
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,1>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,2>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,3>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,4>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,5>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
for (int n = 0; n < 100*fact; ++n) {
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,1>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,2>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,3>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,4>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<7,5>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
for (int n = 0; n < 50*fact; ++n) {
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,1>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,2>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,3>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,4>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,5>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,6>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,7>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<6,8>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
for (int n = 0; n < 50*fact; ++n) {
|
||||
int val;
|
||||
hipErrorCheck(hipDeviceGetAttribute(&val, hipDeviceAttributeMaxThreadsPerBlock, 0));
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<4000,1>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
for (int n = 0; n < 50*fact; ++n) {
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(kernel<5000,1>), dim3(blocks), dim3(threads), 0, 0, x);
|
||||
kernelErrorCheck();
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
hipErrorCheck(hipMemset(x, 0, sz));
|
||||
cpuWork();
|
||||
|
||||
hipErrorCheck(hipDeviceSynchronize());
|
||||
|
||||
}
|
||||
|
||||
hipErrorCheck(hipHostFree(x_h));
|
||||
hipErrorCheck(hipFree(x));
|
||||
hipErrorCheck(hipStreamDestroy(stream));
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/* 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);
|
||||
}
|
||||
Yeni konuda referans
Bir kullanıcı engelle