Cosmetics

This commit is contained in:
François Coppens 2021-07-09 16:00:29 +02:00
parent 43b996dad9
commit 4f0aaa5763

View File

@ -60,9 +60,9 @@ int test_cycle(H5File file, int cycle, std::string version, double tolerance) {
double *u = new double[nupdates * dim]; double *u = new double[nupdates * dim];
/* Test */ /* Test */
#ifdef DEBUG2 #ifdef DEBUG2
showMatrix(slater_inverse, dim, "OLD Inverse"); showMatrix(slater_inverse, dim, "OLD Inverse");
#endif #endif
// Transform replacement updates in 'updates[]' into additive updates in 'u[]' // Transform replacement updates in 'updates[]' into additive updates in 'u[]'
for (j = 0; j < nupdates; j++) { for (j = 0; j < nupdates; j++) {
@ -74,18 +74,15 @@ int test_cycle(H5File file, int cycle, std::string version, double tolerance) {
} }
} }
#ifdef DEBUG2 #ifdef DEBUG2
showMatrix(slater_matrix, dim, "OLD Slater"); showMatrix(slater_matrix, dim, "OLD Slater");
#endif
#ifdef DEBUG2
showMatrix(u, dim, "Updates"); showMatrix(u, dim, "Updates");
#endif #endif
#ifdef PERF #ifdef PERF
#ifdef DEBUG1 #ifdef DEBUG1
std::cerr << "# of reps. = " << repetition_number << std::endl; std::cerr << "# of reps. = " << repetition_number << std::endl;
#endif #endif // DEBUG1
double *slater_inverse_nonpersistent = new double[dim * dim]; double *slater_inverse_nonpersistent = new double[dim * dim];
if (version == "sm1") { if (version == "sm1") {
for (unsigned int i = 0; i < repetition_number; i++) { for (unsigned int i = 0; i < repetition_number; i++) {
@ -127,20 +124,20 @@ int test_cycle(H5File file, int cycle, std::string version, double tolerance) {
std::memcpy(slater_inverse_nonpersistent, slater_inverse, dim * dim * sizeof(double)); std::memcpy(slater_inverse_nonpersistent, slater_inverse, dim * dim * sizeof(double));
SMWB4(slater_inverse_nonpersistent, dim, nupdates, u, col_update_index); SMWB4(slater_inverse_nonpersistent, dim, nupdates, u, col_update_index);
} }
#ifdef MKL #ifdef MKL
} else if (version == "lapack") { } else if (version == "lapack") {
for (unsigned int i = 0; i < repetition_number; i++) { for (unsigned int i = 0; i < repetition_number; i++) {
std::memcpy(slater_inverse_nonpersistent, slater_matrix, dim * dim * sizeof(double)); std::memcpy(slater_inverse_nonpersistent, slater_matrix, dim * dim * sizeof(double));
inverse(slater_inverse_nonpersistent, dim); inverse(slater_inverse_nonpersistent, dim);
} }
#endif // MKL #endif // MKL
} else { } else {
std::cerr << "Unknown version " << version << std::endl; std::cerr << "Unknown version " << version << std::endl;
exit(1); exit(1);
} }
std::memcpy(slater_inverse, slater_inverse_nonpersistent, dim * dim * sizeof(double)); std::memcpy(slater_inverse, slater_inverse_nonpersistent, dim * dim * sizeof(double));
delete[] slater_inverse_nonpersistent; delete[] slater_inverse_nonpersistent;
#else #else // No performance measurements repetition
if (version == "maponia3") { if (version == "maponia3") {
MaponiA3(slater_inverse, dim, nupdates, u, col_update_index); MaponiA3(slater_inverse, dim, nupdates, u, col_update_index);
} else if (version == "maponia3s") { } else if (version == "maponia3s") {
@ -165,24 +162,21 @@ int test_cycle(H5File file, int cycle, std::string version, double tolerance) {
// SMWB3(slater_inverse, dim, nupdates, u, col_update_index); // SMWB3(slater_inverse, dim, nupdates, u, col_update_index);
} else if (version == "smwb4") { } else if (version == "smwb4") {
SMWB4(slater_inverse, dim, nupdates, u, col_update_index); SMWB4(slater_inverse, dim, nupdates, u, col_update_index);
#ifdef MKL #ifdef MKL
} else if (version == "lapack") { } else if (version == "lapack") {
memcpy(slater_inverse, slater_matrix, dim * dim * sizeof(double)); memcpy(slater_inverse, slater_matrix, dim * dim * sizeof(double));
inverse(slater_inverse, dim); inverse(slater_inverse, dim);
#endif // MKL #endif // MKL
} else { } else {
std::cerr << "Unknown version " << version << std::endl; std::cerr << "Unknown version " << version << std::endl;
exit(1); exit(1);
} }
#endif // PERF #endif // PERF
#ifdef DEBUG2 #ifdef DEBUG2
showMatrix(slater_matrix, dim, "NEW Slater"); showMatrix(slater_matrix, dim, "NEW Slater");
#endif
#ifdef DEBUG2
showMatrix(slater_inverse, dim, "NEW Inverse"); showMatrix(slater_inverse, dim, "NEW Inverse");
#endif #endif
double *res = new double[dim * dim]{0}; double *res = new double[dim * dim]{0};
matMul(slater_matrix, slater_inverse, res, dim); matMul(slater_matrix, slater_inverse, res, dim);
@ -195,9 +189,9 @@ int test_cycle(H5File file, int cycle, std::string version, double tolerance) {
<< res2 << std::endl; << res2 << std::endl;
#endif #endif
#ifdef DEBUG2 #ifdef DEBUG2
showMatrix(res, dim, "Result"); showMatrix(res, dim, "Result");
#endif #endif
delete[] res, updates, u, col_update_index, slater_matrix, slater_inverse; delete[] res, updates, u, col_update_index, slater_matrix, slater_inverse;
@ -205,7 +199,7 @@ int test_cycle(H5File file, int cycle, std::string version, double tolerance) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef PERF #ifdef PERF
if (argc != 5) { if (argc != 5) {
std::cerr << "Execute from within 'datasets/'" << std::endl; std::cerr << "Execute from within 'datasets/'" << std::endl;
std::cerr std::cerr
@ -213,7 +207,7 @@ int main(int argc, char **argv) {
<< std::endl; << std::endl;
return 1; return 1;
} }
#else #else
if (argc != 4) { if (argc != 4) {
std::cerr << "Execute from within 'datasets/'" << std::endl; std::cerr << "Execute from within 'datasets/'" << std::endl;
std::cerr std::cerr
@ -221,7 +215,7 @@ int main(int argc, char **argv) {
<< std::endl; << std::endl;
return 1; return 1;
} }
#endif #endif
std::string version(argv[1]); std::string version(argv[1]);
std::string cyclefile_name(argv[2]); std::string cyclefile_name(argv[2]);
std::ifstream cyclefile(cyclefile_name); std::ifstream cyclefile(cyclefile_name);
@ -231,9 +225,9 @@ int main(int argc, char **argv) {
double tolerance = std::stod(argv[3]); double tolerance = std::stod(argv[3]);
H5File file(FILE_NAME, H5F_ACC_RDONLY); H5File file(FILE_NAME, H5F_ACC_RDONLY);
#ifdef PERF #ifdef PERF
repetition_number = std::stoi(argv[4]); repetition_number = std::stoi(argv[4]);
#endif #endif
bool ok; bool ok;
for (auto & cycle : cycles) { for (auto & cycle : cycles) {