DOI: 10.5281/zenodo.3956056
title: Block-wise sparse matrix-vector product dataset and convolutional neural nets for estimating the run time and energy consumption of the sparse matrix-vector product

description: <strong>Introduction</strong> <strong>SpMV-CNN</strong> is a set of Convolutional Neural Networks (CNNs) that provide accurate estimations of the performance and energy consumption of the SpMV kernel. The proposed CNN-based models use a block-wise approach to make the CNN architecture independent of the matrix size. These models cat be trained to estimate run time as well as total, package and DRAM energy consumption at different processor frequencies. <strong>Prerequisites</strong> <strong>SpMV-CNN</strong> requires Python3 with the following packages: <pre><code>keras==2.1.6 tensorflow==1.8.0 h5py==2.7.1 matplotlib==2.1.1 scikit-learn==0.19.1 </code></pre> <strong>Obtaining the dataset</strong> The execution time and energy consumption data corresponding to the SpMV operation on a set of sparse matrices from the SuiteSparse Matrix Collection have been obtained on an Intel Xeon E5-2630 core running at frequencies 1.2, 1.6, 2.0, 2.4 GHz. The energy consumption measurements are obtained via the Intel RAPL interface and gathered at three different levels (total, package and DRAM, where total = package + DRAM) for this specific processor. The <code>spmv-cnn-dataset.tgz</code> archive contains the whole dataset, including the following HDF5 files: <pre><code>$ tree . |-- test | |-- f_1200000_b250 | | |-- output_2cubes_sphere_1200000.h5 | | |-- output_apache2_1200000.h5 | | |-- output_bcsstk36_1200000.h5 | | |-- output_cfd1_1200000.h5 | | |-- output_cfd2_1200000.h5 | | |-- output_ct20stif_1200000.h5 | | |-- output_denormal_1200000.h5 | | |-- output_Dubcova2_1200000.h5 | | |-- output_Dubcova3_1200000.h5 | | |-- output_ecology2_1200000.h5 | | |-- output_gyro_1200000.h5 | | |-- output_gyro_k_1200000.h5 | | |-- output_msc10848_1200000.h5 | | |-- output_msc23052_1200000.h5 | | |-- output_nasasrb_1200000.h5 | | |-- output_nd3k_1200000.h5 | | |-- output_offshore_1200000.h5 | | |-- output_oilpan_1200000.h5 | | |-- output_olafu_1200000.h5 | | |-- output_parabolic_fem_1200000.h5 | | |-- output_qa8fm_1200000.h5 | | |-- output_raefsky4_1200000.h5 | | |-- output_s3dkq4m2_1200000.h5 | | |-- output_s3dkt3m2_1200000.h5 | | |-- output_ship_001_1200000.h5 | | |-- output_ship_003_1200000.h5 | | |-- output_shipsec1_1200000.h5 | | |-- output_shipsec5_1200000.h5 | | |-- output_shipsec8_1200000.h5 | | |-- output_smt_1200000.h5 | | |-- output_thermomech_dM_1200000.h5 | | |-- output_thread_1200000.h5 | | `-- output_vanbody_1200000.h5 | |-- f_1600000_b250 | | |-- output_2cubes_sphere_1600000.h5 | | |—- ... | | `-- output_vanbody_1600000.h5 | |-- f_2000000_b250 | | |-- output_2cubes_sphere_2000000.h5 | | |—- ... | | `-- output_vanbody_2000000.h5 | `-- f_2400000_b250 | |-- output_2cubes_sphere_2400000.h5 | |—- ... | `-- output_vanbody_2400000.h5 |-- test_pagerank | |-- f_1200000_b250 | | |-- output_adaptive_1200000.h5 | | |-- output_cit-HepPh_1200000.h5 | | |-- output_delaunay_n22_1200000.h5 | | |-- output_email-Enron_1200000.h5 | | |-- output_email-EuAll_1200000.h5 | | |-- output_europe_osm_1200000.h5 | | |-- output_hugebubbles-00020_1200000.h5 | | |-- output_rgg_n_2_24_s0_1200000.h5 | | |-- output_road_usa_1200000.h5 | | |-- output_Stanford_1200000.h5 | | |-- output_wb-edu_1200000.h5 | | |-- output_web-BerkStan_1200000.h5 | | |-- output_web-Google_1200000.h5 | | |-- output_web-NotreDame_1200000.h5 | | |-- output_wiki-Talk_1200000.h5 | | `-- output_wiki-Vote_1200000.h5 | |-- f_1600000_b250 | | |-- output_adaptive_1600000.h5 | | |—- ... | | `-- output_wiki-Vote_1600000.h5 | |-- f_2000000_b250 | | |-- output_adaptive_2000000.h5 | | |—- ... | | `-- output_wiki-Vote_2000000.h5 | `-- f_2400000_b250 | |-- output_adaptive_2400000.h5 | |—- ... | `-- output_wiki-Vote_2400000.h5 `-- train |-- merged_energy_train_shuffle_f1200000_250.h5 |-- merged_energy_train_shuffle_f1600000_250.h5 |-- merged_energy_train_shuffle_f2000000_250.h5 `-- merged_energy_train_shuffle_f2400000_250.h5 </code></pre> The matrices contained in the merged training files (<code>merged_energy_train_shuffle_fXX00000_250.h5</code>) are the following: <pre><code>$ tree . |-- output_af_0_k101_1200000.h5 |-- output_af_1_k101_1200000.h5 |-- output_af_2_k101_1200000.h5 |-- output_af_3_k101_1200000.h5 |-- output_af_4_k101_1200000.h5 |-- output_af_5_k101_1200000.h5 |-- output_af_shell10_1200000.h5 |-- output_af_shell1_1200000.h5 |-- output_af_shell2_1200000.h5 |-- output_af_shell3_1200000.h5 |-- output_af_shell4_1200000.h5 |-- output_af_shell5_1200000.h5 |-- output_af_shell6_1200000.h5 |-- output_af_shell7_1200000.h5 |-- output_af_shell8_1200000.h5 |-- output_af_shell9_1200000.h5 |-- output_atmosmodd_1200000.h5 |-- output_atmosmodj_1200000.h5 |-- output_atmosmodl_1200000.h5 |-- output_audikw_1_1200000.h5 |-- output_BenElechi1_1200000.h5 |-- output_bmw3_2_1200000.h5 |-- output_bmw7st_1_1200000.h5 |-- output_bmwcra_1_1200000.h5 |-- output_bone010_1200000.h5 |-- output_boneS01_1200000.h5 |-- output_boneS10_1200000.h5 |-- output_bundle_adj_1200000.h5 |-- output_cage14_1200000.h5 |-- output_cage15_1200000.h5 |-- output_circuit5M_1200000.h5 |-- output_circuit5M_dc_1200000.h5 |-- output_CO_1200000.h5 |-- output_consph_1200000.h5 |-- output_CoupCons3D_1200000.h5 |-- output_crankseg_1_1200000.h5 |-- output_crankseg_2_1200000.h5 |-- output_CurlCurl_2_1200000.h5 |-- output_CurlCurl_3_1200000.h5 |-- output_CurlCurl_4_1200000.h5 |-- output_dielFilterV2real_1200000.h5 |-- output_dielFilterV3real_1200000.h5 |-- output_Emilia_923_1200000.h5 |-- output_ESOC_1200000.h5 |-- output_F1_1200000.h5 |-- output_F2_1200000.h5 |-- output_Fault_639_1200000.h5 |-- output_Freescale1_1200000.h5 |-- output_Freescale2_1200000.h5 |-- output_FullChip_1200000.h5 |-- output_G3_circuit_1200000.h5 |-- output_Ga10As10H30_1200000.h5 |-- output_Ga19As19H42_1200000.h5 |-- output_Ga3As3H12_1200000.h5 |-- output_Ga41As41H72_1200000.h5 |-- output_Ge87H76_1200000.h5 |-- output_Ge99H100_1200000.h5 |-- output_Geo_1438_1200000.h5 |-- output_gsm_106857_1200000.h5 |-- output_Hardesty3_1200000.h5 |-- output_hood_1200000.h5 |-- output_Hook_1498_1200000.h5 |-- output_human_gene1_1200000.h5 |-- output_human_gene2_1200000.h5 |-- output_inline_1_1200000.h5 |-- output_JP_1200000.h5 |-- output_kkt_power_1200000.h5 |-- output_ldoor_1200000.h5 |-- output_Long_Coup_dt0_1200000.h5 |-- output_Long_Coup_dt6_1200000.h5 |-- output_mat_104_10000_1200000.h5 |-- output_mat_104_1000_1200000.h5 |-- output_mat_104_5000_1200000.h5 |-- output_mat_112_10000_1200000.h5 |-- output_mat_112_1000_1200000.h5 |-- output_mat_112_5000_1200000.h5 |-- output_mat_120_10000_1200000.h5 |-- output_mat_120_1000_1200000.h5 |-- output_mat_120_5000_1200000.h5 |-- output_mat_128_10000_1200000.h5 |-- output_mat_128_1000_1200000.h5 |-- output_mat_128_5000_1200000.h5 |-- output_mat_16_10000_1200000.h5 |-- output_mat_16_1000_1200000.h5 |-- output_mat_16_5000_1200000.h5 |-- output_mat_24_10000_1200000.h5 |-- output_mat_24_1000_1200000.h5 |-- output_mat_24_5000_1200000.h5 |-- output_mat_32_10000_1200000.h5 |-- output_mat_32_1000_1200000.h5 |-- output_mat_32_5000_1200000.h5 |-- output_mat_40_10000_1200000.h5 |-- output_mat_40_1000_1200000.h5 |-- output_mat_40_5000_1200000.h5 |-- output_mat_48_10000_1200000.h5 |-- output_mat_48_1000_1200000.h5 |-- output_mat_48_5000_1200000.h5 |-- output_mat_56_10000_1200000.h5 |-- output_mat_56_1000_1200000.h5 |-- output_mat_56_5000_1200000.h5 |-- output_mat_64_10000_1200000.h5 |-- output_mat_64_1000_1200000.h5 |-- output_mat_64_5000_1200000.h5 |-- output_mat_72_10000_1200000.h5 |-- output_mat_72_1000_1200000.h5 |-- output_mat_72_5000_1200000.h5 |-- output_mat_80_10000_1200000.h5 |-- output_mat_80_1000_1200000.h5 |-- output_mat_80_5000_1200000.h5 |-- output_mat_8_10000_1200000.h5 |-- output_mat_8_1000_1200000.h5 |-- output_mat_8_5000_1200000.h5 |-- output_mat_88_10000_1200000.h5 |-- output_mat_88_1000_1200000.h5 |-- output_mat_88_5000_1200000.h5 |-- output_mat_96_10000_1200000.h5 |-- output_mat_96_1000_1200000.h5 |-- output_mat_96_5000_1200000.h5 |-- output_memchip_1200000.h5 |-- output_ML_Laplace_1200000.h5 |-- output_mouse_gene_1200000.h5 |-- output_msdoor_1200000.h5 |-- output_m_t1_1200000.h5 |-- output_nd12k_1200000.h5 |-- output_nd24k_1200000.h5 |-- output_nd6k_1200000.h5 |-- output_nlpkkt120_1200000.h5 |-- output_nlpkkt80_1200000.h5 |-- output_PFlow_742_1200000.h5 |-- output_pwtk_1200000.h5 |-- output_rajat31_1200000.h5 |-- output_RM07R_1200000.h5 |-- output_Rucci1_1200000.h5 |-- output_Serena_1200000.h5 |-- output_Si34H36_1200000.h5 |-- output_Si41Ge41H72_1200000.h5 |-- output_Si87H76_1200000.h5 |-- output_SiO2_1200000.h5 |-- output_sls_1200000.h5 |-- output_StocF-1465_1200000.h5 |-- output_TEM152078_1200000.h5 |-- output_TEM181302_1200000.h5 |-- output_thermal2_1200000.h5 |-- output_tmt_sym_1200000.h5 |-- output_torso1_1200000.h5 |-- output_Transport_1200000.h5 |-- output_TSOPF_FS_b300_c2_1200000.h5 |-- output_TSOPF_FS_b300_c3_1200000.h5 |-- output_TSOPF_RS_b2383_1200000.h5 |-- output_TSOPF_RS_b2383_c1_1200000.h5 |-- output_TSOPF_RS_b678_c2_1200000.h5 `-- output_x104_1200000.h5 f_1600000_b250 |-- output_af_0_k101_1600000.h5 |—- ... `-- output_x104_1600000.h5 f_2000000_b250 |-- output_af_0_k101_2000000.h5 |—- ... `-- output_x104_2000000.h5 f_2400000_b250 |-- output_af_0_k101_2400000.h5 |—- ... `-- output_x104_2400000.h5 </code></pre> <strong>Creating your own dataset</strong> If you wish to create your own training/testing dataset on a different target architecture you need to take the following steps: Build the SpMV driver: Go to <code>cd SpMV-driver/src</code> Edit makefile and set the PAPI and HDF5 install prefixes. Build the driver via <code>make.</code> Run the SpMV driver: <code>./driver &lt;arg0&gt; &lt;arg1&gt; ...</code> List of driver arguments: <pre><code>matrix = audikw_1.rb # Input matrix in rb format reps = 10000 # Number of repetitions of the operation to avoid overhead block_size_ini = 250 # Minimum block size block_size_end = 1000 # Maximum block size increment = 250 # Increment between block sizes base = 0 # Starting nnz of the matrix freq = [2400000, 2000000, 1600000, 1200000] # Operating frequency sym = 1 # If 1 the matrix is symmetric. If 0 the matrix is no-symmetric.</code></pre> Example: <code>numactl --membind 0 taskset -c 0 ./src/driver audikw_1.rb 10000 250 1000 250 0 2400000</code> Note that <code>numactl</code> and <code>taskset</code> utilities are used to guarantee both NUMA and process-to-core affinity. Generating the dataset: Edit the <code>SpMV-driver/run_all.sh</code> and uncomment the line <code>matrices =</code> in order to launch the driver for Train_symmetric / Train_noSymmetric / Test_symmetric / Test_noSymmetric matrices. Edit the 3rd parameter in the command SpMV-driver/run_driver.sh: 1 for symmetric matrices, 2 for unsymmetric matrices. Edit the command in SpMV-driver/run_driver.sh to select the input parameters of the driver as explained before. Run <code>SpMV-driver/run_all.sh</code> to obtain <code>hdf5</code> files that will create the dataset. Merging the dataset: Run the script <code>python3 SpMV-driver/merge_train_matrices.py /path/to/hdf5/matrix/files /output/path</code> to obtain a single <code>hdf5</code> file containing all data from individual <code>hdf5</code> files obtained in the previous step. This merged file is the training dataset. <strong>Hyperparameter search</strong> The script <code>spmv_cnn_hyperas.py</code> performs the hyperparameter search via the Hyperas tool. This script requires the hdf5 file dataset in the directory <code>dataset/train/</code> and produces both a <code>best_model_*.json</code> and <code>best_run_*.json </code>files in the <code>results/models/</code> directory containing the model structure and hyperparameters of the best performing configuration. This script can be invoked in the following way: <code>python3 spmv_cnn_hyper.py 2400000 Time</code> where <code>2400000</code> is the operating processor frequency (2.4 GHz) at which the dataset was generated and <code>Time</code> the modeled metric. According to the labels in the dataset, the hyperparameter search can also be performed with the <code>Energy</code>, <code>EPKG</code> and <code>EDRAM</code> metrics, corresponding to the energy measured by the Intel RAPL counters from our Intel Xeon Haswell core. In our case, however, we only search hyperparameters for the <code>Time</code> and <code>Energy</code> metrics at 2.4 GHz. Other metrics and frequencies inherit the best performing model and settings from the previous configuration. <strong>Training</strong> The script <code>spmv_cnn_train.py</code> performs the training on the best performing models obtained on the previous step. For that, it uses both the <code>best_model_*.json</code> and <code>best_run_*.json</code> files obtained in the hyperparameter search. This script can be invoked in the following way: <code>python3 spmv_cnn_train.py 2400000 Time</code> where <code>2400000</code> is the operating processor frequency (2.4 GHz) and <code>Time</code> the modeled metric. The training should be performed per metric and frequency. The training produces a file that contains the trained weights, so the model is ready for performing inference (testing). <strong>Testing</strong> The script <code>spmv_cnn_test.py</code> performs the test on the set of testing matrices involved in the SpMV operation. This script can be invoked in the following way: <code>python3 spmv_cnn_test.py 2400000 Time</code> where <code>2400000</code> is the operating processor frequency (2.4 GHz) and <code>Time</code> the modeled metric. The test should be performed per metric and frequency. The training produces two files in the <code>results/tests/</code> directory: <code>Pred_*.txt</code>: This file contains the real measurements and the predictions obtained by the CNN for the individual vpos blocks of the testing matrices. <code>Test_*.txt</code>: This file summarizes the information of <code>Pred_*.txt</code> file, showing the average relative error among the blocks of each test matrix and the total relative error, which is computed by summing up the real measurements and the predictions for all the blocks of a same matrix and computing the relative error upon those values. <em>Note that this testing step and the two previous steps (hyperparameter search and training) can be performed at once using the <code>run.sh</code> script.</em> <strong>References</strong> Publications describing <strong>SpMV-CNN-Model</strong>: Barreda, M., Dolz, M.F., Castaño, M.A. et al. Performance modeling of the sparse matrix–vector product via convolutional neural networks. J Supercomputing (2020). https://doi.org/10.1007/s11227-020-03186-1 <strong>Acknowledgments</strong> The <strong>SpMV-CNN-Model</strong> research has been partially supported by: Project TIN2017-82972-R <strong>“Agorithmic Techniques for Energy-Aware and Error-Resilient High Performance Computing”</strong> funded by the Spanish Ministry of Economy and Competitiveness (2018-2020). Project CDEIGENT/2017/04 <strong>“High Performance Computing for Neural Networks” </strong>funded by the Valencian Government. Project UJI-A2019-11 <strong>“Energy-Aware High Performance Computing for Deep Neural Networks”</strong> funded by the Universitat Jaume I.
description: {"references": ["https://github.com/hpca-uji/SpMV-CNN-Model"]}