Skip to content

Commit 9d78cd8

Browse files
aristeidis-mastorasanhansson
authored andcommitted
419 benchmarking spmv spmspv spmspm (#75)
This MR adds three kernel-level performance tests to ALP/GraphBLAS: sparse matrix--dense vector multiplication, sparse matrix--sparse vector multiplication, and sparse matrix--sparse matrix multiplication. These three tests run on arbitrary input data sets, and employ the usual benchmarking methodology by default: run at least 10 experiments while computing the min, max, avg, and stddev aggregates and while sleeping for one second between experiments. Individual timings, again when used in default mode, will take at least 100 ms.-- if a single computation is shorter than that, then an "individual" timing in fact corresponds to n such timings, where n is the minimum number of times for which the computation takes 100 milliseconds or more. Both the resulting "inner" (100 ms.) and "outer" (10) repetitions may of course also be manually set. The performance test script is updated to run these three new performance tests on a fixed series of datasets. If one of the test sets is not available, then the experiment is skipped. For the sparse matrix--sparse matrix multiplication, square matrices are multiplied with itself; this test is, by default, only enabled for the smaller matrices in the dataset. The dataset series can easily be extended in the script should need be. The new performance tests are only run for the smallest datasets for the hyperdags backend, in-line with the current behaviour of performance tests for that backend already present in the main branch. The MR also includes minor code style fixes, as well as a workaround for CIs that run out of storage capacity due to the -g generating large binary files, while, related, not archiving some additional files that are not required to execute tests after building them. Thanks to Anders Hansson and Aristeidis Mastoras for contributing this MR!
1 parent 9c6286a commit 9d78cd8

File tree

7 files changed

+1274
-2
lines changed

7 files changed

+1274
-2
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,15 @@ build_test:
122122
- apt update && apt -y install make cmake libnuma-dev coreutils
123123
script:
124124
- mkdir -p install build && cd ./build && ../bootstrap.sh --prefix=../install && make -j$(nproc) build_tests_all
125+
- strip -s $(find tests/unit/ -type f -executable -print) $(find tests/smoke/ -type f -executable -print) $(find tests/performance/ -type f -executable -print)
125126
artifacts:
126127
paths:
127128
- build/
128129
exclude:
129130
- build/**/*.o
130131
- build/**/*.o.d
132+
- build/**/CMakeFiles
133+
- build/**/*.dir
131134
expire_in: 30 minutes
132135

133136

include/graphblas/algorithms/conjugate_gradient.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ namespace grb {
384384

385385
sigma = beta;
386386

387-
} while( iter++ < max_iterations && ret == SUCCESS );
387+
} while( ++iter < max_iterations && ret == SUCCESS );
388388

389389
// output
390390
iterations = iter;

tests/performance/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ add_grb_executables( driver_label ../smoke/label.cpp
7878
ADDITIONAL_LINK_LIBRARIES test_utils_headers
7979
)
8080

