Changeset: 4d5de3bd9c62 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4d5de3bd9c62 Branch: strimps-updates Log Message:
Merge with default diffs (truncated from 10035 to 300 lines): diff --git a/cmake/monetdb-options.cmake b/cmake/monetdb-options.cmake --- a/cmake/monetdb-options.cmake +++ b/cmake/monetdb-options.cmake @@ -79,6 +79,14 @@ option(UNDEFINED "Enable support for the GCC undefined sanitizer (default=OFF)" OFF) +option(PGOTRAIN + "Enable support for the profile generated optimization training (default=OFF)" + OFF) + +option(PGOBUILD + "Enable support for the profile generated optimization build (using optained data) (default=OFF)" + OFF) + option(STRICT "Enable strict compiler flags (default=ON for development sources, OFF for tarball installation)" "${DEVELOPMENT}") diff --git a/cmake/monetdb-toolchain.cmake b/cmake/monetdb-toolchain.cmake --- a/cmake/monetdb-toolchain.cmake +++ b/cmake/monetdb-toolchain.cmake @@ -56,6 +56,36 @@ function(monetdb_default_compiler_option endif() endif() + if(PGOTRAIN) + if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + SET(PGO_COMPILE_FLAGS "-fprofile-generate=${CMAKE_BINARY_DIR}/profile-data") + endif() + if ("${CMAKE_C_COMPILER_ID}" MATCHES "^(Clang|AppleClang)$") + SET(PGO_COMPILE_FLAGS "-fprofile-instr-generate") + endif() + SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PGO_COMPILE_FLAGS}" PARENT_SCOPE) + endif() + + if(PGOBUILD) + if(NOT PGO_TRAINING_DIR) + SET(PGO_TRAINING_DIR ../training) + endif() + SET(PGO_TRAINING_DATA ${CMAKE_BINARY_DIR}/${PGO_TRAINING_DIR}/profile-data) + + if(NOT EXISTS ${PGO_TRAINING_DATA}) + message(FATAL_ERROR "No profiling Data Found so can't Build. Ensure that the training run was executed in the training build directory. Training data expected in Directory: " ${PGO_TRAINING_DATA}) + endif() + + if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + SET(PGO_COMPILE_FLAGS "-fprofile-use=${PGO_TRAINING_DATA} -fprofile-correction -Wno-missing-profile -Wno-coverage-mismatch") + endif() + if ("${CMAKE_C_COMPILER_ID}" MATCHES "^(Clang|AppleClang)$") + SET(PGO_COMPILE_FLAGS "-fprofile-instr-use") + endif() + + SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PGO_COMPILE_FLAGS}" PARENT_SCOPE ) + endif() + if(STRICT) if(${CMAKE_C_COMPILER_ID} MATCHES "^(GNU|Clang|AppleClang)$") add_compile_options("-Werror") diff --git a/ctest/monetdb5/mal/test_malEmbeddedBoot.c b/ctest/monetdb5/mal/test_malEmbeddedBoot.c --- a/ctest/monetdb5/mal/test_malEmbeddedBoot.c +++ b/ctest/monetdb5/mal/test_malEmbeddedBoot.c @@ -18,6 +18,12 @@ main(void) char* msg = MAL_SUCCEED; gdk_return gdk_res; + if (BBPaddfarm(NULL, (1U << PERSISTENT) | (1U << TRANSIENT), false) != GDK_SUCCEED) { + /* set in memory dbfarm */ + createException(MAL, "embedded.monetdb_startup", "BBPaddfram() failed"); + return 1; + } + gdk_res = GDKinit(NULL, 0, true, NULL); if (gdk_res != GDK_SUCCEED) { msg = createException(MAL, "embedded.monetdb_startup", "GDKinit() failed"); diff --git a/ctest/monetdb5/mal/test_malInclude.c b/ctest/monetdb5/mal/test_malInclude.c --- a/ctest/monetdb5/mal/test_malInclude.c +++ b/ctest/monetdb5/mal/test_malInclude.c @@ -18,6 +18,12 @@ main(void) { gdk_return gdk_res; + if (BBPaddfarm(NULL, (1U << PERSISTENT) | (1U << TRANSIENT), false) != GDK_SUCCEED) { + /* set in memory dbfarm */ + createException(MAL, "embedded.monetdb_startup", "BBPaddfram() failed"); + return 1; + } + gdk_res = GDKinit(NULL, 0, true, NULL); if (gdk_res != GDK_SUCCEED) { createException(MAL, "embedded.monetdb_startup", "GDKinit() failed"); diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c --- a/gdk/gdk_firstn.c +++ b/gdk/gdk_firstn.c @@ -229,7 +229,7 @@ BATfirstn_unique(BATiter *bi, BAT *s, BU /* trivial: return all candidates */ bn = canditer_slice(&ci, 0, ci.ncand); if (bn && lastp) - *lastp = BUNtoid(bn, cnt - 1); + *lastp = oid_nil; TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT ",n=" BUNFMT " -> " ALGOOPTBATFMT " (trivial -- " LLFMT " usec)\n", @@ -1061,7 +1061,7 @@ BATfirstn_grouped(BAT **topn, BAT **gids BBPunfix(bn1->batCacheid); if (bn == NULL) return GDK_FAIL; - } else { + } else if (last != oid_nil) { BAT *bn1, *bn2; bn1 = bn; diff --git a/gdk/gdk_rtree.c b/gdk/gdk_rtree.c --- a/gdk/gdk_rtree.c +++ b/gdk/gdk_rtree.c @@ -30,6 +30,7 @@ RTREEdecref(BAT *b) ATOMIC_DESTROY(&b->trtree->refs); rtree_destroy(b->trtree->rtree); b->trtree->rtree = NULL; + GDKfree(b->trtree); b->trtree = NULL; } diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -290,31 +290,29 @@ wkbCollectAggr (wkb **out, const bat *bi static str wkbCollect (wkb **out, wkb * const *a, wkb * const *b) { str err = MAL_SUCCEED; - GEOSGeom ga, gb, collection; - GEOSGeom *collect = NULL; + GEOSGeom collection; + /* geom_a and geom_b */ + GEOSGeom geoms[2] = {NULL, NULL}; int type_a, type_b; - if ((err = wkbGetCompatibleGeometries(a, b, &ga, &gb)) != MAL_SUCCEED) + if ((err = wkbGetCompatibleGeometries(a, b, &geoms[0], &geoms[1])) != MAL_SUCCEED) throw(MAL,"geom.Collect", "%s", err); - if ((collect = GDKmalloc(sizeof(GEOSGeom) * 2)) == NULL) { - throw(MAL, "geom.Collect", SQLSTATE(HY013) MAL_MALLOC_FAIL); - } - - collect[0] = ga; - collect[1] = gb; + //int srid = GEOSGetSRID(ga); - type_a = GEOSGeomTypeId(ga); - type_b = GEOSGeomTypeId(gb); - + type_a = GEOSGeomTypeId(geoms[0]); + type_b = GEOSGeomTypeId(geoms[1]); + + /* NOTE: geoms will be moved to collection. no need for cleanup */ if (type_a == type_b) - collection = GEOSGeom_createCollection(GEOSGeom_getCollectionType(type_a), collect, (unsigned int) 2); + collection = GEOSGeom_createCollection(GEOSGeom_getCollectionType(type_a), geoms, (unsigned int) 2); else - collection = GEOSGeom_createCollection(GEOS_GEOMETRYCOLLECTION, collect, (unsigned int) 2); + collection = GEOSGeom_createCollection(GEOS_GEOMETRYCOLLECTION, geoms, (unsigned int) 2); if ((*out = geos2wkb(collection)) == NULL) err = createException(MAL, "geom.Collect", SQLSTATE(38000) "Geos operation geos2wkb failed"); - GEOSGeom_destroy(ga); - GEOSGeom_destroy(gb); + + GEOSGeom_destroy(collection); + return err; } /** @@ -3431,8 +3429,10 @@ wkbExtractPointToCoordSeq(GEOSCoordSeq * GEOSCoordSeq_getY(inCoordSeq, 0, &y); if (!GEOSCoordSeq_setX(*outCoordSeq, index, x) || !GEOSCoordSeq_setY(*outCoordSeq, index, y)) { + GEOSGeom_destroy(inGeometry); throw(MAL, "geom.MakeLine", SQLSTATE(38000) "Geos operation GEOSCoordSeq_set[XY] failed"); } + GEOSGeom_destroy(inGeometry); return msg; } @@ -3475,6 +3475,8 @@ wkbMakeLineAggrArray(wkb **outWKB, wkb * msg = createException(MAL, "geom.MakeLine", SQLSTATE(38000) "Geos operation GEOSGeom_createLineString failed"); } *outWKB = geos2wkb(outGeometry); + GEOSGeom_destroy(outGeometry); + /* no need to clean outCoordSeq. it is destroyed via outGeometry */ return msg; } @@ -3574,13 +3576,20 @@ wkbMakeLineAggrSubGroupedCand(bat *outid lineGroup[position++] = inWKB; } msg = wkbMakeLineAggrArray(&lines[lastGrp], lineGroup, position); + GDKfree(lineGroup); if (BUNappendmulti(out, lines, ngrp, false) != GDK_SUCCEED) { msg = createException(MAL, "geom.Union", SQLSTATE(38000) "BUNappend operation failed"); + for (BUN i = 0; i < ngrp; i++) + GDKfree(lines[i]); + GDKfree(lines); bat_iterator_end(&bi); goto free; } + for (BUN i = 0; i < ngrp; i++) + GDKfree(lines[i]); + GDKfree(lines); bat_iterator_end(&bi); *outid = out->batCacheid; diff --git a/geom/monetdb5/geom_atoms.c b/geom/monetdb5/geom_atoms.c --- a/geom/monetdb5/geom_atoms.c +++ b/geom/monetdb5/geom_atoms.c @@ -96,7 +96,15 @@ wkbHASH(const void *W) BUN h = 0; for (i = 0; i < (w->len - 1); i += 2) { - int a = *(w->data + i), b = *(w->data + i + 1); + BUN a = ((unsigned char *) w->data)[i]; + BUN b = ((unsigned char *) w->data)[i + 1]; +#if '\377' < 0 /* char is signed? */ + /* maybe sign extend */ + if (a & 0x80) + a |= ~(BUN)0x7f; + if (b & 0x80) + b |= ~(BUN)0x7f; +#endif h = (h << 3) ^ (h >> 11) ^ (h >> 17) ^ (b << 8) ^ a; } return h; @@ -456,7 +464,8 @@ BUN mbrHASH(const void *ATOM) { const mbr *atom = ATOM; - return (BUN) (((int) atom->xmin * (int)atom->ymin) *((int) atom->xmax * (int)atom->ymax)); + return ATOMhash(TYPE_flt, &atom->xmin) ^ ATOMhash(TYPE_flt, &atom->ymin) ^ + ATOMhash(TYPE_flt, &atom->xmax) ^ ATOMhash(TYPE_flt, &atom->ymax); } const void * @@ -1228,7 +1237,15 @@ wkbaHASH(const void *WARRAY) for (j = 0; j < wArray->itemsNum; j++) { wkb *w = wArray->data[j]; for (i = 0; i < (w->len - 1); i += 2) { - int a = *(w->data + i), b = *(w->data + i + 1); + BUN a = ((unsigned char *) w->data)[i]; + BUN b = ((unsigned char *) w->data)[i + 1]; +#if '\377' < 0 /* char is signed? */ + /* maybe sign extend */ + if (a & 0x80) + a |= ~(BUN)0x7f; + if (b & 0x80) + b |= ~(BUN)0x7f; +#endif h = (h << 3) ^ (h >> 11) ^ (h >> 17) ^ (b << 8) ^ a; } } @@ -1459,4 +1476,3 @@ wkbInteriorRings(wkba **geomArray, wkb * return MAL_SUCCEED; } - diff --git a/geom/sql/functions/Tests/All b/geom/sql/functions/Tests/All --- a/geom/sql/functions/Tests/All +++ b/geom/sql/functions/Tests/All @@ -15,8 +15,10 @@ HAVE_GEOM?ST_Collect HAVE_GEOM?ST_MakeLine HAVE_GEOM?loadTestPolygons HAVE_GEOM?ST_Intersects +HAVE_GEOM?ST_DWithin + +HAVE_GEOM?createRTreeIndex HAVE_GEOM?ST_IntersectsRTree -HAVE_GEOM?ST_DWithin HAVE_GEOM?ST_DWithinRTree HAVE_GEOM?loadTestGeometries diff --git a/geom/sql/functions/Tests/ST_DWithinRTree.test b/geom/sql/functions/Tests/ST_DWithinRTree.test --- a/geom/sql/functions/Tests/ST_DWithinRTree.test +++ b/geom/sql/functions/Tests/ST_DWithinRTree.test @@ -4,61 +4,61 @@ query T rowsort SELECT geom -FROM geometries +FROM geometries_rtree WHERE [ST_POINT(10,10)] ST_DWITHIN [geom, 5] ---- -POLYGON ((10 10, 20 10, 20 20, 10 20, 10 10)) +POLYGON ((0 20, 10 20, 20 20, 20 10, 0 20)) POLYGON ((10 10, 20 10, 10 20, 10 10)) -POLYGON ((0 20, 10 20, 20 20, 20 10, 0 20)) +POLYGON ((10 10, 20 10, 20 20, 10 20, 10 10)) query T rowsort _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org