From 99b297435cee8383e9992b300674c7cf17fda109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delval?= Date: Fri, 7 May 2021 13:23:50 +0200 Subject: [PATCH] Add squared Frobenius norm to vfc_test_h5 Besides the new variable addition, vfc_test_h5 has also be made simpler by executing directly all the possible lagorithms (instead of requiring argument). This results in a much more concise vfc_tests_config.json, since only one executable invocation is required. --- tests/vfc_test_h5.cpp | 46 ++++++++++++++++++++++---------- vfc_tests_config.json | 62 +------------------------------------------ 2 files changed, 33 insertions(+), 75 deletions(-) diff --git a/tests/vfc_test_h5.cpp b/tests/vfc_test_h5.cpp index 7b63b5d..2753ce8 100644 --- a/tests/vfc_test_h5.cpp +++ b/tests/vfc_test_h5.cpp @@ -44,6 +44,16 @@ double residual2(double * A, unsigned int Dim) { return res; } +double frobenius2(double * A, unsigned int Dim) { + double res = 0.0; + for (unsigned int i = 0; i < Dim; i++) { + for (unsigned int j = 0; j < Dim; j++) { + res += A[i * Dim + j] * A[i * Dim + j]; + } + } + return res; +} + void read_int(H5File file, std::string key, unsigned int * data) { DataSet ds = file.openDataSet(key); ds.read(data, PredType::STD_U32LE); @@ -158,6 +168,7 @@ int test_cycle(H5File file, int cycle, std::string version, vfc_probes * probes) double res_max = residual_max(res, dim); double res2 = residual2(res, dim); + double frob2 = frobenius2(res, dim); #ifdef DEBUG showMatrix(res, dim, "Result"); @@ -165,6 +176,7 @@ int test_cycle(H5File file, int cycle, std::string version, vfc_probes * probes) vfc_put_probe(probes, &(zero_padded_group)[0], &("res_max_" + version)[0], res_max); vfc_put_probe(probes, &(zero_padded_group)[0], &("res2_" + version)[0], res2); + vfc_put_probe(probes, &(zero_padded_group)[0], &("frob2_" + version)[0], frob2); delete [] res, updates, u, col_update_index, slater_matrix, slater_inverse; @@ -173,29 +185,35 @@ int test_cycle(H5File file, int cycle, std::string version, vfc_probes * probes) } int main(int argc, char **argv) { - if (argc != 3) { + if (argc != 2) { std::cerr << "Execute from within '/'" << std::endl; - std::cerr << "usage: test_h5 " << std::endl; + std::cerr << "usage: test_h5 " << std::endl; return 1; } - std::string version(argv[1]); - std::vector cycles_list = get_cycles_list(argv[2]); + std::vector cycles_list = get_cycles_list(argv[1]); H5File file(FILE_NAME, H5F_ACC_RDONLY); vfc_probes probes = vfc_init_probes(); probes = vfc_init_probes(); + std::vector algorithms = { + "maponia3", "sm1", "sm2", "sm3", "sm4" + }; bool ok; - for (int i = 0; i < cycles_list.size(); i++) { - ok = test_cycle(file, cycles_list[i], version, &probes); - if (ok) { - std::cout << "ok -- cycle " << std::to_string(i) - << std::endl; - } - else { - std::cerr << "failed -- cycle " << std::to_string(i) - << std::endl; - } + + for(int i = 0; i < algorithms.size(); i++) { + std::cout << "Using algorithm : " << algorithms[i] << std::endl; + for (int j = 0; j < cycles_list.size(); j++) { + ok = test_cycle(file, cycles_list[j], algorithms[i], &probes); + if (ok) { + std::cout << "ok -- cycle " << std::to_string(j) + << std::endl; + } + else { + std::cerr << "failed -- cycle " << std::to_string(j) + << std::endl; + } + } } vfc_dump_probes(&probes); diff --git a/vfc_tests_config.json b/vfc_tests_config.json index 5c61a1e..158a5ad 100644 --- a/vfc_tests_config.json +++ b/vfc_tests_config.json @@ -3,67 +3,7 @@ "executables": [ { "executable": "bin/vfc_test_h5", - "parameters" : "maponia3 vfc_ci_cycles.txt", - "vfc_backends": [ - { - "name": "libinterflop_mca.so", - "repetitions": 50 - }, - { - "name": "libinterflop_mca.so --mode=rr", - "repetitions": 50 - } - ] - }, - - { - "executable": "bin/vfc_test_h5", - "parameters" : "sm1 vfc_ci_cycles.txt", - "vfc_backends": [ - { - "name": "libinterflop_mca.so", - "repetitions": 50 - }, - { - "name": "libinterflop_mca.so --mode=rr", - "repetitions": 50 - } - ] - }, - - { - "executable": "bin/vfc_test_h5", - "parameters" : "sm2 vfc_ci_cycles.txt", - "vfc_backends": [ - { - "name": "libinterflop_mca.so", - "repetitions": 50 - }, - { - "name": "libinterflop_mca.so --mode=rr", - "repetitions": 50 - } - ] - }, - - { - "executable": "bin/vfc_test_h5", - "parameters" : "sm3 vfc_ci_cycles.txt", - "vfc_backends": [ - { - "name": "libinterflop_mca.so", - "repetitions": 50 - }, - { - "name": "libinterflop_mca.so --mode=rr", - "repetitions": 50 - } - ] - }, - - { - "executable": "bin/vfc_test_h5", - "parameters" : "sm4 vfc_ci_cycles.txt", + "parameters" : "vfc_ci_cycles.txt", "vfc_backends": [ { "name": "libinterflop_mca.so",