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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.