public static void optimize(POptMode type,ParForStatementBlock sb,ParForProgramBlock pb,ExecutionContext ec,boolean monitor) throws DMLRuntimeException {
  Timing time=new Timing(true);
  LOG.debug("ParFOR Opt: Running optimization for ParFOR(" + pb.getID() + ")");
  int ck=UtilFunctions.toInt(Math.max(InfrastructureAnalyzer.getCkMaxCP(),InfrastructureAnalyzer.getCkMaxMR()) * PAR_FACTOR_INFRASTRUCTURE);
  double cm=InfrastructureAnalyzer.getCmMax() * OptimizerUtils.MEM_UTIL_FACTOR;
  optimize(type,ck,cm,sb,pb,ec,monitor);
  double timeVal=time.stop();
  LOG.debug("ParFOR Opt: Finished optimization for PARFOR(" + pb.getID() + ") in "+ timeVal+ "ms.");
  if (monitor)   StatisticMonitor.putPFStat(pb.getID(),Stat.OPT_T,timeVal);
}

public static void optimize ( POptMode type , ParForStatementBlock sb , ParForProgramBlock pb , ExecutionContext ec , boolean monitor ) throws DMLRuntimeException { Timing time = new Timing ( true ) ; LOG . debug ( "ParFOR Opt: Running optimization for ParFOR(" + pb . getID ( ) + ")" ) ; int ck = UtilFunctions . toInt ( Math . max ( InfrastructureAnalyzer . getCkMaxCP ( ) , InfrastructureAnalyzer . getCkMaxMR ( ) ) * PAR_FACTOR_INFRASTRUCTURE ) ; double cm = InfrastructureAnalyzer . getCmMax ( ) * OptimizerUtils . MEM_UTIL_FACTOR ; optimize ( type , ck , cm , sb , pb , ec , monitor ) ; double timeVal = time . stop ( ) ; LOG . debug ( "ParFOR Opt: Finished optimization for PARFOR(" + pb . getID ( ) + ") in " + timeVal + "ms." ) ; if ( monitor ) StatisticMonitor . putPFStat ( pb . getID ( ) , Stat . OPT_T , timeVal ) ; }
called once per top - level parfor ( during runtime , on parfor execute ) in order to optimize the specific parfor program block . note : this is the default way to invoke parfor optimizers .
