Changeset: d7692ebfdbb3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d7692ebfdbb3
Modified Files:
        monetdb5/scheduler/Tests/matpack00.mal
        monetdb5/scheduler/mut_pack.c
        monetdb5/scheduler/mut_policy.c
        monetdb5/scheduler/run_multicore.c
Branch: mutation
Log Message:

mat.pack through subselect mutation
The first operator exchange is working


diffs (155 lines):

diff --git a/monetdb5/scheduler/Tests/matpack00.mal 
b/monetdb5/scheduler/Tests/matpack00.mal
--- a/monetdb5/scheduler/Tests/matpack00.mal
+++ b/monetdb5/scheduler/Tests/matpack00.mal
@@ -23,6 +23,7 @@ function query(b:bat[:oid,:lng],c:bat[:o
 end query;
 
 optimizer.multicore("user","query");
+mdb.list("user","query");
 function testrun(limit:lng);
        t0:= alarm.usec();
        b:= initialize(limit);
diff --git a/monetdb5/scheduler/mut_pack.c b/monetdb5/scheduler/mut_pack.c
--- a/monetdb5/scheduler/mut_pack.c
+++ b/monetdb5/scheduler/mut_pack.c
@@ -37,8 +37,8 @@ static int
 getArgPos(InstrPtr p, int var)
 {
        int i;
-       for ( i=0; i<p->argc; i++)
-       if ( getArg(p,0) == var)
+       for ( i=0; i < p->argc; i++)
+       if ( getArg(p,i) == var)
                return i;
        return -1;
 }
@@ -62,16 +62,17 @@ void
 mutationPack(Client cntxt, Mutant m){
     int pc = m->target, i, j, mvar, svar, dvar, limit;
     InstrPtr p=0, *old= m->src->stmt, q, qq, newpack = 0;
-       //int profiler=0;
+       int profiler=0;
 
     (void) cntxt;
     limit= m->src->stop;
     if ( newMalBlkStmt(m->src, m->src->ssize) < 0)
         return;
+       pushInstruction(m->src,old[0]);//needed for debugging
 
        // first phase, see if we need to undo a bat.partition
        svar = -1; mvar = -1; dvar = -1;
-    for (j = i = 0; i < limit; i++) {
+    for (j = i = 1; i < limit; i++) {
         p= old[i];
                if (  i == pc){
                        if ( m->stk->stksize < m->src->vtop + p->argc){
@@ -111,40 +112,42 @@ mutationPack(Client cntxt, Mutant m){
        DEBUG_MULTICORE {
                mnstr_printf(cntxt->fdout,"#mutationPack mvar %d svar %d dvar 
%d leftover %d\n", mvar,svar,dvar,limit);
                for( i= 0; i< limit; i++)
-                       printInstruction(cntxt->fdout, m->src, m->stk, old[i], 
LIST_MAL_ALL);
+                       printInstruction(cntxt->fdout, m->src, 0, old[i], 
LIST_MAL_ALL);
        }
 
        // second phase, replace matpack with its successor
-    for (i = 0; i < limit; i++) {
+    for (i = 1; i < limit; i++) {
         p= old[i];
-               //profiler = m->src->profiler[i].trace;
+               profiler = m->src->profiler[i].trace;
 
-               if (qq == p && newpack && getArgPos(p, mvar) >=0 )
+               if (newpack && getArgPos(p, mvar) >=0 )
                {
-                       q= old[++i];
-                       if ( getModuleId(q) == algebraRef)
+                       if (qq == p &&  getModuleId(p) == algebraRef)
                        {
-                               if (getFunctionId(q) == joinRef || 
getFunctionId(q)== leftjoinRef || getFunctionId(q) == selectRef){
+                               if (getFunctionId(p) == joinRef || 
getFunctionId(p)== leftjoinRef || getFunctionId(p) == subselectRef){
                                        for( j= newpack->retc; j 
<newpack->argc; j++){
-                                               qq= copyInstruction(q);
-                                               getArg(qq,getArgPos(qq,svar)) = 
getArg(newpack,j);
+                                               qq= copyInstruction(p);
+                                               getArg(qq,getArgPos(qq,mvar)) = 
getArg(newpack,j);
                                                getArg(qq,0) = 
newTmpVariable(m->src, getArgType(m->src, qq,0));
                                                getArg(newpack,j)= getArg(qq,0);
                                                pushInstruction(m->src,qq);
+                                               
m->src->profiler[m->src->stop-1].trace = profiler;
                                        }
-                                       freeInstruction(q);
+                                       setArgType(m->src, newpack,0, 
getArgType(m->src,p,0));
                                        pushInstruction(m->src,newpack);
                                        newpack = 0;
                                        continue;
                                } 
                        }
+                       pushInstruction(m->src, p);
                } 
-               if ( qq == p){
-                       // handle non-partitioned operators
-                       if (getFunctionId(q) == joinRef || getFunctionId(q)== 
leftjoinRef || getFunctionId(q) == selectRef){
-                       }
-               }  else
-                       pushInstruction(m->src,p);
+               // handle non-partitioned operators
+               pushInstruction(m->src,p);
+       }
+       DEBUG_MULTICORE {
+               mnstr_printf(cntxt->fdout,"#mutationPack mvar %d svar %d dvar 
%d leftover %d\n", mvar,svar,dvar,limit);
+               for( i= 0; i< limit; i++)
+                       printFunction(cntxt->fdout, m->src, 0, LIST_MAL_ALL);
        }
     GDKfree(old);
 }
diff --git a/monetdb5/scheduler/mut_policy.c b/monetdb5/scheduler/mut_policy.c
--- a/monetdb5/scheduler/mut_policy.c
+++ b/monetdb5/scheduler/mut_policy.c
@@ -30,6 +30,7 @@
 #include "mut_leftjoin.h"
 #include "mut_aggr.h"
 #include "mut_matpack.h"
+#include "mut_pack.h"
 #include "mal_profiler.h"
 #include "opt_prelude.h"
 #include "mut_policy.h"
@@ -115,14 +116,13 @@ MUTpolicyBaseline(Client cntxt, Mutant m
                        mutationJoin(cntxt,m);
                else if(getFunctionId(p) == subselectRef)
                        mutationSelect(cntxt,m);
-                                       else if(getFunctionId(p) == 
leftfetchjoinRef)
-                                                       
mutationLeftFetchJoin(cntxt,m);
+               else if(getFunctionId(p) == leftfetchjoinRef)
+                               mutationLeftFetchJoin(cntxt,m);
        }
        if ( getModuleId(p) && strncmp(getModuleId(p), "aggr",4)== 0)
                mutationSum(cntxt,m);
-               if ( getModuleId(p) && strncmp(getModuleId(p), "mat",3)== 0)
-                       if(getFunctionId(p) == packRef)
-                               mutationMatPack(cntxt,m);
+       if ( getModuleId(p) && strncmp(getModuleId(p), "mat",3)== 0 && 
getFunctionId(p) == packRef)
+                       mutationPack(cntxt,m);
 
        /* reset/expand the profiler */
        if (ssize < src->ssize){
diff --git a/monetdb5/scheduler/run_multicore.c 
b/monetdb5/scheduler/run_multicore.c
--- a/monetdb5/scheduler/run_multicore.c
+++ b/monetdb5/scheduler/run_multicore.c
@@ -18,8 +18,7 @@
  */
 
 /*
- * @f run_multicore
- * @a M. Kersten, M. Gawade
+ * (c) M. Kersten, M. Gawade
  * Run mutated query plans
  * The infrastructure to adapatively create multi-processor parallel plans.
  */
@@ -69,6 +68,7 @@ RUNmulticore(Client cntxt, MalBlkPtr mb,
        mutant->runtime += GDKusec()- clk;
        mutant->totalQueryTime = GDKusec() - clkInit;
        mutant->calls++;
+       mb->calls++;
 
        if ( mb->calls == 1 ){
                mutant->globalMinExec = mutant->totalQueryTime;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to