Commit e927710b authored by Farzad Sehat's avatar Farzad Sehat

Ajout de règles dans le parser afin de pouvoir acceder à un indice particulier...

Ajout de règles dans le parser afin de pouvoir acceder à un indice particulier de INPUT et de OUTPUT dans EASEA GP
parent a1eb0c08
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -558,6 +558,54 @@ exponent ([Ee][+-]?[0-9]+)
}
<COPY_GP_EVAL>"OUTPUT["[0-9]+"]" {
char* endptr;
unsigned no_output = strtol(yytext+strlen("OUTPUT["),&endptr,10);
if( bIsCopyingGPEval)
if( bCOPY_GP_EVAL_GPU )
fprintf(fpOutputFile, "outputs[i*NUMTHREAD2+tid+%d]", no_output);
else fprintf(fpOutputFile, "outputs[i+%d]", no_output );
}
<COPY_GP_EVAL>"OUTPUT["[a-zA-Z][a-zA-Z0-9]*"]" {
char *var;
var = strndup(yytext+strlen("OUTPUT["), strlen(yytext) - strlen("OUTPUT[") - 1);
if( bIsCopyingGPEval)
if( bCOPY_GP_EVAL_GPU )
fprintf(fpOutputFile, "outputs[i*NUMTHREAD2+tid+%s]", var);
else fprintf(fpOutputFile, "outputs[i+%s]", var);
}
<COPY_GP_EVAL>"INPUT" {
if( bIsCopyingGPEval)
if( bCOPY_GP_EVAL_GPU )
fprintf(fpOutputFile, "k_inputs[i*NUMTHREAD2+tid]" );
else fprintf(fpOutputFile, "inputs[i][0]" );
}
<COPY_GP_EVAL>"INPUT["[0-9]+"]" {
char* endptr;
unsigned no_input = strtol(yytext+strlen("INPUT["),&endptr,10);
if( bIsCopyingGPEval)
if( bCOPY_GP_EVAL_GPU )
fprintf(fpOutputFile, "k_inputs[i*NUMTHREAD2+tid+%d]", no_input);
else fprintf(fpOutputFile, "inputs[i][%d]", no_input );
}
<COPY_GP_EVAL>"INPUT["[a-zA-Z][a-zA-Z0-9]*"]" {
char *var;
var = strndup(yytext+strlen("INPUT["), strlen(yytext) - strlen("INPUT[") - 1);
if( bIsCopyingGPEval)
if( bCOPY_GP_EVAL_GPU )
fprintf(fpOutputFile, "k_inputs[i*NUMTHREAD2+tid+%s]", var);
else fprintf(fpOutputFile, "inputs[i][%s]", var);
}
<COPY_GP_EVAL>"return " {
if( bIsCopyingGPEval )
if( iCOPY_GP_EVAL_STATUS==EVAL_FTR )
......
......@@ -126,10 +126,13 @@ unsigned evaluation_threads_status;
#define PROBABLY_ZERO 1.11E-15f
#define BIG_NUMBER 1.0E15f
/* Insert declarations about opcodes*/
\INSERT_GP_OPCODE_DECL
\INSERT_USER_DECLARATIONS
\INSERT_USER_FUNCTIONS
float recEval(GPNode* root, float* input) {
float OP1=0, OP2= 0, RESULT = 0;
if( opArity[root->opCode]>=1) OP1 = recEval(root->children[0],input);
......@@ -549,13 +552,10 @@ float IndividualImpl::evaluate(){
\INSERT_USER_DECLARATIONS
\ANALYSE_USER_CLASSES
\INSERT_USER_CLASSES
\INSERT_USER_FUNCTIONS
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
......
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