void _IGraph_SetNumDims( void* _self, int nDims ) { IGraph* self = (IGraph*)_self; int d_i; IGraph_ClearDims( self ); _MeshTopology_SetNumDims( self, nDims ); self->locals = AllocArray( Decomp*, self->nTDims ); self->remotes = AllocArray( Sync*, self->nTDims ); self->nIncEls = AllocArray2D( int*, self->nTDims, self->nTDims ); self->incEls = AllocArray2D( int**, self->nTDims, self->nTDims ); for( d_i = 0; d_i < self->nTDims; d_i++ ) { self->locals[d_i] = Decomp_New(); Stg_Class_AddRef( self->locals[d_i] ); self->remotes[d_i] = Sync_New(); Stg_Class_AddRef( self->remotes[d_i] ); if( self->comm ) Decomp_SetMPIComm( self->locals[d_i], Comm_GetMPIComm( self->comm ) ); Sync_SetDecomp( self->remotes[d_i], self->locals[d_i] ); if( self->comm ) Sync_SetComm( self->remotes[d_i], self->comm ); memset( self->nIncEls[d_i], 0, sizeof(int**) * self->nTDims ); memset( self->incEls[d_i], 0, sizeof(int***) * self->nTDims ); } }
void DecompSuite_TestDecomp( DecompSuiteData* data ) { Decomp* decomp; int nLocs, *locs, *ranks; int l_i, g_i; nLocs = 10; locs = MemArray( int, nLocs, "testDecomp" ); decomp = Decomp_New(); for( l_i = 0; l_i < nLocs; l_i++ ) locs[l_i] = data->rank * nLocs + l_i; pcu_check_noassert( Decomp_SetLocals( decomp, nLocs, locs ) ); for( g_i = 0; g_i < data->nProcs * nLocs; g_i++ ) { if( g_i >= data->rank * nLocs && g_i < (data->rank + 1) * nLocs ) { pcu_check_true( IMap_Map( decomp->owners, g_i ) == data->rank ); } else { pcu_check_true( !IMap_Has( decomp->owners, g_i ) ); } } for( l_i = 0; l_i < nLocs; l_i++ ) { locs[l_i] = (data->rank * nLocs + nLocs / 2 + l_i) % (data->nProcs * nLocs); } pcu_check_noassert( Decomp_SetLocals( decomp, nLocs, locs ) ); for( g_i = 0; g_i < data->nProcs * nLocs; g_i++ ) { if( g_i >= data->rank * nLocs && g_i < (data->rank + 1) * nLocs ) { if( g_i < data->rank * nLocs + nLocs / 2 ) { if( data->rank > 0 ) { pcu_check_true( IMap_Map( decomp->owners, g_i ) == data->rank - 1 ); } else { pcu_check_true( IMap_Map( decomp->owners, g_i ) == data->nProcs - 1 ); } } else { pcu_check_true( IMap_Map( decomp->owners, g_i ) == data->rank ); } } else { pcu_check_true( !IMap_Has( decomp->owners, g_i ) ); } } locs = MemRearray( locs, int, data->nProcs * nLocs, "testDecomp" ); ranks = MemArray( int, data->nProcs * nLocs, "testDecomp" ); for( g_i = 0; g_i < data->nProcs * nLocs; g_i++ ) locs[g_i] = g_i; pcu_check_noassert( Decomp_FindOwners( decomp, data->nProcs * nLocs, locs, ranks ) ); Stg_Class_Delete( decomp ); MemFree( locs ); MemFree( ranks ); }
Bool testAll( unsigned rank, unsigned nProcs, unsigned watch ) { Bool result = True; DecompTransfer* transfer; Decomp* decomps[2]; UIntMap* map; unsigned nLocals[2]; unsigned* locals[2]; unsigned l_i, ind_i; nLocals[0] = 10; locals[0] = Memory_Alloc_Array_Unnamed( unsigned, nLocals[0] ); for( l_i = 0; l_i < nLocals[0]; l_i++ ) locals[0][l_i] = rank * nLocals[0] + l_i; decomps[0] = Decomp_New( "" ); Decomp_SetLocals( decomps[0], nLocals[0], locals[0] ); nLocals[1] = 10; locals[1] = Memory_Alloc_Array_Unnamed( unsigned, nLocals[1] ); for( l_i = 0; l_i < nLocals[0]; l_i++ ) locals[1][l_i] = (nProcs - rank - 1) * nLocals[1] + l_i; decomps[1] = Decomp_New( "" ); Decomp_SetLocals( decomps[1], nLocals[1], locals[1] ); map = UIntMap_New(); for( ind_i = 0; ind_i < nLocals[0]; ind_i++ ) UIntMap_Insert( map, Decomp_GlobalToLocal( decomps[0], locals[0][ind_i] ), locals[1][ind_i] ); transfer = DecompTransfer_New( "" ); DecompTransfer_SetDecomps( transfer, decomps[0], decomps[1], map ); if( rank == watch ) { } done: FreeObject( transfer ); return result; }