Changeset: 1393ed882614 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1393ed882614
Modified Files:
        sql/backends/monet5/sql.c
Branch: less_explain_info
Log Message:

Merge with default branch


diffs (truncated from 4310 to 300 lines):

diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -65,24 +65,26 @@
 
 #include <atomic>
 
-#if SIZEOF_LONG_LONG == 8
-#if ATOMIC_LLONG_LOCK_FREE != 2
-#if ATOMIC_LLONG_LOCK_FREE != 1
-#error "we need _Atomic(unsigned [long] long) to be lock free"
-#endif
-typedef atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long ATOMIC_BASE_TYPE;
-#else
-typedef atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long long ATOMIC_BASE_TYPE;
-#endif
-#elif SIZEOF_LONG == 8
+#if SIZEOF_LONG == 8
 #if ATOMIC_LONG_LOCK_FREE != 2
 #error "we need _Atomic(unsigned long) to be lock free"
 #endif
-typedef atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef unsigned long ATOMIC_BASE_TYPE;
+#elif SIZEOF_LONG_LONG == 8
+#if ATOMIC_LLONG_LOCK_FREE != 2
+#if SIZEOF_SIZE_T == 4 && ATOMIC_LONG_LOCK_FREE == 2
+/* on 32 bit arch, fall back to 32 bit atomics if 64 bit is not lock free */
+typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(4)));
 typedef unsigned long ATOMIC_BASE_TYPE;
 #else
+#error "we need _Atomic(unsigned [long] long) to be lock free"
+#endif
+#else
+typedef volatile atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef unsigned long long ATOMIC_BASE_TYPE;
+#endif
+#else
 #error "we need a 64 bit atomic type"
 #endif
 
@@ -90,23 +92,25 @@ typedef unsigned long ATOMIC_BASE_TYPE;
 
 #include <stdatomic.h>
 
-#if SIZEOF_LONG_LONG == 8
-#if ATOMIC_LLONG_LOCK_FREE != 2
-#if ATOMIC_LLONG_LOCK_FREE != 1
-#error "we need _Atomic(unsigned [long] long) to be lock free"
-#endif
-typedef atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long ATOMIC_BASE_TYPE;
-#else
-typedef volatile atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long long ATOMIC_BASE_TYPE;
-#endif
-#elif SIZEOF_LONG == 8
+#if SIZEOF_LONG == 8
 #if ATOMIC_LONG_LOCK_FREE != 2
 #error "we need _Atomic(unsigned long) to be lock free"
 #endif
 typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
 typedef unsigned long ATOMIC_BASE_TYPE;
+#elif SIZEOF_LONG_LONG == 8
+#if ATOMIC_LLONG_LOCK_FREE != 2
+#if SIZEOF_SIZE_T == 4 && ATOMIC_LONG_LOCK_FREE == 2
+/* on 32 bit arch, fall back to 32 bit atomics */
+typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(4)));
+typedef unsigned long ATOMIC_BASE_TYPE;
+#else
+#error "we need _Atomic(unsigned [long] long) to be lock free"
+#endif
+#else
+typedef volatile atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef unsigned long long ATOMIC_BASE_TYPE;
+#endif
 #else
 #error "we need a 64 bit atomic type"
 #endif
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -946,12 +946,12 @@ BATsettrivprop(BAT *b)
                                        b->tmaxpos = 0;
                                }
                                b->tseqbase = sqbs;
