Line data Source code
1 1 : /** 2 : * @file lib/topology/topology.h 3 : * 4 : * @brief Topology library 5 : * 6 : * This library is allows models to setup and query different topologies. 7 : * 8 : * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com> 9 : * SPDX-License-Identifier: GPL-3.0-only 10 : */ 11 : #pragma once 12 : 13 : #include <core/core.h> 14 : 15 : #include <limits.h> 16 : #include <stdint.h> 17 : 18 1 : extern void topology_global_init(void); 19 : 20 0 : enum _topology_geometry_t { 21 : TOPOLOGY_HEXAGON = 1, //!< hexagonal grid topology 22 : TOPOLOGY_SQUARE, //!< square grid topology 23 : TOPOLOGY_RING, //!< a ring shaped topology walkable in a single direction 24 : TOPOLOGY_BIDRING, //!< a ring shaped topology 25 : TOPOLOGY_TORUS, //!< a torus shaped grid topology (a wrapping around square topology) 26 : TOPOLOGY_STAR, //!< a star shaped topology 27 : TOPOLOGY_MESH, //!< an arbitrary shaped topology 28 : }; 29 : 30 0 : enum _direction_t { 31 : DIRECTION_N, //!< North direction 32 : DIRECTION_S, //!< South direction 33 : DIRECTION_E, //!< East direction 34 : DIRECTION_W, //!< West direction 35 : DIRECTION_NE, //!< North-east direction 36 : DIRECTION_SW, //!< South-west direction 37 : DIRECTION_NW, //!< North-west direction 38 : DIRECTION_SE, //!< South-east direction 39 : 40 : // FIXME this is bad if the n_lps is more than INT_MAX - 1 41 : DIRECTION_INVALID = INT_MAX //!< A generic invalid direction 42 : }; 43 : 44 : /// This is declared by the model to setup the topology module 45 1 : extern struct topology_settings_t { 46 : /// The default geometry to use when nothing else is specified 47 : enum _topology_geometry_t default_geometry; 48 : /// The minimum number of LPs needed for out of the topology logic 49 1 : lp_id_t out_of_topology; 50 0 : } topology_settings; 51 : 52 0 : extern __attribute__ ((pure)) lp_id_t RegionsCount(void); 53 0 : extern __attribute__ ((pure)) lp_id_t DirectionsCount(void); 54 0 : extern __attribute__ ((pure)) lp_id_t GetReceiver(lp_id_t from, enum _direction_t direction); 55 0 : extern lp_id_t FindReceiver(void);