diff --git a/include/main.h b/include/main.h index 3cd3e678e400aef9a290600bc4c67cc0f2e87c3d..ad76a72bfa7677593264857fba5a3240a0a0f67b 100644 --- a/include/main.h +++ b/include/main.h @@ -16,6 +16,8 @@ #include "hmat/hmat.h" #include "util.h" +extern hmat_interface_t * interface; + /*! \brief Number of right hand sides for the test */ extern int nbRHS; diff --git a/src/hmat.c b/src/hmat.c index 05016cd4067131c9eaee1112b89fe18a6a21886b..ad9d5c4aba0ff6ab89c9f08b60991bf8793d9b4a 100644 --- a/src/hmat.c +++ b/src/hmat.c @@ -1,21 +1,11 @@ #include "main.h" int init_hmat_interface() { -#ifdef HAVE_HMAT - if(mpf_hmat_settings.interface_initialized) - return 0; - for(int i = HMAT_SIMPLE_PRECISION; i <= HMAT_DOUBLE_COMPLEX; i++) { - mpf_hmat_settings.interfaces[i] = MpfCalloc(1, sizeof(hmat_interface_t)); - switch(mpf_hmat_settings.engine) { - case mpf_hmat_seq: hmat_init_default_interface(mpf_hmat_settings.interfaces[i], i); break; - default: break; - } - if (!mpf_hmat_settings.interfaces[i]->init) + interface = calloc(1, sizeof(hmat_interface_t)); CHKPTRQ(interface); + hmat_init_default_interface(interface, HMAT_DOUBLE_PRECISION); + if (!interface->init) SETERRQ(1, "No valid HMatrix interface. Incorrect parameters ?"); - mpf_hmat_settings.interfaces[i]->init(); - } - mpf_hmat_settings.interface_initialized = true; -#endif + interface->init(); return 0; } diff --git a/src/main.c b/src/main.c index 452ce14b9fcfc87b7aadf604e95b331fd8461353..0faa448fd13a6a2244936573dc1e5241fd75eaeb 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,8 @@ #include "main.h" +hmat_interface_t * interface = NULL; + // instantiation of globales defined in main.h int nbRHS = 1; int sparseRHS; diff --git a/src/testHMAT.c b/src/testHMAT.c index 2b535dacd4f560538e9dd2f1d993e984220fb029..4d2bc4aba690e03d1bf982bf9072ca235a535101 100644 --- a/src/testHMAT.c +++ b/src/testHMAT.c @@ -25,9 +25,6 @@ int testHMAT(double * relative_error) { temps_initial = getTime (); printf("\n**** Creating HMAT...\n") ; - /* We use the hmat interface initialized in MPF (default is starpu, --hmat-seq or --hmat-toyrt to change it) */ - hmat_interface_t *hi = mpf_hmat_settings.interfaces[HMAT_DOUBLE_PRECISION]; - // hmat_factorization_none mean the user did not chose a factorization so we // must choose one for him if(mpf_hmat_settings.factorization_type == hmat_factorization_none) { @@ -36,7 +33,7 @@ int testHMAT(double * relative_error) { } HMAT_desc_t *hdesc; - hdesc = HMAT_generate_matrix( hi ); + hdesc = HMAT_generate_matrix( interface ); hmat_matrix_t *hmatrix = hdesc->hmatrix; temps_final = getTime (); temps_cpu = temps_final - temps_initial ; @@ -45,7 +42,7 @@ int testHMAT(double * relative_error) { /* display some informations (synchronous) */ if (hmat_get_sync_exec()) { hmat_info_t info; - hi->get_info(hmatrix, &info); + interface->get_info(hmatrix, &info); printf("Compressed size: %ld\n", info.compressed_size); printf("<PERFTESTS> AssembledSizeMb = %f \n", (double)info.compressed_size*sizeof(double)/1024./1024.) ; printf("Uncompressed size: %ld\n", info.uncompressed_size); @@ -65,7 +62,7 @@ int testHMAT(double * relative_error) { ctx.progress = &mpf_hmat_settings.progress; ctx.progress->user_data = NULL; ctx.factorization = mpf_hmat_settings.factorization_type; - ierr = hi->factorize_generic(hmatrix, &ctx); CHKERRQ(ierr); + ierr = interface->factorize_generic(hmatrix, &ctx); CHKERRQ(ierr); temps_final = getTime (); temps_cpu = (temps_final - temps_initial) ; @@ -74,7 +71,7 @@ int testHMAT(double * relative_error) { /* display some informations (synchronous) */ if (hmat_get_sync_exec()) { hmat_info_t info; - hi->get_info(hmatrix, &info); + interface->get_info(hmatrix, &info); printf("Compressed size: %ld\n", info.compressed_size); printf("<PERFTESTS> FactorizedSizeMb = %f \n", (double)info.compressed_size*sizeof(double)/1024./1024.) ; printf("Uncompressed size: %ld\n", info.uncompressed_size); @@ -87,7 +84,7 @@ int testHMAT(double * relative_error) { temps_initial = getTime (); - ierr = hi->solve_systems(hmatrix, solCLA, nbRHS); CHKERRQ(ierr); + ierr = interface->solve_systems(hmatrix, solCLA, nbRHS); CHKERRQ(ierr); temps_final = getTime (); temps_cpu = (temps_final - temps_initial) ; @@ -104,7 +101,7 @@ int testHMAT(double * relative_error) { #ifdef TESTFEMBEM_DUMP_HMAT hi->dump_info(hmatrix, "testHMAT_matrix"); #endif - HMAT_destroy_matrix( hi, hdesc ); + HMAT_destroy_matrix( interface, hdesc ); MpfFree(solCLA); hmat_tracing_dump("testHMAT_trace.json"); diff --git a/src/util.c b/src/util.c index 12d52488cc808201650962ef541a9869ac0b0171..844bc4765108751e85ab6d243f21927027ff2cb2 100644 --- a/src/util.c +++ b/src/util.c @@ -522,15 +522,7 @@ int SCAB_Init(int* argc, char*** argv) { } /* ================================================================================== */ int SCAB_Exit(int* argc, char** argv) { -#ifdef HAVE_HMAT - if (mpf_hmat_settings.interface_initialized) { - int i; - for(i = HMAT_SIMPLE_PRECISION; i <= HMAT_DOUBLE_COMPLEX; i++) - mpf_hmat_settings.interfaces[i]->finalize(); - mpf_hmat_settings.interface_initialized=0; - } -#endif - + interface->finalize(); return 0 ; } /* ================================================================================== */