コード例 #1
0
ファイル: lpel_hwloc.c プロジェクト: jsyk/lpel
int LpelHwLocCheckConfig(lpel_config_t *cfg)
{
  /* input sanity checks */
  if (  cfg->num_workers <= 0
     || cfg->proc_workers <= 0
     || cfg->proc_others < 0
     ) {
    return LPEL_ERR_INVAL;
  }

  /* check if there are enough processors (if we can check) */
  if (cfg->proc_workers + cfg->proc_others > pu_count) {
    return LPEL_ERR_INVAL;
  }

  /* check exclusive flag sanity */
  if (LPEL_ICFG(LPEL_FLAG_EXCLUSIVE)) {
    /* check if we can do a 1-1 mapping */
    if (cfg->proc_others == 0 || cfg->num_workers > cfg->proc_workers) {
      return LPEL_ERR_INVAL;
    }

    /* pinned flag must also be set */
    if (!LPEL_ICFG(LPEL_FLAG_PINNED)) {
      return LPEL_ERR_INVAL;
    }

    /* check permissions to set exclusive (if we can check) */
    if (!LpelCanSetExclusive()) {
      return LPEL_ERR_EXCL;
    }
  }

  return 0;
}
コード例 #2
0
ファイル: lpel_hwloc.c プロジェクト: nguyenvuthiennga/lpel
int LpelHwLocCheckConfig(lpel_config_t *cfg)
{
	  /* input sanity checks */
	  if (cfg->type == DECEN_LPEL) {
	  	if ( cfg->num_workers <= 0 ||  cfg->proc_workers <= 0 )
	  		return LPEL_ERR_INVAL;
	  } else if (cfg->type == HRC_LPEL) {
	  	if ( cfg->num_workers <= 1 ||  cfg->proc_workers <= 0)
	  	  return LPEL_ERR_INVAL;
	  }

	  if ( cfg->proc_others < 0 ) {
	    return LPEL_ERR_INVAL;
	  }

	  /* check if there are enough processors (if we can check) */
	  if(pu_count != LPEL_ERR_FAIL) {		/* in case can not read the number of cores, no need to check */
	  	if (cfg->proc_workers + cfg->proc_others > pu_count) {
	  		return LPEL_ERR_INVAL;
	  	}
	  	/* check exclusive flag sanity */
	  	if ( LPEL_ICFG( LPEL_FLAG_EXCLUSIVE) ) {
	  		/* check if we can do a 1-1 mapping */
	  		if ( (cfg->proc_others== 0) || (cfg->num_workers > cfg->proc_workers) ) {
	  			return LPEL_ERR_INVAL;
	  		}
	  	}
	  }
	  /* additional flags for exclusive flag */
	  if ( LPEL_ICFG( LPEL_FLAG_EXCLUSIVE) ) {
	  	int can_rt;
	    /* pinned flag must also be set */
	    if ( !LPEL_ICFG( LPEL_FLAG_PINNED) ) {
	      return LPEL_ERR_INVAL;
	    }
	    /* check permissions to set exclusive (if we can check) */
	    if ( 0==LpelCanSetExclusive(&can_rt) && !can_rt ) {
//	          return LPEL_ERR_EXCL;
	    }
	  }

	  return 0;
}