@@ -15,16 +15,16 @@ CKBenchmarkRepoBranchName='main'
1515# when building CK. This is likely a bit conservative.
1616CKBuildParallelism=$( free -g | grep Mem | awk ' {print int($2/8)}' )
1717
18- # Check if the user overrode number of parallel build jobs
19- # via env var
20- if [ ! -z ${CK_BUILD_PARALLELISM} ]; then
18+ # Check if the user overrode number of parallel build jobs via env var
19+ if [ -n " ${CK_BUILD_PARALLELISM} " ]; then
2120 CKBuildParallelism=${CK_BUILD_PARALLELISM}
2221fi
2322
24- realpath=$( realpath $0 )
25- thisdir=$( dirname $realpath )
23+ realpath=$( realpath " $0 " )
24+ thisdir=$( dirname " $realpath " )
2625
27- . $thisdir /aomp_common_vars
26+ # shellcheck disable=SC1091
27+ . " $thisdir " /aomp_common_vars
2828
2929export PATH=$AOMP /bin:$PATH
3030
@@ -56,10 +56,10 @@ function getIndexListByTargetArch {
5656 # Then match lines containing the target arch and capture the bracketed index.
5757 # Finally, we use xargs to format the results into a tidy, single-line list.
5858 OnlyVisibleDevices=" "
59- if [ ! -z " ${ROCR_VISIBLE_DEVICES} " ]; then
59+ if [ -n " ${ROCR_VISIBLE_DEVICES} " ]; then
6060 OnlyVisibleDevices=" $( echo " -d ${ROCR_VISIBLE_DEVICES} " | tr ' ,' ' ' ) "
6161 fi
62- GPUList=" $( rocm-smi --showproductname ${OnlyVisibleDevices} ) "
62+ GPUList=" $( rocm-smi --showproductname " ${OnlyVisibleDevices} " ) "
6363 GPURegex=" s/^GPU\[([0-9]+)\].*${TargetArch} $/\1/p"
6464 TargetArchIndexList=$( echo " ${GPUList} " | sed -En " ${GPURegex} " | xargs echo)
6565
@@ -74,15 +74,15 @@ function distributeWorkToGPUs {
7474
7575 # Sanity checks
7676 if [ " ${# WorkItems[@]} " -eq 0 ] ||
77- ( [ " ${# WorkItems[@]} " -eq 1 ] && [ -z " ${WorkItems[@ ]} " ]) ; then
77+ { [ " ${# WorkItems[@]} " -eq 1 ] && [ -z " ${WorkItems[0 ]} " ]; } ; then
7878 echo " Error: Received empty list of commands"
7979 exit 1
8080 fi
8181
8282 # Get and count available GPUs (as list)
8383 GPUList=" $( getIndexListByTargetArch " ${CK_GPU_TARGETS} " ) "
8484 GPUCount=$( echo " ${GPUList} " | wc -w)
85- if [ ${GPUCount} -le 0 ]; then
85+ if [ " ${GPUCount} " -le 0 ]; then
8686 echo " No target GPUs available"
8787 exit 1
8888 fi
@@ -93,7 +93,7 @@ function distributeWorkToGPUs {
9393 # Run the work items, using GNU parallel
9494 # Note: {%} provides the job slot (thread) index, {#} the job sequence index
9595 echo " Running ${# WorkItems[@]} work items in parallel, using ${GPUCount} GPUs"
96- parallel -j ${GPUCount} --line-buffer \
96+ parallel -j " ${GPUCount} " --line-buffer \
9797 ' read -ra AvailableGPUs <<< "${GPUList}"
9898 GPUIndex=$(({%} - 1))
9999 SelectedGPU=${AvailableGPUs[GPUIndex]}
@@ -226,34 +226,34 @@ while getopts "j:hilrubs:t:" opt; do
226226done
227227
228228# Set the default build prefix, i.e., build-top-level
229- : ${CK_TOP:= $AOMP_REPOS_TEST / composable-kernels}
230- : ${CK_REPO:= $CK_TOP / rocm-libraries}
231- : ${CK_SRC:= $CK_REPO / projects/ composablekernel}
232- : ${CK_BUILD:= $CK_TOP / ck-build}
233- : ${CK_BENCHMARK_REPO:= $CK_TOP / ck-benchmark}
229+ : " ${CK_TOP:= $AOMP_REPOS_TEST / composable-kernels} "
230+ : " ${CK_REPO:= $CK_TOP / rocm-libraries} "
231+ : " ${CK_SRC:= $CK_REPO / projects/ composablekernel} "
232+ : " ${CK_BUILD:= $CK_TOP / ck-build} "
233+ : " ${CK_BENCHMARK_REPO:= $CK_TOP / ck-benchmark} "
234234# Move this to its own place, to avoid potential permission conflicts with certain setups.
235- : ${CK_BENCHMARK_RESULT:= $CK_TOP / ck-benchmark-result}
236- : ${CK_INSTALL:= $CK_TOP / ck-install}
237- : ${CK_CLIENT_EXAMPLES_SOURCE:= $CK_SRC / client_example}
238- : ${CK_CLIENT_EXAMPLES_BUILD:= $CK_TOP / ck-client-examples-build}
235+ : " ${CK_BENCHMARK_RESULT:= $CK_TOP / ck-benchmark-result} "
236+ : " ${CK_INSTALL:= $CK_TOP / ck-install} "
237+ : " ${CK_CLIENT_EXAMPLES_SOURCE:= $CK_SRC / client_example} "
238+ : " ${CK_CLIENT_EXAMPLES_BUILD:= $CK_TOP / ck-client-examples-build} "
239239# Run regular and client examples on multiple GPUs (if present)
240- : ${CK_EXAMPLES_PARALLEL:= ' yes' }
241- : ${CK_EXAMPLES_PREFIX:= ' example_' }
242- : ${CK_EXAMPLES_LOG_LOCATION:= $CK_TOP / ck-examples-logs}
243- : ${CK_TESTS_LOG_LOCATION:= $CK_TOP / ck-tests-logs}
240+ : " ${CK_EXAMPLES_PARALLEL:= " yes" } "
241+ : " ${CK_EXAMPLES_PREFIX:= " example_" } "
242+ : " ${CK_EXAMPLES_LOG_LOCATION:= $CK_TOP / ck-examples-logs} "
243+ : " ${CK_TESTS_LOG_LOCATION:= $CK_TOP / ck-tests-logs} "
244244
245245# Some client-examples may take long, override this to skip tests
246246# e.g. CK_CLIENT_EXAMPLES_TO_EXCLUDE=("10_grouped_convnd_bwd_data" "24_grouped_conv_activation")
247- : ${CK_CLIENT_EXAMPLES_TO_EXCLUDE:= " " }
247+ : " ${CK_CLIENT_EXAMPLES_TO_EXCLUDE:= " " } "
248248
249249# Get some info on the system
250- : ${ROCM_PATH:=/ opt/ rocm}
251- : ${CK_GPU_TARGETS:= ' ' }
252- : ${AOMP_LIB_PATH:= " ${AOMP} /.." }
250+ : " ${ROCM_PATH:=/ opt/ rocm} "
251+ : " ${CK_GPU_TARGETS:= " " } "
252+ : " ${AOMP_LIB_PATH:= " ${AOMP} /.." } "
253253
254- if [ -z ${CK_GPU_TARGETS} ]; then
254+ if [ -z " ${CK_GPU_TARGETS} " ]; then
255255 NumGpuArchs=$( amdgpu-arch | sort | uniq | wc -l)
256- if [ ${NumGpuArchs} -gt 1 ]; then
256+ if [ " ${NumGpuArchs} " -gt 1 ]; then
257257 echo " Error: More than one GPU architecture detected. This may cause issues."
258258 echo " Please set the CK_GPU_TARGETS variable to the desired GPU arch."
259259 exit 1
266266echo " Building for ${CK_GPU_TARGETS} "
267267
268268# Check if user overrode number of parallel build jobs
269- if [ ! -z ${CK_BUILD_PARALLELISM} ]; then
269+ if [ -n " ${CK_BUILD_PARALLELISM} " ]; then
270270 CKBuildParallelism=${CK_BUILD_PARALLELISM}
271271fi
272272
273- if [ ! -d ${CK_TOP} ]; then
274- mkdir -p ${CK_TOP} || exit 1
273+ if [ ! -d " ${CK_TOP} " ]; then
274+ mkdir -p " ${CK_TOP} " || exit 1
275275fi
276276
277- if [ ! -d ${CK_REPO} ]; then
278- git clone --single-branch --depth 1 ${CKRepoURL} ${CK_REPO}
277+ if [ ! -d " ${CK_REPO} " ]; then
278+ git clone --single-branch --depth 1 ${CKRepoURL} " ${CK_REPO} "
279279elif [ " ${ShouldUpdateCKRepo} " == ' yes' ]; then
280- pushd ${CK_REPO} || exit 1
280+ pushd " ${CK_REPO} " || exit 1
281281 git reset --hard origin/${CKRepoBranchName}
282282 git pull
283283 # TODO: Write current SHA to somewhere such that it is known which SHA
@@ -310,33 +310,27 @@ CKCmakeCmd+="-DBUILD_DEV=On"
310310# Ensure CK build directory is cleaned.
311311if [ " ${ShouldRebuildCK} " == ' yes' ]; then
312312 echo " Rebuilding the CK repo w/ ${CKBuildParallelism} parallel jobs."
313- rm -rf ${CK_BUILD} || exit 1
313+ rm -rf " ${CK_BUILD} " || exit 1
314314
315315 echo " CMake Config Command:"
316316 echo " ${CKCmakeCmd} "
317+ ${CKCmakeCmd} || exit 1
317318
318- ${CKCmakeCmd}
319- if [ $? -ne 0 ]; then
320- exit 1
321- fi
322319fi
323320
324321# Ensure CK install directory is cleaned.
325322if [ " ${ShouldInstallCK} " == ' yes' ]; then
326323 echo " Purging previous CK installation directory."
327- rm -rf ${CK_INSTALL} || exit 1
324+ rm -rf " ${CK_INSTALL} " || exit 1
328325fi
329326
330327# Perform (incremental) CK build
331328if [ " ${ShouldRebuildCK} " == ' yes' ] || [ " ${ShouldInstallCK} " == ' yes' ]; then
332- pushd ${CK_BUILD} || exit 1
329+ pushd " ${CK_BUILD} " || exit 1
333330
334331 # -k parameter avoids stopping at first error
335332 # ckProfiler target seems to depend on all library targets, which we want to build first
336- /usr/bin/time -o build-times.tlog ${CKBuildTool} -j ${CKBuildParallelism} -k 0 ckProfiler
337- if [ $? -ne 0 ]; then
338- exit 1
339- fi
333+ /usr/bin/time -o build-times.tlog ${CKBuildTool} -j " ${CKBuildParallelism} " -k 0 ckProfiler || exit 1
340334
341335 # Find build success in the build log
342336 echo " CK-BUILD-SUCCESS"
346340
347341# Perform CK installation
348342if [ " ${ShouldInstallCK} " == ' yes' ]; then
349- pushd ${CK_BUILD} || exit 1
343+ pushd " ${CK_BUILD} " || exit 1
350344
351345 # TODO: Check parallelism. This may use all available threads.
352- /usr/bin/time -o install-times.tlog ${CKBuildTool} -k 0 install
353- if [ $? -ne 0 ]; then
354- exit 1
355- fi
346+ /usr/bin/time -o install-times.tlog ${CKBuildTool} -k 0 install || exit 1
356347
357348 # Find install success in the log
358349 echo " CK-INSTALL-SUCCESS"
@@ -364,10 +355,10 @@ echo "Run suite: ${SelectedSuite}"
364355
365356# Check if parallel execution is requested and possible
366357UseParallel=0
367- if ( [ " ${SelectedSuite} " == ' client-examples' ] ||
368- [ " ${SelectedSuite} " == ' examples' ]) &&
358+ if { [ " ${SelectedSuite} " == ' client-examples' ] ||
359+ [ " ${SelectedSuite} " == ' examples' ]; } &&
369360 [ " ${CK_EXAMPLES_PARALLEL} " == ' yes' ]; then
370- if [ ! -z " $( command -v parallel) " ]; then
361+ if [ -n " $( command -v parallel) " ]; then
371362 UseParallel=1
372363 else
373364 echo " Warning: Parallel execution requested, but 'parallel' is not available"
@@ -379,8 +370,8 @@ if [ "${SelectedSuite}" == 'smoke' ]; then
379370 if [ ! -d " ${CK_TESTS_LOG_LOCATION} " ]; then
380371 mkdir -p " ${CK_TESTS_LOG_LOCATION} " || exit 1
381372 fi
382- pushd ${CK_BUILD} || exit 1
383- ${CKBuildTool} -j ${CKBuildParallelism} smoke 2>&1 | tee " ${CK_TESTS_LOG_LOCATION} /smoke_tests.log"
373+ pushd " ${CK_BUILD} " || exit 1
374+ ${CKBuildTool} -j " ${CKBuildParallelism} " smoke 2>&1 | tee " ${CK_TESTS_LOG_LOCATION} /smoke_tests.log"
384375 echo " Log at ${CK_TESTS_LOG_LOCATION} /smoke_tests.log"
385376 popd || exit 1
386377fi
@@ -390,8 +381,8 @@ if [ "${SelectedSuite}" == 'regression' ]; then
390381 if [ ! -d " ${CK_TESTS_LOG_LOCATION} " ]; then
391382 mkdir -p " ${CK_TESTS_LOG_LOCATION} " || exit 1
392383 fi
393- pushd ${CK_BUILD} || exit 1
394- ${CKBuildTool} -j ${CKBuildParallelism} regression 2>&1 | tee " ${CK_TESTS_LOG_LOCATION} /regression_tests.log"
384+ pushd " ${CK_BUILD} " || exit 1
385+ ${CKBuildTool} -j " ${CKBuildParallelism} " regression 2>&1 | tee " ${CK_TESTS_LOG_LOCATION} /regression_tests.log"
395386 echo " Log at ${CK_TESTS_LOG_LOCATION} /regression_tests.log"
396387 popd || exit 1
397388fi
400391if [ " ${SelectedSuite} " == ' benchmarks' ]; then
401392 # The CK benchmarks repo appears to be private (for the time being).
402393
403- if [ ! -d ${CK_BENCHMARK_REPO} ]; then
394+ if [ ! -d " ${CK_BENCHMARK_REPO} " ]; then
404395 echo " CK Benchmarks repo not found. This is a private repo."
405396 echo " Please clone with your preferred method into ${CK_BENCHMARK_REPO} "
406397 exit 1
407398 elif [ " ${ShouldUpdateCKBenchmarks} " == ' yes' ]; then
408- pushd ${CK_BENCHMARK_REPO} || exit 1
399+ pushd " ${CK_BENCHMARK_REPO} " || exit 1
409400 git reset --hard origin/${CKBenchmarkRepoBranchName}
410401 git pull
411402 # TODO: Dump SHA somewhere
412403 popd || exit 1
413404 fi
414405
415- if [ ! -d ${CK_BENCHMARK_RESULT} ]; then
416- mkdir -p ${CK_BENCHMARK_RESULT} || exit 1
406+ if [ ! -d " ${CK_BENCHMARK_RESULT} " ]; then
407+ mkdir -p " ${CK_BENCHMARK_RESULT} " || exit 1
417408 fi
418409
419410 # Check if a specific test was requested
420411 # If yes: check if it exists
421- if [ ! -z ${SelectedTest} ]; then
412+ if [ -n " ${SelectedTest} " ]; then
422413 if [ ! -f " ${CK_BENCHMARK_REPO} /benchmarks/${SelectedTest} " ]; then
423414 echo " Error: Selected benchmark does not exist:"
424415 echo " ${CK_BENCHMARK_REPO} /benchmarks/${SelectedTest} "
@@ -433,14 +424,14 @@ if [ "${SelectedSuite}" == 'benchmarks' ]; then
433424 # This is the command. It requires the envar CK_PROFILER_DIR to be set to the directory
434425 # in the CK build tree that contains the CkProfiler binary.
435426 CKBenchmarkTest=" ../benchmarks/${SelectedTest} "
436- CKBenchmarkName=$( basename ${CKBenchmarkTest} )
427+ CKBenchmarkName=$( basename " ${CKBenchmarkTest} " )
437428 CKBenchmarkResultOutput=" ${CK_BENCHMARK_RESULT} /${CKBenchmarkName} .output"
438429 CKBenchmarkBackend=' ck'
439430 CKBenchmarkCmd=" ./run_gemm.py ${CKBenchmarkBackend} ${CKBenchmarkTest} --output ${CKBenchmarkResultOutput} "
440431 CKBenchmarkProfilerExport=" export CK_PROFILER_DIR=${CK_BUILD} /bin"
441432 CKBenchmarkLDLibraryPathExport=$( getLDLibraryPathExportCmd)
442433
443- pushd ${CK_BENCHMARK_REPO} /scripts || exit 1
434+ pushd " ${CK_BENCHMARK_REPO} " /scripts || exit 1
444435
445436 echo " Benchmark Command: ${CKBenchmarkProfilerExport} ; ${CKBenchmarkCmd} "
446437 ${CKBenchmarkLDLibraryPathExport}
@@ -471,22 +462,14 @@ if [ "${SelectedSuite}" == 'client-examples' ]; then
471462 fi
472463
473464 echo " Rebuilding the CK client-examples"
474- rm -rf ${CK_CLIENT_EXAMPLES_BUILD} || exit 1
465+ rm -rf " ${CK_CLIENT_EXAMPLES_BUILD} " || exit 1
475466
476467 echo " CMake Config Command:"
477468 echo " ${CKCmakeCmd} "
469+ ${CKCmakeCmd} || exit 1
478470
479- ${CKCmakeCmd}
480- if [ $? -ne 0 ]; then
481- exit 1
482- fi
483-
484- pushd ${CK_CLIENT_EXAMPLES_BUILD} || exit 1
485-
486- ${CKBuildTool}
487- if [ $? -ne 0 ]; then
488- exit 1
489- fi
471+ pushd " ${CK_CLIENT_EXAMPLES_BUILD} " || exit 1
472+ ${CKBuildTool} || exit 1
490473
491474 # Process directories to exclude
492475 # Usage of here-string to avoid sub-shell and removal of potential parentheses
@@ -507,7 +490,7 @@ if [ "${SelectedSuite}" == 'client-examples' ]; then
507490 # Also, we always want to prune " ./CMakeFiles" from the results
508491 FindArgs+=(-path " * CMakeFiles* " \) -prune -o)
509492 # If requested, filter the selected tests
510- if [ ! -z ${SelectedTest} ]; then
493+ if [ -n " ${SelectedTest} " ]; then
511494 echo " Filtering client-example paths: ./${SelectedTest} "
512495 FindArgs+=(-path " ./${SelectedTest} " )
513496 fi
@@ -537,7 +520,7 @@ if [ "${SelectedSuite}" == 'client-examples' ]; then
537520
538521 NumJobs=${# ExampleRunCmds[@]}
539522 echo " Found ${NumJobs} client-examples to run"
540- if [ ${NumJobs} == 0 ]; then
523+ if [ " ${NumJobs} " == 0 ]; then
541524 # When running this script, we should expect to run something
542525 # Exit silently, but indicate error via returncode
543526 exit 1
@@ -572,7 +555,7 @@ if [ "${SelectedSuite}" == 'examples' ]; then
572555
573556 # Build argument list for find
574557 FindArgs=(. -mindepth 1 -maxdepth 1 -type f)
575- if [ -z ${SelectedTest} ]; then
558+ if [ -z " ${SelectedTest} " ]; then
576559 # No filtering requested: select all " * " tests
577560 SelectedTest=" * "
578561 else
@@ -605,16 +588,16 @@ if [ "${SelectedSuite}" == 'examples' ]; then
605588
606589 NumJobs=${# ExampleRunCmds[@]}
607590 echo " Found ${NumJobs} examples to run"
608- if [ ${NumJobs} == 0 ]; then
591+ if [ " ${NumJobs} " == 0 ]; then
609592 # When running this script, we should expect to run something
610593 # Exit silently, but indicate error via returncode
611594 exit 1
612595 fi
613596
614597 # Avoid picking up stale logs
615598 echo " Purging CK examples logs"
616- rm -rf ${CK_EXAMPLES_LOG_LOCATION} || exit 1
617- mkdir -p ${CK_EXAMPLES_LOG_LOCATION} || exit 1
599+ rm -rf " ${CK_EXAMPLES_LOG_LOCATION} " || exit 1
600+ mkdir -p " ${CK_EXAMPLES_LOG_LOCATION} " || exit 1
618601
619602 # Run each example
620603 if [ ${UseParallel} == 1 ]; then
0 commit comments