Example #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);
  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();
}
Example #2
0
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();
}
Example #3
0
int SNetThreadingInit(int argc, char **argv)
{
	/* init map from file */
	SNetLocvecMapInit(argc, argv);


#ifdef USE_LOGGING
	char *mon_elts = NULL;
#endif

	lpel_config_t config;
	int i;
	memset(&config, 0, sizeof(lpel_config_t));
	config.type = DECEN_LPEL;

	config.flags = LPEL_FLAG_PINNED; // pinned by default

	/* task migration configure */
	lpel_tm_config_t tm_conf;
	memset(&tm_conf, 0, sizeof(lpel_tm_config_t));
	int tm_mech = 0;
	double tm_threshold = 0.0;

	for (i=0; i<argc; i++) {
		if(strcmp(argv[i], "-m") == 0 && i + 1 <= argc) {
			/* Monitoring level */
			i = i + 1;
#ifdef USE_LOGGING
			mon_elts = argv[i];
#endif
		} else if(strcmp(argv[i], "-excl") == 0 ) {
			/* Assign realtime priority to workers*/
			config.flags |= LPEL_FLAG_EXCLUSIVE;
		} else if(strcmp(argv[i], "-dloc") == 0 ) {
			/* Use distributed s-net location placement */
			dloc_placement = true;
		} else if(strcmp(argv[i], "-co") == 0 && i + 1 <= argc) {
			/* Number of cores for others */
			i = i + 1;
			proc_others = atoi(argv[i]);
		} else if(strcmp(argv[i], "-cw") == 0 && i + 1 <= argc) {
			/* Number of cores for others */
			i = i + 1;
			proc_workers = atoi(argv[i]);
		} else if(strcmp(argv[i], "-w") == 0 && i + 1 <= argc) {
			/* Number of workers */
			i = i + 1;
			num_workers = atoi(argv[i]);
		} else if(strcmp(argv[i], "-sosi") == 0) {
			sosi_placement = true;
		} else if (strcmp(argv[i], "-np") == 0) { // no pinned
			config.flags ^= LPEL_FLAG_PINNED;
		} else if (strcmp(argv[i], "-tm") == 0) {
			i = i + 1;
			tm_mech = atoi(argv[i]);
		} else if (strcmp(argv[i], "-threshold") == 0) {
			i = i +1;
			tm_threshold = atof(argv[i]);
		}
	}

	/* set up task migration configuration */
	switch (tm_mech) {
	case 1:
		tm_conf.mechanism = LPEL_MIG_RAND;
		if (tm_threshold <= 0)
			tm_threshold = 0.5;
		tm_conf.threshold = tm_threshold;
		break;
	case 2:
		tm_conf.mechanism = LPEL_MIG_WAIT_PROP;
		break;
	default:
		tm_conf.mechanism = LPEL_MIG_NONE;
		break;
	}

#ifdef USE_LOGGING
	char fname[20+1];
	if (mon_elts != NULL) {

		if (strchr(mon_elts, MON_ALL_FLAG) != NULL) {
			mon_flags = (1<<7) - 1;
		} else {
			if (strchr(mon_elts, MON_MAP_FLAG) != NULL) mon_flags |= SNET_MON_MAP;
			if (strchr(mon_elts, MON_TIME_FLAG) != NULL) mon_flags |= SNET_MON_TIME;
			if (strchr(mon_elts, MON_WORKER_FLAG) != NULL) mon_flags |= SNET_MON_WORKER;
			if (strchr(mon_elts, MON_TASK_FLAG) != NULL) mon_flags |= SNET_MON_TASK;
			if (strchr(mon_elts, MON_STREAM_FLAG) != NULL) mon_flags |= SNET_MON_STREAM;
			if (strchr(mon_elts, MON_MESSAGE_FLAG) != NULL) mon_flags |= SNET_MON_MESSAGE;
			if (strchr(mon_elts, MON_LOAD_FLAG) != NULL) mon_flags |= SNET_MON_LOAD;
		}

		/* set monitoring framework for task migration */
		if (tm_conf.mechanism == LPEL_MIG_WAIT_PROP)
			mon_flags |= SNET_MON_WAIT_PROP;


		if ( mon_flags & SNET_MON_MAP) {
			snprintf(fname, 20, "n%02d_tasks.map", SNetDistribGetNodeId() );
			/* create a map file */
			mapfile = fopen(fname, "w");
			assert( mapfile != NULL);
			(void) fprintf(mapfile, "%s%c", LOG_FORMAT_VERSION, END_LOG_ENTRY);
		}
	}

#endif

  /* determine number of cpus */
	if ( 0 != LpelGetNumCores( &num_cpus) ) {
		SNetUtilDebugFatal("Could not determine number of cores!\n");
		assert(0);
	}

	if (num_workers == -1)
		config.num_workers = num_cpus;
	else
		config.num_workers = num_workers;

	if (proc_workers == -1)
		config.proc_workers = num_cpus;
	else
		config.proc_workers = proc_workers;

	config.proc_others = proc_others;
#ifdef USE_LOGGING
	/* initialise monitoring module */
	config.mon.num_workers = config.num_workers;
	SNetThreadingMonInit(&config.mon, SNetDistribGetNodeId(), mon_flags);
#endif

	/* assin non-sosi task to non-sosi workers */
	SNetAssignInit(config.num_workers);

	LpelInit(&config);

	/* init task migration */
	tm_conf.num_workers = config.num_workers;
	LpelTaskMigrationInit(&tm_conf);

	/* start Lpel */
	if (LpelStart(&config)) SNetUtilDebugFatal("Could not initialize LPEL!");

	return 0;
}
Example #4
0
int SNetThreadingInit(int argc, char **argv)
{
  lpel_config_t config;
  char fname[20+1];
  int num_others = 0;
  char *mon_elts = NULL;

  LpelInit(&config);

  config.flags = LPEL_FLAG_PINNED;
  config.threshold = 0;

  for (int i = 0; i < argc; i++) {
    if(strcmp(argv[i], "-m") == 0 && i + 1 <= argc) {
      /* Monitoring level */
      i = i + 1;
      mon_elts = argv[i];
    } else if(strcmp(argv[i], "-excl") == 0 ) {
      /* Assign realtime priority to workers*/
      config.flags |= LPEL_FLAG_EXCLUSIVE;
    } else if(strcmp(argv[i], "-dloc") == 0 ) {
      /* Use distributed s-net location placement */
      dloc_placement = true;
    } else if(strcmp(argv[i], "-wo") == 0 && i + 1 <= argc) {
      /* Number of cores for others */
      i = i + 1;
      num_others = atoi(argv[i]);
    } else if(strcmp(argv[i], "-w") == 0 && i + 1 <= argc) {
      /* Number of workers */
      i = i + 1;
      num_workers = atoi(argv[i]);
    } else if(strcmp(argv[i], "-threshold") == 0 && i + 1 <= argc) {
      /* Threshold for placement scheduler */
      i = i + 1;
      config.threshold = atof(argv[i]);
    } else if(strcmp(argv[i], "-sockets") == 0 && i + 1 <= argc) {
      i = i + 1;
      config.sockets = atoi(argv[i]);
    } else if(strcmp(argv[i], "-cores") == 0 && i + 1 <= argc) {
      i = i + 1;
      config.cores = atoi(argv[i]);
    } else if(strcmp(argv[i], "-threads") == 0 && i + 1 <= argc) {
      i = i + 1;
      config.threads = atoi(argv[i]);
    } else if(strcmp(argv[i], "-gather") == 0) {
      config.gather = 1;
    }
  }


#ifdef USE_LOGGING
  if (mon_elts != NULL) {
    if (strchr(mon_elts, MON_ALL_FLAG) != NULL) {
      mon_flags = (1<<7) - 1;
    } else {
      if (strchr(mon_elts, MON_MAP_FLAG) != NULL) mon_flags |= SNET_MON_MAP;
      if (strchr(mon_elts, MON_TIME_FLAG) != NULL) mon_flags |= SNET_MON_TIME;
      if (strchr(mon_elts, MON_WORKER_FLAG) != NULL) mon_flags |= SNET_MON_WORKER;
      if (strchr(mon_elts, MON_TASK_FLAG) != NULL) mon_flags |= SNET_MON_TASK;
      if (strchr(mon_elts, MON_STREAM_FLAG) != NULL) mon_flags |= SNET_MON_STREAM;
      if (strchr(mon_elts, MON_MESSAGE_FLAG) != NULL) mon_flags |= SNET_MON_MESSAGE;
      if (strchr(mon_elts, MON_LOAD_FLAG) != NULL) mon_flags |= SNET_MON_LOAD;
    }



    if ( mon_flags & SNET_MON_MAP) {
      snprintf(fname, 20, "n%02d_tasks.map", SNetDistribGetNodeId() );
      /* create a map file */
      mapfile = fopen(fname, "w");
      assert( mapfile != NULL);
      (void) fprintf(mapfile, "%s%c", LOG_FORMAT_VERSION, END_LOG_ENTRY);
    }
  }
#endif

  config.proc_others = num_others;
  if (num_workers) {
    config.proc_workers = num_workers;
    config.num_workers = config.proc_others + config.proc_workers;
  } else {
    config.proc_workers = config.num_workers - config.proc_others;
    num_workers = config.proc_workers;
  }

#ifdef USE_LOGGING
  /* initialise monitoring module */
  SNetThreadingMonInit(&config.mon, SNetDistribGetNodeId(), mon_flags);
#endif

  SNetAssignInit(config.num_workers);

  if (LpelStart(&config)) SNetUtilDebugFatal("Could not initialize LPEL!");

  return 0;
}