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); }
/***************************************************************************** * Spawn a new task ****************************************************************************/ int SNetThreadingSpawn(snet_entity_t *ent) /* snet_entity_type_t type, snet_locvec_t *locvec, int location, const char *name, snet_entityfunc_t func, void *arg ) */ { int worker; snet_entity_descr_t type = SNetEntityDescr(ent); int location = SNetEntityNode(ent); const char *name = SNetEntityName(ent); int l1 = strlen(SNET_SOURCE_PREFIX); int l2 = strlen(SNET_SINK_PREFIX); if ( type != ENTITY_other) { if (sosi_placement && (strnstr(name, SNET_SOURCE_PREFIX, l1) || strnstr(name, SNET_SINK_PREFIX, l2))) { worker = LPEL_MAP_SOSI; // sosi placemnet and entity is source/sink } else if (dloc_placement) { assert(location != -1); worker = location % num_workers; } else worker = SNetAssignTask( (type==ENTITY_box), name ); } else worker = SNetEntityNode(ent); //wrapper lpel_task_t *t = LpelTaskCreate( worker, //(lpel_taskfunc_t) func, EntityTask, ent, GetStacksize(type) ); #ifdef USE_LOGGING if ((mon_flags & SNET_MON_TASK) || (mon_flags & SNET_MON_WAIT_PROP)){ 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) { int tid = LpelTaskGetId(t); (void) fprintf(mapfile, "%d%s %d%c", tid, SNetEntityStr(ent), worker, END_LOG_ENTRY); } #endif if (type != ENTITY_box && type != ENTITY_fbbuf) { LpelTaskSetPriority(t, 1); } //FIXME only for debugging purposes //fflush(mapfile); LpelTaskStart(t); return 0; }