Bench22 (#786)
* added changes required for the new AMG benchmark, including a new routine that returns wall clock time and some new parameters which generate cumulative numbers of nonzeros for A, coarse grid and prolongation operators in AMG
This commit is contained in:
		
							parent
							
								
									9bbdd9799f
								
							
						
					
					
						commit
						af9c59cc34
					
				| @ -2113,3 +2113,26 @@ HYPRE_BoomerAMGSetIsolatedFPoints(HYPRE_Solver   solver, | ||||
|                                       1, num_isolated_fpt, | ||||
|                                       isolated_fpt_index) ); | ||||
| } | ||||
| 
 | ||||
| /*--------------------------------------------------------------------------
 | ||||
|  * HYPRE_BoomerAMGSetCumNnzAP | ||||
|  *--------------------------------------------------------------------------*/ | ||||
| 
 | ||||
| HYPRE_Int | ||||
| HYPRE_BoomerAMGSetCumNnzAP( HYPRE_Solver  solver, | ||||
|                             HYPRE_Real    cum_nnz_AP ) | ||||
| { | ||||
|    return( hypre_BoomerAMGSetCumNnzAP( (void *) solver, cum_nnz_AP ) ); | ||||
| } | ||||
| 
 | ||||
| /*--------------------------------------------------------------------------
 | ||||
|  * HYPRE_BoomerAMGGetCumNnzAP | ||||
|  *--------------------------------------------------------------------------*/ | ||||
| 
 | ||||
