Пример #1
0
	PModule PModule::importModule(char* name, PyObject* globals, PyObject* locals) {
		PyObject* ret;
		if (locals == globals == NULL) {
			ret = ::PyImport_ImportModule(name);
			return PModule(ret, true);
		}
		if (::PyMapping_Check(locals) == 0) {
			throw new CPPPythonException("PModule::importModule: locals must be a valid mapping");
		}
		if (::PyMapping_Check(globals) == 0) {
			throw new CPPPythonException("PModule::importModule: globals must be a valid mapping");
		}
		ret = ::PyImport_ImportModuleEx(name, globals, locals, NULL);
		return PModule(ret, true);
	}
Пример #2
0
int main(int argc, char** argv) {
  GEOS::init();

  LLVMContext &Context = getGlobalContext();
  SMDiagnostic Error;

  gcl::GEOSParseCommandLineOptions(argc, argv);

  Module *MyModule = 
    parseIRFile(LLVMFilename.c_str(), Error, Context).release();

  std::shared_ptr<ProfileModule> PModule(new ProfileModule(MyModule));
  PModule->print("teste");
  CostEstimatorOptions Opts = gcl::populatePModule(PModule);
  int PAPIEvents[1] = {PAPI_TOT_CYC};

  double BestOfBest = 0;
  double BestOfBestEstimation = 0;
  for(int j = 0; j < 5; j++) {
    double Cost = GEOS::analyseCost(PModule, Opts);
    double RealCost = 
      (GEOS::getPAPIProfile(PModule, ExecutionKind::JIT, PAPIEvents, 1))[0];

    std::shared_ptr<ProfileModule> Best;
    PassSequence BestSeq;
    double BestSpeedup = 0;

    for (int i = 0; i < 200; i++) {
      PassSequence Passes;
      std::shared_ptr<ProfileModule> PO;

      while (!PO) {
        Passes.randomize(50, true);
        PO = GEOS::applyPasses(PModule, Passes);
      }

      double NewCost = GEOS::analyseCost(PO, Opts);

      if ((Cost/NewCost) > BestSpeedup) {
        BestSpeedup = Cost/NewCost;
        Best = PO;
        BestSeq = Passes;
      } 
    }
    BestSeq.print();
    double NewRealCost = (double)
      (GEOS::getPAPIProfile(Best, ExecutionKind::JIT, PAPIEvents, 1))[0];

    printf("\nBEST: %lf | %lf \n", BestSpeedup, RealCost/NewRealCost);

    if ((RealCost/NewRealCost) > BestOfBest) {
      BestOfBest = RealCost/NewRealCost;
      BestOfBestEstimation = BestSpeedup;
    }
  }
  
  printf("\nBEST OF BEST: %lf | %lf \n", BestOfBestEstimation, BestOfBest);
  return 0;
}
Пример #3
0
void PModList( mod_entry *head )
/*************************************/
{
    mod_entry           *obj;

    for( obj = head; obj != NULL; obj = obj->n.next_mod ) {
        PModule( obj );
    }
}
Пример #4
0
	PModule PModule::getNewModule(const char *name) {
		PModule ret = PModule(::PyModule_New(name), true);
		return ret;
	}
Пример #5
0
	PModule PModule::getModule(const char *name) {
		PModule ret = PModule(::PyImport_AddModule(name)); //borrowed
		return ret;
	}