From 2f4269d06d803541057c6d4ef9ec192660d22fbc Mon Sep 17 00:00:00 2001 From: gilbertlee-amd <44450918+gilbertlee-amd@users.noreply.github.com> Date: Thu, 12 Dec 2019 15:20:54 -0700 Subject: [PATCH] Adding new sleep after sync capability for data fabric profiling (#162) Fixing missing header include for ROCM 3.0 changes --- tools/TransferBench/TransferBench.cpp | 18 +++++++++++++----- tools/TransferBench/TransferBench.hpp | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/TransferBench/TransferBench.cpp b/tools/TransferBench/TransferBench.cpp index afb548ff58..016ff80ed4 100644 --- a/tools/TransferBench/TransferBench.cpp +++ b/tools/TransferBench/TransferBench.cpp @@ -27,6 +27,7 @@ THE SOFTWARE. #include #include #include +#include #include #include "copy_kernel.h" @@ -49,12 +50,13 @@ int main(int argc, char **argv) printf("\n"); printf("Environment variables:\n"); printf("======================\n"); - printf(" USE_HIP_CALL - Use hip calls (hipMemcpyAsync/hipMemset) instead of kernel\n"); - printf(" USE_MEMSET - Write constant value (instead of doing a copy)\n"); - printf(" USE_COARSE_MEM - Use coarse-grained dst GPU memory (instead of fine-grained)\n"); - printf(" USE_SINGLE_SYNC - Only synchronize once at end of iterations (disables GPU times)\n"); - printf(" USE_INTERACTIVE - Waits for user-input prior to start and after transfer loop (for profiling)\n"); + printf(" USE_HIP_CALL - Use hip calls (hipMemcpyAsync/hipMemset) instead of kernel\n"); + printf(" USE_MEMSET - Write constant value (instead of doing a copy)\n"); + printf(" USE_COARSE_MEM - Use coarse-grained dst GPU memory (instead of fine-grained)\n"); + printf(" USE_SINGLE_SYNC - Only synchronize once at end of iterations (disables GPU times)\n"); + printf(" USE_INTERACTIVE - Waits for user-input prior to start and after transfer loop (for profiling)\n"); printf(" USE_ITERATIONS=N - Sets number of iterations to run (default is 10)\n"); + printf(" USE_SLEEP - Adds a 100ms sleep after sync (for profiling)\n"); exit(0); } @@ -74,6 +76,7 @@ int main(int argc, char **argv) bool useCoarseMem = getenv("USE_COARSE_MEM"); bool useSingleSync = getenv("USE_SINGLE_SYNC"); bool useInteractive = getenv("USE_INTERACTIVE"); + bool useSleep = getenv("USE_SLEEP"); int numWarmups = 3; int numIterations = getenv("USE_ITERATIONS") ? atoi(getenv("USE_ITERATIONS")) : 10; @@ -99,6 +102,10 @@ int main(int argc, char **argv) printf("Running in interactive mode (USE_INTERACTIVE)\n"); else printf("Running in non-interactive mode (enable interactive mode via USE_INTERACTIVE)\n"); + if (useSleep) + printf("Adding 100ms sleep after sync (USE_SLEEP)\n"); + else + printf("No sleep per sync (enable sleep via USE_SLEEP)\n"); printf("Executing %d warmup iteration(s), and %d timed iteration(s) (Set via USE_ITERATION=#)\n", numWarmups, numIterations); @@ -314,6 +321,7 @@ int main(int argc, char **argv) auto cpuDelta = std::chrono::high_resolution_clock::now() - cpuStart; double deltaSec = std::chrono::duration_cast>(cpuDelta).count(); + if (useSleep) usleep(100000); if (iteration >= 0) { diff --git a/tools/TransferBench/TransferBench.hpp b/tools/TransferBench/TransferBench.hpp index 5fde8f58fe..92c596d672 100644 --- a/tools/TransferBench/TransferBench.hpp +++ b/tools/TransferBench/TransferBench.hpp @@ -20,6 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + // Helper macro for catching HIP errors #define HIP_CALL(cmd) \ do { \