81+
add_grb_executables( driver_spmv spmv.cpp
82+
BACKENDS reference reference_omp bsp1d hybrid hyperdags
83+
ADDITIONAL_LINK_LIBRARIES test_utils_headers
84+
)
85+
86+
add_grb_executables( driver_spmspv spmspv.cpp
87+
BACKENDS reference reference_omp bsp1d hybrid hyperdags
88+
ADDITIONAL_LINK_LIBRARIES test_utils_headers
89+
)
90+
91+
add_grb_executables( driver_spmspm spmspm.cpp
92+
BACKENDS reference reference_omp bsp1d hybrid hyperdags
93+
ADDITIONAL_LINK_LIBRARIES test_utils_headers
94+
)
95+
8196
# targets to list and build the test for this category
8297
get_property( performance_tests_list GLOBAL PROPERTY tests_category_performance )
8398
add_custom_target( "list_tests_category_performance"

tests/performance/performancetests.sh

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ DATASET_SIZES=(497 4039 27770 334863 1134890 3774768 3072441)
7373
KNN4SOLS=(118 499 2805 1 64 1 1048907)
7474
KNN6SOLS=(357 547 5176 1 246 1 1453447)
7575

76+
#the following datasets are used for benchmarking SpMV, SpMSpV, and SpMSpM
77+
MULTIPLICATION_DATASETS=(west0497.mtx fidap037.mtx cavity17.mtx s3rmt3m3.mtx bloweybq.mtx bcsstk17.mtx Pres_Poisson.mtx gyro_m.mtx memplus.mtx lhr34.mtx bcsstk32.mtx vanbody.mtx s3dkt3m2.mtx G2_circuit.mtx Stanford.mtx coPapersCiteseer.mtx bundle_adj.mtx Stanford_Berkeley.mtx apache2.mtx Emilia_923.mtx ldoor.mtx ecology2.mtx Serena.mtx cage14.mtx G3_circuit.mtx wikipedia-20051105.mtx wikipedia-20061104.mtx Freescale1.mtx wikipedia-20070206.mtx Queen_4147.mtx cage15.mtx adaptive.mtx rgg_n_2_24_s0.mtx uk-2002.mtx road_usa.mtx MOLIERE_2016.mtx europe_osm.mtx twitter.mtx com-Friendster.mtx)
78+
7679
#which command to use to run a GraphBLAS program
7780
LPF=yes
7881
if [ -z "${LPFRUN}" ]; then
@@ -277,6 +280,81 @@ runOtherBenchMarkTests()
277280
echo >> ${TEST_OUT_DIR}/benchmarks
278281
}
279282

283+
runMultiplicationKernels()
284+
{
285+
local runner=$1
286+
local backend=$2
287+
local dataSet=$3
288+
local parseMode=$4
289+
local i=$5
290+
291+
# the check for the matrices existence is assumed to have already passed
292+
293+
if [ -z "$EXPTYPE" ] || [ "$EXPTYPE" == "SPMV" ]; then
294+
295+
# ---------------------------------------------------------------------
296+
# spmv
297+
echo ">>> [ ] [x] Testing spmv using ${dataSet} dataset, $backend backend."
298+
echo
299+
$runner ${TEST_BIN_DIR}/driver_spmv_${backend} ${INPUT_DIR}/${dataSet} ${parseMode} &> ${TEST_OUT_DIR}/driver_spmv_${backend}_${dataSet}
300+
head -1 ${TEST_OUT_DIR}/driver_spmv_${backend}_${dataSet}
301+
if grep -q "Test OK" ${TEST_OUT_DIR}/driver_spmv_${backend}_${dataSet}; then
302+
printf "Test OK\n\n"
303+
else
304+
printf "Test FAILED\n\n"
305+
fi
306+
echo "$backend spmv using the ${dataSet} dataset" >> ${TEST_OUT_DIR}/benchmarks
307+
egrep 'Avg|Std' ${TEST_OUT_DIR}/driver_spmv_${backend}_${dataSet} >> ${TEST_OUT_DIR}/benchmarks
308+
echo >> ${TEST_OUT_DIR}/benchmarks
309+
310+
fi
311+
312+
if [ -z "$EXPTYPE" ] || [ "$EXPTYPE" == "SPMSPV" ]; then
313+
314+
# ---------------------------------------------------------------------
315+
# spmspv
316+
echo ">>> [ ] [x] Testing spmspv using ${dataSet} dataset, $backend backend."
317+
echo
318+
$runner ${TEST_BIN_DIR}/driver_spmspv_${backend} ${INPUT_DIR}/${dataSet} ${parseMode} &> ${TEST_OUT_DIR}/driver_spmspv_${backend}_${dataSet}
319+
head -1 ${TEST_OUT_DIR}/driver_spmspv_${backend}_${dataSet}
320+
if grep -q "Test OK" ${TEST_OUT_DIR}/driver_spmspv_${backend}_${dataSet}; then
321+
printf "Test OK\n\n"
322+
else
323+
printf "Test FAILED\n\n"
324+
fi
325+
echo "$backend spmspv using the ${dataSet} dataset" >> ${TEST_OUT_DIR}/benchmarks
326+
egrep 'Avg|Std' ${TEST_OUT_DIR}/driver_spmspv_${backend}_${dataSet} >> ${TEST_OUT_DIR}/benchmarks
327+
echo >> ${TEST_OUT_DIR}/benchmarks
328+
329+
fi
330+
331+
if [ -z "$EXPTYPE" ] || [ "$EXPTYPE" == "SPMSPM" ]; then
332+
333+
# ---------------------------------------------------------------------
334+
# spmspm
335+
echo ">>> [ ] [x] Testing spmspm using ${dataSet} dataset, $backend backend."
336+
echo
337+
if [ "$BACKEND" = "bsp1d" ] || [ "$BACKEND" = "hybrid" ]; then
338+
echo "Test DISABLED: no sparse level-3 operations recommended for 1D distributions."
339+
echo " "
340+
elif [ "$i" -gt "14" ]; then
341+
echo "Tests DISABLED: by default, long-running sparse matrix--sparse matrix multiplications are disabled (skipping dataset ${dataSet})."
342+
echo " "
343+
else
344+
$runner ${TEST_BIN_DIR}/driver_spmspm_${backend} ${INPUT_DIR}/${dataSet} ${INPUT_DIR}/${dataSet} ${parseMode} &> ${TEST_OUT_DIR}/driver_spmspm_${backend}_${dataSet}
345+
head -1 ${TEST_OUT_DIR}/driver_spmspm_${backend}_${dataSet}
346+
if grep -q "Test OK" ${TEST_OUT_DIR}/driver_spmspm_${backend}_${dataSet}; then
347+
printf "Test OK\n\n"
348+
else
349+
printf "Test FAILED\n\n"
350+
fi
351+
echo "$backend spmspm using the ${dataSet} dataset" >> ${TEST_OUT_DIR}/benchmarks
352+
egrep 'Avg|Std' ${TEST_OUT_DIR}/driver_spmspm_${backend}_${dataSet} >> ${TEST_OUT_DIR}/benchmarks
353+
echo >> ${TEST_OUT_DIR}/benchmarks
354+
fi
355+
fi
356+
}
357+
280358
# end helper functions
281359

