tp_network.hpp 1.47 KB
Newer Older
Preeti Malakar's avatar
Preeti Malakar committed
1
/* Adapted from https://github.com/pmalakar/parco16 */
2 3
#ifndef TP_NETWORK_H
#define TP_NETWORK_H
Francois Tessier's avatar
Francois Tessier committed
4 5 6 7

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
8
#include <mpi.h>
Francois Tessier's avatar
Francois Tessier committed
9 10 11 12 13 14
#include <spi/include/kernel/location.h>
#include <spi/include/kernel/process.h>
#include <spi/include/kernel/memory.h>
#include <firmware/include/personality.h>
#include <hwi/include/bqc/nd_500_dcr.h>
#include <mpix.h>
15
#include "tp_network_interface.hpp"
Francois Tessier's avatar
Francois Tessier committed
16

17 18
#define MAX_IONODES 1

Francois Tessier's avatar
Francois Tessier committed
19 20
class Topology: public iTopology {
public:
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
  /**********************/
  /*  |-- Nodes         */
  /**********************/
  int IONodeId ();
  int BridgeNodeId ();
  int ComputeNodeId ();
  int ProcessPerNode ();
  int IONodesPerFile ( char* filename, int *nodesList );

  /**********************/
  /*  |-- Network       */
  /**********************/
  int NetworkDimensions ();

  /*  |---- Coordinates */
  void RankToCoordinates ( int rank, int* coord );
  void IONodeCoordinates ( int* coord );

  /*  |---- Distance    */
  int DistanceToIONode ( int srcRank );
  /* Minimal distance between two ranks considering a dragonfly network */
  int DistanceBetweenRanks ( int srcRank, int destRank );

  /*  |---- Routes      */
  int RouteToIONode ( int srcRank, int* path );
  int RouteBetweenRanks ( int srcRank, int destRank, int* path );

  /*  |---- Links       */
  void LinksList ( int* linksList );
Francois Tessier's avatar
Francois Tessier committed
50 51

private:
52 53
  int getRoutingOrder ( int *ro );
  int RouteBetweenCoords ( int *srcCoords, int *destCoords, int *path );
Francois Tessier's avatar
Francois Tessier committed
54 55
};

56
#endif // TP_NETWORK_H