Changeset: 8f645ae6bbea for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8f645ae6bbea
Modified Files:
        monetdb5/scheduler/mut_join.c
        monetdb5/scheduler/mut_pack.c
        monetdb5/scheduler/mut_policy.c
        monetdb5/scheduler/mut_select.c
        monetdb5/scheduler/run_multicore.c
Branch: mutation
Log Message:

Minor debugging issues


diffs (266 lines):

diff --git a/monetdb5/scheduler/mut_join.c b/monetdb5/scheduler/mut_join.c
--- a/monetdb5/scheduler/mut_join.c
+++ b/monetdb5/scheduler/mut_join.c
@@ -68,7 +68,9 @@ mutationJoin_(MalBlkPtr mb, MalStkPtr st
        q= copyInstruction(p);
        getArg(q,2)= b1;
        *v1Ptr = getArg(q,0)= newTmpVariable(mb,TYPE_any);
+       stk->stk[getArg(q,0)].vtype= getVarGDKType(mb,getArg(q,0));
        *z1Ptr = getArg(q,1)= newTmpVariable(mb,TYPE_any);
+       stk->stk[getArg(q,1)].vtype= getVarGDKType(mb,getArg(q,1));
        pushInstruction(mb,q);
        mb->profiler[mb->stop-1].trace = profiler;
 }
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
@@ -61,14 +61,11 @@ validswitch(InstrPtr p, InstrPtr q)
 int 
 mutationPack(Client cntxt, Mutant m){
        MalBlkPtr mb = m->src;
-    int pc = m->target, i, j, mvar, limit, packpc=0;
+       MalStkPtr stk= m->stk;
+    int pc = m->target, i, j, mvar, limit, packpc=0, pos=0;
     InstrPtr p=0, *old= mb->stmt, q, newpack = 0, newpack1=0, newpack2 = 0;
        int profiler=0, modified= 0;
 
-       DEBUG_MULTICORE {
-               mnstr_printf(cntxt->fdout,"#MUTATIONPACK\n");
-               printFunction(cntxt->fdout, mb, 0, LIST_MAL_ALL);
-       }
     (void) cntxt;
     limit= mb->stop;
     if ( newMalBlkStmt(mb, mb->ssize) < 0)
@@ -86,7 +83,7 @@ mutationPack(Client cntxt, Mutant m){
 
                        DEBUG_MULTICORE 
mnstr_printf(cntxt->fdout,"#MUTATIONPACK move %d ",pc);
                        // move ahead to first candidate for consolidation
-                       for(i++ ; i < limit && validswitch(old[pc],old[i]); 
i++){
+                       for(i++ ; i < limit && validswitch(p,old[i]); i++){
                                old[pc] = old[i];
                                old[i] = p;
                                pc = i;
@@ -105,6 +102,7 @@ mutationPack(Client cntxt, Mutant m){
                        // this means we replace the partitions by the matpack 
components
                                
                                int partitions = 
getVarConstant(mb,getArg(q,2)).val.ival;
+                               DEBUG_MULTICORE 
mnstr_printf(cntxt->fdout,"#MUTATIONPACK PARTITION %d %d partitions 
%d\n",pc,i,partitions);
                                for(j =i; j< limit; j++)
                                if (getModuleId(q= old[j]) == batRef && 
getFunctionId(q) == partitionRef && getArgPos(q,mvar) >=0){
                                        partitions --;
@@ -122,6 +120,7 @@ mutationPack(Client cntxt, Mutant m){
                                                // inject an empty partition
                                                clrFunction(q);
                                                q = 
pushArgument(mb,q,newTmpVariable(mb,getArgType(mb,q,0)));
+                                               stk->stk[getArg(q,0)].vtype= 
getVarGDKType(mb,getArg(q,0));
                                        }
                                }
                                packpc = 0;
@@ -132,7 +131,11 @@ mutationPack(Client cntxt, Mutant m){
                } 
        }
 
-       DEBUG_MULTICORE mnstr_printf(cntxt->fdout,"#mutationPack mvar %d packpc 
%d\n", mvar,packpc);
+       DEBUG_MULTICORE{
+               mnstr_printf(cntxt->fdout,"#MUTATIONPACK mvar %d packpc %d 
newpack %s\n", mvar,packpc, (newpack?"available" : ""));
+               if( newpack)
+                       
printInstruction(cntxt->fdout,mb,0,newpack,LIST_MAL_ALL);
+       }
 
        // second phase, replace matpack with its successor
     for (i = 1; i < limit; i++) 
@@ -144,11 +147,12 @@ mutationPack(Client cntxt, Mutant m){
                        pushInstruction(mb,p);
                        continue;
                }
-               if (newpack && getArgPos(p, mvar) >=0 )
+               if (newpack && (pos = getArgPos(p, mvar)) >=0 )
                {
                        if (getModuleId(p) == algebraRef)
                        {
-                               if (getFunctionId(p) == joinRef || 
getFunctionId(p)== leftjoinRef || getFunctionId(p) == subselectRef){
+                               if (getFunctionId(p) == joinRef || 
getFunctionId(p)== leftjoinRef || getFunctionId(p) == subselectRef || 
getFunctionId(p) == thetasubselectRef){
+                                       DEBUG_MULTICORE 
mnstr_printf(cntxt->fdout,"#MUTATIONPACK [*JOIN][[THETA]SUBSELECT] \n");
                                        newpack1 = copyInstruction(newpack);
                                        getArg(newpack1,0) = getArg(p,0);
                                        setArgType(mb, newpack1, 0, 
getArgType(mb,p,0));
@@ -162,14 +166,18 @@ mutationPack(Client cntxt, Mutant m){
                                                q= copyInstruction(p);
                                                getArg(q,getArgPos(q,mvar)) = 
getArg(newpack,j);
                                                getArg(q,0) = 
newTmpVariable(mb, getArgType(mb, q, 0));
+                                               stk->stk[getArg(q,0)].vtype= 
getVarGDKType(mb,getArg(q,0));
                                                getArg(newpack1,j)= getArg(q,0);
                                                if ( newpack2){
                                                        getArg(q,1) = 
newTmpVariable(mb, getArgType(mb, q, 1));
+                                                       
stk->stk[getArg(q,1)].vtype= getVarGDKType(mb,getArg(q,1));
                                                        getArg(newpack2,j)= 
getArg(q,1);
                                                }
                                                pushInstruction(mb,q);
                                                mb->profiler[mb->stop-1].trace 
= profiler;
                                        }
+                                       if ( pos == 2 && getFunctionId(p) == 
subselectRef)
+                                               setFunctionId(newpack1, 
putName("mergepack",9));
                                        pushInstruction(mb, newpack1);
                                        if ( newpack2)
                                                pushInstruction(mb, newpack2);
@@ -181,20 +189,20 @@ mutationPack(Client cntxt, Mutant m){
                        } 
                        if(  getModuleId(p) == sqlRef  &&
                          (getFunctionId(p) == subdeltaRef || getFunctionId(p) 
== projectdeltaRef)){
+                               DEBUG_MULTICORE 
mnstr_printf(cntxt->fdout,"#MUTATIONPACK [PROJECT][SUB]DELTA \n");
+                                       getArg(newpack,0) = getArg(p,0);
                                        newpack1 = copyInstruction(newpack);
-                                       getArg(newpack1,0) = getArg(p,0);
-                                       setArgType(mb, newpack1, 0, 
getArgType(mb,p,0));
 
                                        for( j= newpack->retc; j 
<newpack->argc; j++){
                                                q= copyInstruction(p);
                                                getArg(q,getArgPos(q,mvar)) = 
getArg(newpack,j);
-                                               getArg(q,0) = 
newTmpVariable(mb, getArgType(mb, q, 0));
-                                               getArg(newpack1,j)= getArg(q,0);
+                                               getArg(newpack1,j)= getArg(q,0) 
= newTmpVariable(mb, getArgType(mb, p, 0));
+                                               stk->stk[getArg(q,0)].vtype= 
getVarGDKType(mb,getArg(q,0));
                                                pushInstruction(mb,q);
                                                mb->profiler[mb->stop-1].trace 
= profiler;
                                        }
+                                       setFunctionId(newpack1, 
putName("mergepack",9));
                                        pushInstruction(mb, newpack1);
-                                       newpack1 = 0;
                                        modified++;
                                        continue;
                        }
@@ -203,11 +211,12 @@ mutationPack(Client cntxt, Mutant m){
                        // handle non-partitioned operators
                        pushInstruction(mb,p);
        } else
-       if ( packpc == i )
+       if ( packpc == i ){
                pushInstruction(mb,newpack);
-       DEBUG_MULTICORE
-       if( modified)
-               printFunction(cntxt->fdout, mb, 0, LIST_MAL_ALL);
+               newpack = 0;
+       }
+       if( newpack)
+               freeInstruction(newpack);
     GDKfree(old);
        return modified;
 }
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
@@ -92,6 +92,10 @@ MUTpolicyBaseline(Client cntxt, Mutant m
        lng threshold = 0;
        InstrPtr p;
 
+       DEBUG_MULTICORE{
+               mnstr_printf(cntxt->fdout, "#START MUTATION\n");
+               printFunction(cntxt->fdout, m->src,0,LIST_MAL_ALL);
+       }
        do {
                modified = 0;
                // Find the next most expensive instruction to replace
@@ -105,7 +109,7 @@ MUTpolicyBaseline(Client cntxt, Mutant m
                p = copyInstruction( getInstrPtr(mb, m->target));
                DEBUG_MULTICORE{
                        if ( mb->profiler && m->target) {
-                               mnstr_printf(cntxt->fdout,"#mutation winner %s 
%d calls %d cost "LLFMT"\n", 
+                               mnstr_printf(cntxt->fdout,"#MUTATION WINNER %s 
%d calls %d cost "LLFMT"\n", 
                                        getFunctionId(p),m->target, mb->calls, 
mb->profiler[m->target].ticks/mb->calls);
                        }
                }
@@ -133,16 +137,18 @@ MUTpolicyBaseline(Client cntxt, Mutant m
                //if ( getModuleId(p) == sqlRef && ( getFunctionId(p) == 
subdeltaRef || getFunctionId(p) == projectdeltaRef))
                                //modified = mutationSQL(cntxt,m);
 
-               DEBUG_MULTICORE
+               DEBUG_MULTICORE{
                        mnstr_printf(cntxt->fdout, "#MODIFIED %s modified %d 
threshold "LLFMT" cost"LLFMT" %s\n",
                                (modified>0? getFunctionId(p):""),modified, 
threshold, mb->profiler[m->target].ticks/mb->calls, m->comment);
+                       if( !modified){
+                               mnstr_printf(cntxt->fdout, "#MODIFIED 
FAILED\n");
+                               printFunction(cntxt->fdout, 
m->src,0,LIST_MAL_ALL);
+                       }
+               }
                freeInstruction(p);
        } while (!modified);
-       if ( modified < 0){
-               DEBUG_MULTICORE
-                       mnstr_printf(cntxt->fdout, "#MODIFIED FAILED\n");
+       if ( !modified )
                return 0;
-       }
 
        /* reset/expand the profiler */
        if (ssize < mb->ssize){
@@ -158,11 +164,13 @@ MUTpolicyBaseline(Client cntxt, Mutant m
        mb->calls = 0;
        chkProgram(cntxt->fdout,cntxt->nspace,mb);
        chkFlow(cntxt->fdout,mb);
-       malGarbageCollector(mb);
        DEBUG_MULTICORE{
                mnstr_printf(cntxt->fdout,"Final plan to execute, errors 
%d\n",mb->errors);
-               //printFunction(cntxt->fdout, mb,0,LIST_MAL_ALL);
+               if( mb->errors)
+                       printFunction(cntxt->fdout, mb,0,LIST_MAL_ALL);
+               mnstr_printf(cntxt->fdout,"\n\n\n");
        }
+       malGarbageCollector(mb);
        if ( mb->errors)
                return -1;
        return 1;
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
@@ -67,11 +67,28 @@ mutationSelect_(MalBlkPtr mb, MalStkPtr 
        q= copyInstruction(p);
        getArg(q,1)= b1;
        v = getArg(q,0)= newTmpVariable(mb,TYPE_any);
+       stk->stk[getArg(q,0)].vtype= getVarGDKType(mb,getArg(q,0));
        pushInstruction(mb,q);
        mb->profiler[getPC(mb,q)].trace = profiler;
        return v;
 }
 
+static void
+mutationMergePack(MalBlkPtr mb, int start, int cand)
+{
+       InstrPtr q;
+       int j,k;
+
+       for(j = start; j >0; j--){
+               q= getInstrPtr(mb,j);
+               if ( getFunctionId(q) == packRef && getModuleId(q)== matRef && 
getArg(q,0) == cand){
+                       setFunctionId(q, putName("mergepack",9));
+                       for(k = q->retc; k<q->argc; k++)
+                               mutationMergePack(mb,j-1,getArg(q,k));
+               }
+       }
+}
+
 int 
 mutationSelect(Client cntxt, Mutant m){
     int pc = m->target, i, limit, v1,v2;
@@ -86,6 +103,10 @@ mutationSelect(Client cntxt, Mutant m){
     assert( m->src->profiler);
     for (i = 0; i < limit; i++) {
         p= old[i];
+               // check candidate list packing and redo the matpacks
+               if (0  && getModuleId(p) == algebraRef && (getFunctionId(p) == 
subselectRef || getFunctionId(p)== thetasubselectRef) && 
isaBatType(getArgType(m->src,p,2)))
+                       mutationMergePack(m->src,i-1,getArg(p,2));
+
                if ( i == pc){
 
                        profiler = m->src->profiler[i].trace;
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
@@ -86,7 +86,7 @@ RUNmulticore(Client cntxt, MalBlkPtr mb,
                mutant->serialExecTime = mutant->next->serialExecTime;
                MUTupdateGlobalMin(mutant);     
                MUTupdateRateOfFall(cntxt, mutant);
-               trimMalVariables(mb,stk);
+               trimMalVariables(mb,mutant->stk);
        }
 
        DEBUG_PRINT_TIME
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to