282360
if [ -z "$EXPTYPE" ] || ! [ "$EXPTYPE" == "KERNEL" ]; then
@@ -360,7 +438,8 @@ if [ -z "$EXPTYPE" ] || ! [ "$EXPTYPE" == "KERNEL" ]; then
360438

361439
# test for file
362440
if [ ! -f ${INPUT_DIR}/${DATASET} ]; then
363-
echo "Warning: dataset/${DATASET} not found. Provide the dataset to enable performance tests with it."
441+
echo ">>> [x] [x] Test algorithms using ${DATASET} dataset, ${BACKEND} backend."
442+
echo "Tests DISABLED: dataset/${DATASET} not found. Provide the dataset to enable performance tests with it."
364443
echo " "
365444
continue
366445
fi
@@ -396,6 +475,35 @@ if [ -z "$EXPTYPE" ] || ! [ "$EXPTYPE" == "KERNEL" ]; then
396475
fi
397476
done
398477

478+
for ((i=0;i<${#MULTIPLICATION_DATASETS[@]};++i));
479+
do
480+
if [ ! -z "$DATASETTORUN" ] && [ "$DATASETTORUN" != "${MULTIPLICATION_DATASETS[i]}" ]; then
481+
continue
482+
fi
483+
484+
if [ "$BACKEND" = "hyperdags" ] && [ "$i" -gt "0" ]; then
485+
echo "Info: hyperdags performance tests run only on the smallest dataset"
486+
echo " "
487+
break
488+
fi
489+
490+
# initialise parameters
491+
DATASET=${MULTIPLICATION_DATASETS[i]}
492+
PARSE_MODE=direct
493+
494+
# test for file
495+
if [ ! -f ${INPUT_DIR}/${DATASET} ]; then
496+
echo ">>> [ ] [x] Test multiplication kernels using ${DATASET} dataset,"
497+
echo " ${BACKEND} backend."
498+
echo "Tests DISABLED: dataset/${DATASET} not found. Provide the dataset to enable performance tests with it."
499+
echo " "
500+
continue
501+
fi
502+
503+
runMultiplicationKernels "$runner" "$BACKEND" "$DATASET" "$PARSE_MODE" "$i"
504+
505+
done
506+
399507
done
400508

401509
fi

0 commit comments

Comments
 (0)