Changeset: fcbc964389f8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fcbc964389f8
Removed Files:
        sql/test/BugTracker-2011/Tests/and-power.Bug-3013.stable.out.int128
Modified Files:
        NT/monetdb_config.h.in
        configure.ag
        gdk/gdk_aggr.c
        gdk/gdk_atoms.c
        gdk/gdk_calc.c
        monetdb5/modules/kernel/mmath.h
        sql/test/BugTracker-2011/Tests/and-power.Bug-3013.stable.out
        sql/test/BugTracker-2017/Tests/All
        sql/test/mergetables/Tests/All
        testing/Mtest.py.in
Branch: default
Log Message:

Merge with Jul2017 branch.


diffs (truncated from 497 to 300 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -160,14 +160,6 @@
 /* Define if the fits module is to be enabled */
 /* #undef HAVE_FITS */
 
-/* Define to 1 if you have the `fpclass' function. */
-#define HAVE_FPCLASS 1         /* uses _fpclass, see mmath.c */
-
-/* Define to 1 if you have the `fpclassify' function. */
-#if defined(_MSC_VER) && _MSC_VER > 1600
-#define HAVE_FPCLASSIFY 1
-#endif
-
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 /* #undef HAVE_FSEEKO */
 
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2722,8 +2722,6 @@ AC_CHECK_FUNCS([\
        fabsf \
        fallocate \
        fcntl \
-       fpclass \
-       fpclassify \
        fsync \
        ftime \
        getexecname \
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -10,7 +10,7 @@
 #include "gdk.h"
 #include "gdk_private.h"
 #include "gdk_calc_private.h"
-#ifdef __INTEL_COMPILER
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
 #include <mathimf.h>
 #else
 #include <math.h>
@@ -151,13 +151,11 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e,
 /* ---------------------------------------------------------------------- */
 /* sum */
 
-#if defined(_MSC_VER) && _MSC_VER < 1800
-#ifndef isnan
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && _MSC_VER < 1800
+#include <float.h>
 #define isnan(x)       _isnan(x)
-#endif
-#ifndef isinf
 #define isinf(x)       (_fpclass(x) & (_FPCLASS_NINF | _FPCLASS_PINF))
-#endif
+#define isfinite(x)    _finite(x)
 #endif
 
 static inline int
@@ -199,14 +197,19 @@ dofsum(const void *restrict values, oid 
        int nil_if_empty, const char *func)
 {
        struct pergroup {
-               size_t npartials;
-               size_t maxpartials;
-               double *partials;
+               int npartials;
+               int maxpartials;
                int valseen;
+#ifdef INFINITES_ALLOWED
+               float infs;
+#else
+               int infs;
+#endif
+               double *partials;
        } *pergroup;
-       size_t listi;
-       size_t parti;
-       size_t i;
+       BUN listi;
+       int parti;
+       int i;
        BUN grp;
        double x, y;
        volatile double lo, hi;
@@ -230,9 +233,10 @@ dofsum(const void *restrict values, oid 
        if (pergroup == NULL)
                return BUN_NONE;
        for (grp = 0; grp < ngrp; grp++) {
-               pergroup[grp].npartials = 1;
+               pergroup[grp].npartials = 0;
                pergroup[grp].valseen = 0;
-               pergroup[grp].maxpartials = 32;
+               pergroup[grp].maxpartials = 2;
+               pergroup[grp].infs = 0;
                pergroup[grp].partials = GDKmalloc(pergroup[grp].maxpartials * 
sizeof(double));
                if (pergroup[grp].partials == NULL) {
                        while (grp > 0)
@@ -240,7 +244,6 @@ dofsum(const void *restrict values, oid 
                        GDKfree(pergroup);
                        return BUN_NONE;
                }
-               pergroup[grp].partials[0] = 0;
        }
        for (;;) {
                if (cand) {
@@ -276,8 +279,14 @@ dofsum(const void *restrict values, oid 
                        continue;
                }
                pergroup[grp].valseen = 1;
-               i = 1;
-               for (parti = 1; parti < pergroup[grp].npartials; parti++) {
+#ifdef INFINITES_ALLOWED
+               if (isinf(x)) {
+                       pergroup[grp].infs += x;
+                       continue;
+               }
+#endif
+               i = 0;
+               for (parti = 0; parti < pergroup[grp].npartials; parti++) {
                        y = pergroup[grp].partials[parti];
                        if (fabs(x) < fabs(y))
                                exchange(&x, &y);
@@ -286,7 +295,7 @@ dofsum(const void *restrict values, oid 
                                int sign = hi > 0 ? 1 : -1;
                                hi = x - twopow * sign;
                                x = hi - twopow * sign;
-                               pergroup[grp].partials[0] += sign;
+                               pergroup[grp].infs += sign;
                                if (fabs(x) < fabs(y))
                                        exchange(&x, &y);
                                twosum(&hi, &lo, x, y);
@@ -296,12 +305,10 @@ dofsum(const void *restrict values, oid 
                        x = hi;
                }
                if (x != 0) {
-                       if (i == pergroup[grp].maxpartials - 1) {
-                               /* -1 to make sure we have one spare
-                                 * for the final step below */
+                       if (i == pergroup[grp].maxpartials) {
                                double *temp;
                                pergroup[grp].maxpartials += 
pergroup[grp].maxpartials;
-                               temp = GDKrealloc(pergroup[grp].partials, 
pergroup[grp].maxpartials);
+                               temp = GDKrealloc(pergroup[grp].partials, 
pergroup[grp].maxpartials * sizeof(double));
                                if (temp == NULL)
                                        goto bailout;
                                pergroup[grp].partials = temp;
@@ -324,10 +331,8 @@ dofsum(const void *restrict values, oid 
                        pergroup[grp].partials = NULL;
                        continue;
                }
-               if (isinf(pergroup[grp].partials[0]) ||
-                   isnan(pergroup[grp].partials[0])) {
-                       /* isnan: cannot happen: infinities of both
-                        * signs in summands */
+#ifdef INFINITES_ALLOWED
+               if (isinf(pergroup[grp].infs) || isnan(pergroup[grp].infs)) {
                        if (abort_on_error) {
                                goto overflow;
                        }
@@ -340,17 +345,18 @@ dofsum(const void *restrict values, oid 
                        pergroup[grp].partials = NULL;
                        continue;
                }
+#endif
 
-               if (fabs(pergroup[grp].partials[0]) == 1.0 &&
-                   pergroup[grp].npartials > 1 &&
-                   !samesign(pergroup[grp].partials[0], 
pergroup[grp].partials[pergroup[grp].npartials - 1])) {
-                       twosum(&hi, &lo, pergroup[grp].partials[0] * twopow, 
pergroup[grp].partials[pergroup[grp].npartials - 1] / 2);
+               if ((pergroup[grp].infs == 1 || pergroup[grp].infs == -1) &&
+                   pergroup[grp].npartials > 0 &&
+                   !samesign(pergroup[grp].infs, 
pergroup[grp].partials[pergroup[grp].npartials - 1])) {
+                       twosum(&hi, &lo, pergroup[grp].infs * twopow, 
pergroup[grp].partials[pergroup[grp].npartials - 1] / 2);
                        if (isinf(2 * hi)) {
                                y = 2 * lo;
                                x = hi + y;
                                x -= hi;
                                if (x == y &&
-                                   pergroup[grp].npartials > 2 &&
+                                   pergroup[grp].npartials > 1 &&
                                    samesign(lo, 
pergroup[grp].partials[pergroup[grp].npartials - 2])) {
                                        GDKfree(pergroup[grp].partials);
                                        pergroup[grp].partials = NULL;
@@ -375,18 +381,27 @@ dofsum(const void *restrict values, oid 
                                }
                        } else {
                                if (lo) {
-                                       /* we made sure above that we
-                                        * have space for one more
-                                        * partial */
+                                       if (pergroup[grp].npartials == 
pergroup[grp].maxpartials) {
+                                               double *temp;
+                                               /* we need space for one more */
+                                               pergroup[grp].maxpartials++;
+                                               temp = 
GDKrealloc(pergroup[grp].partials, pergroup[grp].maxpartials * sizeof(double));
+                                               if (temp == NULL)
+                                                       goto bailout;
+                                               pergroup[grp].partials = temp;
+                                       }
                                        
pergroup[grp].partials[pergroup[grp].npartials - 1] = 2 * lo;
                                        
pergroup[grp].partials[pergroup[grp].npartials++] = 2 * hi;
                                } else {
                                        
pergroup[grp].partials[pergroup[grp].npartials - 1] = 2 * hi;
                                }
-                               pergroup[grp].partials[0] = 0;
+                               pergroup[grp].infs = 0;
                        }
                }
 
+               if (pergroup[grp].infs != 0)
+                       goto overflow;
+
                if (pergroup[grp].npartials == 0) {
                        GDKfree(pergroup[grp].partials);
                        pergroup[grp].partials = NULL;
@@ -396,8 +411,6 @@ dofsum(const void *restrict values, oid 
                                ((dbl *) results)[grp] = 0;
                        continue;
                }
-               if (pergroup[grp].partials[0] != 0)
-                       goto overflow;
 
                /* accumulate into hi */
                hi = pergroup[grp].partials[--pergroup[grp].npartials];
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -23,12 +23,18 @@
 #include "monetdb_config.h"
 #include "gdk.h"
 #include "gdk_private.h"
-#include <math.h>              /* for isfinite macro */
-#ifdef HAVE_IEEEFP_H
-#include <ieeefp.h>            /* for Solaris */
-#ifndef isfinite
-#define isfinite(f)    finite(f)
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
+#include <mathimf.h>                   /* Intel compiler on Windows */
+#else
+#include <math.h>                              /* anywhere else */
 #endif
+
+/* these are only for older Visual Studio compilers (VS 2010) */
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && _MSC_VER < 1800
+#include <float.h>
+#define isnan(x)       _isnan(x)
+#define isinf(x)       (_fpclass(x) & (_FPCLASS_NINF | _FPCLASS_PINF))
+#define isfinite(x)    _finite(x)
 #endif
 
 static int
@@ -906,10 +912,6 @@ atom_io(ptr, Int, int)
 #else /* SIZEOF_VOID_P == SIZEOF_LNG */
 atom_io(ptr, Lng, lng)
 #endif
-#if defined(_MSC_VER) && !defined(isfinite)
-/* with more recent Visual Studio, isfinite is defined */
-#define isfinite(x)    _finite(x)
-#endif
 
 ssize_t
 dblFromStr(const char *src, size_t *len, dbl **dst)
@@ -947,9 +949,7 @@ dblFromStr(const char *src, size_t *len,
                        p = pe;
                n = (ssize_t) (p - src);
                if (n == 0 || (errno == ERANGE && (d < -1 || d > 1))
-#ifdef isfinite
                    || !isfinite(d) /* no NaN or Infinte */
-#endif
                    ) {
                        GDKerror("overflow or not a number\n");
                        return -1;
@@ -1021,9 +1021,7 @@ fltFromStr(const char *src, size_t *len,
 #else /* no strtof, try sscanf */
                if (sscanf(src, "%f%n", &f, &n) <= 0 || n <= 0
 #endif
-#ifdef isfinite
                    || !isfinite(f) /* no NaN or infinite */
-#endif
                    ) {
                        GDKerror("overflow or not a number\n");
                        return -1;
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -10,7 +10,11 @@
 #include "gdk.h"
 #include "gdk_private.h"
 #include "gdk_calc_private.h"
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
+#include <mathimf.h>
+#else
 #include <math.h>
+#endif
 
 /* Define symbol FULL_IMPLEMENTATION to get implementations for all
  * sensible output types for +, -, *, /.  Without the symbol, all
diff --git a/monetdb5/modules/kernel/mmath.h b/monetdb5/modules/kernel/mmath.h
--- a/monetdb5/modules/kernel/mmath.h
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to