public void Schedule(MyProject project) { MyExecutionPlan singleCoreExecutionPlan = ExecutionPlanner.CreateExecutionPlan(project); ExecutionPlan = PartitioningStrategy.Divide(singleCoreExecutionPlan); //TODO: remove this and replace with proper project traversal to find nodes with no tasks! ExtractPartitioningFromExecutionPlan(); }
static bool check_params(PartitioningStrategy partitioningStrategy, /* global partitioning algorithm */ LocalPartitioningStrategy localPartitioningAlgorithm, /* local partitioning algorithm */ bool rqi_flag, /* use multilevel eigensolver? */ int ndims /* number of eigenvectors */ ) { var parameterErrorDetected = false; if (OUTPUT_TIME < 0 || OUTPUT_TIME > 2) { Trace.WriteLine($"WARNING: OUTPUT_TIME ({OUTPUT_TIME:d}) should be in [0,2]."); } if (partitioningStrategy == PartitioningStrategy.Multilevel_KL || partitioningStrategy == PartitioningStrategy.Spectral) { if (EXPERT) { if ((int)LANCZOS_TYPE < 1 || (int)LANCZOS_TYPE > 4) { Trace.WriteLine($"LANCZOS_TYPE ({(int) LANCZOS_TYPE:d}) should be in [1,4]."); parameterErrorDetected = true; } } else { if ((int)LANCZOS_TYPE < 1 || (int)LANCZOS_TYPE > 3) { Trace.WriteLine($"LANCZOS_TYPE ({(int) LANCZOS_TYPE:d}) should be in [1,3]."); parameterErrorDetected = true; } } if (EIGEN_TOLERANCE <= 0) { Trace.WriteLine($"EIGEN_TOLERANCE ({EIGEN_TOLERANCE:g}) should be positive."); parameterErrorDetected = true; } if (LANCZOS_SO_INTERVAL <= 0) { Trace.WriteLine($"LANCZOS_SO_INTERVAL ({LANCZOS_SO_INTERVAL:d}) should be positive."); parameterErrorDetected = true; } if (LANCZOS_SO_INTERVAL == 1) { Trace.WriteLine("WARNING: More efficient if LANCZOS_SO_INTERVAL = 2, not 1."); } if (BISECTION_SAFETY <= 0) { Trace.WriteLine($"BISECTION_SAFETY ({BISECTION_SAFETY:g}) should be positive."); parameterErrorDetected = true; } if (LANCZOS_CONVERGENCE_MODE < 0 || LANCZOS_CONVERGENCE_MODE > 1) { Trace.WriteLine($"LANCZOS_CONVERGENCE_MODE ({LANCZOS_CONVERGENCE_MODE:d}) should be in [0,1]."); parameterErrorDetected = true; } if (WARNING_ORTHTOL <= 0.0d) { Trace.WriteLine($"WARNING: WARNING_ORTHTOL ({WARNING_ORTHTOL:g}) should be positive."); } if (WARNING_MISTOL <= 0.0d) { Trace.WriteLine($"WARNING: WARNING_MISTOL ({WARNING_MISTOL:g}) should be positive."); } if (LANCZOS_SO_PRECISION < 1 || LANCZOS_SO_PRECISION > 2) { Trace.WriteLine($"LANCZOS_SO_PRECISION ({LANCZOS_SO_PRECISION:d}) should be in [1,2]."); parameterErrorDetected = true; } if (PERTURB) { if (NPERTURB < 0) { Trace.WriteLine($"NPERTURB ({NPERTURB:d}) should be nonnegative."); parameterErrorDetected = true; } if (NPERTURB > 0 && PERTURB_MAX < 0) { Trace.WriteLine($"PERTURB_MAX ({PERTURB_MAX:g}) should be nonnegative."); parameterErrorDetected = true; } } if ((int)MAPPING_TYPE < 0 || (int)MAPPING_TYPE > 3) { Trace.WriteLine($"MAPPING_TYPE ({(int) MAPPING_TYPE:d}) should be in [0,3]."); parameterErrorDetected = true; } if (ndims == 3 && OPT3D_NTRIES <= 0) { Trace.WriteLine($"OPT3D_NTRIES ({OPT3D_NTRIES:d}) should be positive."); parameterErrorDetected = true; } if (partitioningStrategy == PartitioningStrategy.Spectral && rqi_flag) { if (COARSE_NLEVEL_RQI <= 0) { Trace.WriteLine($"COARSE_NLEVEL_RQI ({COARSE_NLEVEL_RQI:d}) should be positive."); parameterErrorDetected = true; } if (RQI_CONVERGENCE_MODE < 0 || RQI_CONVERGENCE_MODE > 1) { Trace.WriteLine($"RQI_CONVERGENCE_MODE ({RQI_CONVERGENCE_MODE:d}) should be in [0,1]."); parameterErrorDetected = true; } if (TERM_PROP) { Trace.WriteLine("WARNING: Using default Lanczos for extended eigenproblem, not RQI/Symmlq."); } } if (partitioningStrategy == PartitioningStrategy.Multilevel_KL && COARSE_NLEVEL_KL <= 0) { Trace.WriteLine($"COARSE_NLEVEL_KL ({COARSE_NLEVEL_KL:d}) should be positive."); parameterErrorDetected = true; } if (partitioningStrategy == PartitioningStrategy.Multilevel_KL || partitioningStrategy == PartitioningStrategy.Spectral && rqi_flag) { if (COARSEN_RATIO_MIN < .5) { Trace.WriteLine($"COARSEN_RATIO_MIN ({COARSEN_RATIO_MIN:g}) should be at least 1/2."); parameterErrorDetected = true; } if ((int)MATCH_TYPE < 1 || (int)MATCH_TYPE > 9) { Trace.WriteLine($"MATCH_TYPE ({MATCH_TYPE:d}) should be in [1,9]."); parameterErrorDetected = true; } } } if (partitioningStrategy == PartitioningStrategy.Multilevel_KL || localPartitioningAlgorithm == LocalPartitioningStrategy.KernighanLin) { if ((int)KL_METRIC < 1 || (int)KL_METRIC > 2) { Trace.WriteLine($"KL_METRIC ({KL_METRIC:d}) should be in [1,2]."); parameterErrorDetected = true; } if (KL_BAD_MOVES < 0) { Trace.WriteLine($"KL_BAD_MOVES ({KL_BAD_MOVES:d}) should be non-negative."); parameterErrorDetected = true; } if (KL_NTRIES_BAD < 0) { Trace.WriteLine($"KL_NTRIES_BAD ({KL_NTRIES_BAD:d}) should be non-negative."); parameterErrorDetected = true; } if (KL_IMBALANCE < 0.0 || KL_IMBALANCE > 1.0) { Trace.WriteLine($"KL_IMBALANCE ({KL_IMBALANCE:g}) should be in [0,1]."); parameterErrorDetected = true; } } if (SIMULATOR < 0 || SIMULATOR > 3) { Trace.WriteLine($"SIMULATOR ({SIMULATOR:d}) should be in [0,3]."); parameterErrorDetected = true; } // ReSharper disable once InvertIf if (TERM_PROP) { if (CUT_TO_HOP_COST <= 0) { Trace.WriteLine($"CUT_TO_HOP_COST ({CUT_TO_HOP_COST:g}) should be positive."); parameterErrorDetected = true; } if (ndims > 1) { Trace.WriteLine("WARNING: May ignore terminal propagation in spectral quadri/octa section"); } } return(parameterErrorDetected); }
/* Check graph and input options and parameters. */ public static bool check_input(vtx_data **graph, /* linked lists of vertex data */ int nvtxs, /* number of vertices */ int nedges, /* number of edges */ int igeom, /* geometric dimension for inertial method */ float **coords, /* coordinates for inertial method */ int *assignment, /* set numbers if read-from-file */ double[] goal, /* desired sizes of different sets */ int architecture, /* 0=> hypercube, d=> d-dimensional mesh */ int ndims_tot, /* number of hypercube dimensions */ int[] mesh_dims /*[3]*/, /* size of mesh in each dimension */ PartitioningStrategy partitioningStrategy, /* global partitioning algorithm */ LocalPartitioningStrategy localParitioningStrategy, /* local partitioning algorithm */ bool rqi_flag, /* flag for RQI/symmlq eigensolver */ int *vmax, /* smallest acceptable coarsened nvtxs */ int ndims, /* partitioning level */ double eigtol /* tolerance for eigen-pairs */ ) { if (architecture > 0 && mesh_dims == null) { throw new ArgumentNullException(nameof(mesh_dims)); } if (DEBUG_TRACE) { Trace.WriteLine("<Entering check_input>"); } /* First check for consistency in the graph. */ bool graphError; /* does graph check out OK? */ if (graph != null) { graphError = check_graph(graph, nvtxs, nedges); if (graphError) { Trace.WriteLine("ERRORS in graph."); } else { Trace.WriteLine("Graph check OK"); } } else { /* Only allowed if simple or inertial w/o KL and no weights. */ graphError = false; if (partitioningStrategy == PartitioningStrategy.Multilevel_KL || partitioningStrategy == PartitioningStrategy.Spectral || localParitioningStrategy == LocalPartitioningStrategy.KernighanLin) { Trace.WriteLine("No graph input. Only allowed for inertial or simple methods without KL."); graphError = true; } } /* Now check the input values. */ var errorFound = false; var assignmentError = false; if (architecture < 0 || architecture > 3) { Trace.WriteLine($"Machine architecture parameter = {architecture:d}, must be in [0,3]."); errorFound = true; } else if (architecture == 0) { if (ndims_tot < 0) { Trace.WriteLine($"Dimension of hypercube = {ndims_tot:d}, must be at least 1."); errorFound = true; } } else if (architecture > 0) { if (architecture == 1 && mesh_dims[0] <= 0) { Trace.WriteLine($"Size of 1-D mesh improperly specified, {mesh_dims[0]:d}."); errorFound = true; } if (architecture == 2 && (mesh_dims[0] <= 0 || mesh_dims[1] <= 0)) { Trace.WriteLine($"Size of 2-D mesh improperly specified, {mesh_dims[0]:d}x{mesh_dims[1]:d}."); errorFound = true; } if (architecture == 2 && (mesh_dims[0] <= 0 || mesh_dims[1] <= 0 || mesh_dims[2] <= 0)) { Trace.WriteLine($"Size of 3-D mesh improperly specified, {mesh_dims[0]:d}x{mesh_dims[1]:d}x{mesh_dims[2]:d}."); errorFound = true; } } if (ndims < 1 || ndims > MAXDIMS) { Trace.WriteLine($"Partitioning at each step = {ndims:d}, should be in [1,{MAXDIMS:d}]."); errorFound = true; } var nprocs = 0; /* number of processors partitioning for */ if (architecture == 0) { if (!errorFound) { nprocs = 1 << ndims_tot; } } else if (architecture > 0) { nprocs = mesh_dims[0] * mesh_dims[1] * mesh_dims[2]; } if (1 << ndims > nprocs) { Trace.WriteLine($"Partitioning step {ndims:d} too large for {nprocs:d} processors."); errorFound = true; } if ((int)partitioningStrategy < 1 || (int)partitioningStrategy > 7) { Trace.WriteLine($"Global partitioning method = {(int) partitioningStrategy:d}, must be in [1,7]."); errorFound = true; } if ((int)localParitioningStrategy < 1 || (int)localParitioningStrategy > 2) { Trace.WriteLine($"Local partitioning method = {(int) localParitioningStrategy:d}, must be in [1,2]."); errorFound = true; } if (partitioningStrategy == PartitioningStrategy.Multilevel_KL || (partitioningStrategy == PartitioningStrategy.Spectral && rqi_flag)) { var i = 2 * (1 << ndims); if (*vmax < i) { Trace.WriteLine($"WARNING: Number of vertices in coarse graph ({*vmax:d}) being reset to {i:d}."); *vmax = i; } } if ((partitioningStrategy == PartitioningStrategy.Multilevel_KL || partitioningStrategy == PartitioningStrategy.Spectral) && eigtol <= 0) { Trace.WriteLine($"Eigen tolerance ({eigtol:g}) must be positive value"); errorFound = true; } if (partitioningStrategy == PartitioningStrategy.Inertial || (MATCH_TYPE == MatchingRoutine.maxmatch5_geometric && (partitioningStrategy == PartitioningStrategy.Multilevel_KL || (partitioningStrategy == PartitioningStrategy.Spectral && rqi_flag)))) { if (igeom < 1 || igeom > 3) { Trace.WriteLine("Geometry must be 1-, 2- or 3-dimensional"); errorFound = true; } if (igeom > 0 && coords == null) { Trace.WriteLine("No coordinates given"); errorFound = false; } else if (igeom > 0 && coords[0] == null) { Trace.WriteLine("No X-coordinates given"); errorFound = true; } else if (igeom > 1 && coords[1] == null) { Trace.WriteLine("No Y-coordinates given"); errorFound = true; } else if (igeom > 2 && coords[2] == null) { Trace.WriteLine("No Z-coordinates given"); errorFound = true; } } if (partitioningStrategy == PartitioningStrategy.ReadFromFile && localParitioningStrategy == LocalPartitioningStrategy.KernighanLin) { if (nprocs > 1 << ndims) { Trace.WriteLine("Can only use local method on single level of read-in assignment,"); Trace.WriteLine($" but ndims = {ndims:d}, while number of processors = {nprocs:d}."); errorFound = true; } } /* Now check for consistency in the goal array. */ double vertexWeightSum; if (graph != null) { vertexWeightSum = 0; for (var i = 1; i <= nvtxs; i++) { vertexWeightSum += graph[i]->vwgt; } } else { vertexWeightSum = nvtxs; } double vertexGoalSum = 0; for (var i = 0; i < nprocs; i++) { if (goal[i] < 0) { Trace.WriteLine($"goal[{i:d}] is {goal[i]:g}, but should be nonnegative."); errorFound = true; } vertexGoalSum += goal[i]; } if (Math.Abs(vertexWeightSum - vertexGoalSum) > 1e-5 * (vertexWeightSum + vertexGoalSum)) { Trace.WriteLine($"Sum of values in goal ({vertexGoalSum:g}) not equal to sum of vertex weights ({vertexWeightSum:g})."); errorFound = true; } /* Check assignment file if read in. */ if (partitioningStrategy == PartitioningStrategy.ReadFromFile && !errorFound) { assignmentError = check_assignment(assignment, nvtxs, nprocs, ndims, localParitioningStrategy); } /* Add some checks for model parameters */ /* Finally, check the parameters. */ var parameterError = check_params(partitioningStrategy, localParitioningStrategy, rqi_flag, ndims); errorFound = errorFound || graphError || assignmentError || parameterError; return(errorFound); }
public static void reflect_params(PartitioningStrategy global_method, /* global partitioning algorithm */ LocalPartitioningStrategy localPartitioningStrategy, /* local partitioning algorithm */ bool rqi_flag, /* use RQI/SYMMLQ eigensolver? */ int ndims) /* number of eigenvectors to generate */ { Trace.WriteLine("Active Parameters:"); Trace.WriteLine(string.Format(" CHECK_INPUT = {0}", CHECK_INPUT ? "True" : "False")); if (global_method == PartitioningStrategy.Multilevel_KL || global_method == PartitioningStrategy.Linear) { Trace.WriteLine(" LANCZOS_TYPE: "); if (LANCZOS_TYPE == LanczosType.FullOrthogonalization) { Trace.Write(" Full orthogonalization"); } else if (LANCZOS_TYPE == LanczosType.FullOrthogonalizationInverseOperator) { Trace.Write("Full orthogonalization, inverse operator"); } else if (LANCZOS_TYPE == LanczosType.SelectiveOrthogonalization) { Trace.Write("Selective orthogonalization"); } else if (LANCZOS_TYPE == LanczosType.SelectiveOrthogonalizationDoubleEnded) { if (EXPERT) { Trace.Write("Selective orthogonalization against both ends"); } else { /* Check input should catch this, but just in case ... */ //LANCZOS_TYPE = LanczosType.SelectiveOrthogonalization; throw new InvalidOperationException("Only use " + nameof(LanczosType.SelectiveOrthogonalizationDoubleEnded) + " in " + nameof(EXPERT) + " mode"); Trace.Write("Selective orthogonalization"); } } Trace.WriteLine(""); Trace.WriteLine($" EIGEN_TOLERANCE = {EIGEN_TOLERANCE:g}"); if (SRESTOL > 0) { Trace.WriteLine($" SRESTOL = {SRESTOL:g}"); } else { Trace.WriteLine($" SRESTOL = {SRESTOL:g} ... autoset to square of eigen tolerance"); } if (LANCZOS_MAXITNS > 0) { Trace.WriteLine($" LANCZOS_MAXITNS = {LANCZOS_MAXITNS:d}"); } else { Trace.WriteLine($" LANCZOS_MAXITNS = {LANCZOS_MAXITNS:d} ... autoset to twice # vertices"); } if (LANCZOS_SO_PRECISION == 1) { Trace.WriteLine(" LANCZOS_SO_PRECISION = 1 ... single precision"); } else { Trace.WriteLine(" LANCZOS_SO_PRECISION = 2 ... double precision"); } Trace.WriteLine($" LANCZOS_SO_INTERVAL = {LANCZOS_SO_INTERVAL:d}"); if (LANCZOS_CONVERGENCE_MODE == 1) { Trace.WriteLine(" LANCZOS_CONVERGENCE_MODE = 1 ... partition tolerance"); } else { Trace.WriteLine(" LANCZOS_CONVERGENCE_MODE = 0 ... residual tolerance"); } Trace.WriteLine($" BISECTION_SAFETY = {BISECTION_SAFETY:g}"); if (LANCZOS_TYPE == LanczosType.SelectiveOrthogonalization || LANCZOS_TYPE == LanczosType.SelectiveOrthogonalizationDoubleEnded) { if (!LANCZOS_TIME) { Trace.WriteLine(" LANCZOS_TIME = 0 ... no detailed timing"); } else { Trace.WriteLine(" LANCZOS_TIME = 1 ... detailed timing"); } } if (WARNING_EVECS > 0) { Trace.WriteLine($" WARNING_EVECS = {WARNING_EVECS:d}"); } if (MAPPING_TYPE == MappingType.CutAtOrigin) { Trace.WriteLine(" MAPPING_TYPE = 0 ... cut at origin"); } else if (MAPPING_TYPE == MappingType.MinCost) { Trace.WriteLine(" MAPPING_TYPE = 1 ... min-cost assignment"); } else if (MAPPING_TYPE == MappingType.RecursiveMedian) { Trace.WriteLine(" MAPPING_TYPE = 2 ... recursive median"); } else if (MAPPING_TYPE == MappingType.IndependantMedians) { Trace.WriteLine(" MAPPING_TYPE = 3 ... independent medians"); } Trace.WriteLine(string.Format(" MAKE_CONNECTED = {0}", MAKE_CONNECTED ? "True" : "False")); Trace.WriteLine(string.Format(" PERTURB = {0}", PERTURB ? "True" : "False")); if (PERTURB) { Trace.WriteLine($" NPERTURB = {NPERTURB:d}"); Trace.WriteLine($" PERTURB_MAX = {PERTURB_MAX:g}"); } if (ndims == 3) { Trace.WriteLine($" OPT3D_NTRIES = {OPT3D_NTRIES:d}"); } } if (global_method == PartitioningStrategy.Multilevel_KL) { Trace.WriteLine($" COARSEN_RATIO_MIN = {COARSEN_RATIO_MIN:g}"); Trace.WriteLine($" COARSE_NLEVEL_KL = {COARSE_NLEVEL_KL:d}"); Trace.WriteLine($" MATCH_TYPE = {MATCH_TYPE:d}"); Trace.WriteLine(string.Format(" HEAVY_MATCH = {0}", HEAVY_MATCH ? "True" : "False")); Trace.WriteLine(string.Format(" COARSE_KL_BOTTOM = {0}", COARSE_KL_BOTTOM ? "True" : "False")); Trace.WriteLine(string.Format(" COARSEN_VWGTS = {0}", COARSEN_VWGTS ? "True" : "False")); Trace.WriteLine(string.Format(" COARSEN_EWGTS = {0}", COARSEN_EWGTS ? "True" : "False")); Trace.WriteLine(string.Format(" KL_ONLY_BNDY = {0}", KL_ONLY_BNDY ? "True" : "False")); } if (global_method == PartitioningStrategy.Spectral && rqi_flag) { Trace.WriteLine($" COARSE_NLEVEL_RQI = {COARSE_NLEVEL_RQI:d)}"); if (RQI_CONVERGENCE_MODE == 1) { Trace.WriteLine(" RQI_CONVERGENCE_MODE = 1 ... partition tolerance"); } else { Trace.WriteLine(" RQI_CONVERGENCE_MODE = 0 ... residual tolerance"); } Trace.WriteLine($" COARSEN_RATIO_MIN = {COARSEN_RATIO_MIN:g}"); Trace.WriteLine(string.Format(" COARSEN_VWGTS = {0}", COARSEN_VWGTS ? "True" : "False")); Trace.WriteLine(string.Format(" COARSEN_EWGTS = {0}", COARSEN_EWGTS ? "True" : "False")); } if (global_method == PartitioningStrategy.Multilevel_KL || localPartitioningStrategy == LocalPartitioningStrategy.KernighanLin) { Trace.WriteLine(string.Format(" KL_RANDOM = {0}", KL_RANDOM ? "True" : "False")); if (KL_METRIC == KernighanLinMetric.Cuts) { Trace.WriteLine(" KL_METRIC = Cuts"); } else if (KL_METRIC == KernighanLinMetric.Hops) { Trace.WriteLine(" KL_METRIC = Hops"); } Trace.WriteLine(string.Format(" KL_NTRIES_BAD = {0:d}", KL_NTRIES_BAD)); Trace.WriteLine(string.Format(" KL_BAD_MOVES = {0:d}", KL_BAD_MOVES)); Trace.WriteLine(string.Format(" KL_UNDO_LIST = {0}", KL_UNDO_LIST ? "True" : "False")); Trace.WriteLine(string.Format(" KL_IMBALANCE = {0:g}", KL_IMBALANCE)); } if (global_method == PartitioningStrategy.Multilevel_KL || global_method == PartitioningStrategy.Spectral || localPartitioningStrategy == LocalPartitioningStrategy.KernighanLin) { Trace.WriteLine(string.Format(" TERM_PROP = {0}", TERM_PROP ? "True" : "False")); if (TERM_PROP) { Trace.WriteLine(string.Format(" CUT_TO_HOP_COST = {0:g}", CUT_TO_HOP_COST)); } } if (SEQUENCE) { Trace.WriteLine(string.Format(" SEQUENCE = {0}", SEQUENCE ? "True" : "False")); } Trace.WriteLine(string.Format(" PRINT_GRAPH_PARTITION_METRICS = {0}", PRINT_GRAPH_PARTITION_METRICS ? "True" : "False")); Trace.WriteLine(string.Format(" PRINT_GRAPH_PARTITION_METRICS_ALL_RECURSION_LEVELS = {0}", PRINT_GRAPH_PARTITION_METRICS_ALL_RECURSION_LEVELS ? "True" : "False")); Trace.WriteLine(string.Format(" PRINT_GRAPH_PARTITION_METRICS_DETAILED = {0}", PRINT_GRAPH_PARTITION_METRICS_DETAILED ? "True" : "False")); Trace.WriteLine(string.Format(" MAKE_VWGTS = {0}", MAKE_VWGTS ? "True" : "False")); Trace.WriteLine(string.Format(" REFINE_MAP = {0}", REFINE_MAP ? "True" : "False")); Trace.WriteLine(string.Format(" REFINE_PARTITION = {0:d}", REFINE_PARTITION)); Trace.WriteLine(string.Format(" INTERNAL_VERTICES = {0}", INTERNAL_VERTICES ? "True" : "False")); if (SIMULATOR != 0) { Trace.WriteLine(string.Format(" SIMULATOR = {0:d}", SIMULATOR)); Trace.WriteLine(string.Format(" SIMULATION_ITNS = {0:d}", SIMULATION_ITNS)); Trace.WriteLine(string.Format(" CUT_COST = {0:g}", CUT_COST)); Trace.WriteLine(string.Format(" HOP_COST = {0:g}", HOP_COST)); Trace.WriteLine(string.Format(" BDY_COST = {0:g}", BDY_COST)); Trace.WriteLine(string.Format(" BDY_HOP_COST = {0:g}", BDY_HOP_COST)); Trace.WriteLine(string.Format(" STARTUP_COST = {0:g}", STARTUP_COST)); } /* Now print out all the nonzero debug parameters. */ if (DEBUG_CONNECTED) { Trace.WriteLine(" DEBUG_CONNECTED = True"); } if (DEBUG_PERTURB) { Trace.WriteLine(" DEBUG_PERTURB = True"); } if (DEBUG_ASSIGN) { Trace.WriteLine(" DEBUG_ASSIGN = True"); } if (DEBUG_INERTIAL) { Trace.WriteLine(" DEBUG_INERTIAL = True"); } if (DEBUG_OPTIMIZE) { Trace.WriteLine(" DEBUG_OPTIMIZE = True"); } if (DEBUG_BPMATCH != DebugFlagBP.NoDebugging) { Trace.WriteLine(" DEBUG_BPMATCH = " + DEBUG_BPMATCH); } if (DEBUG_COARSEN) { Trace.WriteLine(" DEBUG_COARSEN = True"); } if (DEBUG_EVECS != 0) { Trace.WriteLine(string.Format(" DEBUG_EVECS = {0:d}", DEBUG_EVECS)); } if (DEBUG_KL != DebugFlagKL.NoDebugging) { Trace.WriteLine(" DEBUG_KL = " + DEBUG_KL); } if (DEBUG_INTERNAL) { Trace.WriteLine(" DEBUG_INTERNAL = True"); } if (DEBUG_REFINE_PART) { Trace.WriteLine(" DEBUG_REFINE_PART = True"); } if (DEBUG_REFINE_MAP) { Trace.WriteLine(" DEBUG_REFINE_MAP = True"); } if (DEBUG_TRACE) { Trace.WriteLine(string.Format(" DEBUG_TRACE = {0:d}", DEBUG_TRACE)); } if (DEBUG_MACH_PARAMS) { Trace.WriteLine(" DEBUG_MACH_PARAMS = True"); } }
/* Print out the input options. */ public static void reflect_input(int nvtxs, /* number of vertices in graph */ int nedges, /* number of edges in graph */ int igeom, /* geometric dimension for inertial method */ string geomname, /* name of geometry input file */ string inassignname, /* name of assignment input file */ int architecture, /* 0=> hypercube, d=> d-dimensional mesh */ int ndims_tot, /* total number of cuts to make */ int[] mesh_dims /*[3]*/, /* size of mesh */ PartitioningStrategy global_method, /* global partitioning algorithm */ LocalPartitioningStrategy localPartitioningStrategy, /* local partitioning algorithm */ bool rqi_flag, /* use RQI/Symmlq eigensolver? */ int vmax, /* smallest acceptable coarsened nvtxs */ int ndims, /* partitioning level */ double eigtol, /* tolerance on eigenvectors */ long seed) /* random number seed */ { if (DEBUG_TRACE) { Trace.WriteLine("<Entering reflect_input>"); } Trace.WriteLine(""); if (PRINT_HEADERS) { Trace.WriteLine("\n Input and Parameter Values\n"); } Trace.WriteLine($"# vertices = {nvtxs:d}, # edges = {nedges:d}"); /* Print global partitioning strategy. */ Trace.WriteLine("Global method: "); if (global_method == PartitioningStrategy.Multilevel_KL) { Trace.WriteLine("Multilevel-KL"); } else if (global_method == PartitioningStrategy.Spectral) { Trace.WriteLine("Spectral"); } else if (global_method == PartitioningStrategy.Inertial) { Trace.WriteLine("Inertial"); } else if (global_method == PartitioningStrategy.Linear) { Trace.WriteLine("Linear"); } else if (global_method == PartitioningStrategy.Random) { Trace.WriteLine("Random"); } else if (global_method == PartitioningStrategy.Scattered) { Trace.WriteLine("Scattered"); } else if (global_method == PartitioningStrategy.ReadFromFile) { Trace.WriteLine("Read-From-File"); } if (global_method == PartitioningStrategy.Multilevel_KL) { Trace.WriteLine($"Number of vertices to coarsen down to: {vmax:d}"); Trace.WriteLine($"Eigen tolerance: {eigtol:g}"); } else if (global_method == PartitioningStrategy.Spectral) { if (rqi_flag) { Trace.WriteLine("Multilevel RQI/Symmlq eigensolver"); Trace.WriteLine($"Number of vertices to coarsen down to: {vmax:d}"); Trace.WriteLine($"Eigen tolerance: {eigtol:g}"); } } else if (global_method == PartitioningStrategy.Inertial) { if (geomname != null) { Trace.WriteLine($"Geometry input file: `{geomname}', Dimensionality = {igeom:d}"); } } else if (global_method == PartitioningStrategy.ReadFromFile) { Trace.WriteLine(string.Format("Assignment input file: `{0}'", inassignname)); } /* Now describe local method. */ if (localPartitioningStrategy == LocalPartitioningStrategy.KernighanLin) { Trace.WriteLine("Local method: Kernighan-Lin"); } else if (localPartitioningStrategy == LocalPartitioningStrategy.None) { Trace.WriteLine("Local method: None"); } /* Now describe target architecture. */ if (architecture == 0) { Trace.WriteLine($"Partitioning target: {ndims_tot:d}-dimensional hypercube"); } else if (architecture > 0) { Trace.Write($"Partitioning target: {architecture:d}-dimensional mesh of size "); if (architecture == 1) { Trace.WriteLine($"{mesh_dims[0]:d}"); } else if (architecture == 2) { Trace.WriteLine($"{mesh_dims[0]:d}x{mesh_dims[1]:d}"); } else if (architecture == 3) { Trace.WriteLine($"{mesh_dims[0]:d}x{mesh_dims[1]:d}x{mesh_dims[2]:d}"); } } if (ndims == 1) { Trace.WriteLine("Partitioning mode: Bisection"); } else if (ndims == 2) { Trace.WriteLine("Partitioning mode: Quadrisection"); } else if (ndims == 3) { Trace.WriteLine("Partitioning mode: Octasection"); } /* Add stuff about communications simulator. */ Trace.WriteLine($"Random seed: {seed:d}"); if (ECHO_USER_PARAMETERS) { reflect_params(global_method, localPartitioningStrategy, rqi_flag, ndims); } Trace.WriteLine("\n"); }
/// <summary> /// /// </summary> /// <param name="nvtxs">number of vertices in full graph</param> /// <param name="start">start of edge list for each vertex</param> /// <param name="adjacency">edge list data</param> /// <param name="vwgts">weights for all vertices</param> /// <param name="ewgts">weights for all edges</param> /// <param name="x">coordinates for inertial method</param> /// <param name="y">coordinates for inertial method</param> /// <param name="z">coordinates for inertial method</param> /// <param name="assignment">set number of each vtx (length n)</param> /// <param name="architecture">0 => hypercube, d => d-dimensional mesh</param> /// <param name="ndims_tot">total number of cube dimensions to divide</param> /// <param name="mesh_dims">dimensions of mesh of processors</param> /// <param name="goal">desired set sizes for each set</param> /// <param name="globalMethod">global partitioning algorithm</param> /// <param name="localMethod">local partitioning algorithm</param> /// <param name="rqi_flag">should I use RQI/Symmlq eigensolver?</param> /// <param name="vmax">how many vertices to coarsen down to?</param> /// <param name="ndims">number of eigenvectors (2^d sets)</param> /// <param name="eigtol">tolerance on eigenvectors</param> /// <param name="seed">for random graph mutations</param> /// <returns>A flag indicating if an error occured.</returns> public static bool INTERFACE(int nvtxs, int *start, int *adjacency, int *vwgts, float *ewgts, float *x, float *y, float *z, int *assignment, int architecture, int ndims_tot, int[] mesh_dims /*[3]*/, double[] goal, PartitioningStrategy globalMethod, LocalPartitioningStrategy localMethod, bool rqi_flag, int vmax, int ndims, double eigtol, int seed ) { vtx_data **graph = null; /* graph data structure */ float ** coords = null; /* coordinates for vertices if used */ bool flag; /* return code from balance */ int nedges; /* number of edges in graph */ var totalSetsCreated = 0; /* total number of sets being created */ int igeom; /* geometric dimension for inertial method */ bool defaultGoal; /* using default goals? */ if (DEBUG_TRACE) { Trace.WriteLine("<Entering INTERFACE>"); } if (goal == null) { /* If not passed in, default goals have equal set sizes. */ defaultGoal = true; if (architecture == 0) { totalSetsCreated = 1 << ndims_tot; } else if (architecture == 1) { totalSetsCreated = mesh_dims[0]; } else if (architecture == 2) { totalSetsCreated = mesh_dims[0] * mesh_dims[1]; } else if (architecture > 2) { totalSetsCreated = mesh_dims[0] * mesh_dims[1] * mesh_dims[2]; } double vwgt_sum; /* sum of vertex weights */ if (MAKE_VWGTS && start != null) { vwgt_sum = start[nvtxs] - start[0] + nvtxs; } else if (vwgts == null) { vwgt_sum = nvtxs; } else { vwgt_sum = 0; var vptr = vwgts; /* loops through vertex weights */ for (var i = nvtxs; i != 0; i--) { vwgt_sum += *(vptr++); } } if (totalSetsCreated > 0) { vwgt_sum /= totalSetsCreated; } goal = new double[totalSetsCreated]; if (goal == null) { Trace.WriteLine("\nERROR: No room to make goals."); flag = true; goto skip; } for (var i = 0; i < totalSetsCreated; i++) { goal[i] = vwgt_sum; } } else { defaultGoal = false; } if (MAKE_VWGTS) { /* Generate vertex weights equal to degree of node. */ if (vwgts != null) { Trace.WriteLine("WARNING: Vertex weights being overwritten by vertex degrees."); } vwgts = (int *)Marshal.AllocHGlobal(nvtxs * sizeof(int)); if (vwgts == null) { Trace.WriteLine("\nERROR: No room to make vertex weights."); flag = true; goto skip; } if (start != null) { for (var i = 0; i < nvtxs; i++) { vwgts[i] = 1 + start[i + 1] - start[i]; } } else { for (var i = 0; i < nvtxs; i++) { vwgts[i] = 1; } } } var using_vwgts = (vwgts != null); var useEdgeWeights = (ewgts != null); if (start != null || vwgts != null) { /* Reformat into our data structure. */ double time = seconds(); /* timing variable */ flag = reformat(start, adjacency, nvtxs, &nedges, vwgts, ewgts, &graph); if (flag) { Trace.WriteLine("\nERROR: No room to reformat graph."); goto skip; } reformat_time += seconds() - time; } else { nedges = 0; } if (FREE_GRAPH) { /* Free old graph data structures. */ Marshal.FreeHGlobal((IntPtr)start); start = null; Marshal.FreeHGlobal((IntPtr)adjacency); adjacency = null; Marshal.FreeHGlobal((IntPtr)vwgts); vwgts = null; Marshal.FreeHGlobal((IntPtr)ewgts); ewgts = null; } if (globalMethod == PartitioningStrategy.Inertial || (MATCH_TYPE == MatchingRoutine.maxmatch5_geometric && (globalMethod == PartitioningStrategy.Multilevel_KL || (globalMethod == PartitioningStrategy.Spectral && rqi_flag)))) { if (x == null) { igeom = 0; } else { /* Set up coordinate data structure. */ coords = (float **)Marshal.AllocHGlobal(3 * sizeof(float *)); if (coords == null) { Trace.WriteLine("\nERROR: No room to make coordinate array."); flag = true; goto skip; } /* Minus 1's are to allow remainder of program to index with 1. */ coords[0] = x - 1; igeom = 1; if (y != null) { coords[1] = y - 1; igeom = 2; if (z != null) { coords[2] = z - 1; igeom = 3; } } } } else { igeom = 0; } /* Subtract from assignment to allow code to index from 1. */ assignment = assignment - 1; flag = submain(graph, nvtxs, nedges, using_vwgts, useEdgeWeights, igeom, coords, assignment, goal, architecture, ndims_tot, mesh_dims, globalMethod, localMethod, rqi_flag, vmax, ndims, eigtol, seed); skip: Marshal.FreeHGlobal((IntPtr)coords); if (defaultGoal) { goal = null; } if (graph != null) { free_graph(graph); } if (flag && FREE_GRAPH) { Marshal.FreeHGlobal((IntPtr)start); Marshal.FreeHGlobal((IntPtr)adjacency); Marshal.FreeHGlobal((IntPtr)vwgts); Marshal.FreeHGlobal((IntPtr)ewgts); } return(flag); }