From 779c10e3ebe01701ccf062ee04ed5d2e9174e44c Mon Sep 17 00:00:00 2001 From: HazarathKumarM Date: Thu, 11 Jul 2024 12:11:36 +0000 Subject: [PATCH 1/5] fix errors in test suite --- utilities/test_suite/common.py | 2 +- utilities/test_suite/rpp_test_suite_misc.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/utilities/test_suite/common.py b/utilities/test_suite/common.py index e32aac98f..527b40ead 100644 --- a/utilities/test_suite/common.py +++ b/utilities/test_suite/common.py @@ -332,7 +332,7 @@ def get_layout_name(layout): # Prints entire case list if user asks for help def print_case_list(imageAugmentationMap, backendType, parser): - if '--help' or '-h' in sys.argv: + if '--help' in sys.argv or '-h' in sys.argv: parser.print_help() print("\n" + "="*30) print("Functionality Reference List") diff --git a/utilities/test_suite/rpp_test_suite_misc.h b/utilities/test_suite/rpp_test_suite_misc.h index 0a4197caa..9ef118c48 100644 --- a/utilities/test_suite/rpp_test_suite_misc.h +++ b/utilities/test_suite/rpp_test_suite_misc.h @@ -98,6 +98,7 @@ void fill_roi_values(Rpp32u nDim, Rpp32u batchSize, Rpp32u *roiTensor, bool qaMo case 3: { std::array roi = {0, 0, 0, 50, 50, 8}; + for(int i = 0, j = 0; i < batchSize ; i++, j += 6) std::copy(roi.begin(), roi.end(), &roiTensor[j]); break; exit(0); From b3e85ef8cac70b16ddfb93322c1364ae16c6ae2d Mon Sep 17 00:00:00 2001 From: HazarathKumarM Date: Thu, 11 Jul 2024 17:56:00 +0000 Subject: [PATCH 2/5] changes to support tests for all the versions of python --- utilities/test_suite/HIP/runMiscTests.py | 24 +++++----- utilities/test_suite/HIP/runTests.py | 56 ++++++++++++---------- utilities/test_suite/HIP/runVoxelTests.py | 38 ++++++++------- utilities/test_suite/HOST/runAudioTests.py | 19 ++++---- utilities/test_suite/HOST/runMiscTests.py | 15 +++--- utilities/test_suite/HOST/runTests.py | 39 ++++++++------- utilities/test_suite/HOST/runVoxelTests.py | 21 ++++---- utilities/test_suite/common.py | 13 +++-- 8 files changed, 124 insertions(+), 101 deletions(-) diff --git a/utilities/test_suite/HIP/runMiscTests.py b/utilities/test_suite/HIP/runMiscTests.py index f4adbde28..1b35b1161 100644 --- a/utilities/test_suite/HIP/runMiscTests.py +++ b/utilities/test_suite/HIP/runMiscTests.py @@ -74,25 +74,25 @@ def generate_performance_reports(RESULTS_DIR): print(dfPrint_noIndices) def run_unit_test_cmd(numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - print(f"./Tensor_misc_hip {case} {testType} {toggle} {numDims} {batchSize} {numRuns} {additionalArg}") - result = subprocess.run([buildFolderPath + "/build/Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_misc_hip {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): with open("{}/Tensor_misc_hip_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print(f"./Tensor_misc_hip {case} {testType} {toggle} {numDims} {batchSize} {numRuns} {additionalArg}") - process = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + print("./Tensor_misc_hip {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + process = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) def run_performance_test_with_profiler_cmd(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - if not os.path.exists(f"{outFilePath}/case_{case}"): - os.mkdir(f"{outFilePath}/case_{case}") + if not os.path.exists("{}/case_{}".format(outFilePath, case)): + os.mkdir("{}/case_{}".format(outFilePath, case)) with open("{}/Tensor_misc_hip_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print(f"\nrocprof --basenames on --timestamp on --stats -o {outFilePath}/case_{case}/output_case{case}.csv ./Tensor_misc_hip {case} {testType} {toggle} {numDims} {batchSize} {numRuns} {additionalArg}") - process = subprocess.Popen([ 'rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', f"{outFilePath}/case_{case}/output_case{case}.csv", "./Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec - read_from_subprocess_and_write_to_log(process, logFile) + print("\nrocprof --basenames on --timestamp on --stats -o {}/case_{}/output_case{}.csv ./Tensor_misc_hip {} {} {} {} {} {} {}".format(outFilePath, case, case, case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', '{}/case_{}/output_case{}.csv'.format(outFilePath, case, case), "./Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) print("------------------------------------------------------------------------------------------") def run_test(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg, profilingOption = 'NO'): @@ -206,8 +206,8 @@ def rpp_test_suite_parser_and_validator(): os.chdir(buildFolderPath + "/build") # Run cmake and make commands -subprocess.run(["cmake", scriptPath], cwd=".") # nosec -subprocess.run(["make", "-j16"], cwd=".") # nosec +subprocess.call(["cmake", scriptPath], cwd=".") # nosec +subprocess.call(["make", "-j16"], cwd=".") # nosec supportedCaseList = ['0', '1', '2'] for case in caseList: diff --git a/utilities/test_suite/HIP/runTests.py b/utilities/test_suite/HIP/runTests.py index 629da6ae1..0eebe837b 100644 --- a/utilities/test_suite/HIP/runTests.py +++ b/utilities/test_suite/HIP/runTests.py @@ -69,35 +69,39 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo if case == "40" or case == "41" or case == "49" or case == "54": for kernelSize in range(3, 10, 2): - print(f"./Tensor_hip {srcPath1} {srcPath2} {dstPath} {bitDepth} {outputFormatToggle} {case} {kernelSize}") - result = subprocess.run([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(kernelSize), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_hip {} {} {} {} {} {} {}".format(srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, kernelSize)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(kernelSize), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) elif case == "8": # Run all variants of noise type functions with additional argument of noiseType = gausssianNoise / shotNoise / saltandpepperNoise for noiseType in range(3): - print(f"./Tensor_hip {srcPath1} {srcPath2} {dstPathTemp} {bitDepth} {outputFormatToggle} {case} {noiseType} ") - result = subprocess.run([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(noiseType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_hip {} {} {} {} {} {} {}".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, noiseType)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(noiseType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) elif case == "21" or case == "23" or case == "24" or case == "79": # Run all variants of interpolation functions with additional argument of interpolationType = bicubic / bilinear / gaussian / nearestneigbor / lanczos / triangular interpolationRange = 6 if case =='79': interpolationRange = 2 for interpolationType in range(interpolationRange): - print(f"./Tensor_hip {srcPath1} {srcPath2} {dstPathTemp} {bitDepth} {outputFormatToggle} {case} {interpolationType}") - result = subprocess.run([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(interpolationType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_hip {} {} {} {} {} {} {}".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, interpolationType)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(interpolationType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) else: - print(f"./Tensor_hip {srcPath1} {srcPath2} {dstPathTemp} {bitDepth} {outputFormatToggle} {case} 0 {numRuns} {testType} {layout}") - result = subprocess.run([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), "0", str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_hip {} {} {} {} {} {} 0 {} {} {}".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, numRuns, testType, layout)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), "0", str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): with open("{}/Tensor_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print(f"./Tensor_hip {srcPath1} {srcPath2} {dstPath} {bitDepth} {outputFormatToggle} {case} {additionalParam} 0 ") - process = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + print("./Tensor_hip {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam)) + process = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) def run_performance_test(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, case, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): @@ -132,11 +136,11 @@ def run_performance_test(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPa def run_performance_test_with_profiler(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam, additionalParamType, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): addtionalParamString = additionalParamType + str(additionalParam) layoutName = get_layout_name(layout) - if not os.path.isdir(f"{dstPath}/Tensor_{layoutName}/case_{case}"): - os.mkdir(f"{dstPath}/Tensor_{layoutName}/case_{case}") - with open(f"{loggingFolder}/Tensor_hip_{logFileLayout}_raw_performance_log.txt", "a") as logFile: - print(f'rocprof --basenames on --timestamp on --stats -o {dstPath}/Tensor_{layoutName}/case_{case}/output_case{case}_bitDepth{bitDepth}_oft{outputFormatToggle}{addtionalParamString}.csv ./Tensor_hip {srcPath1} {srcPath2} {bitDepth} {outputFormatToggle} {case} {additionalParam} 0') - process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', f'{dstPath}/Tensor_{layoutName}/case_{case}/output_case{case}_bitDepth{bitDepth}_oft{outputFormatToggle}{addtionalParamString}.csv', buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), '0', str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec + if not os.path.isdir("{}/Tensor_{}/case_{}".format(dstPath, layoutName, case)): + os.makedirs("{}/Tensor_{}/case_{}".format(dstPath, layoutName, case)) + with open("{}/Tensor_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: + print("rocprof --basenames on --timestamp on --stats -o {}/Tensor_{}/case_{}/output_case{}_bitDepth{}_oft{}{}.csv ./Tensor_hip {} {} {} {} {} {} 0".format(dstPath, layoutName, case, case, bitDepth, outputFormatToggle, addtionalParamString, srcPath1, srcPath2, bitDepth, outputFormatToggle, case, additionalParam)) + process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', '{}/Tensor_{}/case_{}/output_case{}_bitDepth{}_oft{}{}.csv'.format(dstPath, layoutName, case, case, bitDepth, outputFormatToggle, addtionalParamString), buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), '0', str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() if not output and process.poll() is not None: @@ -171,7 +175,7 @@ def rpp_test_suite_parser_and_validator(): # validate the parameters passed by user if ((args.case_start < caseMin or args.case_start > caseMax) or (args.case_end < caseMin or args.case_end > caseMax)): - print(f"Starting case# and Ending case# must be in the {caseMin}:{caseMax} range. Aborting!") + print("Starting case# and Ending case# must be in the {}:{} range. Aborting!".format(caseMin, caseMax)) exit(0) elif args.case_end < args.case_start: print("Ending case# must be greater than starting case#. Aborting!") @@ -213,7 +217,7 @@ def rpp_test_suite_parser_and_validator(): else: for case in args.case_list: if int(case) < caseMin or int(case) > caseMax: - print(f"Invalid case number {case}! Case number must be in the {caseMin}:{caseMax} range. Aborting!") + print("Invalid case number {}! Case number must be in the {}:{} range. Aborting!".format(case, caseMin, caseMax)) exit(0) return args @@ -271,17 +275,17 @@ def rpp_test_suite_parser_and_validator(): os.chdir(buildFolderPath + "/build") # Run cmake and make commands -subprocess.run(["cmake", scriptPath], cwd=".") # nosec -subprocess.run(["make", "-j16"], cwd=".") # nosec +subprocess.call(["cmake", scriptPath], cwd=".") # nosec +subprocess.call(["make", "-j16"], cwd=".") # nosec # List of cases supported supportedCaseList = ['0', '1', '2', '4', '8', '13', '20', '21', '23', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '45', '46', '54', '61', '63', '65', '68', '70', '79', '80', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92'] # Create folders based on testType and profilingOption if testType == 1 and profilingOption == "YES": - os.makedirs(f"{dstPath}/Tensor_PKD3") - os.makedirs(f"{dstPath}/Tensor_PLN1") - os.makedirs(f"{dstPath}/Tensor_PLN3") + os.makedirs("{}/Tensor_PKD3".format(dstPath)) + os.makedirs("{}/Tensor_PLN1".format(dstPath)) + os.makedirs("{}/Tensor_PLN3".format(dstPath)) print("\n\n\n\n\n") print("##########################################################################################") diff --git a/utilities/test_suite/HIP/runVoxelTests.py b/utilities/test_suite/HIP/runVoxelTests.py index f3ad38025..ef6c0d7f0 100644 --- a/utilities/test_suite/HIP/runVoxelTests.py +++ b/utilities/test_suite/HIP/runVoxelTests.py @@ -57,20 +57,23 @@ def func_group_finder(case_number): return "miscellaneous" def run_unit_test_cmd(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - print(f"./Tensor_voxel_hip {headerPath} {dataPath} {dstPathTemp} {layout} {case} {numRuns} {testType} {qaMode} {batchSize} {bitDepth}") - result = subprocess.run([buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_voxel_hip {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, logFileLayout, headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - with open(f"{loggingFolder}/Tensor_voxel_hip_{logFileLayout}_raw_performance_log.txt", "a") as logFile: - print(f"./Tensor_voxel_hip {headerPath} {dataPath} {dstPathTemp} {layout} {case} {numRuns} {testType} {qaMode} {batchSize} {bitDepth}") - process = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + with open("{}/Tensor_voxel_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: + print("./Tensor_voxel_hip {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + process = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() if not output and process.poll() is not None: break - print(output.strip()) + output = output.decode().strip() # Decode bytes to string and strip extra whitespace + print(output) + logFile.write(output) if "Running" in output or "max,min,avg wall times" in output: cleanedOutput = ''.join(char for char in output if 32 <= ord(char) <= 126) # Remove control characters cleanedOutput = cleanedOutput.strip() # Remove leading/trailing whitespace @@ -81,14 +84,15 @@ def run_performance_test_cmd(loggingFolder, logFileLayout, headerPath, dataPath, def run_performance_test_with_profiler_cmd(loggingFolder, logFileLayout, headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): layoutName = get_layout_name(layout) - if not os.path.exists(f"{loggingFolder}/Tensor_{layoutName}/case_{case}"): - os.mkdir(f"{loggingFolder}/Tensor_{layoutName}/case_{case}") + directory_path = os.path.join(loggingFolder, "Tensor_" + layoutName, "case_" + str(case)) + if not os.path.exists(directory_path): + os.mkdir(directory_path) bitDepths = [0, 2] for bitDepth in bitDepths: - with open(f"{loggingFolder}/Tensor_voxel_hip_{logFileLayout}_raw_performance_log.txt", "a") as logFile: - print(f"\nrocprof --basenames on --timestamp on --stats -o {dstPathTemp}/Tensor_{layoutName}/case_{case}/output_case{case}.csv ./Tensor_voxel_hip {headerPath} {dataPath} {dstPathTemp} {layout} {case}{numRuns} {testType} {qaMode} {batchSize} {bitDepth}") - process = subprocess.Popen([ 'rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', f"{dstPath}/Tensor_{layoutName}/case_{case}/output_case{case}.csv", buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec + with open("{}/Tensor_voxel_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: + print("\nrocprof --basenames on --timestamp on --stats -o {}/Tensor_{}/case_{}/output_case{}.csv ./Tensor_voxel_hip {} {} {} {} {}{} {} {} {}".format(dstPathTemp, layoutName, case, case, headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', '{}/Tensor_{}/case_{}/output_case{}.csv'.format(dstPath, layoutName, case, case), buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() if not output and process.poll() is not None: @@ -227,17 +231,17 @@ def rpp_test_suite_parser_and_validator(): os.chdir(buildFolderPath + "/build") # Run cmake and make commands -subprocess.run(["cmake", scriptPath], cwd=".") # nosec -subprocess.run(["make", "-j16"], cwd=".") # nosec +subprocess.call(["cmake", scriptPath], cwd=".") # nosec +subprocess.call(["make", "-j16"], cwd=".") # nosec # List of cases supported supportedCaseList = ['0', '1', '2', '3', '4', '5', '6'] # Create folders based on testType and profilingOption if testType == 1 and profilingOption == "YES": - os.makedirs(f"{dstPath}/Tensor_PKD3") - os.makedirs(f"{dstPath}/Tensor_PLN1") - os.makedirs(f"{dstPath}/Tensor_PLN3") + os.makedirs("{}/Tensor_PKD3".format(dstPath)) + os.makedirs("{}/Tensor_PLN1".format(dstPath)) + os.makedirs("{}/Tensor_PLN3".format(dstPath)) print("\n\n\n\n\n") print("##########################################################################################") diff --git a/utilities/test_suite/HOST/runAudioTests.py b/utilities/test_suite/HOST/runAudioTests.py index c0600c057..8fe6f9157 100644 --- a/utilities/test_suite/HOST/runAudioTests.py +++ b/utilities/test_suite/HOST/runAudioTests.py @@ -45,15 +45,16 @@ def get_log_file_list(): ] def run_unit_test_cmd(srcPath, case, numRuns, testType, batchSize, outFilePath): - print(f"./Tensor_audio_host {srcPath} {case} {numRuns} {testType} {numRuns} {batchSize}") - result = subprocess.run([buildFolderPath + "/build/Tensor_audio_host", srcPath, str(case), str(testType), str(numRuns), str(batchSize), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_audio_host {} {} {} {} {} {}".format(srcPath, case, numRuns, testType, numRuns, batchSize)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_audio_host", srcPath, str(case), str(testType), str(numRuns), str(batchSize), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, srcPath, case, numRuns, testType, batchSize, outFilePath): with open("{}/Tensor_audio_host_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print(f"./Tensor_audio_host {srcPath} {case} {numRuns} {testType} {numRuns} {batchSize} ") - process = subprocess.Popen([buildFolderPath + "/build/Tensor_audio_host", srcPath, str(case), str(testType), str(numRuns), str(batchSize), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + print("./Tensor_audio_host {} {} {} {} {} {} ".format(srcPath, case, numRuns, testType, numRuns, batchSize)) + process = subprocess.Popen([buildFolderPath + "/build/Tensor_audio_host", srcPath, str(case), str(testType), str(numRuns), str(batchSize), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) print("------------------------------------------------------------------------------------------") @@ -87,7 +88,7 @@ def rpp_test_suite_parser_and_validator(): # validate the parameters passed by user if ((args.case_start < caseMin or args.case_start > caseMax) or (args.case_end < caseMin or args.case_end > caseMax)): - print(f"Starting case# and Ending case# must be in the {caseMin}:{caseMax} range. Aborting!") + print("Starting case# and Ending case# must be in the {}:{} range. Aborting!".format(caseMin, caseMax)) exit(0) elif args.case_end < args.case_start: print("Ending case# must be greater than starting case#. Aborting!") @@ -120,7 +121,7 @@ def rpp_test_suite_parser_and_validator(): else: for case in args.case_list: if int(case) < caseMin or int(case) > caseMax: - print(f"Invalid case number {case}! Case number must be in the {caseMin}:{caseMax} range. Aborting!") + print("Invalid case number {}! Case number must be in the {}:{} range. Aborting!".format(case, caseMin, caseMax)) exit(0) return args @@ -171,8 +172,8 @@ def rpp_test_suite_parser_and_validator(): os.chdir(buildFolderPath + "/build") # Run cmake and make commands -subprocess.run(["cmake", scriptPath], cwd=".") # nosec -subprocess.run(["make", "-j16"], cwd=".") # nosec +subprocess.call(["cmake", scriptPath], cwd=".") # nosec +subprocess.call(["make", "-j16"], cwd=".") # nosec # List of cases supported supportedCaseList = ['0', '1', '2', '3', '4', '5', '6', '7'] diff --git a/utilities/test_suite/HOST/runMiscTests.py b/utilities/test_suite/HOST/runMiscTests.py index 0f428fe40..0ca9ad4f5 100644 --- a/utilities/test_suite/HOST/runMiscTests.py +++ b/utilities/test_suite/HOST/runMiscTests.py @@ -47,15 +47,16 @@ def get_log_file_list(): ] def run_unit_test_cmd(numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - print(f"./Tensor_misc_host {case} {testType} {toggle} {numDims} {batchSize} {numRuns} {additionalArg}") - result = subprocess.run([buildFolderPath + "/build/Tensor_misc_host", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_misc_host {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_host", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): with open("{}/Tensor_misc_host_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print(f"./Tensor_misc_host {case} {testType} {toggle} {numDims} {batchSize} {numRuns} {additionalArg}") - process = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_host", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + print("./Tensor_misc_host {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + process = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_host", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) def run_test(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg = ""): @@ -162,8 +163,8 @@ def rpp_test_suite_parser_and_validator(): os.chdir(buildFolderPath + "/build") # Run cmake and make commands -subprocess.run(["cmake", scriptPath], cwd=".") # nosec -subprocess.run(["make", "-j16"], cwd=".") # nosec +subprocess.call(["cmake", scriptPath], cwd=".") # nosec +subprocess.call(["make", "-j16"], cwd=".") # nosec supportedCaseList = ['0', '1', '2'] for case in caseList: diff --git a/utilities/test_suite/HOST/runTests.py b/utilities/test_suite/HOST/runTests.py index b38a08757..aa000285d 100644 --- a/utilities/test_suite/HOST/runTests.py +++ b/utilities/test_suite/HOST/runTests.py @@ -70,34 +70,37 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo if case == "8": # Run all variants of noise type functions with additional argument of noiseType = gausssianNoise / shotNoise / saltandpepperNoise for noiseType in range(3): - print(f"./Tensor_host {srcPath1} {srcPath2} {dstPathTemp} {bitDepth} {outputFormatToggle} {case} {noiseType} 0 ") - result = subprocess.run([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(noiseType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_host {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, noiseType)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(noiseType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) elif case == "21" or case == "23" or case == "24" or case == "79": # Run all variants of interpolation functions with additional argument of interpolationType = bicubic / bilinear / gaussian / nearestneigbor / lanczos / triangular interpolationRange = 6 if case =='79': interpolationRange = 2 for interpolationType in range(interpolationRange): - print(f"./Tensor_host {srcPath1} {srcPath2} {dstPathTemp} {bitDepth} {outputFormatToggle} {case} {interpolationType} 0") - result = subprocess.run([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(interpolationType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_host {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, interpolationType)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(interpolationType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) else: - print(f"./Tensor_host {srcPath1} {srcPath2} {dstPathTemp} {bitDepth} {outputFormatToggle} {case} 0 {numRuns} {testType} {layout} 0") - result = subprocess.run([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), "0", str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_host {} {} {} {} {} {} 0 {} {} {} 0".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, numRuns, testType, layout)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), "0", str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): if qaMode == 1: with open("{}/BatchPD_host_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - process = subprocess.Popen([buildFolderPath + "/build/BatchPD_host_" + logFileLayout, srcPath1, srcPath2, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), "0"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + process = subprocess.Popen([buildFolderPath + "/build/BatchPD_host_" + logFileLayout, srcPath1, srcPath2, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), "0"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) with open("{}/Tensor_host_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print(f"./Tensor_host {srcPath1} {srcPath2} {dstPath} {bitDepth} {outputFormatToggle} {case} {additionalParam} 0 ") - process = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + print("./Tensor_host {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam)) + process = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) def run_performance_test(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, case, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): @@ -153,7 +156,7 @@ def rpp_test_suite_parser_and_validator(): # validate the parameters passed by user if ((args.case_start < caseMin or args.case_start > caseMax) or (args.case_end < caseMin or args.case_end > caseMax)): - print(f"Starting case# and Ending case# must be in the {caseMin}:{caseMax} range. Aborting!") + print("Starting case# and Ending case# must be in the {}:{} range. Aborting!".format(caseMin, caseMax)) exit(0) elif args.case_end < args.case_start: print("Ending case# must be greater than starting case#. Aborting!") @@ -192,7 +195,7 @@ def rpp_test_suite_parser_and_validator(): else: for case in args.case_list: if int(case) < caseMin or int(case) > caseMax: - print(f"Invalid case number {case}! Case number must be in the {caseMin}:{caseMax} range. Aborting!") + print("Invalid case number {}! Case number must be in the {}:{} range. Aborting!".format(case, caseMin, caseMax)) exit(0) return args @@ -253,8 +256,8 @@ def rpp_test_suite_parser_and_validator(): os.chdir(buildFolderPath + "/build") # Run cmake and make commands -subprocess.run(["cmake", scriptPath], cwd=".") # nosec -subprocess.run(["make", "-j16"], cwd=".") # nosec +subprocess.call(["cmake", scriptPath], cwd=".") # nosec +subprocess.call(["make", "-j16"], cwd=".") # nosec # List of cases supported supportedCaseList = ['0', '1', '2', '4', '8', '13', '20', '21', '23', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '45', '46', '54', '61', '63', '65', '68', '70', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92'] @@ -439,7 +442,7 @@ def rpp_test_suite_parser_and_validator(): summaryRow = {'BatchPD_Augmentation_Type': pd.NA, 'Tensor_Augmentation_Type': pd.NA, 'Performance Speedup (%)': pd.NA, - 'Test_Result': f'Final Results of Tests: Passed: {passedCases}, Failed: {failedCases}'} + 'Test_Result': 'Final Results of Tests: Passed: {}, Failed: {}'.format(passedCases, failedCases)} print("\n", df.to_markdown()) @@ -452,7 +455,7 @@ def rpp_test_suite_parser_and_validator(): print("\n-------------------------------------------------------------------" + resultsInfo + "\n\n-------------------------------------------------------------------") print("\nIMPORTANT NOTE:") print("- The following performance comparison shows Performance Speedup percentages between times measured on previous generation RPP-BatchPD APIs against current generation RPP-Tensor APIs.") - print(f"- All APIs have been improved for performance ranging from {0}% (almost same) to {100}% faster.") + print("- All APIs have been improved for performance ranging from {}% (almost same) to {}% faster.".format(0, 100)) print("- Random observations of negative speedups might always occur due to current test machine temperature/load variances or other CPU/GPU state-dependent conditions.") print("\n-------------------------------------------------------------------\n") elif (testType == 1 and qaMode == 0): diff --git a/utilities/test_suite/HOST/runVoxelTests.py b/utilities/test_suite/HOST/runVoxelTests.py index 3dbe0baa5..420ba0403 100644 --- a/utilities/test_suite/HOST/runVoxelTests.py +++ b/utilities/test_suite/HOST/runVoxelTests.py @@ -58,20 +58,23 @@ def func_group_finder(case_number): return "miscellaneous" def run_unit_test_cmd(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - print(f"./Tensor_voxel_host {headerPath} {dataPath} {dstPathTemp} {layout} {case} {numRuns} {testType} {qaMode} {batchSize} {bitDepth}") - result = subprocess.run([buildFolderPath + "/build/Tensor_voxel_host", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE) # nosec - print(result.stdout.decode()) + print("./Tensor_voxel_host {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + result = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_host", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE) # nosec + stdout_data, stderr_data = result.communicate() + print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, logFileLayout, headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - with open(f"{loggingFolder}/Tensor_voxel_host_{logFileLayout}_raw_performance_log.txt", "a") as logFile: - print(f"./Tensor_voxel_host {headerPath} {dataPath} {dstPathTemp} {layout} {case} {numRuns} {testType} {qaMode} {batchSize} {bitDepth}") - process = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_host", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # nosec + with open("{}/Tensor_voxel_host_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: + print("./Tensor_voxel_host {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + process = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_host", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() if not output and process.poll() is not None: break - print(output.strip()) + output = output.decode().strip() # Decode bytes to string and strip extra whitespace + print(output) + logFile.write(output) if "Running" in output or "max,min,avg wall times" in output: cleanedOutput = ''.join(char for char in output if 32 <= ord(char) <= 126) # Remove control characters cleanedOutput = cleanedOutput.strip() # Remove leading/trailing whitespace @@ -203,8 +206,8 @@ def rpp_test_suite_parser_and_validator(): os.chdir(buildFolderPath + "/build") # Run cmake and make commands -subprocess.run(["cmake", scriptPath], cwd=".") # nosec -subprocess.run(["make", "-j16"], cwd=".") # nosec +subprocess.call(["cmake", scriptPath], cwd=".") # nosec +subprocess.call(["make", "-j16"], cwd=".") # nosec # List of cases supported supportedCaseList = ['0', '1', '2', '3', '4', '5', '6'] diff --git a/utilities/test_suite/common.py b/utilities/test_suite/common.py index 527b40ead..61a03f239 100644 --- a/utilities/test_suite/common.py +++ b/utilities/test_suite/common.py @@ -28,6 +28,12 @@ import datetime import shutil +try: + from errno import FileExistsError +except ImportError: + # Python 2 compatibility + FileExistsError = OSError + imageAugmentationMap = { 0: ["brightness", "HOST", "HIP"], 1: ["gamma_correction", "HOST", "HIP"], @@ -173,7 +179,7 @@ def case_file_check(CASE_FILE_PATH, TYPE, TENSOR_TYPE_LIST, new_file, d_counter) def directory_name_generator(qaMode, affinity, layoutType, case, path, func_group_finder): if qaMode == 0: functionality_group = func_group_finder(int(case)) - dst_folder_temp = f"{path}/rpp_{affinity}_{layoutType}_{functionality_group}" + dst_folder_temp = "{}/rpp_{}_{}_{}".format(path, affinity, layoutType, functionality_group) else: dst_folder_temp = path @@ -318,8 +324,9 @@ def read_from_subprocess_and_write_to_log(process, logFile): output = process.stdout.readline() if not output and process.poll() is not None: break - print(output.strip()) - logFile.write(output) + output = output.decode().strip() # Decode bytes to string and strip extra whitespace + print(output) + logFile.write(output + '\n') # Returns the layout name based on layout value def get_layout_name(layout): From 8be20911226030c11fb037fef5ca15e83033b578 Mon Sep 17 00:00:00 2001 From: HazarathKumarM Date: Fri, 12 Jul 2024 10:28:39 +0000 Subject: [PATCH 3/5] Replace .format() for strings and use concatination --- utilities/test_suite/HIP/runMiscTests.py | 19 ++++++------ utilities/test_suite/HIP/runTests.py | 34 +++++++++++----------- utilities/test_suite/HIP/runVoxelTests.py | 21 +++++++------ utilities/test_suite/HOST/runAudioTests.py | 10 +++---- utilities/test_suite/HOST/runMiscTests.py | 6 ++-- utilities/test_suite/HOST/runTests.py | 20 ++++++------- utilities/test_suite/HOST/runVoxelTests.py | 6 ++-- utilities/test_suite/common.py | 2 +- 8 files changed, 59 insertions(+), 59 deletions(-) diff --git a/utilities/test_suite/HIP/runMiscTests.py b/utilities/test_suite/HIP/runMiscTests.py index 1b35b1161..ee97f4547 100644 --- a/utilities/test_suite/HIP/runMiscTests.py +++ b/utilities/test_suite/HIP/runMiscTests.py @@ -74,25 +74,26 @@ def generate_performance_reports(RESULTS_DIR): print(dfPrint_noIndices) def run_unit_test_cmd(numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - print("./Tensor_misc_hip {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + print("./Tensor_misc_hip " + str(case) + " " + str(testType) + " " + str(toggle) + " " + str(numDims) + " " + str(batchSize) + " " + str(numRuns) + " " + str(additionalArg)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - with open("{}/Tensor_misc_hip_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print("./Tensor_misc_hip {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + with open(loggingFolder + "/Tensor_misc_hip_raw_performance_log.txt", "a") as logFile: + logFile.write("./Tensor_misc_hip " + str(case) + " " + str(testType) + " " + str(toggle) + " " + str(numDims) + " " + str(batchSize) + " " + str(numRuns) + " " + str(additionalArg) + "\n") process = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) def run_performance_test_with_profiler_cmd(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - if not os.path.exists("{}/case_{}".format(outFilePath, case)): - os.mkdir("{}/case_{}".format(outFilePath, case)) + if not os.path.exists(outFilePath + "/case_" + str(case)): + os.mkdir(outFilePath + "/case_" + str(case)) - with open("{}/Tensor_misc_hip_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print("\nrocprof --basenames on --timestamp on --stats -o {}/case_{}/output_case{}.csv ./Tensor_misc_hip {} {} {} {} {} {} {}".format(outFilePath, case, case, case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) - process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', '{}/case_{}/output_case{}.csv'.format(outFilePath, case, case), "./Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) + with open(loggingFolder + "/Tensor_misc_hip_raw_performance_log.txt", "a") as logFile: + logFile.write("\nrocprof --basenames on --timestamp on --stats -o " + outFilePath + "/case_" + str(case) + "/output_case" + str(case) + ".csv ./Tensor_misc_hip " + str(case) + " " + str(testType) + " " + str(toggle) + " " + str(numDims) + " " + str(batchSize) + " " + str(numRuns) + " " + str(additionalArg) + "\n") + process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', outFilePath + "/case_" + str(case) + "/output_case" + str(case) + ".csv", "./Tensor_misc_hip", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec + read_from_subprocess_and_write_to_log(process, logFile) print("------------------------------------------------------------------------------------------") def run_test(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg, profilingOption = 'NO'): @@ -253,7 +254,7 @@ def rpp_test_suite_parser_and_validator(): continue new_file.close() - subprocess.call(['chown', '{}:{}'.format(os.getuid(), os.getgid()), CONSOLIDATED_FILE]) # nosec + subprocess.call(['chown', str(os.getuid()) + ':' + str(os.getgid()), CONSOLIDATED_FILE]) # nosec try: generate_performance_reports(RESULTS_DIR) except ImportError: diff --git a/utilities/test_suite/HIP/runTests.py b/utilities/test_suite/HIP/runTests.py index 0eebe837b..e595b3f75 100644 --- a/utilities/test_suite/HIP/runTests.py +++ b/utilities/test_suite/HIP/runTests.py @@ -69,14 +69,14 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo if case == "40" or case == "41" or case == "49" or case == "54": for kernelSize in range(3, 10, 2): - print("./Tensor_hip {} {} {} {} {} {} {}".format(srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, kernelSize)) + print("./Tensor_hip " + srcPath1 + " " + srcPath2 + " " + dstPath + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(kernelSize)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(kernelSize), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) elif case == "8": # Run all variants of noise type functions with additional argument of noiseType = gausssianNoise / shotNoise / saltandpepperNoise for noiseType in range(3): - print("./Tensor_hip {} {} {} {} {} {} {}".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, noiseType)) + print("./Tensor_hip " + srcPath1 + " " + srcPath2 + " " + dstPathTemp + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(noiseType)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(noiseType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) @@ -86,12 +86,12 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo if case =='79': interpolationRange = 2 for interpolationType in range(interpolationRange): - print("./Tensor_hip {} {} {} {} {} {} {}".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, interpolationType)) + print("./Tensor_hip " + srcPath1 + " " + srcPath2 + " " + dstPathTemp + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(interpolationType)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(interpolationType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) else: - print("./Tensor_hip {} {} {} {} {} {} 0 {} {} {}".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, numRuns, testType, layout)) + print("./Tensor_hip " + srcPath1 + " " + srcPath2 + " " + dstPathTemp + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " 0 " + str(numRuns) + " " + str(testType) + " " + str(layout)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), "0", str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) @@ -99,8 +99,8 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): - with open("{}/Tensor_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print("./Tensor_hip {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam)) + with open(loggingFolder + "/Tensor_hip_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: + print("./Tensor_hip " + srcPath1 + " " + srcPath2 + " " + dstPath + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(additionalParam)) process = subprocess.Popen([buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) @@ -136,11 +136,11 @@ def run_performance_test(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPa def run_performance_test_with_profiler(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam, additionalParamType, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): addtionalParamString = additionalParamType + str(additionalParam) layoutName = get_layout_name(layout) - if not os.path.isdir("{}/Tensor_{}/case_{}".format(dstPath, layoutName, case)): - os.makedirs("{}/Tensor_{}/case_{}".format(dstPath, layoutName, case)) - with open("{}/Tensor_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print("rocprof --basenames on --timestamp on --stats -o {}/Tensor_{}/case_{}/output_case{}_bitDepth{}_oft{}{}.csv ./Tensor_hip {} {} {} {} {} {} 0".format(dstPath, layoutName, case, case, bitDepth, outputFormatToggle, addtionalParamString, srcPath1, srcPath2, bitDepth, outputFormatToggle, case, additionalParam)) - process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', '{}/Tensor_{}/case_{}/output_case{}_bitDepth{}_oft{}{}.csv'.format(dstPath, layoutName, case, case, bitDepth, outputFormatToggle, addtionalParamString), buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), '0', str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec + if not os.path.isdir(dstPath + "/Tensor_" + layoutName + "/case_" + str(case)): + os.makedirs(dstPath + "/Tensor_" + layoutName + "/case_" + str(case)) + with open(loggingFolder + "/Tensor_hip_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: + logFile.write("rocprof --basenames on --timestamp on --stats -o " + dstPath + "/Tensor_" + layoutName + "/case_" + str(case) + "/output_case" + str(case) + "_bitDepth" + str(bitDepth) + "_oft" + addtionalParamString + ".csv ./Tensor_hip " + srcPath1 + " " + srcPath2 + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(additionalParam) + " 0\n") + process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', dstPath + "/Tensor_" + layoutName + "/case_" + str(case) + "/output_case" + str(case) + "_bitDepth" + str(bitDepth) + "_oft" + addtionalParamString + ".csv", buildFolderPath + "/build/Tensor_hip", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), '0', str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() if not output and process.poll() is not None: @@ -175,7 +175,7 @@ def rpp_test_suite_parser_and_validator(): # validate the parameters passed by user if ((args.case_start < caseMin or args.case_start > caseMax) or (args.case_end < caseMin or args.case_end > caseMax)): - print("Starting case# and Ending case# must be in the {}:{} range. Aborting!".format(caseMin, caseMax)) + print("Starting case# and Ending case# must be in the " + str(caseMin) + ":" + str(caseMax) + " range. Aborting!") exit(0) elif args.case_end < args.case_start: print("Ending case# must be greater than starting case#. Aborting!") @@ -217,7 +217,7 @@ def rpp_test_suite_parser_and_validator(): else: for case in args.case_list: if int(case) < caseMin or int(case) > caseMax: - print("Invalid case number {}! Case number must be in the {}:{} range. Aborting!".format(case, caseMin, caseMax)) + print("Invalid case number " + str(case) + "! Case number must be in the " + str(caseMin) + ":" + str(caseMax) + " range. Aborting!") exit(0) return args @@ -283,9 +283,9 @@ def rpp_test_suite_parser_and_validator(): # Create folders based on testType and profilingOption if testType == 1 and profilingOption == "YES": - os.makedirs("{}/Tensor_PKD3".format(dstPath)) - os.makedirs("{}/Tensor_PLN1".format(dstPath)) - os.makedirs("{}/Tensor_PLN3".format(dstPath)) + os.makedirs(dstPath + "/Tensor_PKD3") + os.makedirs(dstPath + "/Tensor_PLN1") + os.makedirs(dstPath + "/Tensor_PLN3") print("\n\n\n\n\n") print("##########################################################################################") @@ -447,7 +447,7 @@ def rpp_test_suite_parser_and_validator(): continue new_file.close() - subprocess.call(['chown', '{}:{}'.format(os.getuid(), os.getgid()), RESULTS_DIR + "/consolidated_results_" + TYPE + ".stats.csv"]) # nosec + subprocess.call(['chown', str(os.getuid()) + ':' + str(os.getgid()), RESULTS_DIR + "/consolidated_results_" + TYPE + ".stats.csv"]) # nosec try: generate_performance_reports(d_counter, TYPE_LIST, RESULTS_DIR) diff --git a/utilities/test_suite/HIP/runVoxelTests.py b/utilities/test_suite/HIP/runVoxelTests.py index ef6c0d7f0..2c19b43d7 100644 --- a/utilities/test_suite/HIP/runVoxelTests.py +++ b/utilities/test_suite/HIP/runVoxelTests.py @@ -57,15 +57,15 @@ def func_group_finder(case_number): return "miscellaneous" def run_unit_test_cmd(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - print("./Tensor_voxel_hip {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + print("./Tensor_voxel_hip " + headerPath + " " + dataPath + " " + dstPathTemp + " " + str(layout) + " " + str(case) + " " + str(numRuns) + " " + str(testType) + " " + str(qaMode) + " " + str(batchSize) + " " + str(bitDepth)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, logFileLayout, headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - with open("{}/Tensor_voxel_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print("./Tensor_voxel_hip {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + with open(loggingFolder + "/Tensor_voxel_hip_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: + logFile.write("./Tensor_voxel_hip " + headerPath + " " + dataPath + " " + dstPathTemp + " " + str(layout) + " " + str(case) + " " + str(numRuns) + " " + str(testType) + " " + str(qaMode) + " " + str(batchSize) + " " + str(bitDepth) + "\n") process = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() @@ -90,9 +90,9 @@ def run_performance_test_with_profiler_cmd(loggingFolder, logFileLayout, headerP bitDepths = [0, 2] for bitDepth in bitDepths: - with open("{}/Tensor_voxel_hip_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print("\nrocprof --basenames on --timestamp on --stats -o {}/Tensor_{}/case_{}/output_case{}.csv ./Tensor_voxel_hip {} {} {} {} {}{} {} {} {}".format(dstPathTemp, layoutName, case, case, headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) - process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', '{}/Tensor_{}/case_{}/output_case{}.csv'.format(dstPath, layoutName, case, case), buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec + with open(loggingFolder + "/Tensor_voxel_hip_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: + logFile.write("\nrocprof --basenames on --timestamp on --stats -o " + dstPathTemp + "/Tensor_" + layoutName + "/case_" + str(case) + "/output_case" + str(case) + ".csv ./Tensor_voxel_hip " + headerPath + " " + dataPath + " " + dstPathTemp + " " + str(layout) + " " + str(case) + " " + str(numRuns) + " " + str(testType) + " " + str(qaMode) + " " + str(batchSize) + " " + str(bitDepth) + "\n") + process = subprocess.Popen(['rocprof', '--basenames', 'on', '--timestamp', 'on', '--stats', '-o', dstPath + "/Tensor_" + layoutName + "/case_" + str(case) + "/output_case" + str(case) + ".csv", buildFolderPath + "/build/Tensor_voxel_hip", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() if not output and process.poll() is not None: @@ -239,9 +239,9 @@ def rpp_test_suite_parser_and_validator(): # Create folders based on testType and profilingOption if testType == 1 and profilingOption == "YES": - os.makedirs("{}/Tensor_PKD3".format(dstPath)) - os.makedirs("{}/Tensor_PLN1".format(dstPath)) - os.makedirs("{}/Tensor_PLN3".format(dstPath)) + os.makedirs(dstPath + "/Tensor_PKD3") + os.makedirs(dstPath + "/Tensor_PLN1") + os.makedirs(dstPath + "/Tensor_PLN3") print("\n\n\n\n\n") print("##########################################################################################") @@ -326,8 +326,7 @@ def rpp_test_suite_parser_and_validator(): continue new_file.close() - subprocess.call(['chown', '{}:{}'.format(os.getuid(), os.getgid()), RESULTS_DIR + "/consolidated_results_" + TYPE + ".stats.csv"]) # nosec - try: + subprocess.call(['chown', str(os.getuid()) + ':' + str(os.getgid()), RESULTS_DIR + "/consolidated_results_" + TYPE + ".stats.csv"]) # nosec try: generate_performance_reports(d_counter, TYPE_LIST, RESULTS_DIR) except ImportError: diff --git a/utilities/test_suite/HOST/runAudioTests.py b/utilities/test_suite/HOST/runAudioTests.py index 8fe6f9157..a1771716b 100644 --- a/utilities/test_suite/HOST/runAudioTests.py +++ b/utilities/test_suite/HOST/runAudioTests.py @@ -45,15 +45,15 @@ def get_log_file_list(): ] def run_unit_test_cmd(srcPath, case, numRuns, testType, batchSize, outFilePath): - print("./Tensor_audio_host {} {} {} {} {} {}".format(srcPath, case, numRuns, testType, numRuns, batchSize)) + print("./Tensor_audio_host " + srcPath + " " + str(case) + " " + str(numRuns) + " " + str(testType) + " " + str(numRuns) + " " + str(batchSize)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_audio_host", srcPath, str(case), str(testType), str(numRuns), str(batchSize), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, srcPath, case, numRuns, testType, batchSize, outFilePath): - with open("{}/Tensor_audio_host_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print("./Tensor_audio_host {} {} {} {} {} {} ".format(srcPath, case, numRuns, testType, numRuns, batchSize)) + with open(loggingFolder + "/Tensor_audio_host_raw_performance_log.txt", "a") as logFile: + logFile.write("./Tensor_audio_host " + srcPath + " " + str(case) + " " + str(numRuns) + " " + str(testType) + " " + str(numRuns) + " " + str(batchSize) + "\n") process = subprocess.Popen([buildFolderPath + "/build/Tensor_audio_host", srcPath, str(case), str(testType), str(numRuns), str(batchSize), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) print("------------------------------------------------------------------------------------------") @@ -88,7 +88,7 @@ def rpp_test_suite_parser_and_validator(): # validate the parameters passed by user if ((args.case_start < caseMin or args.case_start > caseMax) or (args.case_end < caseMin or args.case_end > caseMax)): - print("Starting case# and Ending case# must be in the {}:{} range. Aborting!".format(caseMin, caseMax)) + print("Starting case# and Ending case# must be in the " + str(caseMin) + ":" + str(caseMax) + " range. Aborting!") exit(0) elif args.case_end < args.case_start: print("Ending case# must be greater than starting case#. Aborting!") @@ -121,7 +121,7 @@ def rpp_test_suite_parser_and_validator(): else: for case in args.case_list: if int(case) < caseMin or int(case) > caseMax: - print("Invalid case number {}! Case number must be in the {}:{} range. Aborting!".format(case, caseMin, caseMax)) + print("Invalid case number " + str(case) + "! Case number must be in the " + str(caseMin) + ":" + str(caseMax) + " range. Aborting!") exit(0) return args diff --git a/utilities/test_suite/HOST/runMiscTests.py b/utilities/test_suite/HOST/runMiscTests.py index 0ca9ad4f5..931838f71 100644 --- a/utilities/test_suite/HOST/runMiscTests.py +++ b/utilities/test_suite/HOST/runMiscTests.py @@ -47,15 +47,15 @@ def get_log_file_list(): ] def run_unit_test_cmd(numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - print("./Tensor_misc_host {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + print("./Tensor_misc_host " + str(case) + " " + str(testType) + " " + str(toggle) + " " + str(numDims) + " " + str(batchSize) + " " + str(numRuns) + " " + str(additionalArg)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_host", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, numDims, case, numRuns, testType, toggle, batchSize, outFilePath, additionalArg): - with open("{}/Tensor_misc_host_raw_performance_log.txt".format(loggingFolder), "a") as logFile: - print("./Tensor_misc_host {} {} {} {} {} {} {}".format(case, testType, toggle, numDims, batchSize, numRuns, additionalArg)) + with open(loggingFolder + "/Tensor_misc_host_raw_performance_log.txt", "a") as logFile: + logFile.write("./Tensor_misc_host " + str(case) + " " + str(testType) + " " + str(toggle) + " " + str(numDims) + " " + str(batchSize) + " " + str(numRuns) + " " + str(additionalArg) + "\n") process = subprocess.Popen([buildFolderPath + "/build/Tensor_misc_host", str(case), str(testType), str(toggle), str(numDims), str(batchSize), str(numRuns), str(additionalArg), outFilePath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) diff --git a/utilities/test_suite/HOST/runTests.py b/utilities/test_suite/HOST/runTests.py index aa000285d..730252b9e 100644 --- a/utilities/test_suite/HOST/runTests.py +++ b/utilities/test_suite/HOST/runTests.py @@ -70,7 +70,7 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo if case == "8": # Run all variants of noise type functions with additional argument of noiseType = gausssianNoise / shotNoise / saltandpepperNoise for noiseType in range(3): - print("./Tensor_host {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, noiseType)) + print("./Tensor_host " + srcPath1 + " " + srcPath2 + " " + dstPathTemp + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(noiseType) + " 0") result = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(noiseType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) @@ -80,12 +80,12 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo if case =='79': interpolationRange = 2 for interpolationType in range(interpolationRange): - print("./Tensor_host {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, interpolationType)) + print("./Tensor_host " + srcPath1 + " " + srcPath2 + " " + dstPathTemp + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(interpolationType) + " 0") result = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), str(interpolationType), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) else: - print("./Tensor_host {} {} {} {} {} {} 0 {} {} {} 0".format(srcPath1, srcPath2, dstPathTemp, bitDepth, outputFormatToggle, case, numRuns, testType, layout)) + print("./Tensor_host " + srcPath1 + " " + srcPath2 + " " + dstPathTemp + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " 0 " + str(numRuns) + " " + str(testType) + " " + str(layout) + " 0") result = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPathTemp, str(bitDepth), str(outputFormatToggle), str(case), "0", str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) @@ -94,12 +94,12 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo def run_performance_test_cmd(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): if qaMode == 1: - with open("{}/BatchPD_host_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: + with open(loggingFolder + "/BatchPD_host_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: process = subprocess.Popen([buildFolderPath + "/build/BatchPD_host_" + logFileLayout, srcPath1, srcPath2, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), "0"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) - with open("{}/Tensor_host_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print("./Tensor_host {} {} {} {} {} {} {} 0".format(srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam)) + with open(loggingFolder + "/Tensor_host_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: + logFile.write("./Tensor_host " + srcPath1 + " " + srcPath2 + " " + dstPath + " " + str(bitDepth) + " " + str(outputFormatToggle) + " " + str(case) + " " + str(additionalParam) + " 0\n") process = subprocess.Popen([buildFolderPath + "/build/Tensor_host", srcPath1, srcPath2, dstPath, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), str(numRuns), str(testType), str(layout), "0", str(qaMode), str(decoderType), str(batchSize)] + roiList + [scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) @@ -156,7 +156,7 @@ def rpp_test_suite_parser_and_validator(): # validate the parameters passed by user if ((args.case_start < caseMin or args.case_start > caseMax) or (args.case_end < caseMin or args.case_end > caseMax)): - print("Starting case# and Ending case# must be in the {}:{} range. Aborting!".format(caseMin, caseMax)) + print("Starting case# and Ending case# must be in the " + str(caseMin) + ":" + str(caseMax) + " range. Aborting!") exit(0) elif args.case_end < args.case_start: print("Ending case# must be greater than starting case#. Aborting!") @@ -195,7 +195,7 @@ def rpp_test_suite_parser_and_validator(): else: for case in args.case_list: if int(case) < caseMin or int(case) > caseMax: - print("Invalid case number {}! Case number must be in the {}:{} range. Aborting!".format(case, caseMin, caseMax)) + print("Invalid case number " + str(case) + "! Case number must be in the " + str(caseMin) + ":" + str(caseMax) + " range. Aborting!") exit(0) return args @@ -442,7 +442,7 @@ def rpp_test_suite_parser_and_validator(): summaryRow = {'BatchPD_Augmentation_Type': pd.NA, 'Tensor_Augmentation_Type': pd.NA, 'Performance Speedup (%)': pd.NA, - 'Test_Result': 'Final Results of Tests: Passed: {}, Failed: {}'.format(passedCases, failedCases)} + 'Test_Result': 'Final Results of Tests: Passed: ' + str(passedCases) + ', Failed: ' + str(failedCases)} print("\n", df.to_markdown()) @@ -455,7 +455,7 @@ def rpp_test_suite_parser_and_validator(): print("\n-------------------------------------------------------------------" + resultsInfo + "\n\n-------------------------------------------------------------------") print("\nIMPORTANT NOTE:") print("- The following performance comparison shows Performance Speedup percentages between times measured on previous generation RPP-BatchPD APIs against current generation RPP-Tensor APIs.") - print("- All APIs have been improved for performance ranging from {}% (almost same) to {}% faster.".format(0, 100)) + print("- All APIs have been improved for performance ranging from " + str(0) + "% (almost same) to " + str(100) + "% faster.") print("- Random observations of negative speedups might always occur due to current test machine temperature/load variances or other CPU/GPU state-dependent conditions.") print("\n-------------------------------------------------------------------\n") elif (testType == 1 and qaMode == 0): diff --git a/utilities/test_suite/HOST/runVoxelTests.py b/utilities/test_suite/HOST/runVoxelTests.py index 420ba0403..f44c05f78 100644 --- a/utilities/test_suite/HOST/runVoxelTests.py +++ b/utilities/test_suite/HOST/runVoxelTests.py @@ -58,15 +58,15 @@ def func_group_finder(case_number): return "miscellaneous" def run_unit_test_cmd(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - print("./Tensor_voxel_host {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + print("./Tensor_voxel_host " + headerPath + " " + dataPath + " " + dstPathTemp + " " + str(layout) + " " + str(case) + " " + str(numRuns) + " " + str(testType) + " " + str(qaMode) + " " + str(batchSize) + " " + str(bitDepth)) result = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_host", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE) # nosec stdout_data, stderr_data = result.communicate() print(stdout_data.decode()) print("------------------------------------------------------------------------------------------") def run_performance_test_cmd(loggingFolder, logFileLayout, headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize): - with open("{}/Tensor_voxel_host_{}_raw_performance_log.txt".format(loggingFolder, logFileLayout), "a") as logFile: - print("./Tensor_voxel_host {} {} {} {} {} {} {} {} {} {}".format(headerPath, dataPath, dstPathTemp, layout, case, numRuns, testType, qaMode, batchSize, bitDepth)) + with open(loggingFolder + "/Tensor_voxel_host_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: + logFile.write("./Tensor_voxel_host " + headerPath + " " + dataPath + " " + dstPathTemp + " " + str(layout) + " " + str(case) + " " + str(numRuns) + " " + str(testType) + " " + str(qaMode) + " " + str(batchSize) + " " + str(bitDepth) + "\n") process = subprocess.Popen([buildFolderPath + "/build/Tensor_voxel_host", headerPath, dataPath, dstPathTemp, str(layout), str(case), str(numRuns), str(testType), str(qaMode), str(batchSize), str(bitDepth), scriptPath], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec while True: output = process.stdout.readline() diff --git a/utilities/test_suite/common.py b/utilities/test_suite/common.py index 61a03f239..e4129ad2d 100644 --- a/utilities/test_suite/common.py +++ b/utilities/test_suite/common.py @@ -179,7 +179,7 @@ def case_file_check(CASE_FILE_PATH, TYPE, TENSOR_TYPE_LIST, new_file, d_counter) def directory_name_generator(qaMode, affinity, layoutType, case, path, func_group_finder): if qaMode == 0: functionality_group = func_group_finder(int(case)) - dst_folder_temp = "{}/rpp_{}_{}_{}".format(path, affinity, layoutType, functionality_group) + dst_folder_temp = path + "/rpp_" + affinity + "_" + layoutType + "_" + functionality_group else: dst_folder_temp = path From 593f7bd9e71b8b79d902a925f800dbbb6946d092 Mon Sep 17 00:00:00 2001 From: HazarathKumarM Date: Mon, 15 Jul 2024 02:58:28 +0000 Subject: [PATCH 4/5] Fix CI failures --- utilities/test_suite/HIP/runVoxelTests.py | 3 ++- utilities/test_suite/HOST/runTests.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/utilities/test_suite/HIP/runVoxelTests.py b/utilities/test_suite/HIP/runVoxelTests.py index 2c19b43d7..31c9dd22f 100644 --- a/utilities/test_suite/HIP/runVoxelTests.py +++ b/utilities/test_suite/HIP/runVoxelTests.py @@ -326,7 +326,8 @@ def rpp_test_suite_parser_and_validator(): continue new_file.close() - subprocess.call(['chown', str(os.getuid()) + ':' + str(os.getgid()), RESULTS_DIR + "/consolidated_results_" + TYPE + ".stats.csv"]) # nosec try: + subprocess.call(['chown', str(os.getuid()) + ':' + str(os.getgid()), RESULTS_DIR + "/consolidated_results_" + TYPE + ".stats.csv"]) # nosec + try: generate_performance_reports(d_counter, TYPE_LIST, RESULTS_DIR) except ImportError: diff --git a/utilities/test_suite/HOST/runTests.py b/utilities/test_suite/HOST/runTests.py index 730252b9e..eba4f7165 100644 --- a/utilities/test_suite/HOST/runTests.py +++ b/utilities/test_suite/HOST/runTests.py @@ -94,7 +94,7 @@ def run_unit_test(srcPath1, srcPath2, dstPathTemp, case, numRuns, testType, layo def run_performance_test_cmd(loggingFolder, logFileLayout, srcPath1, srcPath2, dstPath, bitDepth, outputFormatToggle, case, additionalParam, numRuns, testType, layout, qaMode, decoderType, batchSize, roiList): if qaMode == 1: - with open(loggingFolder + "/BatchPD_host_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: + with open(loggingFolder + "/BatchPD_host_" + logFileLayout + "_raw_performance_log.txt", "a") as logFile: process = subprocess.Popen([buildFolderPath + "/build/BatchPD_host_" + logFileLayout, srcPath1, srcPath2, str(bitDepth), str(outputFormatToggle), str(case), str(additionalParam), "0"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec read_from_subprocess_and_write_to_log(process, logFile) From f42614dd83a2c217892a3dcc2b27923b06edccbe Mon Sep 17 00:00:00 2001 From: HazarathKumarM Date: Mon, 15 Jul 2024 15:41:49 +0000 Subject: [PATCH 5/5] Modify test suite to support pandas functions for python2 --- utilities/test_suite/HOST/runTests.py | 10 +++++----- utilities/test_suite/common.py | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/utilities/test_suite/HOST/runTests.py b/utilities/test_suite/HOST/runTests.py index eba4f7165..0861b9039 100644 --- a/utilities/test_suite/HOST/runTests.py +++ b/utilities/test_suite/HOST/runTests.py @@ -439,17 +439,17 @@ def rpp_test_suite_parser_and_validator(): passedCases = df['Test_Result'].eq('PASSED').sum() failedCases = df['Test_Result'].eq('FAILED').sum() - summaryRow = {'BatchPD_Augmentation_Type': pd.NA, - 'Tensor_Augmentation_Type': pd.NA, - 'Performance Speedup (%)': pd.NA, + summaryRow = {'BatchPD_Augmentation_Type': None, + 'Tensor_Augmentation_Type': None, + 'Performance Speedup (%)': None, 'Test_Result': 'Final Results of Tests: Passed: ' + str(passedCases) + ', Failed: ' + str(failedCases)} - print("\n", df.to_markdown()) + print("\n" + dataframe_to_markdown(df)) # Append the summary row to the DataFrame # Convert the dictionary to a DataFrame summaryRow = pd.DataFrame([summaryRow]) - df = pd.concat([df, summaryRow], ignore_index=True) + df = pd.concat([df, summaryRow], ignore_index=True, sort = True) df.to_excel(excelFilePath, index=False) print("\n-------------------------------------------------------------------" + resultsInfo + "\n\n-------------------------------------------------------------------") diff --git a/utilities/test_suite/common.py b/utilities/test_suite/common.py index e4129ad2d..3551334ce 100644 --- a/utilities/test_suite/common.py +++ b/utilities/test_suite/common.py @@ -27,6 +27,7 @@ import sys import datetime import shutil +import pandas as pd try: from errno import FileExistsError @@ -360,3 +361,22 @@ def func_group_finder(case_number): if case_number in value: return key return "miscellaneous" + +def dataframe_to_markdown(df): + # Calculate the maximum width of each column + column_widths = {} + for col in df.columns: + max_length = len(col) + for value in df[col]: + max_length = max(max_length, len(str(value))) + column_widths[col] = max_length + + # Create the header row + md = '| ' + ' | '.join([col.ljust(column_widths[col]) for col in df.columns]) + ' |\n' + md += '| ' + ' | '.join(['-' * column_widths[col] for col in df.columns]) + ' |\n' + + # Create the data rows + for i, row in df.iterrows(): + md += '| ' + ' | '.join([str(value).ljust(column_widths[df.columns[j]]) for j, value in enumerate(row.values)]) + ' |\n' + + return md