Changeset 637 for trunk/kernel/kern/dqdt.c
- Timestamp:
- Jul 18, 2019, 2:06:55 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/dqdt.c
r632 r637 2 2 * dqdt.c - Distributed Quaternary Decision Tree implementation. 3 3 * 4 * Author : Alain Greiner (2016,2017,2018 )4 * Author : Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 55 55 56 56 // display node content 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 ); 57 nolock_printk("- [%d,%x] : threads %x / pages %x / clusters %d / cores %d / parent_cxy %x\n", 58 node.level, GET_CXY( node_xp ), 59 node.threads, node.pages, 60 node.clusters, node.cores, 61 GET_CXY( node.parent ) ); 59 62 60 63 // recursive call on children if node is not terminal … … 116 119 xptr_t parent_xp ) 117 120 { 118 assert( (level < 5) , __FUNCTION__, "illegal DQDT level %d\n", level );121 assert( (level <= 5) , __FUNCTION__, "illegal DQDT level %d\n", level ); 119 122 120 123 uint32_t node_x; // node X coordinate … … 147 150 148 151 #if DEBUG_DQDT_INIT 149 printk("\n[ DBG] %s: cxy(%d,%d) / level %d / mask %x / half %d / ptr %x\n",152 printk("\n[%s] thread[%x,%x] : cxy(%d,%d) / level %d / mask %x / half %d / ptr %x\n", 150 153 __FUNCTION__, node_x, node_y, level, mask, half, node_ptr ); 151 154 #endif … … 336 339 void dqdt_init( void ) 337 340 { 338 // get x_size & y_size from cluster manager339 cluster_t * cluster = &cluster_manager;341 // get x_size & y_size 342 cluster_t * cluster = LOCAL_CLUSTER; 340 343 uint32_t x_size = cluster->x_size; 341 344 uint32_t y_size = cluster->y_size; … … 349 352 uint32_t level_max = bits_log2( size_ext ); 350 353 351 // each CP0register the DQDT root in local cluster manager354 // all CP0s register the DQDT root in local cluster manager 352 355 cluster->dqdt_root_xp = XPTR( 0 , &cluster->dqdt_tbl[level_max] ); 353 356 357 // only CP0 in cluster 0 build the DQDT 358 if( local_cxy == 0 ) 359 { 360 354 361 #if DEBUG_DQDT_INIT 355 if( local_cxy == 0 ) 356 printk("\n[ DBG] %s : x_size = %d / y_size = %d / level_max = %d\n",357 __FUNCTION__, x_size, y_size, level_max );362 thread_t * this = CURRENT_THREAD; 363 printk("\n[%s] thread[%x,%x] enters : x_size = %d / y_size = %d / level_max = %d\n", 364 __FUNCTION__, this->process->pid, this->trdid, x_size, y_size, level_max ); 358 365 #endif 359 366 … … 362 369 363 370 #if DEBUG_DQDT_INIT 364 if( local_cxy == 0 ) dqdt_display(); 365 #endif 366 371 dqdt_display(); 372 #endif 373 374 } 367 375 } // end dqdt_init() 368 376 … … 516 524 } 517 525 526 /////////////////////////////////// 527 xptr_t dqdt_get_root( cxy_t cxy, 528 uint32_t level ) 529 { 530 xptr_t node_xp; 531 cxy_t node_cxy; 532 dqdt_node_t * node_ptr; 533 uint32_t current_level; 534 535 assert( (level <= 5) , __FUNCTION__, "illegal DQDT level %d\n", level ); 536 537 #if DEBUG_DQDT_GET_ROOT 538 thread_t * this = CURRENT_THREAD; 539 printk("\n[%s] thread[%x,%x] enters / cxy %x / level %d\n", 540 __FUNCTION__, this->process->pid, this->trdid, cxy, level ); 541 #endif 542 543 // check macro-cluster 544 if( cluster_is_active( cxy ) ) 545 { 546 // initialise node_xp and current_level 547 node_xp = XPTR( cxy , &LOCAL_CLUSTER->dqdt_tbl[0] ); 548 current_level = 0; 549 550 // traverse the quad-tree from bottom to root 551 while( current_level < level ) 552 { 553 node_cxy = GET_CXY( node_xp ); 554 node_ptr = GET_PTR( node_xp ); 555 556 node_xp = hal_remote_l64( XPTR( node_cxy , &node_ptr->parent ) ); 557 current_level++; 558 } 559 } 560 else 561 { 562 node_xp = XPTR_NULL; 563 } 564 565 #if DEBUG_DQDT_GET_ROOT 566 printk("\n[%s] thread[%x,%x] exit / root_xp[%x,%x]\n", 567 __FUNCTION__, this->process->pid, this->trdid, GET_CXY( node_xp ), GET_PTR( node_xp ) ); 568 #endif 569 570 return node_xp; 571 572 } 518 573 519 574 ///////////////////////////////////////////////////////////////////////////////////// … … 584 639 585 640 586 ////////////////////////////////////////// 587 cxy_t dqdt_get_cluster_for_ process( void)641 /////////////////////////////////////////////////// 642 cxy_t dqdt_get_cluster_for_thread( xptr_t root_xp ) 588 643 { 589 644 // call recursive function 590 cxy_t cxy = dqdt_select_cluster( LOCAL_CLUSTER->dqdt_root_xp , false );591 592 #if DEBUG_DQDT_SELECT_FOR_ PROCESS645 cxy_t cxy = dqdt_select_cluster( root_xp , false ); 646 647 #if DEBUG_DQDT_SELECT_FOR_THREAD 593 648 uint32_t cycle = hal_get_cycles(); 594 649 if( cycle > DEBUG_DQDT_SELECT_FOR_PROCESS ) … … 600 655 } 601 656 602 ///////////////////////////////////////// 603 cxy_t dqdt_get_cluster_for_memory( void)657 /////////////////////////////////////////////////// 658 cxy_t dqdt_get_cluster_for_memory( xptr_t root_xp ) 604 659 { 605 660 // call recursive function 606 cxy_t cxy = dqdt_select_cluster( LOCAL_CLUSTER->dqdt_root_xp , true );661 cxy_t cxy = dqdt_select_cluster( root_xp , true ); 607 662 608 663 #if DEBUG_DQDT_SELECT_FOR_MEMORY
Note: See TracChangeset
for help on using the changeset viewer.