Changeset: bae6f75ce282 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bae6f75ce282
Modified Files:
monetdb5/scheduler/Tests/mutation00.mal
monetdb5/scheduler/run_mutation.c
Branch: mutation
Log Message:
Sample code generation for mutations
diffs (132 lines):
diff --git a/monetdb5/scheduler/Tests/mutation00.mal
b/monetdb5/scheduler/Tests/mutation00.mal
--- a/monetdb5/scheduler/Tests/mutation00.mal
+++ b/monetdb5/scheduler/Tests/mutation00.mal
@@ -42,3 +42,5 @@ end query;
scheduler.mutation("user","query");
scheduler.mutation("user","query");
scheduler.mutation("user","query");
+scheduler.mutation("user","query");
+scheduler.mutation("user","query");
diff --git a/monetdb5/scheduler/run_mutation.c
b/monetdb5/scheduler/run_mutation.c
--- a/monetdb5/scheduler/run_mutation.c
+++ b/monetdb5/scheduler/run_mutation.c
@@ -26,6 +26,7 @@
#include "monetdb_config.h"
#include "run_mutation.h"
#include "mal_profiler.h"
+#include "opt_prelude.h"
void
@@ -36,24 +37,27 @@ mutationPrint(Client cntxt, Mutant m)
mutationPrint(cntxt, m->next);
}
+/*
+ * For the time being we focus on a limited set op MAL instructions.
+ */
static int
mutationCandidate(MalBlkPtr mb, InstrPtr p){
(void) mb;
- if ( getModuleId(p) && strncmp(getModuleId(p),"algebra",7) == 0)
+ if ( getModuleId(p) == algebraRef)
return 1;
- if ( getModuleId(p) && strncmp(getModuleId(p),"aggr",4) == 0)
+ if ( getModuleId(p) == aggrRef)
return 1;
return 0;
}
/* Sample plan mutation actions
- * The select mutation simply splits it in the maximum number of cores
+ * The select mutation simply splits the target instruction
* and glues the result using matpack.
*/
static void
mutationSelect(Client cntxt, Mutant m, int pc){
- int i,limit;
- InstrPtr p=0, *old= m->src->stmt;
+ int i,limit, b1,b2, v1,v2;
+ InstrPtr p=0, *old= m->src->stmt, q;
(void) cntxt;
limit= m->src->stop;
@@ -64,8 +68,44 @@ mutationSelect(Client cntxt, Mutant m, i
for (i = 1; i < limit; i++) {
p= old[i];
if ( i == pc){
- /* replace the instruction, e.g. with a partioned one */
- pushInstruction(m->src,p);
+ /* replace the instruction, e.g. with a partioned one.
+ Dont use any partition intelligence, simple half
split
+ v := algebra.select(b,l,h) =>
+ b1 := bat.partition(b,2,0);
+ b2 := bat.partition(b,2,1);
+ v1:= algebra.select(b1,l,h);
+ v2:= algebra.select(b2,l,h);
+ v:= mat.pack(v1,v2);
+ */
+ q= newStmt(m->src, batRef, partitionRef);
+ setVarType(m->src, getArg(q,0), getArgType(m->src, p,
p->retc));
+ b1 = getArg(q,0);
+ q = pushArgument(m->src,q,getArg(p,1));
+ q = pushInt(m->src,q,2);
+ q = pushInt(m->src,q,0);
+
+ q= newStmt(m->src, batRef, partitionRef);
+ setVarType(m->src, getArg(q,0), getArgType(m->src, p,
p->retc));
+ b2 = getArg(q,0);
+ q = pushArgument(m->src,q,getArg(p,1));
+ q = pushInt(m->src,q,2);
+ q = pushInt(m->src,q,1);
+
+ q= copyInstruction(p);
+ getArg(q,1)= b1;
+ v1 = getArg(q,0)= newTmpVariable(m->src,TYPE_any);
+ pushInstruction(m->src,q);
+ q= copyInstruction(p);
+ getArg(q,1)= b2;
+ v2 = getArg(q,0)= newTmpVariable(m->src,TYPE_any);
+ pushInstruction(m->src,q);
+
+ q= newStmt(m->src,matRef,packRef);
+ getArg(q,0)= getArg(p,0);
+ q= pushArgument(m->src,q,v1);
+ q= pushArgument(m->src,q,v2);
+
+ //pushInstruction(m->src,p);
m->target = pc;
m->comment = GDKstrdup("mutationSelect");
} else
@@ -163,13 +203,15 @@ RUNmutation(Client cntxt, MalBlkPtr mb,
printInstruction(cntxt->fdout,src,0,getInstrPtr(src,target),LIST_MAL_ALL);
}
/* At this point we have a target instruction to be replaced */
- /* safe the current version in the history list */
+ /* safe the previous version in the history list */
if ( mutationCandidate(src, p = getInstrPtr(src, target)) ){
/* add the mutation to the collection */
+ /* prepare a new mutation record */
mutant = (Mutant) GDKzalloc(sizeof(struct MUTANT));
- mutant->src = copyMalBlk(src);
mutant->next = ((Mutant)src->mutants);
+ mutant->src = src;
+ ((Mutant) src->mutants)->src = copyMalBlk(src);
src->mutants = (void *) mutant;
/* apply heuristics */
@@ -178,6 +220,13 @@ RUNmutation(Client cntxt, MalBlkPtr mb,
if ( getModuleId(p) && strncmp(getModuleId(p), "aggr",4)== 0)
mutationSum(cntxt,mutant, target);
src = mutant->src;
+
+ /* reset the profiler */
+ for( i = 0; i < src->stop; i++)
+ src->profiler[i].ticks = 0;
+ src->calls = 0;
+ DEBUG_MUTATION
+ printFunction(cntxt->fdout, src,0,LIST_MAL_ALL);
}
clk = GDKusec();
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list