diff --git a/projects/hip-tests/perftests/module/hipPerfModuleLoad.cpp b/projects/hip-tests/perftests/module/hipPerfModuleLoad.cpp new file mode 100755 index 0000000000..06f55ed89d --- /dev/null +++ b/projects/hip-tests/perftests/module/hipPerfModuleLoad.cpp @@ -0,0 +1,244 @@ +/* +Copyright (c) 2015-2017 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. +*/ + +/* HIT_START + * BUILD_CMD: hipPerfModuleLoad %hc -I%S/../../src %S/%s %S/../../src/test_common.cpp -o %T/%t EXCLUDE_HIP_PLATFORM nvcc + * TEST: %t + * HIT_END + */ + +#include "test_common.h" + +#include +#include +#include +#include +#include + +#ifdef __unix__ + +#include + +//List of Download files +std::unordered_map TL_contents { + {"Kernels.so", true}, + {"TensileLibrary.yaml", true}, + {"TensileLibrary_gfx803.co", true}, + {"TensileLibrary_gfx900.co", true}, + {"TensileLibrary_gfx906.co", true}, + {"TensileLibrary_gfx908.co", true}, + {"kernel_names.txt", true} +}; + +bool GetDirectoryContents(std::unordered_map& dir_contents) { + DIR* dir = nullptr; + struct dirent* ent = nullptr; + + //Open Current Directory + if ((dir = opendir(".")) == 0) { + std::cout<<"Failed to open current working directory, check permissions"<d_name, true}); + } + + closedir(dir); + return true; +} + +bool ContentsAvailable() { + std::unordered_map dir_contents; + + //Get recent directory contents + if(!GetDirectoryContents(dir_contents)) { + std::cout<<"Failed to get directory Contents"< mload_duration = (mload_clock_stop - mload_clock_start); + std::cout<<"Time taken for hipModuleLoad : " < + (mload_duration).count()<<" nanoseconds "< kernel_vec; + while (std::getline(kernel_file, kernel_line)) { + kernel_line.erase(std::remove(kernel_line.begin(), kernel_line.end(), '\r'), + kernel_line.end()); + kernel_vec.push_back(kernel_line); + } + + //Measure the first hipModuleGetFunction + hipFunction_t hfunc = nullptr; + auto mgetf_clock_start = std::chrono::steady_clock::now(); + HIPCHECK(hipModuleGetFunction(&hfunc, Module, kernel_vec[0].c_str())); + auto mgetf_clock_stop = std::chrono::steady_clock::now(); + std::chrono::duration mgetf_duration = (mgetf_clock_stop - mgetf_clock_start); + std::cout<<"Time taken to fetch a function via hipModuleGetFunction : " + < + (mgetf_duration).count()<<" nanoseconds "< + (mgetf_duration).count()<<" nanoseconds "< 0) { + std::cout << "Time taken for Average hipModuleGetFunction : " + << (static_cast(all_duration) / static_cast(kernel_vec.size()))<<" nanoseconds "<