From a550cde477bb91bf2a60c728be1e8127aea5cc0d Mon Sep 17 00:00:00 2001 From: gobhardw Date: Tue, 6 Jun 2023 01:48:12 +0530 Subject: [PATCH] Decoupling HIP code with runFeatureTest target Change-Id: I8cac692289c7c9393b76789b0fa67eb239df2079 [ROCm/rocprofiler commit: 7da40d2d7b4e975cab41e2a6ac969b422d8c5f04] --- .../featuretests/profiler/CMakeLists.txt | 9 +- .../profiler/apps/hip_kernels.cpp | 106 +++++ .../featuretests/profiler/apps/hip_kernels.h | 26 ++ .../featuretests/profiler/profiler_gtest.cpp | 421 +++++------------- .../featuretests/profiler/profiler_gtest.h | 53 ++- 5 files changed, 272 insertions(+), 343 deletions(-) create mode 100644 projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.cpp create mode 100644 projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.h diff --git a/projects/rocprofiler/tests-v2/featuretests/profiler/CMakeLists.txt b/projects/rocprofiler/tests-v2/featuretests/profiler/CMakeLists.txt index d170251dd6..d314edb8b4 100644 --- a/projects/rocprofiler/tests-v2/featuretests/profiler/CMakeLists.txt +++ b/projects/rocprofiler/tests-v2/featuretests/profiler/CMakeLists.txt @@ -161,9 +161,10 @@ add_custom_target(hsaco_targets DEPENDS ${HSACO_TARGET_LIST}) # target_link_libraries(profiler_multiqueue_test PRIVATE hsa-runtime64::hsa-runtime64 Threads::Threads dl stdc++fs amd_comgr) # add_dependencies(tests profiler_multiqueue_test) -# Add test cpp file -set_source_files_properties(profiler_gtest.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) -hip_add_executable(runFeatureTests profiler_gtest.cpp +set_source_files_properties(apps/hip_kernels.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) +hip_add_executable(runFeatureTests + profiler_gtest.cpp + apps/hip_kernels.cpp ${GTEST_MAIN_SRC_FILE} ${CORE_HSA_SRC_FILES} ${CORE_HW_SRC_FILES} @@ -179,7 +180,7 @@ target_include_directories(runFeatureTests PRIVATE ${TEST_DIR} # Link test executable against gtest & gtest_main target_link_libraries(runFeatureTests PRIVATE rocprofiler-v2 hsa-runtime64::hsa-runtime64 - GTest::gtest GTest::gtest_main + GTest::gtest GTest::gtest_main Threads::Threads dl stdc++fs amd_comgr) add_dependencies(tests runFeatureTests) target_link_options(runFeatureTests PRIVATE "-Wl,--build-id=md5") diff --git a/projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.cpp b/projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.cpp new file mode 100644 index 0000000000..1a6b856a11 --- /dev/null +++ b/projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.cpp @@ -0,0 +1,106 @@ +#include +#ifdef NDEBUG +#define HIP_ASSERT(x) x +#else +#define HIP_ASSERT(x) (assert((x) == hipSuccess)) +#endif + +#define WIDTH 1024 +#define HEIGHT 1024 + +#define NUM (WIDTH * HEIGHT) + +#define THREADS_PER_BLOCK_X 16 +#define THREADS_PER_BLOCK_Y 16 +#define THREADS_PER_BLOCK_Z 1 + +// empty kernel +__global__ void kernel() {} + +// vector add kernel +__global__ void vectoradd_float(float* __restrict__ a, const float* __restrict__ b, + const float* __restrict__ c, int width, int height) + +{ + int x = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x; + int y = hipBlockDim_y * hipBlockIdx_y + hipThreadIdx_y; + + int i = y * width + x; + if (i < (width * height)) { + a[i] = b[i] + c[i]; + } +} + +// launches an empty kernel in profiler context +void KernelLaunch() { + // run empty kernel + kernel<<<1, 1>>>(); + hipDeviceSynchronize(); +} + +int LaunchVectorAddKernel() { + float* hostA; + float* hostB; + float* hostC; + + float* deviceA; + float* deviceB; + float* deviceC; + + hipDeviceProp_t devProp; + hipGetDeviceProperties(&devProp, 0); + + int i; + int errors; + + hostA = (float*)malloc(NUM * sizeof(float)); + hostB = (float*)malloc(NUM * sizeof(float)); + hostC = (float*)malloc(NUM * sizeof(float)); + + // initialize the input data + for (i = 0; i < NUM; i++) { + hostB[i] = (float)i; + hostC[i] = (float)i * 100.0f; + } + + HIP_ASSERT(hipMalloc((void**)&deviceA, NUM * sizeof(float))); + HIP_ASSERT(hipMalloc((void**)&deviceB, NUM * sizeof(float))); + HIP_ASSERT(hipMalloc((void**)&deviceC, NUM * sizeof(float))); + + HIP_ASSERT(hipMemcpy(deviceB, hostB, NUM * sizeof(float), hipMemcpyHostToDevice)); + HIP_ASSERT(hipMemcpy(deviceC, hostC, NUM * sizeof(float), hipMemcpyHostToDevice)); + + + hipLaunchKernelGGL(vectoradd_float, + dim3(WIDTH / THREADS_PER_BLOCK_X, HEIGHT / THREADS_PER_BLOCK_Y), + dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y), 0, 0, deviceA, deviceB, + deviceC, WIDTH, HEIGHT); + + + HIP_ASSERT(hipMemcpy(hostA, deviceA, NUM * sizeof(float), hipMemcpyDeviceToHost)); + + // verify the results + errors = 0; + for (i = 0; i < NUM; i++) { + if (hostA[i] != (hostB[i] + hostC[i])) { + errors++; + } + } + if (errors != 0) { + printf("FAILED: %d errors\n", errors); + } else { + printf("PASSED!\n"); + } + + HIP_ASSERT(hipFree(deviceA)); + HIP_ASSERT(hipFree(deviceB)); + HIP_ASSERT(hipFree(deviceC)); + + free(hostA); + free(hostB); + free(hostC); + + // hipResetDefaultAccelerator(); + + return errors; +} \ No newline at end of file diff --git a/projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.h b/projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.h new file mode 100644 index 0000000000..c2b80007ba --- /dev/null +++ b/projects/rocprofiler/tests-v2/featuretests/profiler/apps/hip_kernels.h @@ -0,0 +1,26 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +void vectoradd_float(float* a, const float* b, const float* c, int width, int height); +void kernel(); +int LaunchVectorAddKernel(); +void KernelLaunch(); \ No newline at end of file diff --git a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp index 818e1e9b41..5e48082a68 100644 --- a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp +++ b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp @@ -24,18 +24,19 @@ THE SOFTWARE. #include #include -#include + #include "rocprofiler.h" #include #include #include #include -//#include +#include #include "src/utils/helper.h" #include "utils/test_utils.h" #include "utils/csv_parser.h" #include "src/utils/logger.h" +#include "apps/hip_kernels.h" std::string running_path; std::string lib_path; @@ -91,6 +92,7 @@ void ApplicationParser::SetApplicationEnv(const char* app_name) { std::stringstream hsa_tools_lib_path; hsa_tools_lib_path << app_path << lib_path; + setenv("LD_PRELOAD", hsa_tools_lib_path.str().c_str(), true); std::stringstream os; @@ -607,21 +609,6 @@ TEST_F(LoadUnloadTest, WhenLoadingSecondTimeThenToolLoadsUnloadsSuccessfully) { * ################################################### */ -#ifdef NDEBUG -#define HIP_ASSERT(x) x -#else -#define HIP_ASSERT(x) (assert((x) == hipSuccess)) -#endif - -#define WIDTH 1024 -#define HEIGHT 1024 - -#define NUM (WIDTH * HEIGHT) - -#define THREADS_PER_BLOCK_X 16 -#define THREADS_PER_BLOCK_Y 16 -#define THREADS_PER_BLOCK_Z 1 - /** \mainpage ROC Profiler API Test * * \section introduction Introduction @@ -632,20 +619,6 @@ TEST_F(LoadUnloadTest, WhenLoadingSecondTimeThenToolLoadsUnloadsSuccessfully) { * as console output */ - -__global__ void vectoradd_float(float* __restrict__ a, const float* __restrict__ b, - const float* __restrict__ c, int width, int height) - -{ - int x = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x; - int y = hipBlockDim_y * hipBlockIdx_y + hipThreadIdx_y; - - int i = y * width + x; - if (i < (width * height)) { - a[i] = b[i] + c[i]; - } -} - class ATTCollection : public ::testing::Test { public: virtual void SetUp(){}; @@ -690,73 +663,6 @@ class ATTCollection : public ::testing::Test { rocprofiler_next_record(record, &record, session_id, buffer_id); } } - - int LaunchVectorAddKernel() { - float* hostA; - float* hostB; - float* hostC; - - float* deviceA; - float* deviceB; - float* deviceC; - - hipDeviceProp_t devProp; - hipGetDeviceProperties(&devProp, 0); - - int i; - int errors; - - hostA = (float*)malloc(NUM * sizeof(float)); - hostB = (float*)malloc(NUM * sizeof(float)); - hostC = (float*)malloc(NUM * sizeof(float)); - - // initialize the input data - for (i = 0; i < NUM; i++) { - hostB[i] = (float)i; - hostC[i] = (float)i * 100.0f; - } - - HIP_ASSERT(hipMalloc((void**)&deviceA, NUM * sizeof(float))); - HIP_ASSERT(hipMalloc((void**)&deviceB, NUM * sizeof(float))); - HIP_ASSERT(hipMalloc((void**)&deviceC, NUM * sizeof(float))); - - HIP_ASSERT(hipMemcpy(deviceB, hostB, NUM * sizeof(float), hipMemcpyHostToDevice)); - HIP_ASSERT(hipMemcpy(deviceC, hostC, NUM * sizeof(float), hipMemcpyHostToDevice)); - - - hipLaunchKernelGGL(vectoradd_float, - dim3(WIDTH / THREADS_PER_BLOCK_X, HEIGHT / THREADS_PER_BLOCK_Y), - dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y), 0, 0, deviceA, deviceB, - deviceC, WIDTH, HEIGHT); - - - HIP_ASSERT(hipMemcpy(hostA, deviceA, NUM * sizeof(float), hipMemcpyDeviceToHost)); - - // verify the results - errors = 0; - for (i = 0; i < NUM; i++) { - if (hostA[i] != (hostB[i] + hostC[i])) { - errors++; - } - } - if (errors != 0) { - printf("FAILED: %d errors\n", errors); - } else { - printf("PASSED!\n"); - } - - HIP_ASSERT(hipFree(deviceA)); - HIP_ASSERT(hipFree(deviceB)); - HIP_ASSERT(hipFree(deviceC)); - - free(hostA); - free(hostB); - free(hostC); - - // hipResetDefaultAccelerator(); - - return errors; - } }; TEST_F(ATTCollection, WhenRunningATTItCollectsTraceData) { @@ -826,9 +732,6 @@ TEST_F(ATTCollection, WhenRunningATTItCollectsTraceData) { * ################################################### */ -// empty kernel -__global__ void kernel() {} - void __attribute__((constructor)) globalsetting() { init_test_path(); std::string app_path = GetRunningPath(running_path); @@ -850,13 +753,6 @@ class ProfilerAPITest : public ::testing::Test { ASSERT_EQ(status, ROCPROFILER_STATUS_SUCCESS); }; - // launches an empty kernel in profiler context - static void KernelLaunch() { - // run empty kernel - kernel<<<1, 1>>>(); - hipDeviceSynchronize(); - } - // callback function to dump profiler data static void FlushCallback(const rocprofiler_record_header_t* record, const rocprofiler_record_header_t* end_record, @@ -873,9 +769,9 @@ class ProfilerAPITest : public ::testing::Test { const char* kernel_name_c = static_cast(malloc(name_length * sizeof(char))); CheckApi(rocprofiler_query_kernel_info(ROCPROFILER_KERNEL_NAME, profiler_record->kernel_id, &kernel_name_c)); - int gpu_index = profiler_record->gpu_id.handle; - uint64_t start_time = profiler_record->timestamps.begin.value; - uint64_t end_time = profiler_record->timestamps.end.value; + // int gpu_index = profiler_record->gpu_id.handle; + // uint64_t start_time = profiler_record->timestamps.begin.value; + // uint64_t end_time = profiler_record->timestamps.end.value; // printf( // "Kernel Info:\n\tGPU Index: %d\n\tKernel Name: %s\n\tStart " // "Time: " @@ -950,19 +846,6 @@ TEST_F(ProfilerAPITest, WhenRunningMultipleThreadsProfilerAPIsWorkFine) { * ################################################### */ -#if 0 -__global__ void vectoradd_float(float* __restrict__ a, const float* __restrict__ b, - const float* __restrict__ c, int width, int height) { - int x = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x; - int y = hipBlockDim_y * hipBlockIdx_y + hipThreadIdx_y; - - int i = y * width + x; - if (i < (width * height)) { - a[i] = b[i] + c[i]; - } -} -#endif - class ProfilerSPMTest : public ::testing::Test { // function to check spm tracing API status protected: @@ -971,13 +854,6 @@ class ProfilerSPMTest : public ::testing::Test { ASSERT_EQ(status, ROCPROFILER_STATUS_SUCCESS); }; - // launches an empty kernel in profiler context - static void KernelLaunch() { - // run empty kernel - kernel<<<1, 1>>>(); - hipDeviceSynchronize(); - } - static void FlushCallback(const rocprofiler_record_header_t* record, const rocprofiler_record_header_t* end_record, rocprofiler_session_id_t session_id, @@ -988,7 +864,6 @@ class ProfilerSPMTest : public ::testing::Test { else if (record->kind == ROCPROFILER_SPM_RECORD) { const rocprofiler_record_spm_t* spm_record = reinterpret_cast(record); - size_t name_length; int se_num = 4; // iterate over each shader engine for (int i = 0; i < se_num; i++) { @@ -1002,74 +877,6 @@ class ProfilerSPMTest : public ::testing::Test { CheckApi(rocprofiler_next_record(record, &record, session_id, buffer_id)); } } - - int LaunchVectorAddKernel() { - float* hostA; - float* hostB; - float* hostC; - - float* deviceA; - float* deviceB; - float* deviceC; - - hipDeviceProp_t devProp; - hipGetDeviceProperties(&devProp, 0); - - int i; - int errors; - - hostA = (float*)malloc(NUM * sizeof(float)); - hostB = (float*)malloc(NUM * sizeof(float)); - hostC = (float*)malloc(NUM * sizeof(float)); - - // initialize the input data - for (i = 0; i < NUM; i++) { - hostB[i] = (float)i; - hostC[i] = (float)i * 100.0f; - } - - HIP_ASSERT(hipMalloc((void**)&deviceA, NUM * sizeof(float))); - HIP_ASSERT(hipMalloc((void**)&deviceB, NUM * sizeof(float))); - HIP_ASSERT(hipMalloc((void**)&deviceC, NUM * sizeof(float))); - - HIP_ASSERT(hipMemcpy(deviceB, hostB, NUM * sizeof(float), hipMemcpyHostToDevice)); - HIP_ASSERT(hipMemcpy(deviceC, hostC, NUM * sizeof(float), hipMemcpyHostToDevice)); - - - for (int i = 0; i < 20; i++) - hipLaunchKernelGGL(vectoradd_float, - dim3(WIDTH / THREADS_PER_BLOCK_X, HEIGHT / THREADS_PER_BLOCK_Y), - dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y), 0, 0, deviceA, deviceB, - deviceC, WIDTH, HEIGHT); - - - HIP_ASSERT(hipMemcpy(hostA, deviceA, NUM * sizeof(float), hipMemcpyDeviceToHost)); - - // verify the results - errors = 0; - for (i = 0; i < NUM; i++) { - if (hostA[i] != (hostB[i] + hostC[i])) { - errors++; - } - } - if (errors != 0) { - printf("FAILED: %d errors\n", errors); - } else { - printf("PASSED!\n"); - } - - HIP_ASSERT(hipFree(deviceA)); - HIP_ASSERT(hipFree(deviceB)); - HIP_ASSERT(hipFree(deviceC)); - - free(hostA); - free(hostB); - free(hostC); - - // hipResetDefaultAccelerator(); - - return errors; - } }; TEST_F(ProfilerSPMTest, WhenRunningSPMItCollectsSPMData) { @@ -1138,7 +945,7 @@ class MTBinaryTest : public ::testing::Test { countermap counter_map = parser.GetCounterMap(); int dispatch_counter = 0; - for (auto i = 0; i < counter_map.size(); i++) { + for (size_t i = 0; i < counter_map.size(); i++) { std::string* dispatch_id = parser.ReadCounter(i, 1); if (dispatch_id != nullptr) { if (dispatch_id->find("dispatch") != std::string::npos) { @@ -1280,12 +1087,6 @@ TEST_F(ProfilerMQTest, DISABLED_WhenRunningMultiProcessTestItPasses) { * ################################################### */ -void KernelLaunch() { - // run empty kernel - // kernel<<<1, 1>>>(); //TODO: Check the hang - // hipDeviceSynchronize(); -} - TEST(ProfilerMPTest, WhenRunningMultiProcessTestItPasses) { // create as many threads as number of cores in system int num_cpu_cores = GetNumberOfCores(); @@ -1332,125 +1133,121 @@ TEST(ProfilerMPTest, WhenRunningMultiProcessTestItPasses) { * Sets application output dir. */ -/* -void PluginTests::RunApplication(const char* app_name, const char* appParams) { - if (is_installed_path()) return; // Only run these tests from build +// void PluginTests::RunApplication(const char* app_name, const char* appParams) { +// if (is_installed_path()) return; // Only run these tests from build - init_test_path(); - unsetenv("OUTPUT_FOLDER"); +// init_test_path(); +// unsetenv("OUTPUT_FOLDER"); - std::stringstream os; - os << binary_path << appParams << " "; - os << test_app_path << app_name; - ProcessApplication(os); -} +// std::stringstream os; +// os << binary_path << appParams << " "; +// os << test_app_path << app_name; +// ProcessApplication(os); +// } -void PluginTests::ProcessApplication(std::stringstream& ss) { - FILE* handle = popen(ss.str().c_str(), "r"); - ASSERT_NE(handle, nullptr); - pclose(handle); -} +// void PluginTests::ProcessApplication(std::stringstream& ss) { +// FILE* handle = popen(ss.str().c_str(), "r"); +// ASSERT_NE(handle, nullptr); +// pclose(handle); +// } -bool FilePluginTest::hasFileInDir(const std::string& filename, const char* directory) { - if (is_installed_path()) return true; // Only run these tests from build +// bool FilePluginTest::hasFileInDir(const std::string& filename, const char* directory) { +// if (is_installed_path()) return true; // Only run these tests from build - for (const auto& entry : std::experimental::filesystem::directory_iterator(directory)) { - if (filename.size() == 0) - return true; - if (std::string(entry.path().filename()).substr(0, filename.size()) == filename) - return true; - } - return false; -} +// for (const auto& entry : std::experimental::filesystem::directory_iterator(directory)) { +// if (filename.size() == 0) return true; +// if (std::string(entry.path().filename()).substr(0, filename.size()) == filename) return true; +// } +// return false; +// } -class VectorAddFileOnlyTest : public FilePluginTest { - protected: - virtual void SetUp() { - RunApplication("hip_vectoradd", "-o file_test_name"); - } - virtual void TearDown() { - std::string filename = "file_test_name"; - for (const auto& entry : std::experimental::filesystem::directory_iterator("./")) - if (std::string(entry.path().filename()).substr(0, filename.size()) == filename) - std::experimental::filesystem::remove(entry); - } - bool hasFile(){ return hasFileInDir("file_test_name", "."); } -}; +// class VectorAddFileOnlyTest : public FilePluginTest { +// protected: +// virtual void SetUp() { RunApplication("hip_vectoradd", " --hip-activity -o file_test_name "); } +// virtual void TearDown() { +// std::string filename = "file_test_name"; +// for (const auto& entry : std::experimental::filesystem::directory_iterator("./")) +// if (std::string(entry.path().filename()).substr(0, filename.size()) == filename) +// std::experimental::filesystem::remove(entry); +// } +// bool hasFile() { return hasFileInDir("file_test_name", "."); } +// }; -TEST_F(VectorAddFileOnlyTest, WhenRunningProfilerWithFilePluginTest) { - EXPECT_EQ(hasFile(), true); -} +// TEST_F(VectorAddFileOnlyTest, WhenRunningProfilerWithFilePluginTest) { EXPECT_EQ(hasFile(), true); } -class VectorAddFolderOnlyTest : public FilePluginTest { - protected: - virtual void SetUp() { - RunApplication("hip_vectoradd", " --hsa-activity --hip-activity -d ./plugin_test_folder_path"); - } - virtual void TearDown() { std::experimental::filesystem::remove_all("./plugin_test_folder_path"); } - bool hasFile(){ return hasFileInDir("", "./plugin_test_folder_path"); } -}; +// class VectorAddFolderOnlyTest : public FilePluginTest { +// protected: +// virtual void SetUp() { +// RunApplication("hip_vectoradd", " --hsa-activity --hip-activity -d ./plugin_test_folder_path"); +// } +// virtual void TearDown() { +// std::experimental::filesystem::remove_all("./plugin_test_folder_path"); +// } +// bool hasFile() { return hasFileInDir("", "./plugin_test_folder_path"); } +// }; -TEST_F(VectorAddFolderOnlyTest, WhenRunningProfilerWithFilePluginTest) { - EXPECT_EQ(hasFile(), true); -} +// TEST_F(VectorAddFolderOnlyTest, WhenRunningProfilerWithFilePluginTest) { +// EXPECT_EQ(hasFile(), true); +// } -class VectorAddFileAndFolderTest : public FilePluginTest { - protected: - virtual void SetUp() { - RunApplication("hip_vectoradd", " --hip-activity -d ./plugin_test_folder_path -o file_test_name"); - } - virtual void TearDown() { std::experimental::filesystem::remove_all("./plugin_test_folder_path"); } - bool hasFile(){ return hasFileInDir("file_test_name", "./plugin_test_folder_path"); } -}; +// class VectorAddFileAndFolderTest : public FilePluginTest { +// protected: +// virtual void SetUp() { +// RunApplication("hip_vectoradd", +// " --hip-activity -d ./plugin_test_folder_path -o file_test_name"); +// } +// virtual void TearDown() { +// std::experimental::filesystem::remove_all("./plugin_test_folder_path"); +// } +// bool hasFile() { return hasFileInDir("file_test_name", "./plugin_test_folder_path"); } +// }; -TEST_F(VectorAddFileAndFolderTest, WhenRunningProfilerWithFilePluginTest) { - EXPECT_EQ(hasFile(), true); -} +// TEST_F(VectorAddFileAndFolderTest, WhenRunningProfilerWithFilePluginTest) { +// EXPECT_EQ(hasFile(), true); +// } -class VectorAddFilenameMPITest : public FilePluginTest { - protected: - virtual void SetUp() { - setenv("MPI_RANK", "7", true); - RunApplication("hip_vectoradd", " --hip-activity -d ./plugin_test_folder_path -o test_%rank_"); - } - virtual void TearDown() { - std::experimental::filesystem::remove_all("./plugin_test_folder_path"); - unsetenv("MPI_RANK"); - } - bool hasFile(){ return hasFileInDir("test_7_", "./plugin_test_folder_path"); } -}; +// class VectorAddFilenameMPITest : public FilePluginTest { +// protected: +// virtual void SetUp() { +// setenv("MPI_RANK", "7", true); +// RunApplication("hip_vectoradd", " --hip-activity -d ./plugin_test_folder_path -o test_%rank_"); +// } +// virtual void TearDown() { +// std::experimental::filesystem::remove_all("./plugin_test_folder_path"); +// unsetenv("MPI_RANK"); +// } +// bool hasFile() { return hasFileInDir("test_7_", "./plugin_test_folder_path"); } +// }; -TEST_F(VectorAddFilenameMPITest, WhenRunningProfilerWithFilePluginTest) { - EXPECT_EQ(hasFile(), true); -} +// TEST_F(VectorAddFilenameMPITest, WhenRunningProfilerWithFilePluginTest) { +// EXPECT_EQ(hasFile(), true); +// } -bool PerfettoPluginTest::hasFileInDir(const std::string& filename, const char* directory) { - if (is_installed_path()) return true; // Only run these tests from build +// bool PerfettoPluginTest::hasFileInDir(const std::string& filename, const char* directory) { +// if (is_installed_path()) return true; // Only run these tests from build - for (const auto& entry : std::experimental::filesystem::directory_iterator(directory)) { - std::string entrypath = std::string(entry.path().filename()); - if (entrypath.find(".pftrace") == std::string::npos) - continue; - if (entrypath.substr(0, filename.size()) == filename) - return true; - } - return false; -} +// for (const auto& entry : std::experimental::filesystem::directory_iterator(directory)) { +// std::string entrypath = std::string(entry.path().filename()); +// if (entrypath.find(".pftrace") == std::string::npos) continue; +// if (entrypath.substr(0, filename.size()) == filename) return true; +// } +// return false; +// } -class VectorAddPerfettoMPITest : public PerfettoPluginTest { - protected: - virtual void SetUp() { - setenv("MPI_RANK", "7", true); - RunApplication("hip_vectoradd", " -d ./plugin_test_folder_path -o test_%rank_ --plugin perfetto"); - } - virtual void TearDown() { - std::experimental::filesystem::remove_all("./plugin_test_folder_path"); - unsetenv("MPI_RANK"); - } - bool hasFile(){ return hasFileInDir("test_7_", "./plugin_test_folder_path"); } -}; +// class VectorAddPerfettoMPITest : public PerfettoPluginTest { +// protected: +// virtual void SetUp() { +// setenv("MPI_RANK", "7", true); +// RunApplication("hip_vectoradd", +// " -d ./plugin_test_folder_path -o test_%rank_ --plugin perfetto"); +// } +// virtual void TearDown() { +// std::experimental::filesystem::remove_all("./plugin_test_folder_path"); +// unsetenv("MPI_RANK"); +// } +// bool hasFile() { return hasFileInDir("test_7_", "./plugin_test_folder_path"); } +// }; -TEST_F(VectorAddPerfettoMPITest, WhenRunningProfilerWithPerfettoTest) { - EXPECT_EQ(hasFile(), true); -} -*/ +// TEST_F(VectorAddPerfettoMPITest, WhenRunningProfilerWithPerfettoTest) { +// EXPECT_EQ(hasFile(), true); +// } \ No newline at end of file diff --git a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.h b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.h index 0cd0e6d324..5d526ed185 100644 --- a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.h +++ b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.h @@ -107,35 +107,34 @@ class ProfilerTest : public ApplicationParser { virtual void SetUp(const char* app_name) { ApplicationParser::SetUp(app_name); } }; -/* --------------------------------------------------------------------------*/ -/** - * @Synopsis Base class for file plugin tests. - * The file test will check wether certain filenames are created. - * Currently, file plugin tests only from build as they need to create files. - */ -/* --------------------------------------------------------------------------*/ +// /* --------------------------------------------------------------------------*/ +// /** +// * @Synopsis Base class for file plugin tests. +// * The file test will check wether certain filenames are created. +// * Currently, file plugin tests only from build as they need to create files. +// */ +// /* --------------------------------------------------------------------------*/ -/* -class PluginTests : public ::testing::Test { - public: - //!< Sets application environment by seting rocprofv2. - void RunApplication(const char* app_name, const char* appParams); - private: - //!< Runs a given appllication with the hsa activity. - void ProcessApplication(std::stringstream& ss); -}; +// class PluginTests : public ::testing::Test { +// public: +// //!< Sets application environment by seting rocprofv2. +// void RunApplication(const char* app_name, const char* appParams); +// private: +// //!< Runs a given appllication with the hsa activity. +// void ProcessApplication(std::stringstream& ss); +// }; -class FilePluginTest : public PluginTests { - public: - //!< Checks wether a file beginning with "filename" exists in "directory" - static bool hasFileInDir(const std::string& filename, const char* directory); -}; +// class FilePluginTest : public PluginTests { +// public: +// //!< Checks wether a file beginning with "filename" exists in "directory" +// static bool hasFileInDir(const std::string& filename, const char* directory); +// }; + +// class PerfettoPluginTest : public PluginTests { +// public: +// //!< Checks wether a file beginning with "filename" and ending with "pftrace" exists in "directory" +// static bool hasFileInDir(const std::string& filename, const char* directory); +// }; -class PerfettoPluginTest : public PluginTests { - public: - //!< Checks wether a file beginning with "filename" and ending with "pftrace" exists in "directory" - static bool hasFileInDir(const std::string& filename, const char* directory); -}; -*/ #endif // TESTS_FEATURETESTS_PROFILER_GTESTS_APPS_PROFILER_GTEST_H_