-                       } else if ((b->tvheap
-                                   ? ATOMcmp(b->ttype,
-                                             b->tvheap->base + 
VarHeapVal(Tloc(b, 0), 0, b->twidth),
-                                             ATOMnilptr(b->ttype))
-                                   : ATOMcmp(b->ttype, Tloc(b, 0),
-                                             ATOMnilptr(b->ttype))) == 0) {
+                       } else if (b->tvheap
+                                  ? ATOMeq(b->ttype,
+                                           b->tvheap->base + 
VarHeapVal(Tloc(b, 0), 0, b->twidth),
+                                           ATOMnilptr(b->ttype))
+                                  : ATOMeq(b->ttype, Tloc(b, 0),
+                                           ATOMnilptr(b->ttype))) {
                                /* the only value is NIL */
                                b->tminpos = BUN_NONE;
                                b->tmaxpos = BUN_NONE;
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3076,7 +3076,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
        BAT *bn = NULL;
        int t;
        const void *nil;
-       int (*atomcmp)(const void *, const void *);
+       bool (*atomeq)(const void *, const void *);
        struct canditer ci;
        const char *err;
        lng t0 = 0;
@@ -3134,7 +3134,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
        } else {
                t = b->ttype;
                nil = ATOMnilptr(t);
-               atomcmp = ATOMcompare(t);
+               atomeq = ATOMequal(t);
                t = ATOMbasetype(t);
 
                bi = bat_iterator(b);
@@ -3172,7 +3172,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
                                                gid = gids[i] - min;
                                        else
                                                gid = (oid) i;
-                                       if ((*atomcmp)(BUNtail(bi, i), nil) != 
0) {
+                                       if (!(*atomeq)(BUNtail(bi, i), nil)) {
                                                cnts[gid]++;
                                        }
                                }
@@ -3252,6 +3252,7 @@ do_groupmin(oid *restrict oids, BATiter 
        BUN i, nils;
        int t;
        const void *nil;
+       bool (*atomeq)(const void *, const void *);
        int (*atomcmp)(const void *, const void *);
 
        QryCtx *qry_ctx = MT_thread_get_qry_ctx();
@@ -3264,6 +3265,7 @@ do_groupmin(oid *restrict oids, BATiter 
 
        t = bi->b->ttype;
        nil = ATOMnilptr(t);
+       atomeq = ATOMequal(t);
        atomcmp = ATOMcompare(t);
        t = ATOMbasetype(t);
        oid hseq = bi->b->hseqbase;
@@ -3324,7 +3326,7 @@ do_groupmin(oid *restrict oids, BATiter 
                        TIMEOUT_LOOP(ci->ncand, qry_ctx) {
                                i = canditer_next(ci) - hseq;
                                if (!skip_nils ||
-                                   (*atomcmp)(BUNtail(*bi, i), nil) != 0) {
+                                   !(*atomeq)(BUNtail(*bi, i), nil)) {
                                        oids[gid] = i + hseq;
                                        nils--;
                                }
@@ -3338,15 +3340,14 @@ do_groupmin(oid *restrict oids, BATiter 
                                        const void *v = BUNtail(*bi, i);
                                        if (gids)
                                                gid = gids[i] - min;
-                                       if (!skip_nils ||
-                                           (*atomcmp)(v, nil) != 0) {
+                                       if (!skip_nils || !(*atomeq)(v, nil)) {
                                                if (is_oid_nil(oids[gid])) {
                                                        oids[gid] = i + hseq;
                                                        nils--;
                                                } else if (t != TYPE_void) {
                                                        const void *g = 
BUNtail(*bi, (BUN) (oids[gid] - hseq));
-                                                       if ((*atomcmp)(g, nil) 
!= 0 &&
-                                                           ((*atomcmp)(v, nil) 
== 0 ||
+                                                       if (!(*atomeq)(g, nil) 
&&
+                                                           ((*atomeq)(v, nil) 
||
                                                             LT((*atomcmp)(v, 
g), 0)))
                                                                oids[gid] = i + 
hseq;
                                                }
@@ -3375,6 +3376,7 @@ do_groupmax(oid *restrict oids, BATiter 
        int t;
        const void *nil;
        int (*atomcmp)(const void *, const void *);
+       bool (*atomeq)(const void *, const void *);
 
        QryCtx *qry_ctx = MT_thread_get_qry_ctx();
 
@@ -3387,6 +3389,7 @@ do_groupmax(oid *restrict oids, BATiter 
        t = bi->b->ttype;
        nil = ATOMnilptr(t);
        atomcmp = ATOMcompare(t);
+       atomeq = ATOMequal(t);
        t = ATOMbasetype(t);
        oid hseq = bi->b->hseqbase;
 
@@ -3445,7 +3448,7 @@ do_groupmax(oid *restrict oids, BATiter 
                        TIMEOUT_LOOP(ci->ncand, qry_ctx) {
                                i = canditer_next(ci) - hseq;
                                if (!skip_nils ||
-                                   (*atomcmp)(BUNtail(*bi, i), nil) != 0) {
+                                   !(*atomeq)(BUNtail(*bi, i), nil)) {
                                        oids[gid] = i + hseq;
                                        nils--;
                                }
@@ -3459,16 +3462,15 @@ do_groupmax(oid *restrict oids, BATiter 
                                        const void *v = BUNtail(*bi, i);
                                        if (gids)
                                                gid = gids[i] - min;
-                                       if (!skip_nils ||
-                                           (*atomcmp)(v, nil) != 0) {
+                                       if (!skip_nils || !(*atomeq)(v, nil)) {
                                                if (is_oid_nil(oids[gid])) {
                                                        oids[gid] = i + hseq;
                                                        nils--;
                                                } else {
                                                        const void *g = 
BUNtail(*bi, (BUN) (oids[gid] - hseq));
                                                        if (t == TYPE_void ||
-                                                           ((*atomcmp)(g, nil) 
!= 0 &&
-                                                            ((*atomcmp)(v, 
nil) == 0 ||
+                                                           (!(*atomeq)(g, nil) 
&&
+                                                            ((*atomeq)(v, nil) 
||
                                                              GT((*atomcmp)(v, 
g), 0))))
                                                                oids[gid] = i + 
hseq;
                                                }
@@ -3752,14 +3754,14 @@ BATmax_skipnil(BAT *b, void *aggr, bit s
                if (BATordered(b)) {
                        pos = bi.count - 1 + b->hseqbase;
                        if (skipnil && !bi.nonil &&
-                           ATOMcmp(bi.type, BUNtail(bi, bi.count - 1),
-                                   ATOMnilptr(bi.type)) == 0)
+                           ATOMeq(bi.type, BUNtail(bi, bi.count - 1),
+                                  ATOMnilptr(bi.type)))
                                pos = oid_nil; /* no non-nil values */
                } else if (BATordered_rev(b)) {
                        pos = b->hseqbase;
                        if (skipnil && !bi.nonil &&
-                           ATOMcmp(bi.type, BUNtail(bi, 0),
-                                   ATOMnilptr(bi.type)) == 0)
+                           ATOMeq(bi.type, BUNtail(bi, 0),
+                                  ATOMnilptr(bi.type)))
                                pos = oid_nil; /* no non-nil values */
                } else {
                        if (BATcheckorderidx(b)) {
@@ -3796,7 +3798,7 @@ BATmax_skipnil(BAT *b, void *aggr, bit s
 
                                        res = BUNtail(bi, z - b->hseqbase);
 
-                                       if (ATOMcmp(bi.type, res, 
ATOMnilptr(bi.type)) == 0)
+                                       if (ATOMeq(bi.type, res, 
ATOMnilptr(bi.type)))
                                                pos = z;
                                }
                                HEAPdecref(oidxh, false);
@@ -3894,7 +3896,7 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
        const void *nil = ATOMnilptr(tp);
        const void *dnil = nil;
        dbl val;                /* only used for average */
-       int (*atomcmp)(const void *, const void *) = ATOMcompare(tp);
+       bool (*atomeq)(const void *, const void *) = ATOMequal(tp);
        const char *err;
        lng t0 = 0;
 
@@ -4064,7 +4066,7 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
                                assert(qindex >= r && qindex <  p);
                                v = BUNtail(bi, qindex);
                                if (!skip_nils && !bi.nonil)
-                                       nils += (*atomcmp)(v, dnil) == 0;
+                                       nils += (*atomeq)(v, dnil);
                        }
                        while (min < prev) {
                                if (bunfastapp_nocheck(bn, dnil) != GDK_SUCCEED)
@@ -4189,7 +4191,7 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
                        else
                                index = index + t1->tseqbase;
                        v = BUNtail(bi, index);
-                       nils += (*atomcmp)(v, dnil) == 0;
+                       nils += (*atomeq)(v, dnil);
                }
                if (oidxh != NULL)
                        HEAPdecref(oidxh, false);
diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c
--- a/gdk/gdk_analytic_bounds.c
+++ b/gdk/gdk_analytic_bounds.c
@@ -137,12 +137,12 @@ GDKanalyticaldiff(BAT *b, BAT *p, const 
                break;
        default:{
                const void *v = BUNtail(bi, 0), *next;
-               int (*atomcmp) (const void *, const void *) = ATOMcompare(tpe);
+               bool (*atomeq) (const void *, const void *) = ATOMequal(tpe);
                if (np) {
                        for (i = 0; i < cnt; i++) {
                                rb[i] = np[i];
                                next = BUNtail(bi, i);
-                               if (atomcmp(v, next) != 0) {
+                               if (!atomeq(v, next)) {
                                        rb[i] = TRUE;
                                        v = next;
                                }
@@ -151,7 +151,7 @@ GDKanalyticaldiff(BAT *b, BAT *p, const 
                        for (i = 0; i < cnt; i++) {
                                rb[i] = npb;
                                next = BUNtail(bi, i);
-                               if (atomcmp(v, next) != 0) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to