Exemplo n.º 1
0
static void testBasic(void)
{
  lpel_config_t cfg;
  int i;
  lpel_task_t *trelay, *tcons, *intask;

  memset(&cfg, 0, sizeof(lpel_config_t));
  cfg.num_workers = 2;
  cfg.proc_workers = 2;
  cfg.proc_others = 0;
  cfg.flags = 0;

  LpelInit(&cfg);

  /* create streams */
  sinp = LpelStreamCreate(0);
  for (i=0; i<NUM_COLL; i++) {
    scoll[i] = LpelStreamCreate(0);
  }

  /* create tasks */
  trelay = LpelTaskCreate( 0, 0, Relay, NULL, 8192);
  LpelTaskRun(trelay);

  tcons = LpelTaskCreate( 1, 0, Consumer, NULL, 8192);
  LpelTaskRun(tcons);


  intask = LpelTaskCreate( -1, 0, Inputter, sinp, 8192);
  LpelTaskRun(intask);

  LpelStart();

  LpelCleanup();
}
Exemplo n.º 2
0
void SNetThreadingSpawn(snet_entity_t ent, int loc, const char *name,
                        snet_taskfun_t func, void *arg)
{
  int worker = -1;

  if (ent != ENTITY_other) {
    if (dloc_placement) {
      assert(loc != -1);
      worker = loc % num_workers;
    } else {
      worker = SNetAssignTask( (ent==ENTITY_box), name );
    }
  }

  lpel_task_t *t = LpelTaskCreate(worker, func, arg, GetStacksize(ent));

  LpelSetName(t, name);
  LpelSetNameDestructor(t, &SNetMemFree);

#ifdef USE_LOGGING
  if (mon_flags & SNET_MON_TASK){
    mon_task_t *mt = SNetThreadingMonTaskCreate(LpelTaskGetID(t), name);
    LpelTaskMonitor(t, mt);
    /* if we monitor the task, we make an entry in the map file */
  }

  if ((mon_flags & SNET_MON_MAP) && mapfile) {
    // FIXME: change to binary format
    fprintf(mapfile, "%d%s %d%c", LpelTaskGetID(t), name, worker, END_LOG_ENTRY);
  }


#endif

#ifndef NO_PRIORITY
  if (ent != ENTITY_box && ent != ENTITY_fbbuf) {
    LpelTaskPrio(t, 1);
  }
#endif


  LpelTaskRun(t);
}