3 # This script will run all our supported compilers (see the "images" set)
4 # against gem5. The "ubuntu-20.04_all-dependencies" and "clang-version-9"
5 # images are run against all built targets. The remainder are evaluated
6 # against a random shuffling of built targets.
8 dir
="$( cd "$
( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
10 build_dir
="${gem5_root}/build"
13 # All Docker images in the gem5 testing GCR which we want to compile with.
14 images
=("ubuntu-20.04_all-dependencies" # Uses GCC-9
28 # A subset of the above list: these images will build against every target,
29 # ignoring builds_per_compiler.
30 comprehensive
=("ubuntu-20.04_all-dependencies"
33 # All build targets in build_opt/ which we want to build using each image.
35 "ARM_MESI_Three_Level"
40 "NULL_MOESI_CMP_directory"
41 "NULL_MOESI_CMP_token"
49 # The optimizations to use for each build target.
53 # The number of build targets to randomly pull from the build target list for
54 # each compiler. To perform a full comprehensive test which covers every
55 # possible pair of compiler and build target, set builds_per_compiler equal to
56 # the expression ${#builds[@]}.
59 # Base URL of the gem5 testing images.
60 base_url
="gcr.io/gem5-test"
62 # Arguments passed into scons on every build target test.
63 build_args
="-j ${num_cores}"
65 # Testing directory variables
66 mkdir
-p "${build_dir}" # Create the build directory if it doesn't exist.
67 test_dir_final
="${gem5_root}/compile-test-out"
68 test_dir
="${gem5_root}/.compile-test-out"
69 exits
="${test_dir}/exit-codes.csv"
71 # Create the testing output directory and files
72 rm -rf $test_dir_final
76 echo "compiler,build_target,exit_code" >> $exits
78 for compiler
in ${images[@]}; do
79 echo "Starting build tests with '$compiler'..."
80 # Generate a randomized list of build targets
81 build_permutation
=($
(shuf
-i 0-$
((${#builds[@]} - 1)) ))
83 builds_count
=$builds_per_compiler
84 if [[ " ${comprehensive[@]} " =~
" $compiler " ]]; then
85 echo "'$compiler' was found in the comprehensive tests. All ISAs will be built."
86 builds_count
=${#builds[@]}
89 # Slice the first $builds_count entries of the permutation to get our
90 # targets for this test
91 build_indices
=(${build_permutation[@]:0:$builds_count})
93 repo_name
="${base_url}/${compiler}:latest"
96 docker pull
$repo_name >/dev
/null
98 mkdir
"$test_dir/$compiler"
100 for build_index
in ${build_indices[@]}; do
101 for build_opt
in ${opts[@]}; do
102 build
="${builds[$build_index]}"
103 build_out
="build/$build/gem5$build_opt"
104 build_stdout
="$test_dir/$compiler/$build$build_opt.stdout"
105 build_stderr
="$test_dir/$compiler/$build$build_opt.stderr"
108 rm -rf "${build_dir}"
113 echo " * Building target '$build$build_opt' with '$compiler'..."
115 # Build with container
117 docker run
--rm -v ${gem5_root}:/gem5
-u $UID:$GID -w /gem5 \
118 $repo_name scons
$build_out $build_args
119 }>$build_stdout 2>$build_stderr
122 echo "$compiler,$build/gem5$build_opt,$result" >> $exits
123 if [ $result -ne 0 ]; then
124 echo " ! Failed with exit code $result."
132 mv "${test_dir}" "${test_dir_final}"