Commit 029d40c9 authored by maitre's avatar maitre

Version befor finalization for summer school.

parent af46e5da
%{
/****************************************************************************
EaseaLex.l
......@@ -565,13 +566,15 @@ exponent ([Ee][+-]?[0-9]+)
BEGIN PARAMETERS_ANALYSIS;
}
<TEMPLATE_ANALYSIS>"\\INSERT_GEN_FCT_CALL" {
DEBUG_PRT("Generational function call %d",bGenerationFunction);
if (bGenerationFunction) {
if( bVERBOSE ) fprintf(stdout,"Inserting generation function call\n");
if( TARGET==CUDA || TARGET==STD ){
fprintf(fpOutputFile,"\n\tEASEAGenerationFunction(this);");
}
else fprintf(fpOutputFile,"\n EASEAGenerationFunction(ga);\n");
}
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_BOUND_CHECKING_FCT_CALL" {
if (bBoundCheckingFunction) {
......@@ -1082,7 +1085,8 @@ exponent ([Ee][+-]?[0-9]+)
bFunction=1; bGenerationFunction=1;
BEGIN COPY_USER_GENERATION;
}
<COPY_GENERATION_FUNCTION><<EOF>> {bGenerationFunction=0; // No Generation function was found in the .ez file
<COPY_GENERATION_FUNCTION><<EOF>> {
bGenerationFunction=0; // No Generation function was found in the .ez file
if (bVERBOSE) printf("*** No generation function was found. ***\n");
fprintf(fpOutputFile,"\n// No generation function.\n");
rewind(fpGenomeFile);
......@@ -1100,7 +1104,7 @@ exponent ([Ee][+-]?[0-9]+)
bFunction=1; bBoundCheckingFunction=1;
BEGIN COPY_USER_GENERATION;
}
<COPY_BOUND_CHECKING_FUNCTION><<EOF>> {bGenerationFunction=0; // No Generation function was found in the .ez file
<COPY_BOUND_CHECKING_FUNCTION><<EOF>> {bBoundCheckingFunction=0; // No Generation function was found in the .ez file
if (bVERBOSE) printf("*** No bound checking function was found. ***\n");
fprintf(fpOutputFile,"\n// No Bound checking function.\n");
rewind(fpGenomeFile);
......@@ -1577,6 +1581,15 @@ exponent ([Ee][+-]?[0-9]+)
}
<COPY_USER_FUNCTION>"initOpts." {
if( (bWithinEvaluator && !bWithinCUDA_Evaluator) && ( TARGET==STD || TARGET==CUDA )){
fprintf(fpOutputFile,"");
}
else
fprintf(fpOutputFile,"%s",yytext);
}
<COPY_USER_FUNCTION>"Genome" {
if (bWithinDisplayFunction) fprintf(fpOutputFile,"(*this)");
else if ((TARGET==EO)&&(bWithinInitialiser)) fprintf(fpOutputFile, "(*genome)");
......@@ -1662,13 +1675,13 @@ exponent ([Ee][+-]?[0-9]+)
else if( TARGET==CUDA || TARGET==STD) {
if( bWithinCUDA_Evaluator ){
fprintf(fpOutputFile,"return ");
bWithinCUDA_Evaluator = 0;
//bWithinCUDA_Evaluator = 0;
}
else
fprintf(fpOutputFile,"return fitness = ");
bCatchNextSemiColon=false;
}
bWithinEvaluator=0;
//bWithinEvaluator=0;
}
else if ((bWithinMutator)&&(TARGET!=GALIB)) {
fprintf(fpOutputFile,"return ");
......
......@@ -383,7 +383,7 @@ BaseConstructorParameter
GenomeDeclarationSection
: GENOME {
DEBUG_PRT("Yacc genome decl %s",$1.pSymbol->sName);
//DEBUG_PRT("Yacc genome decl %s",$1.pSymbol->sName);
if (bVERBOSE) printf ("\nGenome declaration analysis :\n\n");
pGENOME=new CSymbol("Genome");
pCURRENT_CLASS=SymbolTable.insert(pGENOME);
......
......@@ -134,8 +134,8 @@ void CSymbol::print(FILE *fp){
if( isFlatClass ){
fprintf(fp," ret = (%s*)malloc(sizeof(%s));\n",sName,sName);
fprintf(fp," cudaMemcpy(ret,dev_ptr,sizeof(%s),cudaMemcpyDeviceToHost);\n",sName);
while (pSym=pSymbolList->walkToNextItem())
fprintf(fp," this->%s=ret->%s;\n",pSym->Object->sName,pSym->Object->sName);
//while (pSym=pSymbolList->walkToNextItem())
//fprintf(fp," this->%s=ret->%s;\n",pSym->Object->sName,pSym->Object->sName);
fprintf(fp," }\n\n");
}
}
......
......@@ -31,9 +31,7 @@ float Rosenbrock(float *, int);
float Schwefel(float *, int);
float Weierstrass(float *, int);
EvalCounter* d_counter;
struct gpuOptions{
EvalCounter* counter;
};
\end
......@@ -170,31 +168,14 @@ float gauss()
}
\end
\Initialisation function:
std::cout<<"************* n: "<<n<<std::endl;
EvalCounter counter;
counter.a = 0;
d_counter = counter.cudaSendToGpuEvalCounter();
initOpts.counter=d_counter;
\end
\Finalization function:
cout << "finalization function called" << endl;
EvalCounter counter;
counter.cudaGetFromGpuEvalCounter(d_counter);
cout << counter << endl;
\end
\User classes :
EvalCounter {
int a;
}
TestClass1 {
int a;
float b;
}
GenomeClass {
float x[SIZE];
float sigma[SIZE]; // auto-adaptative mutation parameter
......@@ -239,7 +220,6 @@ return NbMut;
float Point[SIZE];
for (int i=0; i<N_LIM; i++) Point[i] = Genome.x[i];
Score= Weierstrass(Point, N_LIM);
initOpts.counter->a+=2;
return Score;
\end
......
......@@ -61,7 +61,7 @@ clean:
cd alexyacc && make clean
install:$(EXEC)
sudo cp $< /usr/bin/easea
sudo cp $< /usr/bin/dev-easea
# realclean: clean
# rm -f EaseaParse.cpp EaseaParse.h EaseaLex.cpp EaseaLex.h
......
......@@ -190,12 +190,12 @@ std::ostream& operator << (std::ostream& O, const Individual& B)
{
// ********************
// Problem specific part
O << "\nIndividual : "<< std::endl;
O << "\t\t\t";
// O << "\nIndividual : "<< std::endl;
// O << "\t\t\t";
B.printOn(O);
if( B.valid ) O << "\t\t\tfitness : " << B.fitness;
else O << "fitness is not yet computed" << std::endl;
// if( B.valid ) O << "\t\t\tfitness : " << B.fitness;
//else O << "fitness is not yet computed" << std::endl;
return O;
}
......@@ -500,23 +500,12 @@ void EvolutionaryAlgorithm::addStoppingCriterion(StoppingCriterion* sc){
void EvolutionaryAlgorithm::runEvolutionaryLoop(){
std::vector<Individual*> tmpVect;
/* if( inputfile ){ */
/* DEBUG_PRT("Loading initial population from file : %s",inputfile->c_str()); */
/* std::ifstream ifs("essai.out"); */
/* DEBUG_PRT("parent population size in ea %d",population->parentPopulationSize); */
/* //population->parents = new Individual*[population->parentPopulationSize]; */
/* boost::archive::text_iarchive ia(ifs); */
/* //ia >> *population; */
/* population->syncInVector(); */
/* //ia >> *population; */
/* } */
std::cout << "Parent's population initializing "<< std::endl;
this->population->initializeCudaParentPopulation();
cudaParentEvaluate();
// std::cout << *population << std::endl;
std::cout << *population << std::endl;
DEBUG_PRT("Genome size is %lu",\GENOME_SIZE);
......@@ -567,7 +556,7 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
currentGeneration += 1;
}
population->sortParentPopulation();
//std::cout << *population << std::endl;
std::cout << *population << std::endl;
std::cout << "Generation : " << currentGeneration << std::endl;
SHOW_SIMPLE_TIME(accuEval);
......
......@@ -496,11 +496,14 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
DECLARE_TIME(eval);
DECLARE_TIME(moPop);
struct timeval begin,accuEval;
gettimeofday(&begin,NULL);
accuEval.tv_sec = 0;
accuEval.tv_usec = 0;
struct timeval accuMo = {0,0};
void* d_offspringPopulation;
float* d_fitnesses;
......@@ -520,13 +523,16 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
cudaOffspringEvaluate(d_offspringPopulation,d_fitnesses,dimBlock,dimGrid);
TIME_END(eval);
TIME_ST(moPop);
population->evaluateMoPopulation();
TIME_END(moPop);
COMPUTE_TIME(eval);
//SHOW_TIME(eval);
COMPUTE_TIME(moPop);
timeradd(&accuMo,&moPop_res,&accuMo);
timeradd(&accuEval,&eval_res,&accuEval);
if(reduceParents)
population->reduceParentPopulation(reduceParents);
......@@ -540,12 +546,14 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
showPopulationStats(begin);
currentGeneration += 1;
//SHOW_TIME(moPop);
}
population->sortParentPopulation();
std::cout << *population << std::endl;
std::cout << *population->parents[0] << std::endl;
std::cout << "Generation : " << currentGeneration << std::endl;
SHOW_SIMPLE_TIME(accuMo);
SHOW_SIMPLE_TIME(accuEval);
cudaFree(d_offspringPopulation);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment