Changeset: 2ef3f9a36d65 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2ef3f9a36d65
Added Files:
MonetDB5/mal/mal_function.h
MonetDB5/modules/mal/orderidx.c
MonetDB5/optimizer/opt_pipes.c
MonetDB5/scheduler/run_memo.c
MonetDB5/scheduler/run_pipeline.c
Modified Files:
MonetDB5/mal/mal_dataflow.c
MonetDB5/mal/mal_debugger.c
MonetDB5/mal/mal_function.c
MonetDB5/mal/mal_instruction.c
MonetDB5/modules/mal/mdb.c
MonetDB5/modules/mal/wlc.c
MonetDB5/optimizer/opt_aliases.c
MonetDB5/optimizer/opt_candidates.c
MonetDB5/optimizer/opt_coercion.c
MonetDB5/optimizer/opt_commonTerms.c
MonetDB5/optimizer/opt_constants.c
MonetDB5/optimizer/opt_costModel.c
MonetDB5/optimizer/opt_dataflow.c
MonetDB5/optimizer/opt_deadcode.c
MonetDB5/optimizer/opt_emptybind.c
MonetDB5/optimizer/opt_evaluate.c
MonetDB5/optimizer/opt_garbageCollector.c
MonetDB5/optimizer/opt_generator.c
MonetDB5/optimizer/opt_inline.c
MonetDB5/optimizer/opt_jit.c
MonetDB5/optimizer/opt_json.c
MonetDB5/optimizer/opt_macro.c
MonetDB5/optimizer/opt_matpack.c
MonetDB5/optimizer/opt_mergetable.c
MonetDB5/optimizer/opt_mitosis.c
MonetDB5/optimizer/opt_multiplex.c
MonetDB5/optimizer/opt_oltp.c
MonetDB5/optimizer/opt_postfix.c
MonetDB5/optimizer/opt_profiler.c
MonetDB5/optimizer/opt_projectionpath.c
MonetDB5/optimizer/opt_pushselect.c
MonetDB5/optimizer/opt_querylog.c
MonetDB5/optimizer/opt_reduce.c
MonetDB5/optimizer/opt_remap.c
MonetDB5/optimizer/opt_remoteQueries.c
MonetDB5/optimizer/opt_reorder.c
MonetDB5/optimizer/opt_volcano.c
MonetDB5/optimizer/opt_wlc.c
clients/Tests/exports.stable.out
sql/backends/monet5/wlr.c
Branch: gdk-tracer
Log Message:
Renamed debugFunction to snprintFunction && renamed fprintFunction to
debugFunction
diffs (truncated from 2183 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
@@ -796,7 +796,7 @@ runMALdataflow(Client cntxt, MalBlkPtr m
int i;
DEBUG(MAL_DATAFLOW, "Running for block: %d - %d\n", startpc, stoppc);
- fprintFunction(MAL_DATAFLOW, mb, 0, LIST_MAL_ALL);
+ debugFunction(MAL_DATAFLOW, mb, 0, LIST_MAL_ALL);
/* in debugging mode we should not start multiple threads */
if (stk == NULL)
diff --git a/MonetDB5/mal/mal_debugger.c b/MonetDB5/mal/mal_debugger.c
--- a/MonetDB5/mal/mal_debugger.c
+++ b/MonetDB5/mal/mal_debugger.c
@@ -1106,7 +1106,7 @@ retryRead:
if( lstng == LIST_MAL_NAME)
printFunction(out,
fs->def, 0, lstng);
else
- debugFunction(out,
fs->def, 0, lstng, 0,mb->stop);
+ snprintFunction(out,
fs->def, 0, lstng, 0,mb->stop);
}
continue;
}
@@ -1114,7 +1114,7 @@ retryRead:
if( lstng == LIST_MAL_NAME)
printFunction(out, m, 0, lstng);
else
- debugFunction(out, m, 0, lstng,
0,m->stop);
+ snprintFunction(out, m, 0,
lstng, 0,m->stop);
}
} else {
/*
@@ -1141,7 +1141,7 @@ partial:
mnstr_printf(out, "#line %d out of
range (<=%d)\n", first, mb->stop);
first = pc;
} else {
- debugFunction(out, mb, 0, lstng, first,
stepsize);
+ snprintFunction(out, mb, 0, lstng,
first, stepsize);
first = first + stepsize > mb->stop ?
first : first + stepsize;
}
}
diff --git a/MonetDB5/mal/mal_function.c b/MonetDB5/mal/mal_function.c
--- a/MonetDB5/mal/mal_function.c
+++ b/MonetDB5/mal/mal_function.c
@@ -218,7 +218,7 @@ void chkFlow(MalBlkPtr mb)
if(msg == MAL_SUCCEED && lastInstruction < mb->stop-1 ){
mb->errors = createMalException( mb,lastInstruction,SYNTAX,
"instructions after END");
- fprintFunction(MAL_FCN, mb, 0, LIST_MAL_ALL);
+ debugFunction(MAL_FCN, mb, 0, LIST_MAL_ALL);
}
if( endseen)
for(btop--; btop>=0;btop--){
@@ -370,7 +370,7 @@ cloneFunction(Module scope, Symbol proc,
}
/* now change the definition of the original proc */
DEBUG(MAL_FCN, "Cloned version\n");
- fprintFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
+ debugFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
/* check for errors after fixation , TODO*/
pp = getSignature(new);
@@ -401,7 +401,7 @@ cloneFunction(Module scope, Symbol proc,
clrVarFixed(new->def, i);
DEBUG(MAL_FCN, "Function to be checked\n");
- fprintFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
+ debugFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
/* check for errors after fixation , TODO*/
/* beware, we should now ignore any cloning */
@@ -412,12 +412,12 @@ cloneFunction(Module scope, Symbol proc,
mb->errors = new->def->errors;
mb->errors = createMalException(mb,0,TYPE,"Error in
cloned function");
new->def->errors = 0;
- fprintFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
+ debugFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
}
}
DEBUG(MAL_FCN, "Newly cloned function added to: %s %d\n", scope->name,
i);
- fprintFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
+ debugFunction(MAL_FCN, new->def, 0, LIST_MAL_ALL);
return new;
}
@@ -427,7 +427,7 @@ cloneFunction(Module scope, Symbol proc,
* is returned.
*/
void
-debugFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int flg, int first, int
step)
+snprintFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int flg, int first,
int step)
{
int i,j;
str ps;
@@ -516,7 +516,7 @@ void printFunction(stream *fd, MalBlkPtr
listFunction(fd,mb,stk,flg,0,mb->stop);
}
-void fprintFunction(COMPONENT comp, MalBlkPtr mb, MalStkPtr stk, int flg)
+void debugFunction(COMPONENT comp, MalBlkPtr mb, MalStkPtr stk, int flg)
{
int i,j;
InstrPtr p;
diff --git a/MonetDB5/mal/mal_function.h b/MonetDB5/mal/mal_function.h
new file mode 100644
--- /dev/null
+++ b/MonetDB5/mal/mal_function.h
@@ -0,0 +1,40 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ */
+
+#ifndef _MAL_FCN_H
+#define _MAL_FCN_H
+
+#include "mal_instruction.h"
+#include "mal_module.h"
+#include "mal_resolve.h"
+#include "gdk_tracer.h"
+
+#define getLastUpdate(L,I) ((L)->var[I].updated)
+#define getEndScope(L,I) ((L)->var[I].eolife)
+#define getBeginScope(L,I) ((L)->var[I].declared)
+
+mal_export Symbol newFunction(str mod, str nme,int kind);
+mal_export int getPC(MalBlkPtr mb, InstrPtr p);
+
+mal_export Symbol getFunctionSymbol(Module scope, InstrPtr p);
+mal_export void chkFlow(MalBlkPtr mb);
+mal_export void chkDeclarations(MalBlkPtr mb);
+mal_export void clrDeclarations(MalBlkPtr mb);
+mal_export int isLoopBarrier(MalBlkPtr mb, int pc);
+mal_export int getBlockExit(MalBlkPtr mb,int pc);
+mal_export int getBlockBegin(MalBlkPtr mb,int pc);
+mal_export void setVariableScope(MalBlkPtr mb);
+
+mal_export void printFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int
flg);
+mal_export void debugFunction(COMPONENT comp, MalBlkPtr mb, MalStkPtr stk, int
flg);
+mal_export void snprintFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int
flg, int first, int size);
+
+#include "mal_exception.h"
+
+#define MAXDEPTH 32
+#endif /* _MAL_FCN_H*/
diff --git a/MonetDB5/mal/mal_instruction.c b/MonetDB5/mal/mal_instruction.c
--- a/MonetDB5/mal/mal_instruction.c
+++ b/MonetDB5/mal/mal_instruction.c
@@ -950,7 +950,7 @@ trimMalVariables_(MalBlkPtr mb, MalStkPt
(void) snprintf(mb->var[i].id, IDLENGTH,"%c%c%d", REFMARKER,
TMPMARKER,mb->vid++);
DEBUG(MAL_REDUCE, "After reduction\n");
- fprintFunction(MAL_REDUCE, mb, 0, 0);
+ debugFunction(MAL_REDUCE, mb, 0, 0);
GDKfree(alias);
mb->vtop = cnt;
diff --git a/MonetDB5/modules/mal/mdb.c b/MonetDB5/modules/mal/mdb.c
--- a/MonetDB5/modules/mal/mdb.c
+++ b/MonetDB5/modules/mal/mdb.c
@@ -567,7 +567,7 @@ MDBlistDetail(Client cntxt, MalBlkPtr mb
{
(void) p;
(void) stk;
- debugFunction(cntxt->fdout, mb, 0, LIST_MAL_NAME | LIST_MAL_VALUE |
LIST_MAL_TYPE | LIST_MAL_PROPS, 0, mb->stop );
+ snprintFunction(cntxt->fdout, mb, 0, LIST_MAL_NAME | LIST_MAL_VALUE |
LIST_MAL_TYPE | LIST_MAL_PROPS, 0, mb->stop );
return MAL_SUCCEED;
}
@@ -581,7 +581,7 @@ MDBlist3Detail(Client cntxt, MalBlkPtr m
s = findSymbol(cntxt->usermodule, putName(modnme), putName(fcnnme));
if (s == NULL)
throw(MAL,"mdb.list","Could not find %s.%s", modnme, fcnnme);
- debugFunction(cntxt->fdout, s->def, 0, LIST_MAL_NAME | LIST_MAL_VALUE
| LIST_MAL_TYPE | LIST_MAL_PROPS , 0, s->def->stop);
+ snprintFunction(cntxt->fdout, s->def, 0, LIST_MAL_NAME |
LIST_MAL_VALUE | LIST_MAL_TYPE | LIST_MAL_PROPS , 0, s->def->stop);
(void) mb; /* fool compiler */
return NULL;
}
diff --git a/MonetDB5/modules/mal/orderidx.c b/MonetDB5/modules/mal/orderidx.c
new file mode 100644
--- /dev/null
+++ b/MonetDB5/modules/mal/orderidx.c
@@ -0,0 +1,396 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ */
+
+/*
+ * (c) Martin Kersten, Lefteris Sidirourgos
+ * Implement a parallel sort-merge MAL program generator
+ */
+#include "monetdb_config.h"
+#include "orderidx.h"
+#include "gdk.h"
+#include "gdk_tracer.h"
+
+#define MIN_PIECE ((BUN) 1000) /* TODO use realistic size in
production */
+
+str
+OIDXdropImplementation(Client cntxt, BAT *b)
+{
+ (void) cntxt;
+ OIDXdestroy(b);
+ return MAL_SUCCEED;
+}
+
+str
+OIDXcreateImplementation(Client cntxt, int tpe, BAT *b, int pieces)
+{
+ int i, loopvar, arg;
+ BUN cnt, step=0,o;
+ MalBlkPtr smb;
+ MalStkPtr newstk;
+ Symbol snew = NULL;
+ InstrPtr q, pack;
+ char name[IDLENGTH];
+ str msg= MAL_SUCCEED;
+
+ if (BATcount(b) <= 1)
+ return MAL_SUCCEED;
+
+ /* check if b is sorted, then index does not make sense */
+ if (b->tsorted || b->trevsorted)
+ return MAL_SUCCEED;
+
+ /* check if b already has index */
+ if (BATcheckorderidx(b))
+ return MAL_SUCCEED;
+
+ switch (ATOMbasetype(b->ttype)) {
+ case TYPE_void:
+ /* trivially supported */
+ return MAL_SUCCEED;
+ case TYPE_bte:
+ case TYPE_sht:
+ case TYPE_int:
+ case TYPE_lng:
+#ifdef HAVE_HGE
+ case TYPE_hge:
+#endif
+ case TYPE_flt:
+ case TYPE_dbl:
+ if (GDKnr_threads > 1 && BATcount(b) >= 2 * MIN_PIECE &&
(GDKdebug & FORCEMITOMASK) == 0)
+ break;
+ /* fall through */
+ default:
+ if (BATorderidx(b, true) != GDK_SUCCEED)
+ throw(MAL, "bat.orderidx", TYPE_NOT_SUPPORTED);
+ return MAL_SUCCEED;
+ }
+
+ if( pieces <= 0 ){
+ if (GDKnr_threads <= 1) {
+ pieces = 1;
+ } else if (GDKdebug & FORCEMITOMASK) {
+ /* we want many pieces, even tiny ones */
+ if (BATcount(b) < 4)
+ pieces = 1;
+ else if (BATcount(b) / 2 < (BUN) GDKnr_threads)
+ pieces = (int) (BATcount(b) / 2);
+ else
+ pieces = GDKnr_threads;
+ } else {
+ if (BATcount(b) < 2 * MIN_PIECE)
+ pieces = 1;
+ else if (BATcount(b) / MIN_PIECE < (BUN) GDKnr_threads)
+ pieces = (int) (BATcount(b) / MIN_PIECE);
+ else
+ pieces = GDKnr_threads;
+ }
+ } else if (BATcount(b) < (BUN) pieces || BATcount(b) < MIN_PIECE) {
+ pieces = 1;
+ }
+
+ DEBUG(MAL_OIDX, "Pieces: %d\n", pieces);
+ DEBUG(MAL_OIDX, "oidx ttype: %s - bat: %s\n", ATOMname(b->ttype),
ATOMname(tpe));
+
+ /* create a temporary MAL function to sort the BAT in parallel */
+ snprintf(name, IDLENGTH, "sort%d", rand()%1000);
+ snew = newFunction(putName("user"), putName(name),
+ FUNCTIONsymbol);
+ if(snew == NULL) {
+ msg = createException(MAL, "bat.orderidx", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+ smb = snew->def;
+ q = getInstrPtr(smb, 0);
+ arg = newTmpVariable(smb, tpe);
+ q= pushArgument(smb, q, arg);
+ getArg(q,0) = newTmpVariable(smb, TYPE_void);
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list