From bbe1db3810acda6acd41b543c0419a93bfd2e612 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Wed, 11 May 2022 15:27:01 -0700 Subject: [PATCH] Fix an intermittent failure in "tool flushing test" The test (MatrixTranspose) and the tracer tool both write to stdout which sometime causes a trace corruption. Change the test to emit info messages to stderr instead of stdout, leaving stdout for the tracer tool's exclusive use. Change-Id: I18047dbcd9039b70dd24ef6e7e8e9d89b40bedd2 --- test/MatrixTranspose/MatrixTranspose.cpp | 8 ++++---- test/MatrixTranspose_test/MatrixTranspose.cpp | 16 ++++++++-------- test/run.sh | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/MatrixTranspose/MatrixTranspose.cpp b/test/MatrixTranspose/MatrixTranspose.cpp index 95d699f341..de5136a42d 100644 --- a/test/MatrixTranspose/MatrixTranspose.cpp +++ b/test/MatrixTranspose/MatrixTranspose.cpp @@ -67,7 +67,7 @@ int main() { hipDeviceProp_t devProp; hipGetDeviceProperties(&devProp, 0); - std::cout << "Device name " << devProp.name << std::endl; + std::cerr << "Device name " << devProp.name << std::endl; int i; int errors; @@ -87,7 +87,7 @@ int main() { uint32_t iterations = 100; while (iterations-- > 0) { - std::cout << "## Iteration (" << iterations << ") #################" << std::endl; + std::cerr << "## Iteration (" << iterations << ") #################" << std::endl; // Memory transfer from host to device hipMemcpy(gpuMatrix, Matrix, NUM * sizeof(float), hipMemcpyHostToDevice); @@ -124,9 +124,9 @@ int main() { } } if (errors != 0) { - printf("FAILED: %d errors\n", errors); + fprintf(stderr, "FAILED: %d errors\n", errors); } else { - printf("PASSED!\n"); + fprintf(stderr, "PASSED!\n"); } } diff --git a/test/MatrixTranspose_test/MatrixTranspose.cpp b/test/MatrixTranspose_test/MatrixTranspose.cpp index 87c4167dce..1c7051de3c 100644 --- a/test/MatrixTranspose_test/MatrixTranspose.cpp +++ b/test/MatrixTranspose_test/MatrixTranspose.cpp @@ -126,7 +126,7 @@ int main() { int gpuCount = 1; #if MGPU_TEST hipGetDeviceCount(&gpuCount); - printf("Number of GPUs: %d\n", gpuCount); + fprintf(stderr, "Number of GPUs: %d\n", gpuCount); #endif iterations *= gpuCount; #endif @@ -141,7 +141,7 @@ int main() { hipDeviceProp_t devProp; HIP_CALL(hipGetDeviceProperties(&devProp, 0)); - printf("Device %d name: %s\n", devIndex, devProp.name); + fprintf(stderr, "Device %d name: %s\n", devIndex, devProp.name); #endif Matrix = (float*)malloc(NUM * sizeof(float)); @@ -206,10 +206,10 @@ int main() { } } if ((HIP_TEST != 0) && (errors != 0)) { - printf("FAILED: %d errors\n", errors); + fprintf(stderr, "FAILED: %d errors\n", errors); } else { errors = 0; - printf("PASSED!\n"); + fprintf(stderr, "PASSED!\n"); } // free the resources on device side @@ -325,7 +325,7 @@ void activity_callback(const char* begin, const char* end, void* arg) { } else if (record->domain == ACTIVITY_DOMAIN_EXT_API) { SPRINT(" external_id(%lu)", record->external_id); } else { - fprintf(stderr, "Bad domain %d\n\n", record->domain); + fprintf(stdout, "Bad domain %d\n\n", record->domain); abort(); } SPRINT("\n"); @@ -337,7 +337,7 @@ void activity_callback(const char* begin, const char* end, void* arg) { // Init tracing routine void init_tracing() { - printf("# INIT #############################\n"); + fprintf(stderr, "# INIT #############################\n"); // roctracer properties roctracer_set_properties(ACTIVITY_DOMAIN_HIP_API, NULL); // Allocating tracing pool @@ -361,7 +361,7 @@ void init_tracing() { // Start tracing routine void start_tracing() { - printf("# START (%d) #############################\n", iterations); + fprintf(stderr, "# START (%d) #############################\n", iterations); // Start if ((iterations & 1) == 1) roctracer_start(); @@ -379,7 +379,7 @@ void stop_tracing() { ROCTRACER_CALL(roctracer_disable_domain_activity(ACTIVITY_DOMAIN_HSA_OPS)); ROCTRACER_CALL(roctracer_disable_domain_callback(ACTIVITY_DOMAIN_ROCTX)); ROCTRACER_CALL(roctracer_flush_activity()); - printf("# STOP #############################\n"); + fprintf(stderr, "# STOP #############################\n"); } #else void init_tracing() {} diff --git a/test/run.sh b/test/run.sh index e0143c1cfa..608fe56e26 100755 --- a/test/run.sh +++ b/test/run.sh @@ -80,7 +80,7 @@ eval_test() { echo "test $test_number: $test_name \"$label\"" echo "CMD: \"$cmdline\"" test_runnum=$((test_runnum + 1)) - eval "$cmdline" >$test_trace 2>&1 + eval "$cmdline" 1>$test_trace 2>$test_name.err is_failed=$? if [ $is_failed != 0 ] ; then cat $test_trace