Changeset: 3f7641d438bb for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3f7641d438bb Modified Files: monetdb5/scheduler/mut_leftjoin.c monetdb5/scheduler/mut_select.c monetdb5/scheduler/mut_util.c monetdb5/scheduler/mut_util.h Branch: mutation Log Message:
More code reshuffling. diffs (229 lines): diff --git a/monetdb5/scheduler/mut_leftjoin.c b/monetdb5/scheduler/mut_leftjoin.c --- a/monetdb5/scheduler/mut_leftjoin.c +++ b/monetdb5/scheduler/mut_leftjoin.c @@ -20,15 +20,27 @@ /* * (c) M. Kersten, M. Gawade * The infrastructure to adapatively create multi-processor parallel plans. - * Be careful in handling the stk, because it is also used by the caller functions. + * Dont use any partition intelligence, simple half split + * x1 := algebra.LeftFetchJoin(b,Y) => + * b1 := bat.partition(b,2,0); + * b2 := bat.partition(b,2,1); + * v1:= algebra.leftfetchjoin(b1,Y); + * v2:= algebra.leftfetchjoin(b2,Y); + * x1:= mat.pack(v1,v2); + * + * Be careful not to change the size of the stack, + * for we can not easily pass it back to the + * current interpreter call sequence + * */ #include "monetdb_config.h" #include "mut_leftjoin.h" +#include "mut_util.h" #include "mut_matpack.h" #include "opt_prelude.h" -static void -mutationLeftFetchJoin_(MalBlkPtr mb, MalStkPtr stk, InstrPtr p, int partitions, int slice, int profiler, int *v1Ptr) +static int +mutationLeftFetchJoin_(MalBlkPtr mb, MalStkPtr stk, InstrPtr p, int partitions, int slice, int profiler) { int b1; InstrPtr q; @@ -42,22 +54,21 @@ mutationLeftFetchJoin_(MalBlkPtr mb, Mal stk->stk[getArg(q, q->argc-1)].val.ival = partitions; q = pushInt(mb,q,slice); stk->stk[getArg(q, q->argc-1)].val.ival = slice; - // inherit profiling mb->profiler[mb->stop-1].trace = profiler; q= copyInstruction(p); getArg(q,1)= b1; - *v1Ptr = getArg(q,0)= newTmpVariable(mb,TYPE_any); + getArg(q,0)= newTmpVariable(mb,TYPE_any); pushInstruction(mb,q); - // inherit profiling mb->profiler[mb->stop-1].trace = profiler; + return getArg(q,0); } void mutationLeftFetchJoin(Client cntxt, Mutant m){ - int pc = m->target, i, j, k, limit, v1,v2; - InstrPtr p=0, *old= m->src->stmt, q; - int matpc = 0, profiler; + int pc = m->target, i, limit, v1,v2; + InstrPtr p=0, *old= m->src->stmt; + int profiler; (void) cntxt; @@ -69,19 +80,6 @@ mutationLeftFetchJoin(Client cntxt, Muta for (i = 1; i < limit; i++) { p= old[i]; if ( i == pc){ - // replace the instruction, e.g. with a partioned one. - // Dont use any partition intelligence, simple half split - // x1 := algebra.LeftFetchJoin(b,Y) => - // b1 := bat.partition(b,2,0); - // b2 := bat.partition(b,2,1); - // v1:= algebra.leftfetchjoin(b1,Y); - // v2:= algebra.leftfetchjoin(b2,Y); - // x1:= mat.pack(v1,v2); - // - // Be careful not to change the size of the stack, - // for we can not easily pass it back to the - // current interpreter call sequence - // if ( m->stk->stksize < m->src->vtop + 7){ pushInstruction(m->src,p); continue; @@ -89,39 +87,10 @@ mutationLeftFetchJoin(Client cntxt, Muta profiler = m->src->profiler[i].trace; - mutationLeftFetchJoin_(m->src, m->stk, p, 2, 0, profiler, &v1); - mutationLeftFetchJoin_(m->src, m->stk, p, 2, 1, profiler, &v2); + v1 = mutationLeftFetchJoin_(m->src, m->stk, p, 2, 0, profiler); + v2 = mutationLeftFetchJoin_(m->src, m->stk, p, 2, 1, profiler); + mutationPropagate(m, old, i+1,limit,getArg(p,0),v1,v2,profiler); - // replace its use in other mat packs - for (j = i+1; j < limit; j++) { - q= old[j]; - if ( getModuleId(q) == matRef && getFunctionId(q) == packRef){ - for( k= old[j]->retc; k < old[j]->argc; k++) - if ( getArg(q,k) == getArg(p,0)){ - // replace this argument - matpc++; - delArgument(old[j],k); - old[j] = setArgument(m->src,old[j],k, v2); - old[j] = setArgument(m->src,old[j],k, v1); - break; - } - } - } - - if ( matpc == 0){ - q= newStmt(m->src,matRef,packRef); - getArg(q,0)= getArg(p,0); - q= pushArgument(m->src,q,v1); - q= pushArgument(m->src,q,v2); - m->src->profiler[m->src->stop-1].trace = profiler; - - q= newStmt(m->src, languageRef, passRef); - q = pushArgument(m->src,q, getArg(p,p->retc+1)); - // inherit profiling - m->src->profiler[m->src->stop-1].trace = profiler; - } - - //pushInstruction(m->src,p); m->target = pc; m->comment = GDKstrdup("mutationLeftFetchJoin"); } else diff --git a/monetdb5/scheduler/mut_select.c b/monetdb5/scheduler/mut_select.c --- a/monetdb5/scheduler/mut_select.c +++ b/monetdb5/scheduler/mut_select.c @@ -24,6 +24,7 @@ */ #include "monetdb_config.h" #include "mut_select.h" +#include "mut_util.h" #include "opt_prelude.h" /* Sample plan mutation actions @@ -73,9 +74,9 @@ mutationSelect_(MalBlkPtr mb, MalStkPtr void mutationSelect(Client cntxt, Mutant m){ - int pc = m->target, i, j, k, limit, v1,v2; + int pc = m->target, i, limit, v1,v2; InstrPtr p=0, *old= m->src->stmt, q; - int matpc = 0, profiler=0; + int profiler=0; (void) cntxt; limit= m->src->stop; @@ -101,31 +102,8 @@ mutationSelect(Client cntxt, Mutant m){ q = pushArgument(m->src,q,getArg(p, p->retc)); m->src->profiler[m->src->stop-1].trace = profiler; - // replace its use in other mat packs - matpc = 0; - for (j = i; j < limit; j++) { - q= old[j]; - if ( getModuleId(q) == matRef && getFunctionId(q) == packRef){ - for( k= old[j]->retc; k < old[j]->argc; k++) - if ( getArg(q,k) == getArg(p,0)){ - // replace this argument by both new ones - matpc++; - delArgument(old[j],k); - old[j] = setArgument(m->src,old[j],k, v2); - old[j] = setArgument(m->src,old[j],k, v1); - } - } - } + mutationPropagate(m,old,i,limit,getArg(p,0),v1,v2,profiler); - if ( matpc == 0){ - q= newStmt(m->src,matRef,packRef); - getArg(q,0)= getArg(p,0); - q= pushArgument(m->src,q,v1); - q= pushArgument(m->src,q,v2); - m->src->profiler[m->src->stop-1].trace = profiler; - } - - //pushInstruction(m->src,p); m->target = pc; m->comment = GDKstrdup("mutationSelect"); } else diff --git a/monetdb5/scheduler/mut_util.c b/monetdb5/scheduler/mut_util.c --- a/monetdb5/scheduler/mut_util.c +++ b/monetdb5/scheduler/mut_util.c @@ -179,3 +179,33 @@ multicorePrint(Client cntxt, Mutant m) if ( m->next) multicorePrint(cntxt, m->next); } + +void +mutationPropagate(Mutant m, InstrPtr *old, int start, int limit, int v0, int v1, int v2, int profiler) +{ + int matpc= 0,j,k; + InstrPtr q; + // replace variable use in other mat packs + for (j = start; j < limit; j++) { + q= old[j]; + if ( getModuleId(q) == matRef && getFunctionId(q) == packRef){ + for( k= old[j]->retc; k < old[j]->argc; k++) + if ( getArg(q,k) == v0){ + // replace this argument by both new ones + matpc++; + delArgument(old[j],k); + old[j] = setArgument(m->src,old[j],k, v2); + old[j] = setArgument(m->src,old[j],k, v1); + } + } + } + + if ( matpc == 0){ + q= newStmt(m->src,matRef,packRef); + getArg(q,0)= v0; + q= pushArgument(m->src,q,v1); + q= pushArgument(m->src,q,v2); + m->src->profiler[m->src->stop-1].trace = profiler; + } +} + diff --git a/monetdb5/scheduler/mut_util.h b/monetdb5/scheduler/mut_util.h --- a/monetdb5/scheduler/mut_util.h +++ b/monetdb5/scheduler/mut_util.h @@ -28,6 +28,7 @@ run_multicore_export int MUTshouldrun(MalBlkPtr mb); run_multicore_export void MUTupdateRateOfFall(Client cntxt, Mutant mutant); run_multicore_export void MUTupdateGlobalMin(Mutant mutant); +run_multicore_export void mutationPropagate(Mutant m, InstrPtr *old, int start, int limit, int v0, int v1, int v2, int profiler); #endif /* _MUT_STOPRUNS_ */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list