| HYPRE_Int | ||||
| HYPRE_BoomerAMGGetCumNnzAP( HYPRE_Solver  solver, | ||||
|                             HYPRE_Real   *cum_nnz_AP ) | ||||
| { | ||||
|    return( hypre_BoomerAMGGetCumNnzAP( (void *) solver, cum_nnz_AP ) ); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -155,6 +155,19 @@ HYPRE_Int HYPRE_BoomerAMGGetResidual(HYPRE_Solver     solver, | ||||
| HYPRE_Int HYPRE_BoomerAMGGetNumIterations(HYPRE_Solver  solver, | ||||
|                                           HYPRE_Int          *num_iterations); | ||||
| 
 | ||||
| /*
 | ||||
|  * Returns cumulative num of nonzeros for A and P operators | ||||
|  **/ | ||||
| HYPRE_Int HYPRE_BoomerAMGGetCumNnzAP(HYPRE_Solver  solver, | ||||
|                                      HYPRE_Real   *cum_nnz_AP); | ||||
| 
 | ||||
| /*
 | ||||
|  * Activates cumulative num of nonzeros for A and P operators.  | ||||
|  * Needs to be set to a positive number for activation. | ||||
|  **/ | ||||
| HYPRE_Int HYPRE_BoomerAMGSetCumNnzAP(HYPRE_Solver  solver, | ||||
|                                      HYPRE_Real    cum_nnz_AP); | ||||
| 
 | ||||
| /**
 | ||||
|  * Returns the norm of the final relative residual. | ||||
|  **/ | ||||
|  | ||||
| @ -180,6 +180,8 @@ typedef struct | ||||
|    hypre_Vector       **cheby_ds; | ||||
|    HYPRE_Real         **cheby_coefs; | ||||
| 
 | ||||
|    HYPRE_Real           cum_nnz_AP; | ||||
| 
 | ||||
|    /* data needed for non-Galerkin option */ | ||||
|    HYPRE_Int           nongalerk_num_tol; | ||||
|    HYPRE_Real         *nongalerk_tol; | ||||
| @ -429,6 +431,8 @@ typedef struct | ||||
| #define hypre_ParAMGDataChebyDS(amg_data) ((amg_data)->cheby_ds) | ||||
| #define hypre_ParAMGDataChebyCoefs(amg_data) ((amg_data)->cheby_coefs) | ||||
| 
 | ||||
| #define hypre_ParAMGDataCumNnzAP(amg_data)   ((amg_data)->cum_nnz_AP) | ||||
| 
 | ||||
| /* block */ | ||||
| #define hypre_ParAMGDataABlockArray(amg_data) ((amg_data)->A_block_array) | ||||
| #define hypre_ParAMGDataPBlockArray(amg_data) ((amg_data)->P_block_array) | ||||
| @ -1669,6 +1673,8 @@ HYPRE_Int HYPRE_BoomerAMGSetIsolatedFPoints( HYPRE_Solver solver, HYPRE_Int num_ | ||||
|                                              HYPRE_BigInt *isolated_fpt_index ); | ||||
| HYPRE_Int HYPRE_BoomerAMGSetFPoints( HYPRE_Solver solver, HYPRE_Int num_fpt, | ||||
|                                      HYPRE_BigInt *fpt_index ); | ||||
| HYPRE_Int HYPRE_BoomerAMGSetCumNnzAP ( HYPRE_Solver solver , HYPRE_Real cum_nnz_AP ); | ||||
| HYPRE_Int HYPRE_BoomerAMGGetCumNnzAP ( HYPRE_Solver solver , HYPRE_Real *cum_nnz_AP ); | ||||
| 
 | ||||
| /* HYPRE_parcsr_amgdd.c */ | ||||
| HYPRE_Int HYPRE_BoomerAMGDDSetup ( HYPRE_Solver solver, HYPRE_ParCSRMatrix A, HYPRE_ParVector b, | ||||
| @ -2270,6 +2276,8 @@ HYPRE_Int hypre_BoomerAMGSetCPoints( void *data, HYPRE_Int cpt_coarse_level, | ||||
|                                      HYPRE_Int  num_cpt_coarse, HYPRE_BigInt *cpt_coarse_index ); | ||||
| HYPRE_Int hypre_BoomerAMGSetFPoints( void *data, HYPRE_Int isolated, HYPRE_Int num_points, | ||||
|                                      HYPRE_BigInt *indices ); | ||||
| HYPRE_Int hypre_BoomerAMGSetCumNnzAP ( void *data , HYPRE_Real cum_nnz_AP ); | ||||
| HYPRE_Int hypre_BoomerAMGGetCumNnzAP ( void *data , HYPRE_Real *cum_nnz_AP ); | ||||
| 
 | ||||
| /* par_amg_setup.c */ | ||||
| HYPRE_Int hypre_BoomerAMGSetup ( void *amg_vdata, hypre_ParCSRMatrix *A, hypre_ParVector *f, | ||||
|  | ||||
| @ -134,6 +134,7 @@ hypre_BoomerAMGCreate() | ||||
|    /* log info */ | ||||
|    HYPRE_Int    num_iterations; | ||||
|    HYPRE_Int    cum_num_iterations; | ||||
|    HYPRE_Real   cum_nnz_AP; | ||||
| 
 | ||||
|    /* output params */ | ||||
|    HYPRE_Int    print_level; | ||||
| @ -263,6 +264,7 @@ hypre_BoomerAMGCreate() | ||||
|    /* log info */ | ||||
|    num_iterations = 0; | ||||
|    cum_num_iterations = 0; | ||||
|    cum_nnz_AP = -1.0; | ||||
| 
 | ||||
|    /* output params */ | ||||
|    print_level = 0; | ||||
| @ -509,6 +511,8 @@ hypre_BoomerAMGCreate() | ||||
|    hypre_ParAMGDataIsolatedFPointsMarker(amg_data) = NULL; | ||||
|    hypre_ParAMGDataNumIsolatedFPoints(amg_data) = 0; | ||||
| 
 | ||||
|    hypre_ParAMGDataCumNnzAP(amg_data) = cum_nnz_AP; | ||||
| 
 | ||||
| #ifdef HYPRE_USING_DSUPERLU | ||||
|    hypre_ParAMGDataDSLUThreshold(amg_data) = 0; | ||||
|    hypre_ParAMGDataDSLUSolver(amg_data) = NULL; | ||||
| @ -4952,3 +4956,37 @@ hypre_BoomerAMGSetFPoints(void         *data, | ||||
| 
 | ||||
|    return hypre_error_flag; | ||||
| } | ||||
| 
 | ||||
| HYPRE_Int | ||||
| hypre_BoomerAMGSetCumNnzAP( void       *data, | ||||
|                             HYPRE_Real  cum_nnz_AP ) | ||||
| { | ||||
|    hypre_ParAMGData *amg_data = (hypre_ParAMGData*) data; | ||||
| 
 | ||||
|    if (!amg_data) | ||||
|    { | ||||
|       hypre_error_in_arg(1); | ||||
|       return hypre_error_flag; | ||||
|    } | ||||
|    hypre_ParAMGDataCumNnzAP(amg_data) = cum_nnz_AP; | ||||
| 
 | ||||
|    return hypre_error_flag; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| HYPRE_Int | ||||
| hypre_BoomerAMGGetCumNnzAP( void       *data, | ||||
|                             HYPRE_Real *cum_nnz_AP ) | ||||
| { | ||||
|    hypre_ParAMGData *amg_data = (hypre_ParAMGData*) data; | ||||
| 
 | ||||
|    if (!amg_data) | ||||
|    { | ||||
|       hypre_error_in_arg(1); | ||||
|       return hypre_error_flag; | ||||
|    } | ||||
|    *cum_nnz_AP = hypre_ParAMGDataCumNnzAP(amg_data); | ||||
| 
 | ||||
|    return hypre_error_flag; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -162,6 +162,8 @@ typedef struct | ||||
|    hypre_Vector       **cheby_ds; | ||||
|    HYPRE_Real         **cheby_coefs; | ||||
| 
 | ||||
|    HYPRE_Real           cum_nnz_AP; | ||||
| 
 | ||||
|    /* data needed for non-Galerkin option */ | ||||
|    HYPRE_Int           nongalerk_num_tol; | ||||
|    HYPRE_Real         *nongalerk_tol; | ||||
| @ -411,6 +413,8 @@ typedef struct | ||||
| #define hypre_ParAMGDataChebyDS(amg_data) ((amg_data)->cheby_ds) | ||||
| #define hypre_ParAMGDataChebyCoefs(amg_data) ((amg_data)->cheby_coefs) | ||||
| 
 | ||||
| #define hypre_ParAMGDataCumNnzAP(amg_data)   ((amg_data)->cum_nnz_AP) | ||||
| 
 | ||||
| /* block */ | ||||
| #define hypre_ParAMGDataABlockArray(amg_data) ((amg_data)->A_block_array) | ||||
| #define hypre_ParAMGDataPBlockArray(amg_data) ((amg_data)->P_block_array) | ||||
|  | ||||
| @ -230,6 +230,8 @@ hypre_BoomerAMGSetup( void               *amg_vdata, | ||||
|    char            nvtx_name[1024]; | ||||
| #endif | ||||
| 
 | ||||
|    HYPRE_Real cum_nnz_AP = hypre_ParAMGDataCumNnzAP(amg_data); | ||||
| 
 | ||||
|    hypre_MPI_Comm_size(comm, &num_procs); | ||||
|    hypre_MPI_Comm_rank(comm, &my_id); | ||||
| 
 | ||||
| @ -3698,6 +3700,18 @@ hypre_BoomerAMGSetup( void               *amg_vdata, | ||||
|       hypre_CreateLambda(amg_data); | ||||
|    } | ||||
| 
 | ||||
|    if (cum_nnz_AP > 0.0) | ||||
|    { | ||||
|       cum_nnz_AP = hypre_ParCSRMatrixDNumNonzeros(A_array[0]); | ||||
|       for (j = 0; j < num_levels-1; j++) | ||||
|       { | ||||
|          hypre_ParCSRMatrixSetDNumNonzeros(P_array[j]); | ||||
|          cum_nnz_AP += hypre_ParCSRMatrixDNumNonzeros(P_array[j]); | ||||
|          cum_nnz_AP += hypre_ParCSRMatrixDNumNonzeros(A_array[j+1]); | ||||
|       } | ||||
|       hypre_ParAMGDataCumNnzAP(amg_data) = cum_nnz_AP; | ||||
|    } | ||||
| 
 | ||||
|    /*-----------------------------------------------------------------------
 | ||||
|     * Print some stuff | ||||
|     *-----------------------------------------------------------------------*/ | ||||
|  | ||||
| @ -593,6 +593,8 @@ HYPRE_Int HYPRE_BoomerAMGSetIsolatedFPoints( HYPRE_Solver solver, HYPRE_Int num_ | ||||
|                                              HYPRE_BigInt *isolated_fpt_index ); | ||||
| HYPRE_Int HYPRE_BoomerAMGSetFPoints( HYPRE_Solver solver, HYPRE_Int num_fpt, | ||||
|                                      HYPRE_BigInt *fpt_index ); | ||||
| HYPRE_Int HYPRE_BoomerAMGSetCumNnzAP ( HYPRE_Solver solver , HYPRE_Real cum_nnz_AP ); | ||||
| HYPRE_Int HYPRE_BoomerAMGGetCumNnzAP ( HYPRE_Solver solver , HYPRE_Real *cum_nnz_AP ); | ||||
| 
 | ||||
| /* HYPRE_parcsr_amgdd.c */ | ||||
| HYPRE_Int HYPRE_BoomerAMGDDSetup ( HYPRE_Solver solver, HYPRE_ParCSRMatrix A, HYPRE_ParVector b, | ||||
| @ -1194,6 +1196,8 @@ HYPRE_Int hypre_BoomerAMGSetCPoints( void *data, HYPRE_Int cpt_coarse_level, | ||||
|                                      HYPRE_Int  num_cpt_coarse, HYPRE_BigInt *cpt_coarse_index ); | ||||
| HYPRE_Int hypre_BoomerAMGSetFPoints( void *data, HYPRE_Int isolated, HYPRE_Int num_points, | ||||
|                                      HYPRE_BigInt *indices ); | ||||
| HYPRE_Int hypre_BoomerAMGSetCumNnzAP ( void *data , HYPRE_Real cum_nnz_AP ); | ||||
| HYPRE_Int hypre_BoomerAMGGetCumNnzAP ( void *data , HYPRE_Real *cum_nnz_AP ); | ||||
| 
 | ||||
| /* par_amg_setup.c */ | ||||
| HYPRE_Int hypre_BoomerAMGSetup ( void *amg_vdata, hypre_ParCSRMatrix *A, hypre_ParVector *f, | ||||
|  | ||||
| @ -1103,6 +1103,7 @@ HYPRE_Real time_get_cpu_seconds_( void ); | ||||
| #define hypre_EndTiming(i) | ||||
| #define hypre_PrintTiming(heading, comm) | ||||
| #define hypre_ClearTiming() | ||||
| #define hypre_GetTiming(heading, comm, time) | ||||
| 
 | ||||
| /*--------------------------------------------------------------------------
 | ||||
|  * With timing on | ||||
| @ -1165,6 +1166,7 @@ HYPRE_Int hypre_BeginTiming( HYPRE_Int time_index ); | ||||
| HYPRE_Int hypre_EndTiming( HYPRE_Int time_index ); | ||||
| HYPRE_Int hypre_ClearTiming( void ); | ||||
| HYPRE_Int hypre_PrintTiming( const char *heading, MPI_Comm comm ); | ||||
| HYPRE_Int hypre_GetTiming( const char *heading, HYPRE_Real *wall_time_ptr, MPI_Comm comm ); | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
|  | ||||
| @ -399,3 +399,57 @@ hypre_PrintTiming( const char     *heading, | ||||
| 
 | ||||
|    return ierr; | ||||
| } | ||||
| 
 | ||||
| /*--------------------------------------------------------------------------
 | ||||
|  * hypre_GetTiming | ||||
|  *--------------------------------------------------------------------------*/ | ||||
| 
 | ||||
| HYPRE_Int | ||||
| hypre_GetTiming( const char     *heading, | ||||
|                  HYPRE_Real     *wall_time_ptr, | ||||
|                  MPI_Comm        comm  ) | ||||
| { | ||||
|    HYPRE_Int  ierr = 0; | ||||
| 
 | ||||
|    HYPRE_Real  local_wall_time; | ||||
|    HYPRE_Real  wall_time; | ||||
| 
 | ||||
|    HYPRE_Int     i; | ||||
|    HYPRE_Int     myrank; | ||||
| 
 | ||||
|    if (hypre_global_timing == NULL) | ||||
|    { | ||||
|       return ierr; | ||||
|    } | ||||
| 
 | ||||
|    hypre_MPI_Comm_rank(comm, &myrank ); | ||||
| 
 | ||||
|    /* print heading */ | ||||
|    if (myrank == 0) | ||||
|    { | ||||
|       hypre_printf("=============================================\n"); | ||||
|       hypre_printf("%s:\n", heading); | ||||
|       hypre_printf("=============================================\n"); | ||||
|    } | ||||
| 
 | ||||
|    for (i = 0; i < (hypre_global_timing -> size); i++) | ||||
|    { | ||||
|       if (hypre_TimingNumRegs(i) > 0) | ||||
|       { | ||||
|          local_wall_time = hypre_TimingWallTime(i); | ||||
|          hypre_MPI_Allreduce(&local_wall_time, &wall_time, 1, | ||||
|                              hypre_MPI_REAL, hypre_MPI_MAX, comm); | ||||
| 
 | ||||
|          if (myrank == 0) | ||||
|          { | ||||
|             hypre_printf("%s:\n", hypre_TimingName(i)); | ||||
| 
 | ||||
|             /* print wall clock info */ | ||||
|             hypre_printf("  wall clock time = %f seconds\n", wall_time); | ||||
|          } | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    *wall_time_ptr = wall_time; | ||||
|    return ierr; | ||||
| } | ||||
|  | ||||
| @ -45,6 +45,7 @@ HYPRE_Real time_get_cpu_seconds_( void ); | ||||
| #define hypre_EndTiming(i) | ||||
| #define hypre_PrintTiming(heading, comm) | ||||
| #define hypre_ClearTiming() | ||||
| #define hypre_GetTiming() | ||||
| 
 | ||||
| /*--------------------------------------------------------------------------
 | ||||
|  * With timing on | ||||
| @ -107,6 +108,7 @@ HYPRE_Int hypre_BeginTiming( HYPRE_Int time_index ); | ||||
| HYPRE_Int hypre_EndTiming( HYPRE_Int time_index ); | ||||
| HYPRE_Int hypre_ClearTiming( void ); | ||||
| HYPRE_Int hypre_PrintTiming( const char *heading, MPI_Comm comm ); | ||||
| HYPRE_Int hypre_GetTiming( const char *heading, HYPRE_Real *wall_time_ptr, MPI_Comm comm ); | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 ulrikeyang
						ulrikeyang