📄 check_input.c
字号:
extern int LANCZOS_SO_INTERVAL; /* interval between orthog checks in SO */ extern double BISECTION_SAFETY; /* divides Lanczos bisection tol */ extern int LANCZOS_CONVERGENCE_MODE;/* Lanczos convergence test type */ extern int RQI_CONVERGENCE_MODE; /* rqi convergence test type: */ extern double WARNING_ORTHTOL; /* warn if Ares/bjitol this big */ extern double WARNING_MISTOL; /* warn if Ares/bjitol this big */ extern int LANCZOS_SO_PRECISION; /* single or double precision? */ extern int PERTURB; /* randomly perturb matrix in spectral method? */ extern int NPERTURB; /* if so, how many edges to modify? */ extern double PERTURB_MAX; /* largest value for perturbation */ extern int MAPPING_TYPE; /* how to map from eigenvectors to partition */ extern int COARSE_NLEVEL_RQI; /* levels between RQI calls */ extern int OPT3D_NTRIES; /* # local opts to look for global min in opt3d */ extern int KL_METRIC; /* KL interset cost: 1=>cuts, 2=>hops */ extern int KL_BAD_MOVES; /* number of unhelpful moves in a row allowed */ extern int KL_NTRIES_BAD; /* # unhelpful passes before quitting KL */ extern double KL_IMBALANCE; /* allowed imbalance in KL */ extern double COARSEN_RATIO_MIN; /* required coarsening reduction */ extern int COARSE_NLEVEL_KL;/* # levels between KL calls in uncoarsening */ extern int MATCH_TYPE; /* which type of contraction matching to use? */ extern int SIMULATOR; /* simulate the communication? */ extern int TERM_PROP; /* perform terminal propagation? */ extern double CUT_TO_HOP_COST; /* ..if so, relativ cut/hop importance */ int flag_params; flag_params = FALSE; if (ECHO < -2 || ECHO > 2) { printf("ECHO (%d) should be in [-2,2].\n", ECHO); flag_params = TRUE; } if (OUTPUT_METRICS < -2 || OUTPUT_METRICS > 2) { printf("WARNING: OUTPUT_METRICS (%d) should be in [-2,2].\n", OUTPUT_METRICS); if (Output_File != NULL) { fprintf(Output_File, "WARNING: OUTPUT_METRICS (%d) should be in [-2,2].\n", OUTPUT_METRICS); } } if (OUTPUT_TIME < 0 || OUTPUT_TIME > 2) { printf("WARNING: OUTPUT_TIME (%d) should be in [0,2].\n", OUTPUT_TIME); if (Output_File != NULL) { fprintf(Output_File, "WARNING: OUTPUT_TIME (%d) should be in [0,2].\n", OUTPUT_TIME); } } if (global_method == 1 || global_method == 2) { if (EXPERT) { if (LANCZOS_TYPE < 1 || LANCZOS_TYPE > 4) { printf("LANCZOS_TYPE (%d) should be in [1,4].\n", LANCZOS_TYPE); flag_params = TRUE; } } else { if (LANCZOS_TYPE < 1 || LANCZOS_TYPE > 3) { printf("LANCZOS_TYPE (%d) should be in [1,3].\n", LANCZOS_TYPE); flag_params = TRUE; } } if (EIGEN_TOLERANCE <= 0) { printf("EIGEN_TOLERANCE (%g) should be positive.\n", EIGEN_TOLERANCE); flag_params = TRUE; } if (LANCZOS_SO_INTERVAL <= 0) { printf("LANCZOS_SO_INTERVAL (%d) should be positive.\n", LANCZOS_SO_INTERVAL); flag_params = TRUE; } if (LANCZOS_SO_INTERVAL == 1) { printf("WARNING: More efficient if LANCZOS_SO_INTERVAL = 2, not 1.\n"); if (Output_File != NULL) { fprintf(Output_File, "WARNING: More efficient if LANCZOS_SO_INTERVAL = 2, not 1.\n"); } } if (BISECTION_SAFETY <= 0) { printf("BISECTION_SAFETY (%g) should be positive.\n", BISECTION_SAFETY); flag_params = TRUE; } if (LANCZOS_CONVERGENCE_MODE < 0 || LANCZOS_CONVERGENCE_MODE > 1) { printf("LANCZOS_CONVERGENCE_MODE (%d) should be in [0,1].\n", LANCZOS_CONVERGENCE_MODE); flag_params = TRUE; } if (WARNING_ORTHTOL == 0) { printf("WARNING: WARNING_ORTHTOL (%g) should be positive.\n", WARNING_ORTHTOL); if (Output_File != NULL) { fprintf(Output_File, "WARNING: WARNING_ORTHTOL (%g) should be positive.\n", WARNING_ORTHTOL); } } if (WARNING_MISTOL == 0) { printf("WARNING: WARNING_MISTOL (%g) should be positive.\n", WARNING_MISTOL); if (Output_File != NULL) { fprintf(Output_File, "WARNING: WARNING_MISTOL (%g) should be positive.\n", WARNING_MISTOL); } } if (LANCZOS_SO_PRECISION < 1 || LANCZOS_SO_PRECISION > 2) { printf("LANCZOS_SO_PRECISION (%d) should be in [1,2].\n", LANCZOS_SO_PRECISION); flag_params = TRUE; } if (PERTURB) { if (NPERTURB < 0) { printf("NPERTURB (%d) should be nonnegative.\n", NPERTURB); flag_params = TRUE; } if (NPERTURB > 0 && PERTURB_MAX < 0) { printf("PERTURB_MAX (%g) should be nonnegative.\n", PERTURB_MAX); flag_params = TRUE; } } if (MAPPING_TYPE < 0 || MAPPING_TYPE > 3) { printf("MAPPING_TYPE (%d) should be in [0,3].\n", MAPPING_TYPE); flag_params = TRUE; } if (ndims == 3 && OPT3D_NTRIES <= 0) { printf("OPT3D_NTRIES (%d) should be positive.\n", OPT3D_NTRIES); flag_params = TRUE; } if (global_method == 2 && rqi_flag) { if (COARSE_NLEVEL_RQI <= 0) { printf("COARSE_NLEVEL_RQI (%d) should be positive.\n", COARSE_NLEVEL_RQI); flag_params = TRUE; } if (RQI_CONVERGENCE_MODE < 0 || RQI_CONVERGENCE_MODE > 1) { printf("RQI_CONVERGENCE_MODE (%d) should be in [0,1].\n", RQI_CONVERGENCE_MODE); flag_params = TRUE; } if (TERM_PROP) { printf("WARNING: Using default Lanczos for extended eigenproblem, not RQI/Symmlq.\n"); } } if (global_method == 1) { if (COARSE_NLEVEL_KL <= 0) { printf("COARSE_NLEVEL_KL (%d) should be positive.\n", COARSE_NLEVEL_KL); flag_params = TRUE; } } if (global_method == 1 || (global_method == 2 && rqi_flag)) { if (COARSEN_RATIO_MIN < .5) { printf("COARSEN_RATIO_MIN (%g) should be at least 1/2.\n", COARSEN_RATIO_MIN); flag_params = TRUE; } if (MATCH_TYPE < 1 || MATCH_TYPE > 4) { printf("MATCH_TYPE (%d) should be in [1,4].\n", MATCH_TYPE); flag_params = TRUE; } }/* if (global_method == 1 && LIMIT_KL_EWGTS && EWGT_RATIO_MAX <= 0) { printf("EWGT_RATIO_MAX (%g) should be at positive.\n", EWGT_RATIO_MAX); flag_params = TRUE; }*/ } if (global_method == 1 || local_method == 1) { if (KL_METRIC < 1 || KL_METRIC > 2) { printf("KL_METRIC (%d) should be in [0,1].\n", KL_METRIC); flag_params = TRUE; } if (KL_BAD_MOVES < 0) { printf("KL_BAD_MOVES (%d) should be non-negative.\n", KL_BAD_MOVES); flag_params = TRUE; } if (KL_NTRIES_BAD < 0) { printf("KL_NTRIES_BAD (%d) should be non-negative.\n", KL_NTRIES_BAD); flag_params = TRUE; } if (KL_IMBALANCE < 0.0 || KL_IMBALANCE > 1.0) { printf("KL_IMBALANCE (%g) should be in [0,1].\n", KL_IMBALANCE); flag_params = TRUE; } } if (SIMULATOR < 0 || SIMULATOR > 3) { printf("SIMULATOR (%d) should be in [0,3].\n", SIMULATOR); flag_params = TRUE; } if (TERM_PROP) { if (CUT_TO_HOP_COST <= 0) { printf("CUT_TO_HOP_COST (%g) should be positive.\n", CUT_TO_HOP_COST); flag_params = TRUE; } } return (flag_params);}static int check_assignment(assignment, nvtxs, nsets_tot, ndims, local_method)short *assignment; /* set numbers if read-from-file */int nvtxs; /* number of vertices */int nsets_tot; /* total number of desired sets */{ int flag; /* return status */ int nsets; /* number of sets created at each level */ int i; /* loop counter */ nsets = 1<< ndims; flag = FALSE; for (i=1; i<=nvtxs && !flag; i++) { if (assignment[i] < 0) { printf("Assignment[%d] = %d less than zero.\n", i, assignment[i]); flag = TRUE; } else if (assignment[i] >= nsets_tot) { printf("Assignment[%d] = %d, too large for %d sets.\n", i, assignment[i], nsets_tot); flag = TRUE; } else if (local_method == 1 && assignment[i] >= nsets) { printf("Can only use local method on single level of read-in assignment,\n"); printf(" but assignment[%d] = %d.\n", i, assignment[i]); flag = TRUE; } } return(flag);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -