Ignore:
Timestamp:
Jul 18, 2019, 2:06:55 PM (5 years ago)
Author:
alain
Message:

Introduce the non-standard pthread_parallel_create() system call
and re-write the <fft> and <sort> applications to improve the
intrinsic paralelism in applications.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/dqdt.c

    r632 r637  
    22 * dqdt.c - Distributed Quaternary Decision Tree implementation.
    33 *
    4  * Author : Alain Greiner (2016,2017,2018)
     4 * Author : Alain Greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
     
    5555
    5656    // 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 ) );
    5962
    6063    // recursive call on children if node is not terminal
     
    116119                                  xptr_t   parent_xp )
    117120{
    118     assert( (level < 5) , __FUNCTION__, "illegal DQDT level %d\n", level );
     121    assert( (level <= 5) , __FUNCTION__, "illegal DQDT level %d\n", level );
    119122 
    120123    uint32_t node_x;         // node X coordinate
     
    147150
    148151#if DEBUG_DQDT_INIT
    149 printk("\n[DBG] %s : cxy(%d,%d) / level %d / mask %x / half %d / ptr %x\n",
     152printk("\n[%s] thread[%x,%x] : cxy(%d,%d) / level %d / mask %x / half %d / ptr %x\n",
    150153__FUNCTION__, node_x, node_y, level, mask, half, node_ptr );
    151154#endif
     
    336339void dqdt_init( void )
    337340{
    338     // get x_size & y_size from cluster manager
    339     cluster_t * cluster = &cluster_manager;
     341    // get x_size & y_size
     342    cluster_t * cluster = LOCAL_CLUSTER;
    340343    uint32_t    x_size  = cluster->x_size;
    341344    uint32_t    y_size  = cluster->y_size;
     
    349352    uint32_t  level_max  = bits_log2( size_ext );
    350353
    351     // each CP0 register the DQDT root in local cluster manager
     354    // all CP0s register the DQDT root in local cluster manager
    352355    cluster->dqdt_root_xp = XPTR( 0 , &cluster->dqdt_tbl[level_max] );
    353356
     357    // only CP0 in cluster 0 build the DQDT
     358    if( local_cxy == 0 )
     359    {
     360
    354361#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 );
     362thread_t * this = CURRENT_THREAD;
     363printk("\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 );
    358365#endif
    359366   
     
    362369
    363370#if DEBUG_DQDT_INIT
    364 if( local_cxy == 0 ) dqdt_display();
    365 #endif
    366 
     371dqdt_display();
     372#endif
     373
     374    }
    367375}  // end dqdt_init()
    368376
     
    516524}
    517525
     526///////////////////////////////////
     527xptr_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
     535assert( (level <= 5) , __FUNCTION__, "illegal DQDT level %d\n", level );
     536
     537#if DEBUG_DQDT_GET_ROOT
     538thread_t * this = CURRENT_THREAD;
     539printk("\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
     566printk("\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}
    518573
    519574/////////////////////////////////////////////////////////////////////////////////////
     
    584639
    585640
    586 //////////////////////////////////////////
    587 cxy_t dqdt_get_cluster_for_process( void )
     641///////////////////////////////////////////////////
     642cxy_t dqdt_get_cluster_for_thread( xptr_t root_xp )
    588643{
    589644    // call recursive function
    590     cxy_t cxy = dqdt_select_cluster( LOCAL_CLUSTER->dqdt_root_xp , false );
    591 
    592 #if DEBUG_DQDT_SELECT_FOR_PROCESS
     645    cxy_t cxy = dqdt_select_cluster( root_xp , false );
     646
     647#if DEBUG_DQDT_SELECT_FOR_THREAD
    593648uint32_t cycle = hal_get_cycles();
    594649if( cycle > DEBUG_DQDT_SELECT_FOR_PROCESS )
     
    600655}
    601656
    602 /////////////////////////////////////////
    603 cxy_t dqdt_get_cluster_for_memory( void )
     657///////////////////////////////////////////////////
     658cxy_t dqdt_get_cluster_for_memory( xptr_t root_xp )
    604659{
    605660    // 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 );
    607662
    608663#if DEBUG_DQDT_SELECT_FOR_MEMORY
Note: See TracChangeset for help on using the changeset viewer.