Changeset: 16d6f989eb50 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=16d6f989eb50 Modified Files: monetdb5/scheduler/mut_transforms.c Branch: mutation Log Message:
Remove mat.pack due to base operator partitioning, in case of join remove both mat.packs diffs (truncated from 482 to 300 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,64 @@ mutationLeftFetchJoin(Client cntxt, Muta GDKfree(old); } +//Removes the mat.pack due to base operator partitioned operators. If join is base operator there would be two mat.packs, else one mat.pack +//remove all of them. + +static void +removeMatPack(Mutant m, Client cntxt, InstrPtr instrMatPack) +{ + InstrPtr p, instrJoin; + int i, beginLifeJoin, eofLifeJoin; + Lifespan span; + int j, pc, joinRefInstr; + + pc = m->target; + span = setLifespan(m->src); + //Handle the case when the base operator is a join, and hence has two mat.pck operators to take care of + beginLifeJoin = getBeginLifespan(span, getArg(instrMatPack, instrMatPack->retc + 1)); + instrJoin = getInstrPtr(m->src, beginLifeJoin); + if(getModuleId(instrJoin) == algebraRef && getFunctionId(instrJoin) == joinRef) + { + eofLifeJoin = getEndLifespan(span, getArg(instrJoin, instrJoin->retc -1)); + joinRefInstr = -1; + + // Find reference instruction where the second output of join instr (j2) in (j1,t2=algebra.join(S1,b)), is consumed + // for the first time in a mat.pack, in the above case its mat.pack(t1,t2) + for(i=pc+1; i<=eofLifeJoin; i++) + { + p = getInstrPtr(m->src, i); + for (j = p->retc; j < p->argc; j++) + { + if(getArg(p,j) == getArg(instrJoin, instrJoin->retc-1) && getModuleId(p) == matRef && getFunctionId(p)== packRef) + { + joinRefInstr = i; // the second mat.pack which accepts the second output of join found + break; + } + } + if(joinRefInstr != -1) + break; + } + if(joinRefInstr != -1) + { + // second mat.pack is rendered useless + getInstrPtr(m->src, joinRefInstr)->token = NOOPsymbol; + }else + { + DEBUG_MULTICORE + mnstr_printf(cntxt->fdout, "# No reference to second mat.pack which consumes output of join found\n"); + } + }else + { + DEBUG_MULTICORE + mnstr_printf(cntxt->fdout, "# No algebra.join instruction found as a base operator in the mat.pack back reference\n"); + } + // render the first mat.pack useless + instrMatPack->token = NOOPsymbol; +} + + + + // Case 2 // // A1 := algebra.subselect(....); @@ -633,11 +691,11 @@ mutationLeftFetchJoin(Client cntxt, Muta // M := mat.pack(J1, J2); static void -mutateNonPartitionedOperators(Mutant m, int stmtLoop, int matPackRefInstr, int matPackRefInstrArg, InstrPtr instrMatPack, int profiler) +mutateNonPartitionedOperators(Mutant m, Client cntxt, int stmtLoop, int matPackRefInstr, int matPackRefInstrArg, InstrPtr instrMatPack, int profiler) { int n, j, l, limit, v1[MAX_PARTITIONS], z1[MAX_PARTITIONS]; InstrPtr *old= m->src->stmt, q; - unsigned int matpc = 0, k, mat_pack_partitions; + int matpc = 0, k, mat_pack_partitions; limit= m->src->stop; @@ -707,6 +765,7 @@ mutateNonPartitionedOperators(Mutant m, } if (matpc == 0) { + q= newStmt(m->src,matRef,packRef); getArg(q,0)= getArg(getInstrPtr(m->src,matPackRefInstr),0); @@ -728,157 +787,212 @@ mutateNonPartitionedOperators(Mutant m, m->src->profiler[m->src->stop-1].trace = profiler; } // mask the original algebra.join instruction - getInstrPtr(m->src,matPackRefInstr)->token = NOOPsymbol; - + removeMatPack(m, cntxt, instrMatPack); + //getInstrPtr(m->src,matPackRefInstr)->token = NOOPsymbol; } } //end of the function } + + +//mutatePartitionedOperators(Mutant m, int stmtLoop, int matPackRefInstr, int matPackRefInstrArg, int batPartitionRefInstr, int batPartitionRefRefInstr, int batPartitionRefInstrArg, InstrPtr instrMatPack, int profiler) 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) +mutatePartitionedOperators(Mutant m, Client cntxt, int batPartitionRefRefInstr, int batPartitionRefInstr, int batPartitionRefInstrArg, InstrPtr instrMatPack, int profiler) { - int j, k; - InstrPtr q, depInstrMatPack; - int beginLifePC, beginLifeBatPartition, mat_pack_to_combine; - unsigned int i, mat_pack_partitions, dep_mat_pack_partitions; - Lifespan span; + int j;//,pc; + InstrPtr q, depInstrMatPack, depInstr; + int beginLifePC, beginLifeBatPartition, mat_pack_to_combine; + int i,k, mat_pack_partitions, dep_mat_pack_partitions; + Lifespan span; - span = setLifespan(m->src); + span = setLifespan(m->src); +// pc = m->target; + depInstrMatPack = getInstrPtr(m->src, batPartitionRefRefInstr); // The second mat.pack on dependency operator - 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; - - mat_pack_partitions = instrMatPack->argc - instrMatPack->retc; - dep_mat_pack_partitions = depInstrMatPack->argc - depInstrMatPack->retc; + depInstr = getInstrPtr(m->src, batPartitionRefInstr); - if(mat_pack_partitions > dep_mat_pack_partitions) - { - // replace the algebra.join(Bat_Partition,...) with algebra.join(algebra.select.partition) + if(getModuleId(depInstr) == algebraRef && getFunctionId(depInstr) != joinRef) // case 2 + { + if(mat_pack_partitions > dep_mat_pack_partitions) + { + // replace the algebra.join(Bat_Partition,...) with algebra.join(algebra.select.partition) + // + // 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,T1 := algebra.join(S1,b); + // J2,T2 := algebra.join(S2,b); + // M_ := mat.pack(J1, J2); + // T_ := mat.pack(T1, T2); + + // Morphed into new plan + // + // A1 := algebra.subselect(....); + // A2 := algebra.subselect(....); + // A3 := algebra.subselect(....); + // + // S1 := mat.pack(A2,A3); + // + // J1,T1 := algebra.join(A1,b); + // J2,T2 := algebra.join(S1,b); + // M_ := mat.pack(J1, J2); + // T_ := mat.pack(T1, T2); + + // propogate from dependent operator (total_partition - 1) to base operator all the mapping partitions + for(i=0; i<dep_mat_pack_partitions-1; i++) + { + beginLifePC = getBeginLifespan(span, getArg(depInstrMatPack, depInstrMatPack->retc + i)); + + // 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); + + removeMatPack(m, cntxt, instrMatPack); + + + + // The case when base operator partitions are less than the dependent operator partitions // - // 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); + }else if(mat_pack_partitions < dep_mat_pack_partitions) + { + // replace the algebra.join(Bat_Partition,...) with algebra.join(algebra.select.partition) + // A1 := algebra.subselect(....); + // A2 := algebra.subselect(....); + // M := mat.pack(A1, A2); + // + // S1 := bat.partition(M,2,0); + // S2 := bat.partition(M,2,1); + // S3 := bat.partition(M,2,2); + // + // J1 := algebra.join(S1,b); + // J2 := algebra.join(S2,b); + // J3 := algebra.join(S3,b); + // M_ := mat.pack(J1, J2, J3); - // 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); - - // propogate from dependent operator (total_partition - 1) to base operator all the mapping partitions - for(i=0; i<dep_mat_pack_partitions-1; i++) + // Morphed into new plan + // + // A1 := algebra.subselect(....); + // A2 := algebra.subselect(....); + // + // S1 := bat.partition(A2,2,0); + // S2 := bat.partition(A2,2,1); + // + // J1 := algebra.join(A1,b); + // J2 := algebra.join(S1,b); + // J3 := algebra.join(S2,b); + // M_ := mat.pack(J1, J2, J3); + + // propogate from base operator (total_partition - 1) to dependent operator all the mapping partitions + for(i=0; i<mat_pack_partitions-1; i++) + { + beginLifePC = getBeginLifespan(span, getArg(depInstrMatPack, depInstrMatPack->retc + i)); + + // 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; + } + + // replace the remaining bat.partitions instructions with appropriate parameters to suit new bat.partitions requirements + for(j=0; i< dep_mat_pack_partitions; i++,j++) + { + beginLifePC = getBeginLifespan(span, getArg(depInstrMatPack, depInstrMatPack->retc + i)); + beginLifeBatPartition = getBeginLifespan(span, getArg(getInstrPtr(m->src,beginLifePC),batPartitionRefInstrArg)); + + // reset the s1 := bat.partition(A2,2,0) in the original s2 := bat.partition(M,2,1); + getArg(getInstrPtr(m->src, beginLifeBatPartition), 1) = getArg(instrMatPack, mat_pack_partitions); + getArg(getInstrPtr(m->src, beginLifeBatPartition), 2) = dep_mat_pack_partitions - (mat_pack_partitions -1); + getArg(getInstrPtr(m->src, beginLifeBatPartition), 3) = j; + + // set the J2 := algebra.join(S1,b) the S1 argument to corresponding bat.partition output + getArg(getInstrPtr(m->src, beginLifePC), batPartitionRefInstrArg) = getArg(getInstrPtr(m->src, beginLifeBatPartition), 0); + } + //instrMatPack->token = NOOPsymbol; + removeMatPack(m, cntxt, instrMatPack); + + }else // both base and dependent operator partitions are equal + { // A1 := algebra.subselect(....); + // A2 := algebra.subselect(....); + // M := mat.pack(A1, A2); + // + // S1 := bat.partition(M,2,0); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list