/* * Copyright 1997, Regents of the University of Minnesota * * selectq.c * * This file contains the driving routines for multilevel k-way refinement * * Started 7/28/97 * George * * $Id: selectq.c 10542 2011-07-11 16:56:22Z karypis $ */ #include /*************************************************************************/ /*! This stuff is hardcoded for up to four constraints */ /*************************************************************************/ void Mc_DynamicSelectQueue(ctrl_t *ctrl, idx_t nqueues, idx_t ncon, idx_t subdomain1, idx_t subdomain2, idx_t *currentq, real_t *flows, idx_t *from, idx_t *qnum, idx_t minval, real_t avgvwgt, real_t maxdiff) { idx_t i, j; idx_t hash, index = -1, current; idx_t *cand, *rank, *dont_cares; idx_t nperms, perm[24][5]; real_t sign = 0.0; rkv_t *array; idx_t mype; gkMPI_Comm_rank(MPI_COMM_WORLD, &mype); WCOREPUSH; *qnum = -1; /* allocate memory */ cand = iwspacemalloc(ctrl, ncon); rank = iwspacemalloc(ctrl, ncon); dont_cares = iwspacemalloc(ctrl, ncon); array = rkvwspacemalloc(ctrl, ncon); if (*from == -1) { for (i=0; i avgvwgt*MOC_GD_GRANULARITY_FACTOR) { *from = subdomain1; sign = 1.0; index = 0; } if (flows[array[ncon-1].val] < -1.0*avgvwgt*MOC_GD_GRANULARITY_FACTOR) { *from = subdomain2; sign = -1.0; index = nqueues; } if (*from == -1) goto DONE; } else { ASSERT(*from == subdomain1 || *from == subdomain2); if (*from == subdomain1) { sign = 1.0; index = 0; } else { sign = -1.0; index = nqueues; } } for (i=0; i 0) { *qnum = hash; goto DONE; } } DONE: WCOREPOP; } /*************************************************************************/ /*! This function sorts the nvwgts of a vertex and returns a hashed value */ /*************************************************************************/ idx_t Mc_HashVwgts(ctrl_t *ctrl, idx_t ncon, real_t *nvwgt) { idx_t i; idx_t multiplier, retval; idx_t *rank; rkv_t *array; WCOREPUSH; rank = iwspacemalloc(ctrl, ncon); array = rkvwspacemalloc(ctrl, ncon); for (i=0; i