diff --git a/include/main.h b/include/main.h index 28a329ba9a6621f798d6f9b8243290acdf74d4ed..884788d827c57bb8edf45c2f31f7bd0cc3ee511f 100644 --- a/include/main.h +++ b/include/main.h @@ -65,8 +65,7 @@ int main(int argc, char **argv) ; int computeRhs(void) ; double getTime() ; int displayArray(char *s, void *f, int m, int n) ; -int testHMAT(double * relative_error) ; -int prepareTEST(void); +int testHMAT(double * relative_error); double* createCylinder(void) ; int printHelp() ; void prepare_hmat(int, int, int, int, int*, int*, int*, int*, void*, hmat_block_info_t *); diff --git a/include/util.h b/include/util.h index 6371b1e974d53b23f18659aa4c8707ec50921d43..a135ef949cbd7db460c60580e93f8c5a810b0b52 100644 --- a/include/util.h +++ b/include/util.h @@ -132,10 +132,9 @@ int Mpf_progressBar(int currentValue, int maximumValue) ; int MpfArgGetDouble( int *Argc, char **argv, int rflag, const char *name, double *val ) ; int MpfArgHasName( int *Argc, char **argv, int rflag, const char *name ); int MpfArgGetInt( int *Argc, char **argv, int rflag, const char *name, int *val ); +int MpfArgGetString( int *Argc, char **argv, int rflag, const char *name, char **val ); Time get_time(void); Time time_interval(Time t1, Time t2); Time add_times(Time t1, Time t2); double time_in_s(Time t); double time_interval_in_seconds(Time t1, Time t2); -int SCAB_Init(int* argc, char*** argv) ; -int SCAB_Exit(int* argc, char** argv) ; diff --git a/src/classic.c b/src/classic.c index 1938dce31e0ac0a738e1b6041a0c0c3a768b53ab..116de1a95259cf3e519caf4de8052a83436eca30 100644 --- a/src/classic.c +++ b/src/classic.c @@ -12,10 +12,6 @@ int produitClassiqueBEM(int ffar, void *sol) { if (nbPts==0) return 0; - enter_context("produitClassiqueBEM"); - - printf("BEM: "); - /* Global counter jg = only for progress bar */ jg=0; ierr=Mpf_progressBar(0, nbPts+1) ; CHKERRA(ierr); @@ -30,22 +26,18 @@ int produitClassiqueBEM(int ffar, void *sol) { /* Boucle sur les lignes */ for (i=0 ; i<nbPts ; i++) { ierr=computeCoordCylinder(i, &(coord_i[0])) ; CHKERRA(ierr); - { - ierr=computeKernelBEM(&(coord_i[0]), &(coord_j[0]), i==j, &Aij) ; - for (k=0 ; k<nbRHS ; k++) { - d_sol[(size_t)k*nbPts+i] += Aij * d_rhs[(size_t)k*nbPts+j] ; - } - } /* if testDofNeighbour(.. */ + ierr=computeKernelBEM(&(coord_i[0]), &(coord_j[0]), i==j, &Aij) ; + for (k=0 ; k<nbRHS ; k++) { + d_sol[(size_t)k*nbPts+i] += Aij * d_rhs[(size_t)k*nbPts+j] ; + } } /* for (i=0 */ int jg_bak; jg_bak = jg+=sparseRHS ; - ierr=Mpf_progressBar(jg_bak+1, nbPts+1) ; - } /* for (j=0 */ - ierr=Mpf_progressBar(nbPts+1, nbPts+1) ; + ierr=Mpf_progressBar(jg_bak+1, nbPts+1) ; CHKERRA(ierr); + } - leave_context(); return 0 ; } @@ -57,11 +49,10 @@ int produitClassique(void **sol) { void *solCLA = MpfCalloc((size_t)nbPts*nbRHS, sizeof(double)) ; CHKPTRQ(solCLA) ; temps_initial = getTime (); - ierr = produitClassiqueBEM(2, solCLA) ; CHKERRQ(ierr) ; - //ierr = produitClassiqueFEM(solCLA) ; CHKERRQ(ierr) ; + ierr = produitClassiqueBEM(2, solCLA) ; CHKERRQ(ierr); temps_final = getTime (); temps_cpu = temps_final - temps_initial ; - printf("<PERFTESTS> TpsCpuClassic = %f \n", temps_cpu) ; + printf("[minisolver] classical product time = %f\n", temps_cpu) ; *sol = solCLA; return 0; diff --git a/src/hmat.c b/src/hmat.c index e2e241f770d984d763c96c9955fcb07c1ddc022f..fff785cef1c5c2731147cb5db46b4b1a5b7329a8 100644 --- a/src/hmat.c +++ b/src/hmat.c @@ -188,8 +188,6 @@ HMAT_desc_t *HMAT_generate_matrix( hmat_interface_t *hi ) { MpfFree(points); points=NULL; hmat_delete_cluster_tree_builder( ct_builder ); - printf("ClusterTree node count = %d\n", hmat_tree_nodes_count(cluster_tree)); - /* Create the H-matrix with this cluster tree and an admissibility criteria */ hmat_admissibility_t *admissibilityCondition; diff --git a/src/main.c b/src/main.c index d4b404f955ea870a5607a3795d6931b2e2e20dc2..7bd3e77f357f48cc4405c7fb92c18331cb0b7ea9 100644 --- a/src/main.c +++ b/src/main.c @@ -29,61 +29,70 @@ void update_progress(hmat_progress_t * ctx) { \return 0 for success */ int main(int argc, char **argv) { - int ierr ; - double step, max_error = DBL_MAX; + int ierr; + + printf("[minisolver] minisolver version = %s\n", PACKAGE_VERSION); + printf("[minisolver] hmat version = %s\n", HMAT_VERSION); - /* ------------------------------------------------------------------------- */ - /* ---------------------- INITIATION DE MPF (PARALLELE) -------------------*/ - /* ------------------------------------------------------------------------- */ - - ierr=SCAB_Init(&argc, &argv) ; CHKERRQ(ierr) ; + printf("[minisolver] hmat initialization ... "); ierr = init_hmat_interface(); CHKERRQ(ierr); progress.update = update_progress; + printf("done\n"); + + if (MpfArgGetInt(&argc, argv, 1, "--size", &nbPts)) { + printf("[minisolver] system size = %d\n", nbPts) ; + } - /* ------------------------------------------------------------------------- */ - /* --------------------- DECODAGE DE LA LIGNE D'OPTIONS -------------------*/ - /* ------------------------------------------------------------------------- */ - double nbf; - if (MpfArgGetDouble(&argc, argv, 1, "-nbpts", &nbf)) { - if (nbf<0 || nbf>INT_MAX) - SETERRQ(1, "Incorrect value '-nbpts %.0f' (must be between 0 and %d)", nbf, INT_MAX); - nbPts = (int)nbf; - printf("Reading nbPts = %d\n", nbPts) ; + char * compression = NULL; + if (MpfArgGetString( &argc, argv, 1, "--compression" , &compression)) { + if(strncmp(compression, "medium", 6) == 0) { + epsilon = 1e-6; + } else if(strncmp(compression, "high", 4) == 0) { + epsilon = 1e-10; + } else if(strncmp(compression, "disabled", 6) == 0) { + epsilon = 1e-18; + } + } else { + compression = "low"; } + printf("[minisolver] compression = %s\n", compression); + printf("[minisolver] epsilon = %.0e\n", epsilon); - ierr=initCylinder(&argc, &argv) ; CHKERRQ(ierr) ; + printf("[minisolver] preparing test ... "); + ierr=initCylinder(&argc, &argv); CHKERRQ(ierr); /* Wavelength */ - ierr = getMeshStep(&step) ; - lambda = 10.*step ; - printf(" Setting lambda = %f (with 10 points per wavelength)\n", lambda) ; + double step; + ierr = getMeshStep(&step); + lambda = 10.*step; /* Setting remaining variables */ sparseRHS=(double)nbPts/80./log10((double)nbPts) ; if (sparseRHS<1) sparseRHS = 1; - printf("Setting sparseRHS = %d\n", sparseRHS) ; - printf("<PERFTESTS> TEST_FEMBEM_Version = %s\n" , PACKAGE_VERSION); - printf("<PERFTESTS> HMAT_Version = %s\n" , hmat_get_version() ); + /* Cree le second membre du produit mat-vec */ + rhs = calloc((size_t) nbPts * nbRHS, sizeof(double)); CHKPTRQ(rhs); + ierr = computeRhs(); CHKERRQ(ierr); + printf("done\n"); - /* Prepare the mesh and RHS used for the FMM/HMAT tests */ - ierr = prepareTEST() ; CHKERRQ(ierr) ; + printf("[minisolver] lambda = %f\n", lambda) ; + printf("[minisolver] right-hand side sparsity = %d\n", sparseRHS) ; + double relative_error; - /* Run the test */ - ierr = testHMAT(&relative_error) ; CHKERRQ(ierr) ; - int error_exit = 0; - if(relative_error > max_error) { - error_exit = 1; - printf("Error is too high (%g > %g), exiting with error.", relative_error, max_error); - } - printf("\ntest_FEMBEM : end of computation\n"); + ierr = testHMAT(&relative_error); CHKERRQ(ierr) ; + + printf("[minisolver] computation completed\n"); + printf("[minisolver] cleaning ... "); if (rhs) { MpfFree(rhs); rhs = NULL; } + printf("done\n"); - ierr=SCAB_Exit(&argc, argv); CHKERRQ(ierr); + printf("[minisolver] hmat finalization ... "); + interface->finalize(); + printf("done\n"); - return error_exit; + return 0; } diff --git a/src/prepareTEST.c b/src/prepareTEST.c index 175453f887b18e4b5a4f3238333b840ff982b402..3f98eb5b760cea1e5655ed7f84110c9613e112a8 100644 --- a/src/prepareTEST.c +++ b/src/prepareTEST.c @@ -1,29 +1,5 @@ #include "main.h" -int prepareTEST(void) { - enter_context("prepareTEST()"); - double step; - int ierr; - - printf("Number of points for the test = %d\n", nbPts) ; - printf("Number of right hand sides for the test = %d\n", nbRHS) ; - - getMeshStep(&step) ; - - printf("<PERFTESTS> StepMesh = %e\n" , step); - printf("<PERFTESTS> NbPts = %d \n", nbPts); - printf("<PERFTESTS> NbRhs = %d \n", nbRHS); - printf("<PERFTESTS> Lambda = %e \n", lambda); - - /* Cree le second membre du produit mat-vec */ - printf("Computing RHS...\n") ; - rhs = MpfCalloc((size_t)nbPts*nbRHS, sizeof(double)) ; CHKPTRQ(rhs) ; - ierr = computeRhs() ; CHKERRQ(ierr) ; - - leave_context(); - return 0; -} - double getTime() { return (time_in_s(get_time())) ; } diff --git a/src/testHMAT.c b/src/testHMAT.c index e68d593c50392e362ea2505c82b86398e2080ae8..78e5237b2db4eb37938a66c3edfa305f2addcaa4 100644 --- a/src/testHMAT.c +++ b/src/testHMAT.c @@ -3,51 +3,33 @@ /*! \brief Runs the test of H-matrices : gemv, solve */ int testHMAT(double * relative_error) { -#ifdef HAVE_HMAT - enter_context("testHMAT()"); int ierr; double temps_initial, temps_final, temps_cpu; - printf("<PERFTESTS> Epsilon = %.4e \n", epsilon); - - // String to append to the timer printed when doing asynchronous computation - char *postfix_async = hmat_get_sync_exec() ? "" : "_submission"; - /* Realise le produit matrice vecteur classique : A.rhs -> solCLA */ - printf("\n**** Computing Classical product...\n") ; + printf("[minisolver] computing classical product:"); void *solCLA=NULL; - ierr = produitClassique(&solCLA) ; CHKERRQ(ierr) ; + ierr = produitClassique(&solCLA); CHKERRQ(ierr); /* Cree la H-Matrice */ temps_initial = getTime (); - printf("\n**** Creating HMAT...\n") ; + printf("[minisolver] creating matrix ... "); HMAT_desc_t *hdesc; hdesc = HMAT_generate_matrix( interface ); hmat_matrix_t *hmatrix = hdesc->hmatrix; - temps_final = getTime (); - temps_cpu = temps_final - temps_initial ; - printf("<PERFTESTS> TpsCpuCreation%s = %f \n", postfix_async, temps_cpu) ; - - /* display some informations (synchronous) */ - if (hmat_get_sync_exec()) { - hmat_info_t 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); - printf("Ratio: %g\n", (double)info.compressed_size/info.uncompressed_size); - } - - /* Perform a HMAT solve */ - printf("\n") ; + temps_final = getTime(); + printf("done\n"); + + temps_cpu = temps_final - temps_initial; + printf("[minisolver] matrix creation time = %f\n", temps_cpu); /* Factorize the H-matrix */ - printf("\n**** Factorizing HMAT...\n") ; - temps_initial = getTime (); + printf("[minisolver] factorizing matrix:"); + temps_initial = getTime(); hmat_factorization_context_t ctx; hmat_factorization_context_init(&ctx); @@ -56,52 +38,36 @@ int testHMAT(double * relative_error) { ctx.factorization = hmat_factorization_ldlt; ierr = interface->factorize_generic(hmatrix, &ctx); CHKERRQ(ierr); - temps_final = getTime (); + temps_final = getTime(); temps_cpu = (temps_final - temps_initial) ; - printf("<PERFTESTS> TpsCpuFacto%s = %f \n", postfix_async, temps_cpu) ; - - /* display some informations (synchronous) */ - if (hmat_get_sync_exec()) { - hmat_info_t 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); - printf("Ratio: %g\n", (double)info.compressed_size/info.uncompressed_size); - } + printf("[minisolver] factorization time = %f\n", temps_cpu) ; /* Solve the system : A-1.solCLA -> solCLA */ - printf("\n**** Solve HMAT...\n") ; + printf("[minisolver] solving matrix ... "); - temps_initial = getTime (); + temps_initial = getTime(); ierr = interface->solve_systems(hmatrix, solCLA, nbRHS); CHKERRQ(ierr); - temps_final = getTime (); - temps_cpu = (temps_final - temps_initial) ; - printf("<PERFTESTS> TpsCpuSolve%s = %f \n", postfix_async, temps_cpu) ; + temps_final = getTime(); + printf("done\n"); + + temps_cpu = (temps_final - temps_initial); + printf("[minisolver] solve time = %f\n", temps_cpu); /* Compare the two vectors solCLA and rhs */ - printf("\n**** Comparing results...\n") ; + printf("[minisolver] computing relative error ... "); ierr=computeRelativeError(solCLA, rhs, relative_error); CHKERRQ(ierr); + printf("done\n"); - printf("<PERFTESTS> Error = %.4e \n", *relative_error); + printf("[minisolver] relative error = %.4e\n", *relative_error); - /* Destroys the HMAT structure */ -#ifdef TESTFEMBEM_DUMP_HMAT - hi->dump_info(hmatrix, "testHMAT_matrix"); -#endif + printf("[minisolver] test-specific cleaning ... "); HMAT_destroy_matrix( interface, hdesc ); MpfFree(solCLA); - hmat_tracing_dump("testHMAT_trace.json"); - - leave_context(); - -#else - printf("No HMat support.\n") ; -#endif + printf("done\n"); return 0; } diff --git a/src/util.c b/src/util.c index 09475b527a0e2397c0336a4ac66ec6bc2d8cbb20..fce4c96e193c736545f8757c77775d7fa05756a8 100644 --- a/src/util.c +++ b/src/util.c @@ -120,14 +120,17 @@ int Mpf_progressBar(int currentValue, int maximumValue) { } for (j=progress+1 ; j<=res.quot ; j++) - if (j % 10 == 0) + if (j % 10 == 0) { printf(" %2d%% ", j ) ; - else + fflush(stdout); + } else { printf(".") ; + fflush(stdout); + } progress=res.quot ; if (currentValue>=maximumValue) { /* termine la barre de progression */ - printf(" Done.\n") ; + printf(" done\n") ; progress=-1 ; } @@ -465,50 +468,4 @@ double time_interval_in_seconds(Time t1, Time t2) { /* ================================================================================== */ int hmat_get_sync_exec(void) { return 1; -} -/* ================================================================================== */ -int SCAB_Init(int* argc, char*** argv) { - int ierr; - - printf( "HMATRIX solver\n"); - - if(strcmp(hmat_get_version(), HMAT_VERSION)) - printf( "***\n*** hmat version %s (compiled with version %s)\n", hmat_get_version(), HMAT_VERSION); - else - printf( "***\n*** hmat version %s\n", hmat_get_version()); - const char *d, *t; - hmat_get_build_date(&d, &t); - printf("*** Built on %s at %s\n***\n", d, t); - - if (MpfArgGetDouble( argc, *argv, 1, "-epsilon" , &epsilon )) { - printf("[HMat] Compression/Recompression epsilon: %e\n", epsilon ); - } - - /*! \brief Abort timer (in seconds) - - Abort timer: it is the initial value of the countdown timer started by setitimer(). - When it expires, a SIGALRM signal is delivered, - and (with linux) the execution is stopped. This option can be used to enforce termination after a - given time and avoid deadlocks. Set this value with --abort-timer X - */ -#if !defined(_WIN32) - int chrono_abort_timer=1; - if (MpfArgGetInt(argc, *argv, 1, "--abort-timer", &chrono_abort_timer) > 0) { - printf( "Setting abort timer to %d s.\n", chrono_abort_timer); - struct itimerval tv ; - tv.it_interval.tv_sec = chrono_abort_timer ; - tv.it_interval.tv_usec = 0; - tv.it_value.tv_sec = chrono_abort_timer ; - tv.it_value.tv_usec = 0; - ierr=setitimer(ITIMER_REAL, &tv, NULL) ; CHKERRQ(ierr) ; - } -#endif - - return 0; -} -/* ================================================================================== */ -int SCAB_Exit(int* argc, char** argv) { - interface->finalize(); - return 0 ; -} -/* ================================================================================== */ +} \ No newline at end of file