Changeset: 9a8683b9be5a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9a8683b9be5a
Added Files:
        monetdb5/scheduler/mut_matpack.c
        monetdb5/scheduler/mut_matpack.h
Modified Files:
        gdk/gdk_utils.c
        monetdb5/mal/mal_dataflow.c
        monetdb5/scheduler/Makefile.ag
        monetdb5/scheduler/mut_leftjoin.c
        monetdb5/scheduler/mut_select.h
        monetdb5/scheduler/mut_transforms.c
        monetdb5/scheduler/mut_transforms.h
        monetdb5/scheduler/mut_util.c
        monetdb5/scheduler/mut_util.h
        monetdb5/scheduler/run_multicore.c
        monetdb5/scheduler/run_multicore.h
        monetdb5/scheduler/run_octopus.c
Branch: mutation
Log Message:

Merge with head


diffs (truncated from 1964 to 300 lines):

diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -677,7 +677,7 @@ runMALdataflow(Client cntxt, MalBlkPtr m
                return MAL_SUCCEED;
        }
 
-       assert(stoppc > startpc);
+       assert(stoppc > startpc || stoppc == 0);
 
        /* check existence of free worker group, resort to sequential upon 
failure */
        if( (pool= DFLOWinitialize()) < 0){
diff --git a/monetdb5/scheduler/Makefile.ag b/monetdb5/scheduler/Makefile.ag
--- a/monetdb5/scheduler/Makefile.ag
+++ b/monetdb5/scheduler/Makefile.ag
@@ -35,6 +35,7 @@ lib_scheduler = {
                mut_util.c mut_util.h \
                mut_select.c mut_select.h \
                mut_leftjoin.c mut_leftjoin.h \
+               mut_matpack.c mut_matpack.h \
                mut_policy.c mut_policy.h \
                run_memo.c run_memo.h \
                run_octopus.c run_octopus.h \
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
@@ -24,357 +24,9 @@
  */
 #include "monetdb_config.h"
 #include "mut_leftjoin.h"
+#include "mut_matpack.h"
 #include "opt_prelude.h"
 
-/* Sample plan mutation actions
- * The join mutation simply splits the target instruction
- * and glues the result using matpack.
- * If the target is already input to a mat.pack, then we should add
- * the pieces produced to that instruction instead of making a new mat.pack.
- * 
- * mutationJoinDouble splits both the input relations to the join operator 
- */
-
-static void 
-mutationJoinDouble_(MalBlkPtr mb, MalStkPtr stk, InstrPtr p, int partitions, 
int slice, int profiler, int *b1Ptr, int *y1Ptr)
-{
-       InstrPtr q;
-
-       q= newStmt(mb, batRef, partitionRef);
-       setVarType(mb, getArg(q,0), getArgType(mb, p, p->retc));
-       *b1Ptr = getArg(q,0);
-       q = pushArgument(mb,q,getArg(p,p->retc));
-       q = pushInt(mb,q,2);
-       // update the stack as well, because we are executing
-       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= newStmt(mb, batRef, partitionRef);
-       setVarType(mb, getArg(q,0), getArgType(mb, p, p->retc+1));
-       *y1Ptr = getArg(q,0);
-       q = pushArgument(mb,q,getArg(p,p->retc+1));
-       q = pushInt(mb,q,2);
-       // update the stack as well, because we are executing
-       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;
-
-}
-
-static void
-copyJoinDouble_(MalBlkPtr mb, InstrPtr p, int profiler, int b, int y, int 
*vPtr, int *zPtr)
-{
-       InstrPtr q;
-
-       q= copyInstruction(p);
-       getArg(q,2)= b;
-       getArg(q,3)= y;
-       *vPtr = getArg(q,0)= newTmpVariable(mb,TYPE_any);
-       *zPtr = getArg(q,1)= newTmpVariable(mb,TYPE_any);
-       pushInstruction(mb,q);
-       // inherit profiling
-       mb->profiler[mb->stop-1].trace = profiler;
-
-}
-
-static void
-copyLanguagePassRefJoinDouble_(MalBlkPtr mb, int profiler, int b)
-{
-       InstrPtr q;
-
-       q= newStmt(mb, languageRef, passRef);
-       q = pushArgument(mb,q, b);
-       // inherit profiling
-       mb->profiler[mb->stop-1].trace = profiler;
-}
-
-void mutationJoinDouble(Client cntxt, Mutant m){
-    int pc = m->target, i, j, k, limit, b1,b2, v1,v2,v3,v4, z1,z2,z3,z4,y1,y2 ;
-    InstrPtr p=0, *old= m->src->stmt, q;
-    int matpc = 0, profiler;
-
-    (void) cntxt;
-    limit= m->src->stop;
-    if ( newMalBlkStmt(m->src, m->src->ssize) < 0)
-        return;
-
-    pushInstruction(m->src, old[0]);
-    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,x2 := algebra.join(b,Y) =>
-                       //      b1 := bat.partition(b,2,0);
-                       //      b2 := bat.partition(b,2,1);
-                       //      y1 := bat.partition(Y,2,0);
-                       //      y2 := bat.partition(Y,2,1);
-                       //      v1,z1:= algebra.join(b1,y1);
-                       //      v2,z2:= algebra.join(b2,y1);
-                       //      v3,z3:= algebra.join(b1,y2);
-                       //      v4,z4:= algebra.join(b2,y2);
-                       //      x1:= mat.pack(v1,v2,v3,v4);
-                       //      x2:= mat.pack(z1,z2,z3,z4);
-                       //  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;
-                       }
-               
-                       profiler = m->src->profiler[i].trace;
-                       
-                       mutationJoinDouble_(m->src, m->stk, p, 2, 0, profiler, 
&b1, &y1);
-                       mutationJoinDouble_(m->src, m->stk, p, 2, 1, profiler, 
&b2, &y2);
-                       copyJoinDouble_(m->src, p, profiler, b1, y1, &v1, &z1);
-                       copyJoinDouble_(m->src, p, profiler, b2, y1, &v2, &z2); 
                
-                       copyJoinDouble_(m->src, p, profiler, b1, y2, &v3, &z3); 
                
-                       copyJoinDouble_(m->src, p, profiler, b2, y2, &v4, &z4); 
                
-
-                       copyLanguagePassRefJoinDouble_(m->src, profiler, b1);
-                       copyLanguagePassRefJoinDouble_(m->src, profiler, b2);
-                       copyLanguagePassRefJoinDouble_(m->src, profiler, y1);
-                       copyLanguagePassRefJoinDouble_(m->src, profiler, y2);
-
-
-                       // 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, v4);
-                                                       old[j] = 
setArgument(m->src,old[j],k, v3);
-                                                       old[j] = 
setArgument(m->src,old[j],k, v2);
-                                                       old[j] = 
setArgument(m->src,old[j],k, v1);
-                                                       break;
-                                               }
-                                                               
-                               }
-                               if(matpc>0 && j+1<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,1)){
-                                                               // replace this 
argument 
-                                                               matpc++;
-                                                               
delArgument(old[j],k);
-                                                               old[j] = 
setArgument(m->src,old[j],k, z4);
-                                                               old[j] = 
setArgument(m->src,old[j],k, z3);
-                                                               old[j] = 
setArgument(m->src,old[j],k, z2);
-                                                               old[j] = 
setArgument(m->src,old[j],k, z1);
-                                                               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);
-                               q= pushArgument(m->src,q,v3);
-                               q= pushArgument(m->src,q,v4);
-                               m->src->profiler[m->src->stop-1].trace = 
profiler;
-
-                               q= newStmt(m->src,matRef,packRef);
-                               getArg(q,0)= getArg(p,1);
-                               q= pushArgument(m->src,q,z1);
-                               q= pushArgument(m->src,q,z2);
-                               q= pushArgument(m->src,q,z3);
-                               q= pushArgument(m->src,q,z4);
-                               m->src->profiler[m->src->stop-1].trace = 
profiler;
-
-                       }
-
-                       m->target = pc;
-                       m->comment = GDKstrdup("mutationJoin");
-               } else
-                       pushInstruction(m->src,p);
-       }
-    GDKfree(old);
-}
-
-
-/* Sample plan mutation actions
- * The join mutation simply splits the target instruction
- * and glues the result using matpack.
- * If the target is already input to a mat.pack, then we should add
- * the pieces produced to that instruction instead of making a new mat.pack.
- * 
- * mutationJoin splits only the left relation of the join operator
- *
- */
-
-
-static void 
-mutationJoin_(MalBlkPtr mb, MalStkPtr stk, InstrPtr p, int partitions, int 
slice, int profiler, int *v1Ptr, int *z1Ptr)
-{
-       int b1;
-       InstrPtr q;
-
-       q= newStmt(mb, batRef, partitionRef);
-       setVarType(mb, getArg(q,0), getArgType(mb, p, p->retc));
-       b1 = getArg(q,0);
-       q = pushArgument(mb,q,getArg(p,p->retc));
-       q = pushInt(mb,q,2);
-       // update the stack as well, because we are executing
-       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,2)= b1;
-       *v1Ptr = getArg(q,0)= newTmpVariable(mb,TYPE_any);
-       *z1Ptr = getArg(q,1)= newTmpVariable(mb,TYPE_any);
-       pushInstruction(mb,q);
-       // inherit profiling
-       mb->profiler[mb->stop-1].trace = profiler;
-}
-
-void 
-mutationJoin(Client cntxt, Mutant m){
-    int pc = m->target, i, j, k, limit, v1,v2, z1,z2;
-    InstrPtr p=0, *old= m->src->stmt, q;
-    int matpc = 0, profiler;
-      
-
-    (void) cntxt;
-    limit= m->src->stop;
-    if ( newMalBlkStmt(m->src, m->src->ssize) < 0)
-        return;
-
-    pushInstruction(m->src, old[0]);
-    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,x2 := algebra.join(b,Y) =>
-                       //      b1 := bat.partition(b,2,0);
-                       //      b2 := bat.partition(b,2,1);
-                       //      v1,z1:= algebra.join(b1,Y);
-                       //      v2,z2:= algebra.join(b2,Y);
-                       //      x1:= mat.pack(v1,v2);
-                       //      x2:= mat.pack(z1,z2);
-                       //  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;
-                       }
-               
-                       profiler = m->src->profiler[i].trace;
-                       
-                       mutationJoin_(m->src, m->stk, p, 2, 0, profiler, &v1, 
&z1);
-                       mutationJoin_(m->src, m->stk, p, 2, 1, profiler, &v2, 
&z2);
-                       
-                       // 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 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to