Changeset: 0d8d7e74669d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d8d7e74669d Added Files: monetdb5/modules/mal/Tests/batpartition.mal monetdb5/modules/mal/Tests/batpartition.stable.err monetdb5/modules/mal/Tests/batpartition.stable.out Modified Files: gdk/gdk_atomic.h monetdb5/extras/jaql/jaqlscenario.c monetdb5/mal/Tests/tst274.stable.out.oid64 monetdb5/mal/mal_dataflow.c monetdb5/modules/mal/Tests/All monetdb5/modules/mal/Tests/partition.stable.out monetdb5/modules/mal/batExtensions.c monetdb5/optimizer/Tests/joinpath.mal monetdb5/optimizer/Tests/joinpath.stable.out sql/test/BugTracker-2012/Tests/predicate_select.Bug-3090_nogeom.stable.err sql/test/BugTracker-2012/Tests/predicate_select.Bug-3090_nogeom.stable.out sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err.Windows sql/test/Tests/systemfunctions_nogeom.stable.out sql/test/Tests/trace.stable.out sql/test/Tests/trace_nogeom.stable.out sql/test/leaks/Tests/check0_nogeom.stable.out sql/test/leaks/Tests/check1_nogeom.stable.out sql/test/leaks/Tests/check2_nogeom.stable.out sql/test/leaks/Tests/check3_nogeom.stable.out sql/test/leaks/Tests/check4_nogeom.stable.out sql/test/leaks/Tests/check5_nogeom.stable.out sql/test/leaks/Tests/drop3_nogeom.stable.out sql/test/leaks/Tests/select1_nogeom.stable.out sql/test/leaks/Tests/select2_nogeom.stable.out sql/test/leaks/Tests/temp1_nogeom.stable.out sql/test/leaks/Tests/temp2_nogeom.stable.out sql/test/leaks/Tests/temp3_nogeom.stable.out sql/test/mapi/Tests/php_monetdb_nogeom.stable.out sql/test/testdb/Tests/testdb-dump.stable.out.Windows Branch: mutation Log Message:
Merge with default diffs (truncated from 1569 to 300 lines): diff --git a/gdk/gdk_atomic.h b/gdk/gdk_atomic.h --- a/gdk/gdk_atomic.h +++ b/gdk/gdk_atomic.h @@ -92,7 +92,7 @@ #define ATOMIC_INIT(lck, fcn) ((void) 0) -#elif defined(__GNUC__) || defined(__INTEL_COMPILER) +#elif (defined(__GNUC__) || defined(__INTEL_COMPILER)) && !(defined(__sun__) && SIZEOF_SIZE_T == SIZEOF_LNG) #define ATOMIC_GET_sht(var, lck, fcn) var #define ATOMIC_SET_sht(var, val, lck, fcn) (var = (val)) diff --git a/monetdb5/extras/jaql/jaqlscenario.c b/monetdb5/extras/jaql/jaqlscenario.c --- a/monetdb5/extras/jaql/jaqlscenario.c +++ b/monetdb5/extras/jaql/jaqlscenario.c @@ -28,6 +28,7 @@ #include "mal_scenario.h" #include "mal_instruction.h" #include "optimizer.h" +#include "opt_pipes.h" extern int jaqlparse(jc *j); extern int jaqllex_init_extra(jc *user_defined, void **scanner); @@ -241,6 +242,16 @@ JAQLparser(Client c) j->timing.optimise = GDKusec(); chkTypes(out, c->nspace, prg->def, FALSE); + /* TODO: use a configured pipe */ + addOptimizerPipe(c, prg->def, "minimal_pipe"); + if ((errmsg = optimizeMALBlock(c, prg->def)) != MAL_SUCCEED) { + MSresetInstructions(prg->def, oldstop); + freeVariables(c, prg->def, c->glb, oldvtop); + prg->def->errors = 0; + mnstr_printf(out, "!%s\n", errmsg); + freetree(j->p); + return errmsg; + } j->timing.optimise = GDKusec() - j->timing.optimise; if (prg->def->errors) { /* this is bad already, so let's try to make it debuggable */ @@ -271,7 +282,7 @@ JAQLengine(Client c) /* FIXME: if we don't run this, any barrier will cause an endless loop * (program jumps back to first frame), so this is kind of a - * workaround that maybe can go once we run the optimiser stack */ + * workaround */ chkProgram(c->fdout, c->nspace, c->curprg->def); c->glb = 0; diff --git a/monetdb5/mal/Tests/tst274.stable.out.oid64 b/monetdb5/mal/Tests/tst274.stable.out.oid64 --- a/monetdb5/mal/Tests/tst274.stable.out.oid64 +++ b/monetdb5/mal/Tests/tst274.stable.out.oid64 @@ -56,8 +56,8 @@ exit i; io.print(rdbytes,wrbytes); end main; #monitor -[ 8 ] -[ 8 ] +[ 7 ] +[ 7 ] #-----------------# # h t # name # void lng # type @@ -69,31 +69,28 @@ end main; [ 4@0, 0 ] [ 5@0, 0 ] [ 6@0, 0 ] -[ 7@0, 0 ] #-----------------# # h t # name # void lng # type #-----------------# [ 0@0, 0 ] -[ 1@0, 0 ] -[ 2@0, 160000 ] +[ 1@0, 160000 ] +[ 2@0, 0 ] [ 3@0, 0 ] -[ 4@0, 0 ] +[ 4@0, 160000 ] [ 5@0, 160000 ] -[ 6@0, 160000 ] -[ 7@0, 0 ] +[ 6@0, 0 ] #-------------------------# # h t t # name # void lng lng # type #-------------------------# [ 0@0, 0, 0 ] -[ 1@0, 0, 0 ] -[ 2@0, 0, 160000 ] +[ 1@0, 0, 160000 ] +[ 2@0, 0, 0 ] [ 3@0, 0, 0 ] -[ 4@0, 0, 0 ] +[ 4@0, 0, 160000 ] [ 5@0, 0, 160000 ] -[ 6@0, 0, 160000 ] -[ 7@0, 0, 0 ] +[ 6@0, 0, 0 ] # 17:57:29 > # 17:57:29 > Done. 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 @@ -115,7 +115,7 @@ q_create(int sz, const char *name) return NULL; q->size = ((sz << 1) >> 1); /* we want a multiple of 2 */ q->last = 0; - q->data = (void*)GDKmalloc(sizeof(FlowEvent) * q->size); + q->data = (FlowEvent*) GDKmalloc(sizeof(FlowEvent) * q->size); if (q->data == NULL) { GDKfree(q); return NULL; @@ -140,16 +140,18 @@ q_destroy(queue *q) static void q_enqueue_(queue *q, FlowEvent d) { - assert(d); if (q->last == q->size) { q->size <<= 1; - q->data = GDKrealloc(q->data, sizeof(FlowEvent) * q->size); + q->data = (FlowEvent*) GDKrealloc(q->data, sizeof(FlowEvent) * q->size); + assert(q->data); } q->data[q->last++] = d; } static void q_enqueue(queue *q, FlowEvent d) { + assert(q); + assert(d); MT_lock_set(&q->l, "q_enqueue"); q_enqueue_(q, d); MT_lock_unset(&q->l, "q_enqueue"); @@ -168,20 +170,21 @@ q_requeue_(queue *q, FlowEvent d) { int i; - assert(d); if (q->last == q->size) { /* enlarge buffer */ q->size <<= 1; - q->data = GDKrealloc(q->data, sizeof(void*) * q->size); + q->data = (FlowEvent*) GDKrealloc(q->data, sizeof(FlowEvent) * q->size); + assert(q->data); } for (i = q->last; i > 0; i--) q->data[i] = q->data[i - 1]; - q->data[0] = (void*)d; + q->data[0] = d; q->last++; } static void q_requeue(queue *q, FlowEvent d) { + assert(q); assert(d); MT_lock_set(&q->l, "q_requeue"); q_requeue_(q, d); @@ -195,14 +198,15 @@ q_dequeue(queue *q) { void *r = NULL; + assert(q); MT_sema_down(&q->s, "q_dequeue"); if (exiting) return NULL; MT_lock_set(&q->l, "q_dequeue"); - assert(q->last); + assert(q->last > 0); if (q->last > 0) { /* LIFO favors garbage collection */ - r = q->data[--q->last]; + r = (void*) q->data[--q->last]; q->data[q->last] = 0; } /* else: terminating */ @@ -267,6 +271,7 @@ DFLOWworker(void *t) fnxt = 0; assert(fe); flow = fe->flow; + assert(flow); /* whenever we have a (concurrent) error, skip it */ if (flow->error) { @@ -280,6 +285,7 @@ DFLOWworker(void *t) #ifdef USE_MAL_ADMISSION if (MALadmission(fe->argclaim, fe->hotclaim)) { fe->hotclaim = 0; /* don't assume priority anymore */ + assert(todo); if (todo->last == 0) MT_sleep_ms(DELAYUNIT); q_requeue(todo, fe); @@ -317,6 +323,7 @@ DFLOWworker(void *t) #ifdef USE_MAL_ADMISSION { InstrPtr p = getInstrPtr(flow->mb, fe->pc); + assert(p); fe->hotclaim = 0; for (i = 0; i < p->retc; i++) fe->hotclaim += getMemoryClaim(flow->mb, flow->stk, fe->pc, i, FALSE); @@ -338,6 +345,7 @@ DFLOWworker(void *t) q_enqueue(flow->done, fe); if ( fnxt == 0) { + assert(todo); if (todo->last == 0) profilerHeartbeatEvent("wait"); else @@ -369,6 +377,10 @@ DFLOWinitialize(void) return MAL_SUCCEED; } todo = q_create(2048, "todo"); + if (todo == NULL) { + MT_lock_unset(&mal_contextLock, "DFLOWinitialize"); + throw(MAL, "dataflow", "DFLOWinitialize(): Failed to create todo queue"); + } limit = GDKnr_threads ? GDKnr_threads : 1; for (i = 0; i < limit && i < THREADS; i++) { if (MT_create_thread(&workers[i], DFLOWworker, (void *) &workers[i], MT_THR_JOINABLE) < 0) { @@ -386,18 +398,28 @@ DFLOWinitialize(void) * For each instruction we keep a list of instructions whose * blocking counter should be decremented upon finishing it. */ -static void +static str DFLOWinitBlk(DataFlow flow, MalBlkPtr mb, int size) { int pc, i, j, k, l, n, etop = 0; int *assign; InstrPtr p; + if (flow == NULL) + throw(MAL, "dataflow", "DFLOWinitBlk(): Called with flow == NULL"); + if (mb == NULL) + throw(MAL, "dataflow", "DFLOWinitBlk(): Called with mb == NULL"); PARDEBUG printf("Initialize dflow block\n"); assign = (int *) GDKzalloc(mb->vtop * sizeof(int)); + if (assign == NULL) + throw(MAL, "dataflow", "DFLOWinitBlk(): Failed to allocate assign"); etop = flow->stop - flow->start; for (n = 0, pc = flow->start; pc < flow->stop; pc++, n++) { p = getInstrPtr(mb, pc); + if (p == NULL) { + GDKfree(assign); + throw(MAL, "dataflow", "DFLOWinitBlk(): getInstrPtr() returned NULL"); + } /* initial state, ie everything can run */ flow->status[n].flow = flow; @@ -478,6 +500,7 @@ DFLOWinitBlk(DataFlow flow, MalBlkPtr mb #ifdef USE_MAL_ADMISSION memorypool = memoryclaims = 0; #endif + return MAL_SUCCEED; } /* @@ -513,10 +536,13 @@ DFLOWscheduler(DataFlow flow) int j; InstrPtr p; #endif - int tasks=0, actions = flow->stop - flow->start; + int tasks=0, actions; str ret = MAL_SUCCEED; FlowEvent fe, f = 0; + if (flow == NULL) + throw(MAL, "dataflow", "DFLOWscheduler(): Called with flow == NULL"); + actions = flow->stop - flow->start; if (actions == 0) throw(MAL, "dataflow", "Empty dataflow block"); /* initialize the eligible statements */ @@ -527,6 +553,10 @@ DFLOWscheduler(DataFlow flow) if (fe[i].blocks == 0) { #ifdef USE_MAL_ADMISSION p = getInstrPtr(flow->mb,fe[i].pc); + if (p == NULL) { + MT_lock_unset(&flow->flowlock, "MALworker"); + throw(MAL, "dataflow", "DFLOWscheduler(): getInstrPtr(flow->mb,fe[i].pc) returned NULL"); + } for (j = p->retc; j < p->argc; j++) fe[i].argclaim = getMemoryClaim(fe[0].flow->mb, fe[0].flow->stk, fe[i].pc, j, FALSE); #endif @@ -542,6 +572,8 @@ DFLOWscheduler(DataFlow flow) f = q_dequeue(flow->done); if (exiting) break; + if (f == NULL) + throw(MAL, "dataflow", "DFLOWscheduler(): q_dequeue(flow->done) returned NULL"); /* * When an instruction is finished we have to reduce the blocked @@ -588,6 +620,8 @@ runMALdataflow(Client cntxt, MalBlkPtr m #endif /* in debugging mode we should not start multiple threads */ + if (stk == NULL) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list