source: trunk/kernel/kern/dqdt.h @ 615

Last change on this file since 615 was 583, checked in by alain, 6 years ago

Improve signals.

File size: 7.7 KB
RevLine 
[1]1/*
2 * kern/dqdt.h - Distributed Quad Decision Tree
[19]3 *
[437]4 * Author : Alain Greiner (2016,2017,2018)
[1]5 *
6 * Copyright (c)  UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH
9 *
10 * ALMOS-kernel is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-kernel is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _DQDT_H_
25#define _DQDT_H_
26
[14]27#include <kernel_config.h>
[457]28#include <hal_kernel_types.h>
[1]29#include <hal_atomic.h>
30
31/****************************************************************************************
32 * This DQDT infrastructure maintains a topological description of ressources usage
[582]33 * in each cluster: number of threads, and number of physical pages allocated.
[1]34 *
35 * - If X_SIZE or Y_SIZE are equal to 1, it makes the assumption that the cluster
36 *   topology is a one dimensionnal vector, an build the smallest one-dimensionnal
[19]37 *   quad-tree covering this one-dimensionnal vector. If the number of clusters
[1]38 *   is not a power of 4, the tree is truncated as required.
[564]39 *
[1]40 *   TODO : the mapping for the one dimensionnal topology is not implemented yet [AG].
[19]41 *
42 * - If both Y_SIZE and Y_SIZE are larger than 1, it makes the assumption that
[437]43 *   the clusters topology is a 2D mesh. The [X,Y] coordinates of a cluster are
[582]44 *   obtained from the CXY identifier using the Rrelevant macros.
[1]45 *      X = CXY >> Y_WIDTH   /  Y = CXY & ((1<<Y_WIDTH)-1)
[582]46 * - If the mesh X_SIZE and Y_SIZE dimensions are not equal, or are not power of 2,
47 *   or the mesh contains "holes" reported in the cluster_info[x][y] array,
[1]48 *   we build the smallest two dimensionnal quad-tree covering all clusters,
49 *   and this tree is truncated as required.
[582]50 * - The mesh size is supposed to contain at most 32 * 32 clusters.
51 *   Therefore, it can exist at most 6 DQDT nodes in a given cluster:
[1]52 *   . Level 0 nodes exist on all clusters and have no children.
[19]53 *   . Level 1 nodes exist when both X and Y coordinates are multiple of 2
[1]54 *   . Level 2 nodes exist when both X and Y coordinates are multiple of 4
55 *   . Level 3 nodes exist when both X and Y coordinates are multiple of 8
56 *   . Level 4 nodes exist when both X and Y coordinates are multiple of 16
57 *   . Level 5 nodes exist when both X and Y coordinates are multiple of 32
[582]58 * - For nodes other than level 0, the placement is defined as follow:
59 *   . The root node is placed in the cluster containing the core executing
60 *     the dqdt_init() function.
61 *   . An intermediate node (representing a given sub-tree) is placed in one
62 *     cluster covered by the subtree, pseudo-randomly selected.
[1]63 ***************************************************************************************/
64
65/****************************************************************************************
66 * This structure describes a node of the DQDT.
67 * The max number of children is 4, but it can be smaller for some nodes.
68 * Level 0 nodes are the clusters, and have no children.
[582]69 * The root node has no parent.
[1]70 ***************************************************************************************/
[582]71
[1]72typedef struct dqdt_node_s
73{
[583]74        uint32_t      level;            /*! node level                                     */
75        uint32_t      arity;            /*! actual children number in this node            */
76    uint32_t      threads;          /*! current number of threads in macro-cluster     */
77    uint32_t      pages;            /*! current number of pages in macro-cluster       */
78    uint32_t      cores;            /*! number of active cores in macro cluster        */
79    uint32_t      clusters;         /*! number of active cluster in macro cluster      */ 
80        xptr_t        parent;           /*! extended pointer on parent node                */
81        xptr_t        children[2][2];   /*! extended pointers on children nodes            */
[1]82}
83dqdt_node_t;
84
85
86/****************************************************************************************
[582]87 * This function recursively initializes the DQDT structure from informations
88 * stored in cluster manager (x_size, y_size and cluster_info[x][y].
89 * It is executed in all clusters by the local CP0, to compute level_max and register
90 * the DQDT root node in each cluster manager, but only CPO in cluster 0 build actually
91 * the quad-tree covering all active clusters.
92 * This initialisation can use remote_accesses, because the DQDT nodes are
93 * allocated as global variables in the cluster_manager, and the local addresses
[1]94 * are identical in all clusters.
95 ***************************************************************************************/
[582]96void dqdt_init( void );
[1]97
98/****************************************************************************************
[583]99 * These local function update the total number of threads in level 0 DQDT node,
100 * and immediately propagates the variation to the DQDT upper levels.
101 * They are called on each thread creation or destruction.
[1]102 ***************************************************************************************/
[583]103void dqdt_increment_threads( void );
104void dqdt_decrement_threads( void );
[1]105
106/****************************************************************************************
[438]107 * This local function updates the total number of pages in level 0 DQDT node,
[583]108 * and immediately propagates the variation to the DQDT upper levels.
109 * They are called by PPM on each physical memory page allocation or release.
[1]110 ****************************************************************************************
[583]111 * @ order   : ln2( number of small pages )
[1]112 ***************************************************************************************/
[583]113void dqdt_increment_pages( uint32_t order );
114void dqdt_decrement_pages( uint32_t order );
[1]115
116/****************************************************************************************
117 * This function can be called in any cluster. It traverses the DQDT tree
118 * from the root to the bottom, to analyse the computing load and select the cluster
119 * with the lowest number ot threads to place a new process.
120 ****************************************************************************************
121 * @ returns the cluster identifier with the lowest computing load.
122 ***************************************************************************************/
[485]123cxy_t dqdt_get_cluster_for_process( void );
[1]124
125/****************************************************************************************
126 * This function can be called in any cluster. It traverses the DQDT tree
[19]127 * from the root to the bottom, to analyse the memory load and select the cluster
[1]128 * with the lowest memory load for dynamic memory allocation with no locality constraint.
129 ****************************************************************************************
130 * @ returns the cluster identifier with the lowest memory load.
131 ***************************************************************************************/
[485]132cxy_t dqdt_get_cluster_for_memory( void );
[1]133
[437]134/****************************************************************************************
[438]135 * This function displays on kernel TXT0 the DQDT state for all nodes in the quad-tree.
136 * It traverses the quadtree from root to bottom, and can be called by a thread
137 * running in any cluster
[437]138 ***************************************************************************************/
[485]139void dqdt_display( void );
[1]140
[437]141
[1]142#endif  /* _DQDT_H_ */
Note: See TracBrowser for help on using the repository browser.