Changeset: 6cc100dca57b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6cc100dca57b Added Files: MonetDB5/mal/mal_interpreter.h Modified Files: MonetDB5/mal/mal_dataflow.c Branch: tracer Log Message:
Revert "Added GDKtracer to mal_dataflow" This reverts commit 0f322f61799aa5ea74453dcecd9c5f12ee5f2cde. diffs (281 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 @@ -336,12 +336,10 @@ DFLOWworker(void *T) srand((unsigned int) GDKusec()); #endif GDKsetbuf(GDKmalloc(GDKMAXERRLEN)); /* where to leave errors */ - if( GDKerrbuf == 0) { - CRITICAL(M_ALL, "Could not allocate GDKerrbuf\n"); - } else { + if( GDKerrbuf == 0) + fprintf(stderr,"DFLOWworker:Could not allocate GDKerrbuf\n"); + else GDKclrerr(); - } - cntxt = ATOMIC_PTR_GET(&t->cntxt); if (cntxt) { /* wait until we are allowed to start working */ @@ -399,8 +397,8 @@ DFLOWworker(void *T) } #endif error = runMALsequence(flow->cntxt, flow->mb, fe->pc, fe->pc + 1, flow->stk, 0, 0); - DEBUG(PAR, "Executed pc=%d wrk=%d claim=" LLFMT "," LLFMT "," LLFMT " %s\n", - fe->pc, id, fe->argclaim, fe->hotclaim, fe->maxclaim, error ? error : ""); + PARDEBUG fprintf(stderr, "#executed pc= %d wrk= %d claim= " LLFMT "," LLFMT "," LLFMT " %s\n", + fe->pc, id, fe->argclaim, fe->hotclaim, fe->maxclaim, error ? error : ""); #ifdef USE_MAL_ADMISSION /* release the memory claim */ MALadmission(-fe->argclaim, -fe->hotclaim); @@ -555,7 +553,7 @@ DFLOWinitBlk(DataFlow flow, MalBlkPtr mb throw(MAL, "dataflow", "DFLOWinitBlk(): Called with flow == NULL"); if (mb == NULL) throw(MAL, "dataflow", "DFLOWinitBlk(): Called with mb == NULL"); - DEBUG(PAR, "Initialize dflow block\n"); + PARDEBUG fprintf(stderr, "#Initialize dflow block\n"); assign = (int *) GDKzalloc(mb->vtop * sizeof(int)); if (assign == NULL) throw(MAL, "dataflow", SQLSTATE(HY001) MAL_MALLOC_FAIL); @@ -623,7 +621,7 @@ DFLOWinitBlk(DataFlow flow, MalBlkPtr mb l = getEndScope(mb, getArg(p, j)); if (l != pc && l < flow->stop && l > flow->start) { /* add edge to the target instruction for wakeup call */ - DEBUG(PAR, "Endoflife for %s is %d -> %d\n", getVarName(mb, getArg(p, j)), n + flow->start, l); + PARDEBUG fprintf(stderr, "#endoflife for %s is %d -> %d\n", getVarName(mb, getArg(p, j)), n + flow->start, l); assert(pc < l); /* only dependencies on earlier instructions */ l -= flow->start; if (flow->nodes[n]) { @@ -665,16 +663,19 @@ DFLOWinitBlk(DataFlow flow, MalBlkPtr mb assign[getArg(p, j)] = pc; /* ensure recognition of dependency on first instruction and constant */ } GDKfree(assign); - for (n = 0; n < flow->stop - flow->start; n++) { - DEBUG(PAR, "[%d] %d\n", flow->start + n, n); - fprintInstruction(PAR, mb, 0, getInstrPtr(mb, n + flow->start), LIST_MAL_ALL); - DEBUG(PAR, "[%d] dependents block count %d wakeup\n", flow->start + n, flow->status[n].blocks); - for (j = n; flow->edges[j]; j = flow->edges[j]) { - DEBUG(PAR, "%d\n", flow->start + flow->nodes[j]); - if (flow->edges[j] == -1) - break; + PARDEBUG { + for (n = 0; n < flow->stop - flow->start; n++) { + fprintf(stderr, "#[%d] %d: ", flow->start + n, n); + fprintInstruction(MAL_DATAFLOW, mb, 0, getInstrPtr(mb, n + flow->start), LIST_MAL_ALL); + fprintf(stderr, "#[%d]Dependents block count %d wakeup", flow->start + n, flow->status[n].blocks); + for (j = n; flow->edges[j]; j = flow->edges[j]) { + fprintf(stderr, "%d ", flow->start + flow->nodes[j]); + if (flow->edges[j] == -1) + break; + } + fprintf(stderr, "\n"); } - } + } #ifdef USE_MAL_ADMISSION memorypool = memoryclaims = 0; #endif @@ -696,10 +697,10 @@ static void showFlowEvent(DataFlow flow, int i; FlowEvent fe = flow->status; - INFO(M_ALL, "End of data flow '%d' done '%d'\n", pc, flow->stop - flow->start); + fprintf(stderr, "#end of data flow %d done %d \n", pc, flow->stop - flow->start); for (i = 0; i < flow->stop - flow->start; i++) if (fe[i].state != DFLOWwrapup && fe[i].pc >= 0) { - INFO(M_ALL, "Missed pc %d status %d %d blocks %d\n", fe[i].state, i, fe[i].pc, fe[i].blocks); + fprintf(stderr, "#missed pc %d status %d %d blocks %d", fe[i].state, i, fe[i].pc, fe[i].blocks); fprintInstruction(MAL_DATAFLOW, fe[i].flow->mb, 0, getInstrPtr(fe[i].flow->mb, fe[i].pc), LIST_MAL_MAPI); } } @@ -740,12 +741,12 @@ DFLOWscheduler(DataFlow flow, struct wor #endif q_enqueue(todo, flow->status + i); flow->status[i].state = DFLOWrunning; - DEBUG(PAR, "Enqueue pc=%d claim=" LLFMT "\n", flow->status[i].pc, flow->status[i].argclaim); + PARDEBUG fprintf(stderr, "#enqueue pc=%d claim=" LLFMT "\n", flow->status[i].pc, flow->status[i].argclaim); } MT_lock_unset(&flow->flowlock); MT_sema_up(&w->s); - DEBUG(PAR, "Run '%d' instructions in dataflow block\n", actions); + PARDEBUG fprintf(stderr, "#run %d instructions in dataflow block\n", actions); while (actions != tasks ) { f = q_dequeue(flow->done, NULL); @@ -769,7 +770,7 @@ DFLOWscheduler(DataFlow flow, struct wor flow->status[i].state = DFLOWrunning; flow->status[i].blocks--; q_enqueue(todo, flow->status + i); - DEBUG(PAR, "Enqueue pc=%d claim=" LLFMT "\n", flow->status[i].pc, flow->status[i].argclaim); + PARDEBUG fprintf(stderr, "#enqueue pc=%d claim= " LLFMT "\n", flow->status[i].pc, flow->status[i].argclaim); } else { flow->status[i].blocks--; } @@ -782,7 +783,7 @@ DFLOWscheduler(DataFlow flow, struct wor /* wrap up errors */ assert(flow->done->last == 0); if ((ret = ATOMIC_PTR_XCG(&flow->error, NULL)) != NULL ) { - DEBUG(PAR, "Errors encountered %s\n", ret); + PARDEBUG fprintf(stderr, "#errors encountered %s ", ret); } return ret; } @@ -810,8 +811,10 @@ runMALdataflow(Client cntxt, MalBlkPtr m bit *ret; int i; - DEBUG(MAL_DATAFLOW, "Running for block: %d - %d\n", startpc, stoppc); - fprintFunction(MAL_DATAFLOW, mb, 0, LIST_MAL_ALL); +#ifdef DEBUG_FLOW + fprintf(stderr, "#runMALdataflow for block %d - %d\n", startpc, stoppc); + fprintFunction(MAL_DATAFLOW, mb, 0, LIST_ALL); +#endif /* in debugging mode we should not start multiple threads */ if (stk == NULL) diff --git a/MonetDB5/mal/mal_interpreter.h b/MonetDB5/mal/mal_interpreter.h new file mode 100644 --- /dev/null +++ b/MonetDB5/mal/mal_interpreter.h @@ -0,0 +1,140 @@ +/* + * 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. + */ + +/* + * Author M. Kersten + * The MAL Interpreter + */ + +#ifndef _MAL_INTERPRET_H +#define _MAL_INTERPRET_H + +#include "mal_client.h" +#include "mal_factory.h" +#include "mal_profiler.h" + +/* + * Activation of a thread requires construction of the argument list + * to be passed by a handle. + */ + +/* #define DEBUG_FLOW */ + +mal_export MalStkPtr prepareMALstack(MalBlkPtr mb, int size); +mal_export str runMAL(Client c, MalBlkPtr mb, MalBlkPtr mbcaller, MalStkPtr env); +mal_export str runMALsequence(Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller); +mal_export str reenterMAL(Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk); +mal_export str callMAL(Client cntxt, MalBlkPtr mb, MalStkPtr *glb, ValPtr argv[], char debug); +mal_export void garbageElement(Client cntxt, ValPtr v); +mal_export void garbageCollector(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int flag); +mal_export str malCommandCall(MalStkPtr stk, InstrPtr pci); +mal_export int isNotUsedIn(InstrPtr p, int start, int a); + +mal_export ptr getArgReference(MalStkPtr stk, InstrPtr pci, int k); +#if !defined(NDEBUG) && defined(__GNUC__) +/* for ease of programming and debugging (assert reporting a useful + * location), we use a GNU C extension to check the type of arguments, + * and of course only when assertions are enabled */ +#define getArgReference_TYPE(s, pci, k, TYPE) \ + ({ \ + assert((s)->stk[(pci)->argv[k]].vtype == TYPE_##TYPE); \ + (TYPE *) getArgReference((s), (pci), (k)); \ + }) +#define getArgReference_bit(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_bit); \ + (bit *) &v->val.btval; \ + }) +#define getArgReference_sht(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_sht); \ + &v->val.shval; \ + }) +#define getArgReference_bat(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_bat); \ + &v->val.bval; \ + }) +#define getArgReference_int(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_int); \ + &v->val.ival; \ + }) +#define getArgReference_bte(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_bte); \ + &v->val.btval; \ + }) +#define getArgReference_oid(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_oid || v->vtype == TYPE_void); \ + &v->val.oval; \ + }) +#define getArgReference_ptr(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_ptr); \ + &v->val.pval; \ + }) +#define getArgReference_flt(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_flt); \ + &v->val.fval; \ + }) +#define getArgReference_dbl(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_dbl); \ + &v->val.dval; \ + }) +#define getArgReference_lng(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_lng); \ + &v->val.lval; \ + }) +#ifdef HAVE_HGE +#define getArgReference_hge(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_hge); \ + &v->val.hval; \ + }) +#endif +#define getArgReference_str(s, pci, k) \ + ({ \ + ValRecord *v = &(s)->stk[(pci)->argv[k]]; \ + assert(v->vtype == TYPE_str); \ + &v->val.sval; \ + }) +#else +#define getArgReference_TYPE(s, pci, k, TYPE) ((TYPE *) getArgReference(s, pci, k)) +#define getArgReference_bit(s, pci, k) ((bit *) &(s)->stk[(pci)->argv[k]].val.btval) +#define getArgReference_sht(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.shval) +#define getArgReference_bat(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.bval) +#define getArgReference_int(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.ival) +#define getArgReference_bte(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.btval) +#define getArgReference_oid(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.oval) +#define getArgReference_ptr(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.pval) +#define getArgReference_flt(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.fval) +#define getArgReference_dbl(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.dval) +#define getArgReference_lng(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.lval) +#ifdef HAVE_HGE +#define getArgReference_hge(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.hval) +#endif +#define getArgReference_str(s, pci, k) (&(s)->stk[(pci)->argv[k]].val.sval) +#endif + +#endif /* _MAL_INTERPRET_H*/ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list