Commit 4f7c8599 authored by Francois Tessier's avatar Francois Tessier

Start implementing a function writing a nodes adjency list as output

parent 78ad44b8
#include "tp_network.hpp"
#include <math.h>
#define MAX_IONODES 1
......@@ -116,6 +117,56 @@ void Topology::LinksList ( int* list ) {
}
void Topology::PrintNodesAdjencyList ( ) {
int rankCoords[5];
int *worldCoords;
MPI_Comm nodeComm, masterComm;
int size, rank, nodeRank, masterRank, masterSize, i, color = 0;
int src, dest;
MPI_Comm_size (MPI_COMM_WORLD, &size);
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
this->RankToCoordinates ( rank, rankCoords );
for ( i = 0; i < 5; i++ )
color += rankCoords[i] * pow (10.0, (double)i);
MPI_Comm_split ( MPI_COMM_WORLD, color, rank, &nodeComm );
MPI_Comm_rank ( nodeComm, &nodeRank );
MPI_Comm_split ( MPI_COMM_WORLD, nodeRank == 0, rank, &masterComm );
MPI_Comm_rank ( masterComm, &masterRank );
MPI_Comm_size ( masterComm, &masterSize );
worldCoords = (int *) malloc ( masterSize * 5 * sizeof ( int ) );
MPI_Gather ( rankCoords, 5, MPI_INT, worldCoords, 5, MPI_INT, 0, masterComm );
if ( masterRank == 0 ) {
for ( src = 0; src < masterSize; src++ ) {
for ( i = 0; i < 5; i++ )
fprintf ( stdout, "%d", worldCoords [ src * 5 + i ] );
fprintf ( stdout, ": " );
for ( dest = 0; dest < masterSize; dest++ ) {
if ( DistanceBetweenRanks ( src, dest ) == 1 ) {
for ( i = 0; i < 5; i++ )
fprintf ( stdout, "%d", worldCoords [ dest * 5 + i ] );
fprintf ( stdout, " " );
}
}
fprintf ( stdout, "\n" );
}
}
return;
}
int Topology::getRoutingOrder ( int *ro ) {
uint64_t dcr_det_order = DCRReadUser(ND_500_DCR(CTRL_DET_ORDER));
......
......@@ -48,6 +48,8 @@ public:
/* |---- Links */
void LinksList ( int* linksList );
/* |---- Adjency list */
void PrintNodesAdjencyList ( );
private:
int getRoutingOrder ( int *ro );
int RouteBetweenCoords ( int *srcCoords, int *destCoords, int *path );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment