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); LpelStart(&cfg); /* create streams */ sinp = LpelStreamCreate(0); for (i=0; i<NUM_COLL; i++) { scoll[i] = LpelStreamCreate(0); } /* create tasks */ trelay = LpelTaskCreate( 0, Relay, NULL, 8192); LpelTaskStart(trelay); tcons = LpelTaskCreate( 1, Consumer, NULL, 8192); LpelTaskStart(tcons); intask = LpelTaskCreate( -1, Inputter, sinp, 8192); LpelTaskStart(intask); LpelCleanup(); }
static void testBasic(void) { lpel_stream_t *in, *out; lpel_config_t cfg; lpel_task_t *intask, *outtask; mon_task_t *mt; cfg.num_workers = 2; cfg.proc_workers = 2; cfg.proc_others = 0; cfg.flags = 0; cfg.type = HRC_LPEL; unsigned long flags = 1 << 7 - 1; flags=0; // LpelMonInit(&cfg.mon, flags); LpelInit(&cfg); if (SccGetNodeID()==0){ in = LpelStreamCreate(0); out = PipeElement(in, 4); outtask = LpelTaskCreate( -1, Outputter, out, 8192); // mt = LpelMonTaskCreate( LpelTaskGetId(outtask), "outtask"); // LpelTaskMonitor(outtask, mt); LpelTaskStart(outtask); printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! outtask started !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); intask = LpelTaskCreate( -1, Inputter, in, 8192); // mt = LpelMonTaskCreate( LpelTaskGetId(intask), "intask"); // LpelTaskMonitor(intask, mt); LpelTaskStart(intask); printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! intask started !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); } LpelStart(); LpelCleanup(); LpelMonCleanup(); }
lpel_stream_t *PipeElement(lpel_stream_t *in, int depth) { lpel_stream_t *out; channels_t *ch; lpel_task_t *t; int wid = depth % 2; mon_task_t *mt; out = LpelStreamCreate(0); ch = ChannelsCreate( in, out, depth); t = LpelTaskCreate( 0, Relay, ch, 8192); //mt = LpelMonTaskCreate(LpelTaskGetId(t), NULL); //LpelTaskMonitor(t, mt); LpelTaskStart(t); printf("Created Relay %d\n", depth ); return (depth > 0) ? PipeElement( out, depth-1) : out; }
/***************************************************************************** * 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; }