Changeset 428


Ignore:
Timestamp:
Oct 4, 2014, 3:19:32 PM (10 years ago)
Author:
alain
Message:

Introducing fixed format (X_WIDTH / Y_WIDTH / P_WIDTH) for processor index.

Location:
soft/giet_vm/giet_kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_kernel/ctx_handler.c

    r391 r428  
    3333{
    3434    unsigned int gpid       = _get_procid();
    35     unsigned int cluster_xy = gpid / NB_PROCS_MAX;
    36     unsigned int lpid       = gpid % NB_PROCS_MAX;
     35    unsigned int cluster_xy = gpid >> P_WIDTH;
     36    unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
    3737
    3838    // get scheduler address
     
    104104{
    105105    unsigned int gpid       = _get_procid();
    106     unsigned int cluster_xy = gpid / NB_PROCS_MAX;
    107     unsigned int lpid       = gpid % NB_PROCS_MAX;
     106    unsigned int cluster_xy = gpid >> P_WIDTH;
    108107    unsigned int x          = cluster_xy >> Y_WIDTH;
    109108    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
     109    unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
    110110
    111111    while(1)
  • soft/giet_vm/giet_kernel/exc_handler.c

    r294 r428  
    7272{
    7373    unsigned int gpid       = _get_procid();
    74     unsigned int cluster_xy = gpid / NB_PROCS_MAX;
    75     unsigned int lpid       = gpid % NB_PROCS_MAX;
     74    unsigned int cluster_xy = gpid >> P_WIDTH;
    7675    unsigned int x          = cluster_xy >> Y_WIDTH;
    7776    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
     77    unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
     78
    7879    unsigned int task       = _get_context_slot(CTX_LTID_ID);
    7980
  • soft/giet_vm/giet_kernel/irq_handler.c

    r346 r428  
    5151{
    5252    unsigned int gpid           = _get_procid();
    53     unsigned int cluster_xy     = gpid / NB_PROCS_MAX;
     53    unsigned int cluster_xy     = gpid >> P_WIDTH;
    5454    unsigned int x              = cluster_xy >> Y_WIDTH;
    5555    unsigned int y              = cluster_xy & ((1<<Y_WIDTH)-1);
    56     unsigned int lpid           = gpid % NB_PROCS_MAX;
     56    unsigned int lpid           = gpid & ((1<<P_WIDTH)-1);
    5757    unsigned int irq_id;
    5858    unsigned int irq_type;
     
    144144{
    145145    unsigned int gpid       = _get_procid();
    146     unsigned int cluster_xy = gpid / NB_PROCS_MAX;
     146    unsigned int cluster_xy = gpid >> P_WIDTH;
    147147    unsigned int x          = cluster_xy >> Y_WIDTH;
    148148    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    149     unsigned int lpid       = gpid % NB_PROCS_MAX;
     149    unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
    150150
    151151    _printf("\n[GIET WARNING] IRQ handler called but no active IRQ "
     
    164164                 unsigned int channel )   // unused
    165165{
    166     unsigned int procid     = _get_procid();
    167     unsigned int cluster_xy = procid / NB_PROCS_MAX;
     166    unsigned int gpid       = _get_procid();
     167    unsigned int cluster_xy = gpid >> P_WIDTH;
    168168    unsigned int x          = cluster_xy >> Y_WIDTH;
    169169    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    170     unsigned int lpid       = procid % NB_PROCS_MAX;
     170    unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
     171
    171172    unsigned int task       = _get_current_task_id();
    172173    unsigned int value;
     
    219220                unsigned int channel )   // channel index if HWI
    220221{
    221     unsigned int procid     = _get_procid();
    222     unsigned int cluster_xy = procid / NB_PROCS_MAX;
     222    unsigned int gpid       = _get_procid();
     223    unsigned int cluster_xy = gpid >> P_WIDTH;
    223224
    224225    // acknowledge HWI or PTI
     
    229230unsigned int x          = cluster_xy >> Y_WIDTH;
    230231unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    231 unsigned int lpid       = procid % NB_PROCS_MAX;
     232unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
    232233_puts("\n[IRQS DEBUG] Processor[");
    233234_putd( x );
  • soft/giet_vm/giet_kernel/kernel_init.c

    r410 r428  
    133133
    134134__attribute__((section (".kdata")))
    135 volatile static_scheduler_t* _schedulers[NB_PROCS_MAX<<(X_WIDTH+Y_WIDTH)];
     135volatile static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX];
    136136
    137137////////////////////////////////////////////////////////////////////////////////////
     
    140140
    141141__attribute__((section (".kdata")))
    142 volatile unsigned int _init_barrier = 0;
     142volatile unsigned int kernel_init_barrier = 0;
    143143
    144144///////////////////////////////////////////////////////////////////////////////////
    145145__attribute__((section (".kinit"))) void kernel_init()
    146146{
    147     unsigned int global_pid = _get_procid();
    148     unsigned int cluster_xy = global_pid / NB_PROCS_MAX;
    149     unsigned int x          = cluster_xy >> Y_WIDTH;
     147    // gpid : hardware processor index (fixed format: X_WIDTH|Y_WIDTH|P_WIDTH)
     148    // lpid : local processor id in a cluster ( lpid < NB_PROCS_MAX)
     149    // cpid : "continuous" processor index = (((x * Y_SIZE + y) * NB_PROCS_MAX) + p
     150
     151    unsigned int gpid       = _get_procid();
     152    unsigned int cluster_xy = gpid >> P_WIDTH;
     153    unsigned int x          = cluster_xy >> Y_WIDTH & ((1<<X_WIDTH)-1);
    150154    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    151     unsigned int lpid       = global_pid % NB_PROCS_MAX;
    152     unsigned int pid        = ((( x * Y_SIZE) + y) * NB_PROCS_MAX) + lpid;
    153 
    154     // This last initialisation phase is done sequencially:
    155     while( pid != _init_barrier ) asm volatile ( "nop" );
     155    unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
     156    unsigned int cpid       = ((( x * Y_SIZE) + y) * NB_PROCS_MAX) + lpid;
     157
     158
     159    // This initialisation is done sequencially by each processor
     160    while( cpid != kernel_init_barrier ) asm volatile ( "nop" );
    156161
    157162    // Step 1 : each processor get its scheduler virtual address from CP0 register
     
    161166    unsigned int        tasks      = psched->tasks;
    162167
    163     _schedulers[global_pid] = psched;
     168    _schedulers[x][y][lpid] = psched;
    164169
    165170#if GIET_DEBUG_INIT
     
    183188    for (ltid = 0; ltid < tasks; ltid++)
    184189    {
    185         unsigned int vsid = _get_task_slot( global_pid, ltid , CTX_VSID_ID );
    186         unsigned int ptab = _get_task_slot( global_pid, ltid , CTX_PTAB_ID );
    187         unsigned int ptpr = _get_task_slot( global_pid, ltid , CTX_PTPR_ID );
     190        unsigned int vsid = _get_task_slot( x, y, lpid, ltid , CTX_VSID_ID );
     191        unsigned int ptab = _get_task_slot( x, y, lpid, ltid , CTX_PTAB_ID );
     192        unsigned int ptpr = _get_task_slot( x, y, lpid, ltid , CTX_PTPR_ID );
    188193
    189194        // initialize PTABS arrays
     
    204209        // compute ctx_ra
    205210        unsigned int ctx_ra = (unsigned int)(&_ctx_eret);
    206         _set_task_slot( global_pid, ltid, CTX_RA_ID, ctx_ra );
     211        _set_task_slot( x, y, lpid, ltid, CTX_RA_ID, ctx_ra );
    207212
    208213        // compute ctx_epc
    209         unsigned int* ptr = (unsigned int*)_get_task_slot( global_pid, ltid, CTX_EPC_ID );
    210         _set_task_slot( global_pid, ltid, CTX_EPC_ID, *ptr );
     214        unsigned int* ptr = (unsigned int*)_get_task_slot( x, y, lpid, ltid, CTX_EPC_ID );
     215        _set_task_slot( x, y, lpid, ltid, CTX_EPC_ID, *ptr );
    211216
    212217#if GIET_DEBUG_INIT
     
    215220        " - ctx_ra    = %x\n",
    216221        x, y, lpid, ltid,
    217         _get_task_slot( global_pid, ltid, CTX_EPC_ID ),
    218         _get_task_slot( global_pid, ltid, CTX_RA_ID ) );
     222        _get_task_slot( x, y, lpid, ltid, CTX_EPC_ID ),
     223        _get_task_slot( x, y, lpid, ltid, CTX_RA_ID ) );
    219224#endif
    220225
     
    297302    unsigned int pstack = ((unsigned int)psched) + 0x2000;
    298303
    299     _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_SP_ID,  pstack);
    300     _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_RA_ID,  (unsigned int) &_ctx_eret);
    301     _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_EPC_ID, (unsigned int) &_idle_task);
     304    _set_task_slot( x, y, lpid, IDLE_TASK_INDEX, CTX_SP_ID,  pstack);
     305    _set_task_slot( x, y, lpid, IDLE_TASK_INDEX, CTX_RA_ID,  (unsigned int) &_ctx_eret);
     306    _set_task_slot( x, y, lpid, IDLE_TASK_INDEX, CTX_EPC_ID, (unsigned int) &_idle_task);
    302307
    303308#if GIET_DEBUG_INIT
     
    326331    }
    327332
    328     unsigned int sp_value   = _get_task_slot(global_pid, ltid, CTX_SP_ID);
    329     unsigned int sr_value   = _get_task_slot(global_pid, ltid, CTX_SR_ID);
    330     unsigned int ptpr_value = _get_task_slot(global_pid, ltid, CTX_PTPR_ID);
    331     unsigned int epc_value  = _get_task_slot(global_pid, ltid, CTX_EPC_ID);
     333    unsigned int sp_value   = _get_task_slot( x, y, lpid, ltid, CTX_SP_ID);
     334    unsigned int sr_value   = _get_task_slot( x, y, lpid, ltid, CTX_SR_ID);
     335    unsigned int ptpr_value = _get_task_slot( x, y, lpid, ltid, CTX_PTPR_ID);
     336    unsigned int epc_value  = _get_task_slot( x, y, lpid, ltid, CTX_EPC_ID);
    332337
    333338#if GIET_DEBUG_INIT
     
    337342
    338343    // increment barrier counter
    339     _init_barrier++;
     344    kernel_init_barrier++;
    340345
    341346    // busy waiting until all processors synchronized
    342     while ( _init_barrier != NB_TOTAL_PROCS );
     347    while ( kernel_init_barrier != NB_TOTAL_PROCS );
    343348
    344349#if GIET_DEBUG_INIT
  • soft/giet_vm/giet_kernel/sys_handler.c

    r410 r428  
    3535const void * _syscall_vector[64] =
    3636{
    37     &_get_procid,          /* 0x00 */
     37    &_proc_xyp,            /* 0x00 */
    3838    &_get_proctime,        /* 0x01 */
    3939    &_tty_write,           /* 0x02 */
     
    113113}
    114114
     115//////////////////////////////////////////////////////////////////////////////
     116// This function returns the processor (x,y,p) identifiers.
     117//////////////////////////////////////////////////////////////////////////////
     118void _proc_xyp( unsigned int* x,
     119                unsigned int* y,
     120                unsigned int* p )
     121{
     122    unsigned int gpid = _get_procid();  // global processor index from CPO register
     123
     124    *x = (gpid >> (Y_WIDTH + P_WIDTH)) & ((1<<X_WIDTH)-1);
     125    *y = (gpid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
     126    *p = gpid & ((1<<P_WIDTH)-1);
     127}
    115128////////////////////////////////////////////////////////////////////////////
    116129// Task suicide... after printing a death message.
     
    119132{
    120133    unsigned int date       = _get_proctime();
    121     unsigned int proc_id    = _get_procid();
    122     unsigned int cluster_xy = proc_id / NB_PROCS_MAX;
     134
     135    unsigned int gpid       = _get_procid();
     136    unsigned int cluster_xy = gpid >> P_WIDTH;
    123137    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    124138    unsigned int x          = cluster_xy >> Y_WIDTH;
    125     unsigned int lpid       = proc_id % NB_PROCS_MAX;
     139    unsigned int lpid       = gpid & ((1<<P_WIDTH)-1);
     140
    126141    unsigned int task_id    = _get_context_slot(CTX_LTID_ID);
    127142
  • soft/giet_vm/giet_kernel/sys_handler.h

    r396 r428  
    2020
    2121void         _sys_ukn();
     22
     23void         _proc_xyp( unsigned int* x,
     24                        unsigned int* y,
     25                        unsigned int* p );
    2226
    2327void         _task_exit();
Note: See TracChangeset for help on using the changeset viewer.