Ignore:
Timestamp:
Jul 18, 2019, 2:06:55 PM (3 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/cluster.c

    r635 r637  
    7676
    7777    // initialize the cluster_info[][] array
    78     for (x = 0; x < CONFIG_MAX_CLUSTERS_X; x++)
    79     {
    80         for (y = 0; y < CONFIG_MAX_CLUSTERS_Y;y++)
     78    for( x = 0 ; x < CONFIG_MAX_CLUSTERS_X ; x++ )
     79    {
     80        for( y = 0; y < CONFIG_MAX_CLUSTERS_Y ; y++ )
    8181        {
    8282            cluster->cluster_info[x][y] = info->cluster_info[x][y];
     
    9595    }
    9696
    97     // initialize number of cores
     97    // initialize number of local cores
    9898        cluster->cores_nr  = info->cores_nr;
    9999
    100100}  // end cluster_info_init()
     101
     102//////////////////////////////////////
     103void cluster_info_display( cxy_t cxy )
     104{
     105    uint32_t  x;
     106    uint32_t  y;
     107    uint32_t  ncores;
     108
     109    cluster_t * cluster = LOCAL_CLUSTER;
     110
     111    // get x_size & y_size from target cluster
     112    uint32_t  x_size = hal_remote_l32( XPTR( cxy , &cluster->x_size ) );
     113    uint32_t  y_size = hal_remote_l32( XPTR( cxy , &cluster->y_size ) );
     114
     115    // get pointers on TXT0 chdev
     116    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
     117    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     118    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     119
     120    // get extended pointer on remote TXT0 lock
     121    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     122
     123    // get TXT0 lock
     124    remote_busylock_acquire( lock_xp );
     125
     126    nolock_printk("\n***** cluster_info in cluster %x / x_size %d / y_size %d\n",
     127    cxy, x_size, y_size );
     128 
     129    for( x = 0 ; x < x_size ; x++ )
     130    {
     131        for( y = 0 ; y < y_size ; y++ )
     132        {
     133            ncores = (uint32_t)hal_remote_lb( XPTR( cxy , &cluster->cluster_info[x][y] ) );
     134            nolock_printk(" - ncores[%d][%d] = %d\n", x, y, ncores );
     135        }
     136    }
     137
     138    // release TXT0 lock
     139    remote_busylock_release( lock_xp );
     140
     141}  // end cluster_info_display()
    101142
    102143/////////////////////////////////////////////////////////
     
    115156printk("\n[%s] thread[%x,%x] enters for cluster %x / cycle %d\n",
    116157__FUNCTION__, this->process->pid, this->trdid, local_cxy , cycle );
     158#endif
     159
     160#if (DEBUG_CLUSTER_INIT & 1)
     161cluster_info_display( local_cxy );
    117162#endif
    118163
     
    243288}
    244289
    245 ////////////////////////////////////////
    246 bool_t cluster_is_undefined( cxy_t cxy )
    247 {
    248     uint32_t  x_size = LOCAL_CLUSTER->x_size;
    249     uint32_t  y_size = LOCAL_CLUSTER->y_size;
    250 
    251     uint32_t  x      = HAL_X_FROM_CXY( cxy );
    252     uint32_t  y      = HAL_Y_FROM_CXY( cxy );
    253 
    254     if( x >= x_size ) return true;
    255     if( y >= y_size ) return true;
    256 
    257     return false;
    258 }
    259 
    260 //////////////////////////////////////
    261 bool_t cluster_is_active ( cxy_t cxy )
     290/////////////////////////////////////////////
     291inline bool_t cluster_is_active ( cxy_t cxy )
    262292{
    263293    uint32_t x = HAL_X_FROM_CXY( cxy );
     
    271301////////////////////////////////////////////////////////////////////////////////////
    272302
    273 ///////////////////////////////////////
    274 lid_t cluster_select_local_core( void )
    275 {
    276     uint32_t      min = 1000;
     303/////////////////////////////////////////////
     304lid_t cluster_select_local_core( cxy_t  cxy )
     305{
     306    uint32_t      min = 1000000;
    277307    lid_t         sel = 0;
    278308    uint32_t      nthreads;
    279309    lid_t         lid;
    280310    scheduler_t * sched;
    281 
    282     cluster_t * cluster = LOCAL_CLUSTER;
    283 
    284     for( lid = 0 ; lid < cluster->cores_nr ; lid++ )
    285     {
    286         sched    = &cluster->core_tbl[lid].scheduler;
    287         nthreads = sched->u_threads_nr + sched->k_threads_nr;
     311    cluster_t   * cluster = LOCAL_CLUSTER;
     312    uint32_t      ncores = hal_remote_l32( XPTR( cxy , &cluster->cores_nr ) );
     313
     314    for( lid = 0 ; lid < ncores ; lid++ )
     315    {
     316        sched  = &cluster->core_tbl[lid].scheduler;
     317
     318        nthreads = hal_remote_l32( XPTR( cxy , &sched->u_threads_nr ) ) +
     319                   hal_remote_l32( XPTR( cxy , &sched->k_threads_nr ) );
    288320
    289321        if( nthreads < min )
     
    700732    uint32_t      pref_nr;       // number of owned processes in cluster cxy
    701733
    702 assert( (cluster_is_undefined( cxy ) == false), "illegal cluster index" );
     734assert( (cluster_is_active( cxy ) ), "illegal cluster index" );
    703735
    704736    // get extended pointer on root and lock for local process list in cluster
Note: See TracChangeset for help on using the changeset viewer.