source: trunk/kernel/kern/dqdt.c @ 593

Last change on this file since 593 was 583, checked in by alain, 5 years ago

Improve signals.

File size: 22.3 KB
RevLine 
[1]1/*
2 * dqdt.c - Distributed Quaternary Decision Tree implementation.
[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-MKH 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-MKH 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-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
[14]24#include <kernel_config.h>
[457]25#include <hal_kernel_types.h>
[1]26#include <hal_special.h>
[582]27#include <hal_macros.h>
[1]28#include <hal_atomic.h>
29#include <hal_remote.h>
[583]30#include <thread.h>
[1]31#include <printk.h>
[438]32#include <chdev.h>
[1]33#include <cluster.h>
34#include <bits.h>
35#include <dqdt.h>
36
37
[438]38///////////////////////////////////////////////////////////////////////////////////////////
39//      Extern variables
40///////////////////////////////////////////////////////////////////////////////////////////
[1]41
[438]42extern chdev_directory_t  chdev_dir;  // defined in chdev.h / allocated in kernel_init.c
43
44///////////////////////////////////////////////////////////////////////////////////////////
45// This static recursive function traverse the DQDT quad-tree from root to bottom.
46///////////////////////////////////////////////////////////////////////////////////////////
47static void dqdt_recursive_print( xptr_t  node_xp )
[1]48{
[582]49        uint32_t x;
50        uint32_t y;
[438]51    dqdt_node_t node;
[1]52
[438]53    // get node local copy
54    hal_remote_memcpy( XPTR( local_cxy , &node ), node_xp , sizeof(dqdt_node_t) );
[1]55
[438]56    // display node content
[583]57        nolock_printk("- level %d / cluster %x : threads = %x / pages = %x / clusters %d / cores %d\n",
58    node.level, GET_CXY( node_xp ), node.threads, node.pages, node.clusters, node.cores );
[1]59
60    // recursive call on children if node is not terminal
[438]61    if ( node.level > 0 )
[1]62    {
[582]63        for ( x = 0 ; x < 2 ; x++ )
[1]64        {
[582]65            for ( y = 0 ; y < 2 ; y++ )
66            {
67                xptr_t iter_xp = node.children[x][y];
68                if ( iter_xp != XPTR_NULL ) dqdt_recursive_print( iter_xp );
69            }
[1]70        }
71    }
[19]72}
73
[564]74/////////////////////////
[485]75void dqdt_display( void )
[438]76{
[582]77    // get extended pointer on DQDT root node
78        cluster_t * cluster = &cluster_manager;
79    xptr_t      root_xp = cluster->dqdt_root_xp;
[438]80
81    // get pointers on TXT0 chdev
82    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
83    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
84    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
85
[564]86    // get extended pointer on remote TXT0 lock
[438]87    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
88
[564]89    // get TXT0 lock
90    remote_busylock_acquire( lock_xp );
[438]91
92    // print header
93    nolock_printk("\n***** DQDT state\n\n");
94
95    // call recursive function
96    dqdt_recursive_print( root_xp );
97
[582]98    // release TXT0 lock
[564]99    remote_busylock_release( lock_xp );
[438]100}
101
[582]102///////////////////////////////////////////////////////////////////////////////////////
103// This static function initializes recursively, from top to bottom, the quad-tree
104// infrastructure. The DQDT nodes are allocated as global variables in each local
[583]105// cluster manager. At each level in the quad-tree, this function initializes the
106// node identified by the <cxy> and <level> arguments, selects in each child
107// macro-cluster the precise cluster where will be placed the subtree root node,
108// and call recursively itself to initialize the child node in the selected cluster.
[582]109///////////////////////////////////////////////////////////////////////////////////////
110// @ node cxy  : cluster containing the node to initialize
111// @ level     : level of node to be initialised
112// @ parent_xp : extended pointer on the parent node
113///////////////////////////////////////////////////////////////////////////////////////
114static void dqdt_recursive_build( cxy_t    node_cxy,
115                                  uint32_t level,
116                                  xptr_t   parent_xp )
[1]117{
[582]118    assert( (level < 5) , __FUNCTION__, "illegal DQDT level %d\n", level );
119 
120    uint32_t node_x;         // node X coordinate
121    uint32_t node_y;         // node Y coordinate
122    uint32_t mask;           // to compute associated macro-cluster coordinates
123    uint32_t node_base_x;    // associated macro_cluster X coordinate
124    uint32_t node_base_y;    // associated macro_cluster y coordinate
125    uint32_t half;           // associated macro-cluster half size
[583]126    uint32_t cores;          // number of cores in macro cluster
127    uint32_t clusters;       // number of clusters in macro cluster
[1]128
[583]129    // get node cluster coordinates
[582]130    node_x = HAL_X_FROM_CXY( node_cxy );
131    node_y = HAL_Y_FROM_CXY( node_cxy );
132       
133    // get macro-cluster mask and half-size
134    mask   = (1 << level) - 1;
135    half   = (level > 0) ? (1 << (level - 1)) : 0;
[564]136
[582]137    // get macro-cluster coordinates
138    node_base_x = node_x & ~mask;
139    node_base_y = node_y & ~mask;
[1]140
[582]141    // get pointer on local cluster manager
142    cluster_t * cluster = LOCAL_CLUSTER;
[1]143
[583]144    // build local and extended pointer on node to be initialized
145    dqdt_node_t * node_ptr = &cluster->dqdt_tbl[level];
146    xptr_t        node_xp  = XPTR( node_cxy , node_ptr );
[1]147
[582]148#if DEBUG_DQDT_INIT
149printk("\n[DBG] %s : cxy(%d,%d) / level %d / mask %x / half %d / ptr %x\n",
[583]150__FUNCTION__, node_x, node_y, level, mask, half, node_ptr );
[582]151#endif
152 
153    // make remote node default initialisation
[583]154    hal_remote_memset( node_xp , 0 , sizeof( dqdt_node_t ) );
[582]155
[583]156    // initialize <parent> field
157    hal_remote_s64( XPTR( node_cxy , &node_ptr->parent ) , parent_xp );
158
159    // initialize <level> field
160    hal_remote_s32( XPTR( node_cxy , &node_ptr->level ) , level );
161
[582]162    // recursive initialisation
[583]163    if( level == 0 )                      // terminal case : cluster
[1]164    {
[583]165        // initialize <clusters> field in node
166        hal_remote_s32( XPTR( node_cxy , &node_ptr->clusters ) , 1 );
167
168        // initialize <cores> field in node
169        cores = hal_remote_l32( XPTR ( node_cxy , &cluster->cores_nr ) );
170        hal_remote_s32( XPTR( node_cxy , &node_ptr->cores ) , cores );
[582]171    }
[583]172    else                                  // non terminal : macro-cluster
[582]173    {
[583]174        bool_t        found;
175        uint32_t      x;
176        uint32_t      y;
177        cxy_t         child_cxy;
178        xptr_t        child_xp;
179        dqdt_node_t * child_ptr =  &cluster->dqdt_tbl[level-1];
[1]180
[583]181        // search an active cluster in child[0][0] macro-cluster
[582]182        found = false; 
183        for( x = node_base_x ; 
184        (x < (node_base_x + half)) && (found == false) ; x++ )
[1]185        {
[582]186            for( y = node_base_y ; 
187            (y < (node_base_y + half)) && (found == false) ; y++ )
188            {
[583]189                child_cxy = HAL_CXY_FROM_XY( x , y );
190
191                if( cluster_is_active( child_cxy ) )
[582]192                {
[583]193                    // initialize recursively selected child[0][0] node
194                    dqdt_recursive_build( child_cxy , level-1 , node_xp );
[1]195
[583]196                    // build extended pointer on child[0][0] node
197                    child_xp = XPTR( child_cxy , child_ptr );
[582]198
[583]199                    // update <cores> field in node
200                    cores = hal_remote_l32( XPTR ( child_cxy , &child_ptr->cores ) );
201                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->cores ) , cores );
202
203                    // update <clusters> field in node
204                    clusters = hal_remote_l32( XPTR ( child_cxy , &child_ptr->clusters ) );
205                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->clusters ) , clusters );
206
207                    // update <child[0][0]> field in node
208                    hal_remote_s64( XPTR( node_cxy , &node_ptr->children[0][0] ), child_xp );
209
210                    // udate <arity> field in node
211                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->arity ) , 1 );
[582]212   
213                    // exit loops
214                    found = true;
215                }
[1]216            }
[582]217        }
[1]218
[583]219        // search an active cluster in child[0][1] macro-cluster
[582]220        found = false; 
221        for( x = node_base_x ; 
222        (x < (node_base_x + half)) && (found == false) ; x++ )
223        {
224            for( y = (node_base_y + half) ; 
[583]225            (y < (node_base_y + (half<<1))) && (found == false) ; y++ )
[1]226            {
[583]227                child_cxy = HAL_CXY_FROM_XY( x , y );
228
229                if( cluster_is_active( child_cxy ) )
[582]230                {
[583]231                    // initialize recursively selected child[0][1] node
232                    dqdt_recursive_build( child_cxy , level-1 , node_xp );
[582]233
[583]234                    // build extended pointer on child[0][1] node
235                    child_xp = XPTR( child_cxy , child_ptr );
[582]236
[583]237                    // update <cores> field in node
238                    cores = hal_remote_l32( XPTR ( child_cxy , &child_ptr->cores ) );
239                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->cores ) , cores );
240
241                    // update <clusters> field in node
242                    clusters = hal_remote_l32( XPTR ( child_cxy , &child_ptr->clusters ) );
243                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->clusters ) , clusters );
244
245                    // update <child[0][1]> field in node
246                    hal_remote_s64( XPTR( node_cxy , &node_ptr->children[0][1] ), child_xp );
247
248                    // udate <arity> field in node
249                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->arity ) , 1 );
[582]250   
251                    // exit loops
252                    found = true;
253                }
[1]254            }
[582]255        }
[583]256
257        // search an active cluster in child[1][0] macro-cluster
[582]258        found = false; 
[583]259        for( x = (node_base_x +half) ; 
[582]260        (x < (node_base_x + (half<<1))) && (found == false) ; x++ )
261        {
262            for( y = node_base_y ; 
263            (y < (node_base_y + half)) && (found == false) ; y++ )
264            {
[583]265                child_cxy = HAL_CXY_FROM_XY( x , y );
266
267                if( cluster_is_active( child_cxy ) )
[582]268                {
[583]269                    // initialize recursively selected child[1][0] node
270                    dqdt_recursive_build( child_cxy , level-1 , node_xp );
[1]271
[583]272                    // build extended pointer on child[1][0] node
273                    child_xp = XPTR( child_cxy , child_ptr );
[582]274
[583]275                    // update <cores> field in node
276                    cores = hal_remote_l32( XPTR ( child_cxy , &child_ptr->cores ) );
277                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->cores ) , cores );
278
279                    // update <clusters> field in node
280                    clusters = hal_remote_l32( XPTR ( child_cxy , &child_ptr->clusters ) );
281                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->clusters ) , clusters );
282
283                    // update <child[1][0]> field in node
284                    hal_remote_s64( XPTR( node_cxy , &node_ptr->children[1][0] ), child_xp );
285
286                    // udate <arity> field in node
287                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->arity ) , 1 );
[582]288   
289                    // exit loops
290                    found = true;
291                }
[1]292            }
[582]293        }
[1]294
[583]295        // search an active cluster in child[1][1] macro-cluster
[582]296        found = false; 
297        for( x = (node_base_x + half) ; 
298        (x < (node_base_x + (half<<1))) && (found == false) ; x++ )
299        {
300            for( y = (node_base_y + half) ; 
[583]301            (y < (node_base_y + (half<<1))) && (found == false) ; y++ )
[1]302            {
[583]303                child_cxy = HAL_CXY_FROM_XY( x , y );
304
305                if( cluster_is_active( child_cxy ) )
[582]306                {
[583]307                    // initialize recursively selected child[1][1] node
308                    dqdt_recursive_build( child_cxy , level-1 , node_xp );
[582]309
[583]310                    // build extended pointer on child[1][1] node
311                    child_xp = XPTR( child_cxy , child_ptr );
[582]312
[583]313                    // update <cores> field in node
314                    cores = hal_remote_l32( XPTR ( child_cxy , &child_ptr->cores ) );
315                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->cores ) , cores );
316
317                    // update <clusters> field in node
318                    clusters = hal_remote_l32( XPTR ( child_cxy , &child_ptr->clusters ) );
319                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->clusters ) , clusters );
320
321                    // update <child[1][1]> field in node
322                    hal_remote_s64( XPTR( node_cxy , &node_ptr->children[1][1] ), child_xp );
323
324                    // udate <arity> field in node
325                    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->arity ) , 1 );
[582]326   
327                    // exit loops
328                    found = true;
329                }
[1]330            }
[582]331        }
332    }
333}  // end dqdt_recursive_build()
[1]334
[582]335//////////////////////
336void dqdt_init( void )
337{
338    // get x_size & y_size from cluster manager
339    cluster_t * cluster = &cluster_manager;
340    uint32_t    x_size  = cluster->x_size;
341    uint32_t    y_size  = cluster->y_size;
[1]342
[582]343    assert( ((x_size <= 16) && (y_size <= 16)) , "illegal mesh size\n");
344 
345    // compute level_max
346    uint32_t  x_size_ext = POW2_ROUNDUP( x_size );
347    uint32_t  y_size_ext = POW2_ROUNDUP( y_size );
348    uint32_t  size_ext   = MAX( x_size_ext , y_size_ext );
349    uint32_t  level_max  = bits_log2( size_ext );
[1]350
[582]351    // each CP0 register the DQDT root in local cluster manager
352    cluster->dqdt_root_xp = XPTR( 0 , &cluster->dqdt_tbl[level_max] );
353
354#if DEBUG_DQDT_INIT
355if( local_cxy == 0 )
356printk("\n[DBG] %s : x_size = %d / y_size = %d / level_max = %d\n",
357__FUNCTION__, x_size, y_size, level_max );
358#endif
359   
360    // only CP0 in cluster 0 call the recursive function to build the quad-tree
361    if (local_cxy == 0) dqdt_recursive_build( local_cxy , level_max , XPTR_NULL );
362
363#if DEBUG_DQDT_INIT
364if( local_cxy == 0 ) dqdt_display();
365#endif
366
367}  // end dqdt_init()
368
[583]369
[1]370///////////////////////////////////////////////////////////////////////////
[583]371// This recursive function is called by both the dqdt_increment_pages()
372// and by the dqdt_decrement_pages() functions.
[1]373// It traverses the quad tree from clusters to root.
374///////////////////////////////////////////////////////////////////////////
[438]375// @ node       : extended pointer on current node
[583]376// @ increment  : number of pages variation
[438]377///////////////////////////////////////////////////////////////////////////
[583]378static void dqdt_propagate_pages( xptr_t  node,
379                                  int32_t increment )
[1]380{
381    // get current node cluster identifier and local pointer
[438]382    cxy_t         cxy = GET_CXY( node );
383    dqdt_node_t * ptr = GET_PTR( node );
[1]384
[583]385    // update current node pages number
386    hal_remote_atomic_add( XPTR( cxy , &ptr->pages ) , increment );
[1]387
388    // get extended pointer on parent node
[564]389    xptr_t parent = (xptr_t)hal_remote_l64( XPTR( cxy , &ptr->parent ) );
[1]390
391    // propagate if required
[583]392    if ( parent != XPTR_NULL ) dqdt_propagate_pages( parent, increment );
[1]393}
394
[583]395///////////////////////////////////////////
396void dqdt_increment_pages( uint32_t order )
397{
398        cluster_t   * cluster = LOCAL_CLUSTER;
399    dqdt_node_t * node    = &cluster->dqdt_tbl[0];
400
401    // update DQDT node level 0
402    hal_atomic_add( &node->pages , (1 << order) );
403
404    // propagate to DQDT upper levels
405    if( node->parent != XPTR_NULL ) dqdt_propagate_pages( node->parent , (1 << order) );
406
407#if DEBUG_DQDT_UPDATE_PAGES
408uint32_t cycle = hal_get_cycles();
409if( cycle > DEBUG_DQDT_UPDATE_PAGES )
410printk("\n[DBG] %s : thread %x in process %x / %x pages in cluster %x / cycle %d\n",
411__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->pages, local_cxy, cycle );
412#endif
413
414}
415
416///////////////////////////////////////////
417void dqdt_decrement_pages( uint32_t order )
418{
419        cluster_t   * cluster = LOCAL_CLUSTER;
420    dqdt_node_t * node    = &cluster->dqdt_tbl[0];
421
422    // update DQDT node level 0
423    hal_atomic_add( &node->pages , -(1 << order) );
424
425    // propagate to DQDT upper levels
426    if( node->parent != XPTR_NULL ) dqdt_propagate_pages( node->parent , -(1 << order) );
427
428#if DEBUG_DQDT_UPDATE_PAGES
429uint32_t cycle = hal_get_cycles();
430if( cycle > DEBUG_DQDT_UPDATE_PAGES )
431printk("\n[DBG] %s : thread %x in process %x / %x pages in cluster %x / cycle %d\n",
432__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->pages, local_cxy, cycle );
433#endif
434
435}
436
437
438
[438]439///////////////////////////////////////////////////////////////////////////
[583]440// This recursive function is called by both the dqdt_increment_threads()
441// and by the dqdt_decrement_threads functions.
[438]442// It traverses the quad tree from clusters to root.
443///////////////////////////////////////////////////////////////////////////
444// @ node       : extended pointer on current node
445// @ increment  : number of pages variation
446///////////////////////////////////////////////////////////////////////////
[583]447static void dqdt_propagate_threads( xptr_t  node,
448                                    int32_t increment )
[1]449{
[438]450    // get current node cluster identifier and local pointer
451    cxy_t         cxy = GET_CXY( node );
452    dqdt_node_t * ptr = GET_PTR( node );
[1]453
[438]454    // update current node threads number
[583]455    hal_remote_atomic_add( XPTR( cxy , &ptr->threads ) , increment );
[1]456
[438]457    // get extended pointer on parent node
[564]458    xptr_t parent = (xptr_t)hal_remote_l64( XPTR( cxy , &ptr->parent ) );
[1]459
[438]460    // propagate if required
[583]461    if ( parent != XPTR_NULL ) dqdt_propagate_threads( parent, increment );
[1]462}
463
[583]464///////////////////////////////////
465void dqdt_increment_threads( void )
[1]466{
[438]467        cluster_t   * cluster = LOCAL_CLUSTER;
468    dqdt_node_t * node    = &cluster->dqdt_tbl[0];
[19]469
[438]470    // update DQDT node level 0
[583]471    hal_atomic_add( &node->threads , 1 );
[1]472
[438]473    // propagate to DQDT upper levels
[583]474    if( node->parent != XPTR_NULL ) dqdt_propagate_threads( node->parent , 1 );
475
476#if DEBUG_DQDT_UPDATE_THREADS
477uint32_t cycle = hal_get_cycles();
478if( cycle > DEBUG_DQDT_UPDATE_THREADS )
479printk("\n[DBG] %s : thread %x in process %x / %d threads in cluster %x / cycle %d\n",
480__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->threads, local_cxy, cycle );
481#endif
482
[1]483}
484
[583]485///////////////////////////////////
486void dqdt_decrement_threads( void )
[1]487{
[438]488        cluster_t   * cluster = LOCAL_CLUSTER;
489    dqdt_node_t * node    = &cluster->dqdt_tbl[0];
[19]490
[438]491    // update DQDT node level 0
[583]492    hal_atomic_add( &node->threads , -1 );
[1]493
[438]494    // propagate to DQDT upper levels
[583]495    if( node->parent != XPTR_NULL ) dqdt_propagate_threads( node->parent , -1 );
496
497#if DEBUG_DQDT_UPDATE_THREADS
498uint32_t cycle = hal_get_cycles();
499if( cycle > DEBUG_DQDT_UPDATE_THREADS )
500printk("\n[DBG] %s : thread %x in process %x / %d threads in cluster %x / cycle %d\n",
501__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->threads, local_cxy, cycle );
502#endif
503
[1]504}
505
[583]506
507/////////////////////////////////////////////////////////////////////////////////////
[1]508// This recursive function is called by both the dqdt_get_cluster_for_process()
[583]509// and by the dqdt_get_cluster_for_memory() functions to select the cluster with the
510// smallest number of threads per core, or the smallest number of pages per cluster.
[1]511// It traverses the quad tree from root to clusters.
[583]512/////////////////////////////////////////////////////////////////////////////////////
[1]513static cxy_t dqdt_select_cluster( xptr_t node,
514                                  bool_t for_memory )
515{
516    dqdt_node_t   node_copy;     // local copy of the current DQDT node
[582]517    xptr_t        child_xp;      // extended pointer on a DQDT child node
518    uint32_t      x;             // child node X coordinate
519    uint32_t      y;             // child node Y coordinate
520    uint32_t      select_x;      // selected child X coordinate
521    uint32_t      select_y;      // selected child Y coordinate
[1]522    uint32_t      load;          // load of the child (threads or pages)
523    uint32_t      load_min;      // current value of the minimal load
524
525    // get DQDT node local copy
526    hal_remote_memcpy( XPTR( local_cxy , &node_copy ), node , sizeof(dqdt_node_t) );
527
528    // return cluster identifier for a terminal mode
529    if( node_copy.level == 0 ) return GET_CXY(node);
530
531    // analyse load for all children in non terminal node
532    load_min = 0xFFFFFFFF;
[582]533    select_x = 0;
534    select_y = 0;
535    for( x = 0 ; x < 2 ; x++ )
[1]536    {
[582]537        for( y = 0 ; y < 2 ; y++ )
[1]538        {
[582]539            child_xp = node_copy.children[x][y];
540            if( child_xp != XPTR_NULL )
[1]541            {
[582]542                cxy_t         cxy  = GET_CXY( child_xp );
543                dqdt_node_t * ptr  = GET_PTR( child_xp );
[583]544
545                // compute average load  for each child
546                if( for_memory )
[582]547                {
[583]548                    load = hal_remote_l32( XPTR( cxy , &ptr->pages ) ) /
549                           hal_remote_l32( XPTR( cxy , &ptr->clusters ) );
550                }
551                else
552                {
553                    load = hal_remote_l32( XPTR( cxy , &ptr->threads ) ) /
554                           hal_remote_l32( XPTR( cxy , &ptr->cores ) );
555                }
556
557                // select children with smallest load
558                if( load <= load_min )
559                {
[582]560                    load_min = load;
561                    select_x = x;
562                    select_y = y;
563                }
[19]564            }
[1]565        }
566    }
567
568    // select the child with the lowest load
[582]569    return dqdt_select_cluster( node_copy.children[select_x][select_y], for_memory );
[1]570
[583]571}  // end dqdt_select_cluster()
572
573
[564]574//////////////////////////////////////////
[485]575cxy_t dqdt_get_cluster_for_process( void )
[1]576{
577    // call recursive function
[583]578    cxy_t cxy = dqdt_select_cluster( LOCAL_CLUSTER->dqdt_root_xp , false );
579
580#if DEBUG_DQDT_SELECT_FOR_PROCESS
581uint32_t cycle = hal_get_cycles();
582if( cycle > DEBUG_DQDT_SELECT_FOR_PROCESS )
583printk("\n[DBG] %s : thread %x in process %x select cluster %x / cycle %d\n",
584__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cxy, cycle );
585#endif
586
587    return cxy;
[1]588}
589
[564]590/////////////////////////////////////////
[485]591cxy_t dqdt_get_cluster_for_memory( void )
[1]592{
593    // call recursive function
[583]594    cxy_t cxy = dqdt_select_cluster( LOCAL_CLUSTER->dqdt_root_xp , true );
595
596#if DEBUG_DQDT_SELECT_FOR_MEMORY
597uint32_t cycle = hal_get_cycles();
598if( cycle > DEBUG_DQDT_SELECT_FOR_MEMORY )
599printk("\n[DBG] %s : thread %x in process %x select cluster %x / cycle %d\n",
600__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cxy, cycle );
601#endif
602
603    return cxy;
[1]604}
605
Note: See TracBrowser for help on using the repository browser.