Changeset: be05e5b865b7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=be05e5b865b7
Added Files:
monetdb5/scheduler/Tests/query00.mal
Modified Files:
monetdb5/modules/mal/batExtensions.c
monetdb5/scheduler/Tests/All
monetdb5/scheduler/run_mutation.c
monetdb5/scheduler/run_mutation.h
monetdb5/scheduler/run_mutation.mal
Branch: mutation
Log Message:
Prepare for optimizer pipe
The stack frame should be used and expanded when you mutate.[todo]
Still a parallel issue in access to underlying BATs
diffs (188 lines):
diff --git a/monetdb5/modules/mal/batExtensions.c
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -263,9 +263,11 @@ CMDbatpartition2(Client cntxt, MalBlkPtr
bn = BATslice(b, lval,hval);
BATseqbase(bn, lval);
if (bn== NULL){
- BBPunfix(b->batCacheid);
+ BBPreleaseref(b->batCacheid);
throw(MAL, "bat.partition", INTERNAL_OBJ_CREATE);
}
+ if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
+
ret= (int *) getArgReference(stk,pci,0);
BBPkeepref(*ret = bn->batCacheid);
BBPreleaseref(b->batCacheid);
diff --git a/monetdb5/scheduler/Tests/All b/monetdb5/scheduler/Tests/All
--- a/monetdb5/scheduler/Tests/All
+++ b/monetdb5/scheduler/Tests/All
@@ -2,3 +2,4 @@ sched00
memo01
memo02
mutation00
+query00
diff --git a/monetdb5/scheduler/Tests/query00.mal
b/monetdb5/scheduler/Tests/query00.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/scheduler/Tests/query00.mal
@@ -0,0 +1,42 @@
+# example framework for a mutation based execution stack
+# illustrate how it would appear after an optimizer call.
+
+function initialize():bat[:oid,:lng];
+ b:= bat.new(:oid,:lng);
+
+ INT_MAX := 2147483647;
+ dbgmsk_restore := mdb.getDebug();
+ dbgmsk_unset := 8+8388608;
+ dbgmsk_keep := calc.xor(INT_MAX,dbgmsk_unset);
+ dbgmsk_set := calc.and(dbgmsk_restore,dbgmsk_keep);
+ mdb.setDebug(dbgmsk_set);
+
+ r:= mmath.srand(0);
+ barrier i:= 0:lng;
+ k:= mmath.rand();
+ l:= calc.lng(k);
+ bat.append(b,l);
+ redo i:= iterator.next(1:lng,1000000:lng);
+ exit i;
+ mdb.setDebug(dbgmsk_restore);
+
+ return b;
+end initialize;
+
+function query(b:bat[:oid,:lng]);
+ scheduler.mutation();
+ t0:= alarm.usec();
+barrier z:= language.dataflow();
+ s1 := algebra.select(b,1:lng,99:lng);
+ s2 := algebra.select(b,1:lng,999:lng);
+ s3 := algebra.select(b,1:lng,9999:lng);
+exit z;
+ t1:= alarm.usec();
+ t2 := t1-t0;
+ io.printf("#%d\n",t2);
+end query;
+
+b:= initialize();
+user.query(b);
+user.query(b);
+user.query(b);
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
@@ -76,6 +76,8 @@ mutationSelect(Client cntxt, Mutant m, i
v1:= algebra.select(b1,l,h);
v2:= algebra.select(b2,l,h);
v:= mat.pack(v1,v2);
+ Also initialize the corresponding stk, which may
actually
+ have to be extended.
*/
q= newStmt(m->src, batRef, partitionRef);
setVarType(m->src, getArg(q,0), getArgType(m->src, p,
p->retc));
@@ -140,21 +142,17 @@ mutationSum(Client cntxt, Mutant m, int
}
GDKfree(old);
}
-
-str
-RUNmutation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+static str
+RUNmutationInternal(Client cntxt, MalStkPtr stk, str modnme, str fcnnme)
{
- str modnme = *(str*) getArgReference(stk,p,1);
- str fcnnme = *(str*) getArgReference(stk,p,2);
int i, target = 0;
Mutant mutant;
MalBlkPtr src=0;
+ InstrPtr p;
Symbol s= 0;
str msg;
lng clk;
- (void) mb;
-
DEBUG_MUTATION{
mnstr_printf(cntxt->fdout,"#mutation %s.%s\n",modnme,fcnnme);
} else
@@ -171,10 +169,13 @@ RUNmutation(Client cntxt, MalBlkPtr mb,
setFilterAll();
mutant = (Mutant) GDKzalloc(sizeof(struct MUTANT));
mutant->src = src;
+ mutant->stk = stk;
mutant->calls = 0;
src->mutants = (void*) mutant;
clk = GDKusec();
- msg = runMAL(cntxt, src,0,0);
+ // assume scheduler call is at line 1
+ // msg = runMALsequence(cntxt, src, 2,src->stop,stk,0,0);
+ msg = runMAL(cntxt, src, 0, 0);
mutant->calls++;
mutant->runtime += GDKusec()- clk;
return msg;
@@ -211,6 +212,7 @@ RUNmutation(Client cntxt, MalBlkPtr mb,
mutant = (Mutant) GDKzalloc(sizeof(struct MUTANT));
mutant->next = ((Mutant)src->mutants);
mutant->src = src;
+ mutant->stk = stk;
((Mutant) src->mutants)->src = copyMalBlk(src);
src->mutants = (void *) mutant;
@@ -230,7 +232,28 @@ RUNmutation(Client cntxt, MalBlkPtr mb,
}
clk = GDKusec();
+ // assume scheduler call is at line 1
+ //msg = runMALsequence(cntxt, src, 2,src->stop,stk,0, 0);
msg = runMAL(cntxt, src, 0, 0);
mutant->runtime += GDKusec()- clk;
return msg;
}
+
+str
+RUNmutationInline(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+ p = getInstrPtr(mb,0);
+
+ (void) stk;
+ return RUNmutationInternal(cntxt, 0, getModuleId(p), getFunctionId(p));
+}
+
+str
+RUNmutation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
+{
+ str modnme = *(str*) getArgReference(stk,p,1);
+ str fcnnme = *(str*) getArgReference(stk,p,2);
+
+ (void) mb;
+ return RUNmutationInternal(cntxt,0, modnme,fcnnme);
+}
diff --git a/monetdb5/scheduler/run_mutation.h
b/monetdb5/scheduler/run_mutation.h
--- a/monetdb5/scheduler/run_mutation.h
+++ b/monetdb5/scheduler/run_mutation.h
@@ -43,12 +43,14 @@ typedef struct MUTANT{
int calls; // how ofthen this plan is used
lng runtime; // accumulated runtime
MalBlkPtr src;
+ MalStkPtr stk;
str comment; // remember what you did
int target; // operation changed from previous
struct MUTANT *next;
} *Mutant;
#define DEBUG_MUTATION if(1)
run_mutation_export str RUNmutation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+run_mutation_export str RUNmutationInline(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr p);
run_mutation_export void mutationPrint(Client cntxt, Mutant m);
#endif /* MAL_RUN_MUTATION */
diff --git a/monetdb5/scheduler/run_mutation.mal
b/monetdb5/scheduler/run_mutation.mal
--- a/monetdb5/scheduler/run_mutation.mal
+++ b/monetdb5/scheduler/run_mutation.mal
@@ -19,3 +19,6 @@ pattern scheduler.mutation(mod:str, fcn:
address RUNmutation
comment "Generate an adaptive plan and execute it";
+pattern scheduler.mutation()
+address RUNmutationInline
+comment "Generate an adaptive plan and execute it";
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list