Skip to content

Commit 8029b4b

Browse files
committed
randomize costs in CI tests
1 parent 1cd0c49 commit 8029b4b

12 files changed

+42
-21
lines changed

include/RevExt.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ struct RevExt {
6969
private:
7070
// RevExt: Randomize instruction costs if randomizeCosts == true
7171
void RandomizeCosts( std::vector<RevInstEntry>& table ) const {
72-
if( feature->GetRandomizeCosts() )
73-
for( auto& entry : table )
74-
if( entry.cost == 1 )
72+
if( feature->GetRandomizeCosts() ) {
73+
for( auto& entry : table ) {
74+
if( entry.cost == 1 ) {
7575
entry.cost = RevRand( 1, MAX_COST );
76+
}
77+
}
78+
}
7679
}
7780

7881
std::string_view const name; ///< RevExt: extension name

scripts/slurm/build-gcc11-sst13.1.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc11-sst14.0.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc11.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc13-sst13.1.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc13-sst14.0.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc13.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-llvm12-sst13.1.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-llvm12-sst14.0.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-llvm12.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRANDOMIZE_COSTS -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

test/CMakeLists.txt

+26-9
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@
99
if(NOT DEFINED TEST_LEVEL)
1010
set(TEST_LEVEL "$ENV{TEST_LEVEL}")
1111
endif()
12-
1312
if(NOT TEST_LEVEL OR TEST_LEVEL GREATER 3 OR TEST_LEVEL LESS 1)
1413
set(TEST_LEVEL 3)
1514
endif()
16-
1715
message("TEST_LEVEL=${TEST_LEVEL}")
1816

17+
if(NOT DEFINED RANDOMIZE_COSTS)
18+
set(RANDOMIZE_COSTS "$ENV{RANDOMIZE_COSTS}")
19+
endif()
20+
if(NOT RANDOMIZE_COSTS)
21+
set(RANDOMIZE_COSTS "")
22+
else()
23+
set(RANDOMIZE_COSTS --randomizeCosts)
24+
endif()
25+
message("RANDOMIZE_COSTS=\"${RANDOMIZE_COSTS}\"")
26+
1927
set(RISCV_ENV "$ENV{RISCV}")
2028
if(RISCV_ENV)
2129
message(STATUS "RISCV environment set to ${RISCV_ENV}")
@@ -65,8 +73,8 @@ set (passRegex "Simulation is complete")
6573
#------- TESTS ---------------
6674
message(STATUS "CTest Setup")
6775

68-
# Macro to build and configure tests in rev based on the labels the test was specified with
69-
macro(add_rev_test test_name test_dir timeout labels)
76+
# Function to build and configure tests in rev based on the labels the test was specified with
77+
function(add_rev_test test_name test_dir timeout labels)
7078
string(TOLOWER ${test_dir} test_dir_lower)
7179
string(TOLOWER ${test_name} test_name_lower)
7280

@@ -135,13 +143,22 @@ macro(add_rev_test test_name test_dir timeout labels)
135143
# set(startSymbol "\"[0:_start]\"")
136144
endif()
137145

146+
string(FIND "${labels}" "cost1" cost1_index)
147+
if(NOT ${cost1_index} EQUAL -1)
148+
set(RANDOMIZE_COSTS "")
149+
endif()
150+
# increase timeout if costs randomized
151+
if(NOT RANDOMIZE_COSTS STREQUAL "")
152+
math(EXPR timeout "${timeout} * 3 /2")
153+
endif()
154+
138155
if(NOT optional_script)
139156
foreach(numHarts IN LISTS numHartsList)
140157
foreach(numCores IN LISTS numCoresList)
141158

142159
# Define revmem target with the new naming convention
143160
add_custom_target(run_${test_name_lower}_revmem_${numHarts}_harts_${numCores}_cores
144-
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/${test_name_lower} && sst --add-lib-path=${CMAKE_SOURCE_DIR}/build/src/ ${CMAKE_SOURCE_DIR}/test/rev-model-options-config.py -- --program="${test_name_lower}.exe" --numHarts=${numHarts} --numCores=${numCores} --machine "${machine_args}" --startSymbol "${startSymbol}"
161+
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/${test_name_lower} && sst --add-lib-path=${CMAKE_SOURCE_DIR}/build/src/ ${CMAKE_SOURCE_DIR}/test/rev-model-options-config.py -- --program="${test_name_lower}.exe" --numHarts=${numHarts} --numCores=${numCores} --machine "${machine_args}" --startSymbol "${startSymbol}" ${RANDOMIZE_COSTS}
145162
DEPENDS build_${test_name_lower}
146163
COMMENT "Running ${test_name_lower} test with revmem, numHarts=${numHarts}, numCores=${numCores}"
147164
)
@@ -154,7 +171,7 @@ macro(add_rev_test test_name test_dir timeout labels)
154171
# If 'memh' label found, add a memHierarchy test
155172
if(add_memh_test)
156173
add_custom_target(run_${test_name_lower}_memh_${numHarts}_harts_${numCores}_cores
157-
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/${test_name_lower} && sst --add-lib-path=${CMAKE_SOURCE_DIR}/build/src/ ${CMAKE_SOURCE_DIR}/test/rev-model-options-config.py -- --program="${test_name_lower}.exe" --numHarts=${numHarts} --numCores=${numCores} --machine "${machine_args}" --enableMemH=1 --startSymbol "${startSymbol}"
174+
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/${test_name_lower} && sst --add-lib-path=${CMAKE_SOURCE_DIR}/build/src/ ${CMAKE_SOURCE_DIR}/test/rev-model-options-config.py -- --program="${test_name_lower}.exe" --numHarts=${numHarts} --numCores=${numCores} --machine "${machine_args}" --enableMemH=1 --startSymbol "${startSymbol}" ${RANDOMIZE_COSTS}
158175
DEPENDS build_${test_name_lower}
159176
COMMENT "Running ${test_name_lower} test with memHierarchy enabled, numHarts=${numHarts}, numCores=${numCores}"
160177
)
@@ -207,7 +224,7 @@ macro(add_rev_test test_name test_dir timeout labels)
207224
set_tests_properties(${test_name_lower}_script PROPERTIES DISABLED TRUE)
208225
endif()
209226
endif()
210-
endmacro()
227+
endfunction()
211228

212229
# Not all toolchains have support RV32, so we test and skip RV32 tests with a warning
213230
execute_process(COMMAND ${RVCC} -march=rv32i -mabi=ilp32 -o /dev/null ex1.c WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ex1 ERROR_VARIABLE RV32_Missing)
@@ -252,8 +269,8 @@ add_rev_test(BACKINGSTORE backingstore 100 "test_level=2;rv64" SCRIPT "run_backi
252269
add_rev_test(MEM_DUMP mem_dump 10 "rv64" SCRIPT "run_mem_dump.sh")
253270
add_rev_test(LWSP lwsp 30 "test_level=2;memh;rv64")
254271
add_rev_test(CSR csr 30 "rv64")
255-
add_rev_test(RDCYCLE rdcycle 5 "test_level=2;rv64")
256-
add_rev_test(RDTIME rdtime 5 "test_level=2;rv64")
272+
add_rev_test(RDCYCLE rdcycle 5 "test_level=2;rv64;cost1")
273+
add_rev_test(RDTIME rdtime 5 "test_level=2;rv64;cost1")
257274
add_rev_test(RDINSTRET rdinstret 5 "test_level=2;memh;rv64")
258275
add_rev_test(Zfa zfa 30 "rv64" SCRIPT "run_zfa_tests.sh")
259276

test/rev-model-options-config.py

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"startAddr" : "[0:0x00000000]",
6161
"startSymbol" : args.startSymbol,
6262
"enable_memH" : args.enableMemH,
63+
"randomizeCosts": args.randomizeCosts,
6364
"args": args.args,
6465
"splash" : 1
6566
})

0 commit comments

Comments
 (0)