Ejemplo n.º 1
0
void timer_intr(void)
{
  timer_systime_counter.low++;
  if(timer_systime_counter.low >= TIMER_SYSTIME_LOW_RESO) {
    timer_systime_counter.high++;
    timer_systime_counter.low = 0;
  }

  pic_eoi(PIC_IRQ_TIMER);	/* notify "Reception completion" to PIC */
/*
{
  static char i=0;
  int pos;
  char s[4];
  byte2hex(i,s);
  i++;
  pos = console_getpos();
  console_locatepos(77,0);
  console_puts(s);
  console_putpos(pos);
}
*/
  alarm_check();

  task_tick();
  task_dispatch();

  return;
}
Ejemplo n.º 2
0
Archivo: kernel.c Proyecto: wuxx/sos
PUBLIC s32 os_sleep(u32 ms)
{

    u32 ticks = (ms * OS_HZ) / 1000;
    current_task->sleep_ticks = ticks;

    current_task->state = TASK_SLEEP;
    task_dispatch();
    return 0;
}
Ejemplo n.º 3
0
Archivo: kernel.c Proyecto: wuxx/sos
PRIVATE void os_clock_irq_hook(struct cpu_context *ctx)
{
    struct __os_task__ *best_task;

    os_tick ++ ;
    
    os_sleep_expire();

    best_task = get_best_task();
    if (best_task == NULL) {
        kassert(current_task == &tcb[IDLE_TASK_ID]);
    } else if (best_task->prio <= current_task->prio) {
        current_task->state = TASK_READY;
        task_dispatch();
    }
}
int main(void){

    init_devices();
    //
    //  start at least one task here
    //
    set_task(7);    //task7 runs
    set_task(6);    //task6 runs
    //      main loop 
    while(1){
        if (tick_flag){
            tick_flag = 0;
            task_dispatch();              // well.... 
        }
    }
    return 0;
}
Ejemplo n.º 5
0
   bool MTFloatRun(Node * node)
   {
        std::vector<sub_op_task> task_list;

        for(int i=0;i<cpu_info->GetCPUNumber()*2;i++)
        {
           sub_op_task task;
           task.exec_func=std::bind(&DemoOps::FloatAider,this,std::placeholders::_1,
                                    std::placeholders::_2,std::placeholders::_3);
           task.seq=i;
           task.data=(void *)((unsigned long)i);

           task_list.push_back(task);
        }

        task_dispatch(task_list,-1);

        wait_done();     

        return true;
   }
Ejemplo n.º 6
0
bool Run(Node * node)
{
    const Tensor * input_tensor=node->GetInputTensor(0);
    Tensor * output_tensor=node->GetOutputTensor(0);

    const TShape&  shape=input_tensor->GetShape();

    const std::vector<int> dims=shape.GetDim();

    int batch_number=dims[0];
    int channel_num=dims[1];
    int channel_size=dims[2]*dims[3];

    Tensor * gamma_tensor=node->GetInputTensor(1);
    Tensor * beta_tensor=node->GetInputTensor(2);
    Tensor * mean_tensor=node->GetInputTensor(3);
    Tensor * var_tensor=node->GetInputTensor(4);


    float * gamma=(float *)get_tensor_mem(gamma_tensor);
    float * beta=(float *)get_tensor_mem(beta_tensor);
    float * mean=(float *)get_tensor_mem(mean_tensor);
    float * var=(float *)get_tensor_mem(var_tensor);

    const float * input=(const float *)get_tensor_mem(input_tensor);
    float * output=(float *)get_tensor_mem(output_tensor);

   int  cpu_number=cpu_info->GetCPUNumber();

    for(int i=0;i<batch_number;i++)
    {

       if(cpu_number==1)
       {
           bn_scale_relu_neon(input,gamma,beta,mean,var,channel_num,channel_size,output);
           input+=channel_size*channel_num;
           output+=channel_size*channel_num;
       }
       else
       {
            std::vector<sub_op_task> task_list;
            std::vector<BNParam> param_list;

            auto f=std::bind(&FusedOps::Aider,this,std::placeholders::_1,
                                std::placeholders::_2,std::placeholders::_3);

            int step=(channel_num+(cpu_number-1))/cpu_number;

            if(channel_num-(cpu_number-1)*step<=0)
                  step=channel_num/cpu_number;

            task_list.resize(cpu_number);
            param_list.resize(cpu_number);

            for(int i=0;i<cpu_number;i++)
            {
                 BNParam * param=&param_list[i];   
                 sub_op_task * task=&task_list[i];

                 task->exec_func=f;
                 task->seq=i;
                 task->data=param;

                 param->input=input;
                 param->gamma=gamma;
                 param->beta=beta;
                 param->mean=mean;
                 param->var=var;

                 param->channel_num=step;
                 param->channel_size=channel_size;
                 param->output=output;

                 input+=channel_size*step;
                 output+=channel_size*step;

                 gamma+=step;
                 beta+=step;
                 mean+=step;
                 var+=step;
            }

            param_list[cpu_number-1].channel_num=channel_num-(cpu_number-1)*step;

            task_dispatch(task_list,-1);
            wait_done();
       }

/*
       the c code of assembly code

        for(int c=0;c<channel_num;c++)
        {
           float s_mean=mean[c];
           float s_var=var[c];
           float s_gamma=gamma[c];
           float s_beta=beta[c];

           for(int l=0;l<channel_size;l++)
           {
              float data=input[l];
              data=data*s_var+s_mean;

              data=data*s_gamma+s_beta;

              if(data<0.0)
                  data=0;

              output[l]=data;
           }

           input+=channel_size;
           output+=channel_size;
        }

*/
    }
    

    return true;

}