21 #include "order/order_internal.h"
22 #if defined(PASTIX_ORDERING_PTSCOTCH)
24 #elif defined(PASTIX_ORDERING_SCOTCH)
48 #if defined(PASTIX_DEBUG_ORDERING)
51 if ( SCOTCH_graphCheck( graph ) ) {
52 pastix_print_error(
"pastix: graphCheck" );
55 pastix_print( procnum, 0,
"SCOTCH_graphCheck done in %lf second\n", clockVal(timer) );
81 pastix_graph_t *graph )
92 colptr = graph->colptr;
93 rowptr = graph->rowptr;
94 baseval = graph->baseval;
97 assert( baseval == colptr[0] );
98 assert( nnz == colptr[n] - colptr[0] );
100 SCOTCH_graphInit( scotchgraph );
107 if ( SCOTCH_graphBuild( scotchgraph,
118 pastix_print_error(
"pastix : SCOTCH_graphBuild" );
160 if ( weights != NULL ) {
161 memFree_null( weights );
164 SCOTCH_graphExit( scotchgraph );
191 SCOTCH_Graph *scotchgraph )
194 SCOTCH_Strat stratdat;
199 SCOTCH_stratInit( &stratdat );
204 static volatile pastix_atomic_lock_t strat_lock = PASTIX_ATOMIC_UNLOCKED;
205 pastix_atomic_lock( &strat_lock );
206 ret = SCOTCH_stratGraphOrder( &stratdat, strat );
207 pastix_atomic_unlock( &strat_lock );
212 ret = SCOTCH_graphOrderList( scotchgraph,
213 (SCOTCH_Num) ordemesh->
vertnbr,
216 (SCOTCH_Num *) ordemesh->
permtab,
217 (SCOTCH_Num *) ordemesh->
peritab,
218 (SCOTCH_Num *)&ordemesh->
cblknbr,
219 (SCOTCH_Num *) ordemesh->
rangtab,
220 (SCOTCH_Num *) ordemesh->
treetab );
222 SCOTCH_stratExit( &stratdat );
224 memFree_null( strat );
228 #if defined(PASTIX_ORDERING_SCOTCH_MT)
231 SCOTCH_Context *scotch_ctx;
232 SCOTCH_Graph *scotch_grf;
253 ocs_compute_graph_ordering_mt( isched_thread_t *ctx,
void *args )
255 struct args_ocs_mt *arg = (
struct args_ocs_mt *)args;
257 SCOTCH_Context *sctx = arg->scotch_ctx;
258 int rank = ctx->rank;
261 SCOTCH_contextInit( sctx );
262 SCOTCH_contextRandomClone( sctx );
265 #if defined(PASTIX_ORDERING_FIX_SEED)
266 SCOTCH_contextRandomSeed( sctx, (SCOTCH_Num)(pastix_data->
id) );
267 #if defined(SCOTCH_OPTIONNUMDETERMINISTIC)
269 SCOTCH_contextOptionSetNum( sctx, SCOTCH_OPTIONNUMDETERMINISTIC, 1 );
277 SCOTCH_contextThreadImport1( sctx, pastix_data->
isched->world_size );
281 isched_barrier_wait( &(ctx->global_ctx->barrier) );
284 SCOTCH_contextThreadImport2( sctx, rank );
287 SCOTCH_Graph *scotchgraph0 = arg->scotch_grf;
288 SCOTCH_Graph scotchgraph1;
292 SCOTCH_graphInit( &scotchgraph1 );
293 SCOTCH_contextBindGraph( sctx, scotchgraph0, &scotchgraph1 );
299 SCOTCH_graphExit( &scotchgraph1 );
302 SCOTCH_contextExit( sctx );
346 pastix_graph_t *graph )
348 SCOTCH_Graph scotchgraph;
354 pastix_print_error(
"orderComputeScotch: Inconsistent integer type between Pastix and Scotch\n" );
362 #if defined(PASTIX_ORDERING_FIX_SEED)
363 SCOTCH_randomSeed( (SCOTCH_Num)(pastix_data->
id) );
364 SCOTCH_randomReset();
376 #if defined(PASTIX_ORDERING_SCOTCH_MT)
381 struct args_ocs_mt args = {
382 .pastix_data = pastix_data,
384 .scotch_grf = &scotchgraph,
387 isched_parallel_call( pastix_data->
isched, ocs_compute_graph_ordering_mt, &args );
BEGIN_C_DECLS typedef int pastix_int_t
@ PASTIX_ERR_INTEGER_TYPE
void graphBase(pastix_graph_t *graph, pastix_int_t baseval)
Rebase the graph to the given value.
pastix_int_t * graphGetWeights(const pastix_graph_t *graph)
Build the vertex weight array out of the dof array.
int pastixOrderAlloc(pastix_order_t *ordeptr, pastix_int_t vertnbr, pastix_int_t cblknbr)
Allocate the order structure.
static int ocs_compute_graph_ordering(pastix_data_t *pastix_data, SCOTCH_Graph *scotchgraph)
Compute the graph ordering.
void order_scotch_reallocate_ordemesh(pastix_order_t *ordemesh)
Reallocate the ordering structure.
static void ocs_graph_check(const SCOTCH_Graph *graph, int procnum)
Check the generated Scotch graph.
int orderComputeScotch(pastix_data_t *pastix_data, pastix_graph_t *graph)
Compute the ordering of the graph given as parameter with Scotch library.
static void ocs_graph_exit(SCOTCH_Graph *scotchgraph)
Cleanup the Scotch graph structure and free the associated data.
char * order_scotch_build_strategy(const pastix_int_t *iparm, pastix_int_t procnum, int isPTscotch)
Generate the ordering strategy string based on the input parameters.
static void ocs_graph_init(SCOTCH_Graph *scotchgraph, pastix_graph_t *graph)
Build the Scotch graph.
void pastixOrderExit(pastix_order_t *ordeptr)
Free the arrays initialized in the order structure.
pastix_order_t * ordemesh
Main PaStiX data structure.