Changeset: a2c1e578da7f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a2c1e578da7f
Modified Files:
monetdb5/scheduler/mut_transforms.c
Branch: mutation
Log Message:
already partitioned dependecy operator mutation base code. mat.pack propogation
when base operator partitions are more than dependency operator partitions
diffs (283 lines):
diff --git a/monetdb5/scheduler/mut_transforms.c
b/monetdb5/scheduler/mut_transforms.c
--- a/monetdb5/scheduler/mut_transforms.c
+++ b/monetdb5/scheduler/mut_transforms.c
@@ -590,6 +590,48 @@ mutationLeftFetchJoin(Client cntxt, Muta
GDKfree(old);
}
+ // Case 2
+ //
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // A3 := algebra.subselect(....);
+ // M := mat.pack(A1, A2, A3);
+ //
+ // S1 := bat.partion(M,2,0);
+ // S2 := bat.partition(M,2,1);
+ //
+ // J1 := algebra.join(S1,b);
+ // J2 := algebra.join(S2,b);
+ // M_ := mat.pack(J1, J2);
+
+ // Morphed into new plan
+ //
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // A3 := algebra.subselect(....);
+ //
+ // S1 := mat.pack(A2,A3);
+ //
+ // J1 := algebra.join(A1,b);
+ // J2 := algebra.join(S1,b);
+ // M_ := mat.pack(J1, J2);
+
+ // Case 1
+ //
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // M1 := mat.pack(A1, A2);
+ // J := algebra.join(M1, b);
+ //
+ //
+ // Morphed into new plan
+ //
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // J1 := algebra.join(A1,b);
+ // J2 := algebra.join(A2,b);
+ // M := mat.pack(J1, J2);
+
static void
mutateNonPartitionedOperators(Mutant m, int stmtLoop, int matPackRefInstr, int
matPackRefInstrArg, InstrPtr instrMatPack, int profiler)
{
@@ -697,14 +739,106 @@ mutateNonPartitionedOperators(Mutant m,
//end of the function
}
+static void
+//mutatePartitionedOperators(Mutant m, int stmtLoop, int matPackRefInstr, int
matPackRefInstrArg, int batPartitionRefInstr, int batPartitionRefRefInstr, int
batPartitionRefInstrArg, InstrPtr instrMatPack, int profiler)
+mutatePartitionedOperators(Mutant m, int batPartitionRefRefInstr, int
batPartitionRefInstrArg, InstrPtr instrMatPack, int profiler)
+{
+ int i, k;
+ InstrPtr q, depInstrMatPack;
+ int mat_pack_partitions, dep_mat_pack_partitions, beginLifePC,
beginLifeBatPartition, mat_pack_to_combine;
+ Lifespan span;
+ span = setLifespan(m->src);
+
+ depInstrMatPack = getInstrPtr(m->src, batPartitionRefRefInstr); // The
second mat.pack on dependency operator
+
+
+ mat_pack_partitions = instrMatPack->argc - instrMatPack->retc;
+ dep_mat_pack_partitions = depInstrMatPack->argc - depInstrMatPack->retc;
+
+ if(mat_pack_partitions > dep_mat_pack_partitions)
+ {
+ for(i=0; i<dep_mat_pack_partitions-1; i++)
+ {
+ beginLifePC = getBeginLifespan(span, getArg(depInstrMatPack,
depInstrMatPack->retc + i));
+ // replace the algebra.join(Bat_Partition,...) with
algebra.join(algebra.select.partition)i
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // A3 := algebra.subselect(....);
+ // M := mat.pack(A1, A2, A3);
+ //
+ // S1 := bat.partion(M,2,0);
+ // S2 := bat.partition(M,2,1);
+ //
+ // J1 := algebra.join(S1,b);
+ // J2 := algebra.join(S2,b);
+ // M_ := mat.pack(J1, J2);
+
+ // Morphed into new plan
+ //
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // A3 := algebra.subselect(....);
+ //
+ // S1 := mat.pack(A2,A3);
+ //
+ // J1 := algebra.join(A1,b);
+ // J2 := algebra.join(S1,b);
+ // M_ := mat.pack(J1, J2);
+
+ // match the partitions of instrMatPack
+ getArg(getInstrPtr(m->src,beginLifePC),
batPartitionRefInstrArg) = getArg(instrMatPack, instrMatPack->retc + i);
+
+ // remove the bat.partition instructions by assigning a
NOOPsymbol
+ beginLifeBatPartition = getBeginLifespan(span,
getArg(getInstrPtr(m->src,beginLifePC),batPartitionRefInstrArg));
+ getInstrPtr(m->src, beginLifeBatPartition)->token = NOOPsymbol;
+ }
+
+ // the last argument adjustment instruction in depInstrMatPack =
+ beginLifePC = getBeginLifespan(span, getArg(depInstrMatPack,
depInstrMatPack->retc + i));
+
+ // remove the last bat.partition instructions corresponding to the last
join instruction by assigning a NOOPsymbol
+ beginLifeBatPartition = getBeginLifespan(span,
getArg(getInstrPtr(m->src,beginLifePC),batPartitionRefInstrArg));
+ getInstrPtr(m->src, beginLifeBatPartition)->token = NOOPsymbol;
+
+ //create S1= mat.pack(A2,A3) instruction
+ mat_pack_to_combine = mat_pack_partitions - (dep_mat_pack_partitions -
1);
+ q= newStmt(m->src,matRef,packRef);
+// getArg(q,0)= getArg(getInstrPtr(m->src,matPackRefInstr),0);
+
+ for(k=0; k<mat_pack_to_combine; k++)
+ q= pushArgument(m->src,q,getArg(instrMatPack,
instrMatPack->retc + (dep_mat_pack_partitions - 1) + k ));
+ m->src->profiler[m->src->stop-1].trace = profiler;
+
+ // Adjusted the value of J2 := algebra.join(S1, b);
+ getArg(getInstrPtr(m->src,beginLifePC), batPartitionRefInstrArg) =
getArg(q,0);
+
+ instrMatPack->token = NOOPsymbol;
+
+ }else if(mat_pack_partitions < dep_mat_pack_partitions)
+ {
+
+ }else
+ {
+
+
+ }
+}
void
mutationMatPack(Client cntxt, Mutant m) {
int pc = m->target, i, j, limit, profiler;
- InstrPtr p=0, *old= m->src->stmt, instrMatPack;
+ InstrPtr p=0, *old= m->src->stmt, instrMatPack, instrBatPartition,
instrBatPartitionRef;
- int stmtLoop, matPackRefInstr, matPackRefInstrArg;
+ int stmtLoop; // Loop that goes through the entire instruction
statements
+ int matPackRefInstr; // first instruction referring the mat.pack
result
+ int matPackRefInstrArg; // The argument number in the first instruction
referring mat.pack result.
+ int batPartitionRefInstr;
+ int batPartitionRefInstrArg;
+ int batPartitionRefRefInstr;
+// int batPartitionRefRefInstrArg;
+
+
// search for the mat.pack outuput variable
@@ -803,27 +937,115 @@ mutationMatPack(Client cntxt, Mutant m)
if(matPackRefInstr != -1)
break;
}
+ // Case 2
+
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // A3 := algebra.subselect(....);
+ // M := mat.pack(A1, A2, A3);
+ //
+ // S1 := bat.partion(M,2,0);
+ // S2 := bat.partition(M,2,1);
+ //
+ // J1 := algebra.join(S1,b);
+ // J2 := algebra.join(S2,b);
+ // M_ := mat.pack(J1, J2);
+
// Find what kind of case this is (case 1, or case 2)
if(matPackRefInstr != -1)
{
if(getModuleId(getInstrPtr(m->src,matPackRefInstr)) == batRef)
{
-
if(getFunctionId(getInstrPtr(m->src,matPackRefInstr)) == partitionRef)
+
if(getFunctionId(getInstrPtr(m->src,matPackRefInstr)) == partitionRef) // case
2
{
- //mutatePartitionedOperator();
+ // mutatePartitionedOperator(m,
stmtLoop, matPackRefInstr, matPackRefInstrArg, instrMatPack, profiler);
- }
-
- }else
+ // Find the output of the
bat.partition
+ // Find the instruction that
refers to the output of the bat partition
+ // Find the output of this
instruction, because that will be the input to the mat.pack
+ // Find the number of
partitions of this mat.pack operation
+
+ instrBatPartition =
old[matPackRefInstr]; // bat.partition instruction pointer saved
+ batPartitionRefInstr = -1;
+
+ // Find reference instruction
where the bat.partition.output s1 in case 2, is consumed
+ // for the first time
+ for(i=pc+1;
getEndOfLife(m->src, getArg(instrBatPartition, 0)); i++)
+ {
+ p = getInstrPtr(m->src,
i);
+ for (j = p->retc; j <
p->argc; j++)
+ {
+ if(getArg(p,j)
== getArg(instrBatPartition, 0))
+ {
+
batPartitionRefInstr = i;
+
batPartitionRefInstrArg = j;
+ break;
+ }
+ }
+ if(batPartitionRefInstr
!= -1)
+ break;
+ }
+ if(batPartitionRefInstr != -1)
+ {
+ instrBatPartitionRef =
old[batPartitionRefInstr]; // J1 := algebra.join(S1,b);
+ batPartitionRefRefInstr
= -1;
+
+ // Find reference
instruction where the output of batPartition reference instr
(algebra.join(S1,b)) in case 2, is consumed
+ // for the first time
, in the above case its mat.pack(J1,J2)
+ for(i=pc+1;
getEndOfLife(m->src, getArg(instrBatPartitionRef, 0)); i++)
+ {
+ p =
getInstrPtr(m->src, i);
+ for (j =
p->retc; j < p->argc; j++)
+ {
+
if(getArg(p,j) == getArg(instrBatPartitionRef, 0))
+ {
+
batPartitionRefRefInstr = i;
+
//batPartitionRefRefInstrArg = j;
+
break;
+ }
+ }
+
if(batPartitionRefRefInstr != -1)
+ break;
+ }
+
if(batPartitionRefRefInstr != -1)
+ {
+
//mutatePartitionedOperators(m, stmtLoop, matPackRefInstr, matPackRefInstrArg,
batPartitionRefInstr, batPartitionRefRefInstr, batPartitionRefInstrArg,
instrMatPack, profiler);
+
mutatePartitionedOperators(m, batPartitionRefRefInstr,
batPartitionRefInstrArg, instrMatPack, profiler);
+
+ }else
+ {
+ DEBUG_MULTICORE
+
mnstr_printf(cntxt->fdout, "# No reference to bat.partitioned 'ref' 'ref'
output in instruction found, for example no mat.pack that consumes algebra.join
output found\n");
+ }
+
+ }else
+ {
+ DEBUG_MULTICORE
+
mnstr_printf(cntxt->fdout, "# No reference to bat.partitioned output in
instruction found\n");
+ }
+
+ }
+ }else // case 1
{
+ // Case 1
+ //
+ // A1 := algebra.subselect(....);
+ // A2 := algebra.subselect(....);
+ // M1 := mat.pack(A1, A2);
+ // J := algebra.join(M1, b);
+
// instruction referring mat.pack results
mutateNonPartitionedOperators(m,
stmtLoop, matPackRefInstr, matPackRefInstrArg, instrMatPack, profiler);
}
//pushInstruction(m->src,p);
m->target = pc;
m->comment = GDKstrdup("mutationMatPack");
- }
+ }else
+ {
+ DEBUG_MULTICORE
+ mnstr_printf(cntxt->fdout, "# No
reference to the mat.pack instruction found");
+ }
}else
pushInstruction(m->src,p);
}
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list