From 38bda5b8365668ab7927445347645d610000dbba Mon Sep 17 00:00:00 2001 From: Brad Barber <bradb@shore.net> Date: Sat, 9 Jan 2010 10:11:42 -0500 Subject: [PATCH] Rebuild libqhull.a with qh_QHpointer=0 for qhull, rbox, etc. Create libqhullp.a with qh_QHpointer=1 for qhullcpp.dll, etc. gcc has halved the cost of qh_QHpointer by using more space Add <time.h> to user.h for CLOCKS_PER_SEC Move ostream<<QhullFacetList from inline to compiled. It tripped a double define error like the other classes. Remove ptr_intT from qh_matchvertices. Not needed. Fix name of qh_QHpointer --- cpp/QhullFacetList.cpp | 10 ++- cpp/QhullFacetList.h | 2 +- cpp/QhullFacetSet.h | 2 +- project/libqhullcpp/libqhullcpp.pro | 9 +-- project/libqhullp/libqhullp.pro | 101 ++++++++++++++++++++++++++++ project/qhull-all.pro | 1 + project/qhulltest/qhulltest.pro | 1 + project/user_eg3/user_eg3.pro | 1 + src/Changes.txt | 21 +++--- src/libqhull.h | 2 +- src/poly.c | 9 ++- src/user.h | 8 ++- 12 files changed, 142 insertions(+), 25 deletions(-) create mode 100644 project/libqhullp/libqhullp.pro diff --git a/cpp/QhullFacetList.cpp b/cpp/QhullFacetList.cpp index bdba96d..8a074bc 100644 --- a/cpp/QhullFacetList.cpp +++ b/cpp/QhullFacetList.cpp @@ -1,8 +1,8 @@ /**************************************************************************** ** ** Copyright (C) 2008-2010 C.B. Barber. All rights reserved. -** $Id: //product/qhull/main/rel/cpp/QhullFacetList.cpp#22 $$Change: 1139 $ -** $DateTime: 2010/01/03 11:20:29 $$Author: bbarber $ +** $Id: //product/qhull/main/rel/cpp/QhullFacetList.cpp#23 $$Change: 1171 $ +** $DateTime: 2010/01/09 10:11:25 $$Author: bbarber $ ** ****************************************************************************/ @@ -120,4 +120,10 @@ operator<<(ostream &os, const QhullFacetList::PrintVertices &pr) return os; }//printVertices +std::ostream & +operator<<(ostream &os, const QhullFacetList &fs) +{ + os << fs.printFacets(UsingLibQhull::NOqhRunId); + return os; +}//QhullFacetList diff --git a/cpp/QhullFacetList.h b/cpp/QhullFacetList.h index 2d678b3..e817708 100644 --- a/cpp/QhullFacetList.h +++ b/cpp/QhullFacetList.h @@ -97,6 +97,6 @@ public: std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList::PrintFacetList &p); std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList::PrintFacets &p); std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList::PrintVertices &p); -std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList &fs) { os << fs.printFacets(orgQhull::UsingLibQhull::NOqhRunId); return os; } +std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList &fs); #endif // QHULLFACETLIST_H diff --git a/cpp/QhullFacetSet.h b/cpp/QhullFacetSet.h index 57bfa43..9e0e6cb 100644 --- a/cpp/QhullFacetSet.h +++ b/cpp/QhullFacetSet.h @@ -87,7 +87,7 @@ public: #//== Global namespace ========================================= -std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetSet &fs); // FIXUP QH10000 no 'const ...PrintFacetSet as below! { os << fs.print(orgQhull::UsingLibQhull::NOqhRunId, ""); } +std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetSet &fs); std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetSet::PrintFacetSet &pr); std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetSet::PrintIdentifiers &p); diff --git a/project/libqhullcpp/libqhullcpp.pro b/project/libqhullcpp/libqhullcpp.pro index 03791d9..549272a 100644 --- a/project/libqhullcpp/libqhullcpp.pro +++ b/project/libqhullcpp/libqhullcpp.pro @@ -7,15 +7,16 @@ TEMPLATE = lib CONFIG += shared warn_on CONFIG -= app_bundle LIBS += -L../.. +DEFINES += qh_QHpointer build_pass:CONFIG(debug, debug|release):{ TARGET = qhullcppd - LIBS += libqhulld - PRE_TARGETDEPS += ../../libqhulld.a + LIBS += libqhullpd # qh_QHpointer + PRE_TARGETDEPS += ../../libqhullpd.a OBJECTS_DIR = ../../tmp/libqhullcpp/Debug }else:build_pass:CONFIG(release, debug|release):{ TARGET = qhullcpp - LIBS += libqhull - PRE_TARGETDEPS += ../../libqhull.a + LIBS += libqhullp + PRE_TARGETDEPS += ../../libqhullp.a OBJECTS_DIR = ../../tmp/libqhullcpp/Release } QT -= gui diff --git a/project/libqhullp/libqhullp.pro b/project/libqhullp/libqhullp.pro new file mode 100644 index 0000000..5a29ebf --- /dev/null +++ b/project/libqhullp/libqhullp.pro @@ -0,0 +1,101 @@ +# ------------------------------------------------- +# libqhullp.pro -- Qhull static library with qh_qhPointer +# ------------------------------------------------- + +DESTDIR = ../.. +TEMPLATE = lib +CONFIG += staticlib warn_on +CONFIG -= app_bundle qt +DEFINES += qh_QHpointer +# Appears to be needed for gcc 4.1, 4.2, and 4.3 with -O2 +#QMAKE_CFLAGS += -fno-strict-aliasing +QMAKE_CFLAGS += -Wall -Wextra -Wshadow -Wcast-qual -Wwrite-strings +QMAKE_CFLAGS += -Wno-sign-conversion # Many size_t vs. int errors +#QMAKE_CFLAGS_DEBUG += -Wconversion # no workaround for bit-field conversion errors +build_pass:CONFIG(debug, debug|release):{ + TARGET = qhullpd + OBJECTS_DIR = ../../tmp/libqhullp/Debug +}else:build_pass:CONFIG(release, debug|release):{ + TARGET = qhullp + OBJECTS_DIR = ../../tmp/libqhullp/Release +} +MOC_DIR = ../../tmp/moc +RCC_DIR = ../../tmp/rcc + +VPATH= ../.. +SOURCES += src/geom.c +SOURCES += src/geom2.c +SOURCES += src/global.c +SOURCES += src/io.c +SOURCES += src/mem.c +SOURCES += src/merge.c +SOURCES += src/poly2.c +SOURCES += src/poly.c +SOURCES += src/libqhull.c +SOURCES += src/qset.c +SOURCES += src/random.c +SOURCES += src/rboxlib.c +SOURCES += src/stat.c +SOURCES += src/user.c +SOURCES += src/usermem.c +SOURCES += src/userprintf.c +OTHER_FILES += Announce.txt +OTHER_FILES += COPYING.txt +OTHER_FILES += File_id.diz +OTHER_FILES += html/index.htm +OTHER_FILES += html/qconvex.htm +OTHER_FILES += html/qdelau_f.htm +OTHER_FILES += html/qdelaun.htm +OTHER_FILES += html/qhalf.htm +OTHER_FILES += html/qh-code.htm +OTHER_FILES += html/qh-eg.htm +OTHER_FILES += html/qh-faq.htm +OTHER_FILES += html/qh-get.htm +OTHER_FILES += html/qh-impre.htm +OTHER_FILES += html/qh-optc.htm +OTHER_FILES += html/qh-optf.htm +OTHER_FILES += html/qh-optg.htm +OTHER_FILES += html/qh-opto.htm +OTHER_FILES += html/qh-optp.htm +OTHER_FILES += html/qh-optq.htm +OTHER_FILES += html/qh-optt.htm +OTHER_FILES += html/qh-quick.htm +OTHER_FILES += html/qhull.htm +OTHER_FILES += html/qhull.man +OTHER_FILES += html/qhull.txt +OTHER_FILES += html/qhull-cpp.xml +OTHER_FILES += html/qvoron_f.htm +OTHER_FILES += html/qvoronoi.htm +OTHER_FILES += html/rbox.htm +OTHER_FILES += html/rbox.man +OTHER_FILES += html/rbox.txt +OTHER_FILES += index.htm +OTHER_FILES += README.txt +OTHER_FILES += REGISTER.txt +OTHER_FILES += src/Changes.txt +OTHER_FILES += src/index.htm +OTHER_FILES += src/Make-config.sh +OTHER_FILES += src/Makefile.txt +OTHER_FILES += src/Mborland +OTHER_FILES += src/qh-geom.htm +OTHER_FILES += src/qh-globa.htm +OTHER_FILES += src/qh-io.htm +OTHER_FILES += src/qh-mem.htm +OTHER_FILES += src/qh-merge.htm +OTHER_FILES += src/qh-poly.htm +OTHER_FILES += src/qh-qhull.htm +OTHER_FILES += src/qh-set.htm +OTHER_FILES += src/qh-stat.htm +OTHER_FILES += src/qh-user.htm +HEADERS += src/geom.h +HEADERS += src/io.h +HEADERS += src/mem.h +HEADERS += src/merge.h +HEADERS += src/poly.h +# qhull.h is for backwards compatibility +HEADERS += src/libqhull.h +HEADERS += src/qhull_a.h +HEADERS += src/qset.h +HEADERS += src/random.h +HEADERS += src/stat.h +HEADERS += src/user.h diff --git a/project/qhull-all.pro b/project/qhull-all.pro index b4ba739..7514ad5 100644 --- a/project/qhull-all.pro +++ b/project/qhull-all.pro @@ -6,6 +6,7 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS += libqhull +SUBDIRS += libqhullp #qh_QHpointer SUBDIRS += user_eg SUBDIRS += user_eg2 SUBDIRS += qhull diff --git a/project/qhulltest/qhulltest.pro b/project/qhulltest/qhulltest.pro index 06594d4..1fe9dee 100644 --- a/project/qhulltest/qhulltest.pro +++ b/project/qhulltest/qhulltest.pro @@ -8,6 +8,7 @@ TEMPLATE = app CONFIG += console qtestlib warn_on CONFIG -= app_bundle LIBS += -L../.. +DEFINES += qh_QHpointer build_pass:CONFIG(debug, debug|release):{ LIBS += libqhullcppd PRE_TARGETDEPS += ../../libqhullcppd.a diff --git a/project/user_eg3/user_eg3.pro b/project/user_eg3/user_eg3.pro index 4ec2412..cbd457f 100644 --- a/project/user_eg3/user_eg3.pro +++ b/project/user_eg3/user_eg3.pro @@ -6,6 +6,7 @@ DESTDIR = ../.. TEMPLATE = app CONFIG += console warn_on LIBS += -L../.. +DEFINES += qh_QHpointer build_pass:CONFIG(debug, debug|release):{ LIBS += libqhullcppd PRE_TARGETDEPS += ../../libqhullcppd.a diff --git a/src/Changes.txt b/src/Changes.txt index 76cc290..7540ecf 100644 --- a/src/Changes.txt +++ b/src/Changes.txt @@ -94,23 +94,26 @@ To do - review all #pragma - review all FIXUP [^0-9] - Number the FIXUPS - - Review ptr_intT in qh_matchvertices [poly.c] - clean up warnings for libqhullcpp - - user.h qh_qhPOINTER 0 for qhull -- need two static libraries - - review os << QhullFacetSet vs QhullFacetList vs. QhullHyperplane vs. QhullPoint QhullRidge - - generate static qhull for qhull.exe - - timer is off by 3 orders of magnitude + - add labels to git for Qhull + - Make backup Need help - ConvexHull is a submodule to git. How to get rid of? - - Set up configure and debian build. If possible, please use project/ instead of qhull-2010.1/ - - Set up CMake. If possible, please use project/ instead of qhull-2010.1/ - - The C++ interface needs a lot of work + - Set up configure and debian build. If possible, please keep qhull-2010.1/ clean + Use qhull-2010.1/project/ for build-related files + - Set up CMake. + - The C++ interface needs work. Give it a try and make it better. -qhull 2010.1 2010/01/08 +qhull 2010.1 2010/01/09 - Patched qh_gethash. See project/patch/qhull-2003.1 with patched poly.c and patch. Compared results of q_test, q_eg, and q_egtest with patched poly.c, qhull-2003.1 - Remove user_eg.exe and user_eg2.exe from Windows distribution + - Remove ptr_intT from qh_matchvertices. It was int since the beginning. + - Use qh_QHpointer=0 for libqhull.a, qhull, rbox, etc. + Use -Dqh_QHpointer for libqhullp.a, qhullcpp.dll, etc. + Cost of qh_QHpointer: [2003, msvc] 8% time 2% space, [2010, gcc] 4% time 4% space + - user.h requires <time.h> for CLOCKS_PER_SEC qhull 2010.1 2010/01/07 - Assign type to qh.old_qhstat and memT.tempstack [amorilia] diff --git a/src/libqhull.h b/src/libqhull.h index bab9c4d..9cec975 100644 --- a/src/libqhull.h +++ b/src/libqhull.h @@ -31,7 +31,7 @@ /*=========================== -included files ==============*/ -#include "user.h" /* user definable constants (e.g., qh_QHPOINTER) */ +#include "user.h" /* user definable constants (e.g., qh_QHpointer) */ #include <setjmp.h> #include <float.h> diff --git a/src/poly.c b/src/poly.c index 9bdb419..bc87bc6 100644 --- a/src/poly.c +++ b/src/poly.c @@ -10,8 +10,8 @@ (all but top 50 and their callers 12/3/95) copyright (c) 1993-2010 The Geometry Center. - $Id: //product/qhull/main/rel/src/poly.c#25 $$Change: 1164 $ - $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $ + $Id: //product/qhull/main/rel/src/poly.c#26 $$Change: 1171 $ + $DateTime: 2010/01/09 10:11:25 $$Author: bbarber $ */ #include "qhull_a.h" @@ -958,9 +958,8 @@ boolT qh_matchvertices(int firstindex, setT *verticesA, int skipA, }while (*(++elemAp)); if (!skipBp) skipBp= ++elemBp; - *skipB= SETindex_(verticesB, skipB); - /* WARN64 -- This expression on pointers returns 0 or 1 */ - *same= !(int)((((ptr_intT)skipA & 0x1) ^ ((ptr_intT)*skipB & 0x1))); + *skipB= SETindex_(verticesB, skipB); /* i.e., skipBp - verticesB */ + *same= !((skipA & 0x1) ^ (*skipB & 0x1)); /* result is 0 or 1 */ trace4((qh ferr, 4054, "qh_matchvertices: matched by skip %d(v%d) and skip %d(v%d) same? %d\n", skipA, (*skipAp)->id, *skipB, (*(skipBp-1))->id, *same)); return(True); diff --git a/src/user.h b/src/user.h index 4a36cb7..d203d7c 100644 --- a/src/user.h +++ b/src/user.h @@ -24,6 +24,8 @@ Code flags -- */ +#include <time.h> + #ifndef qhDEFuser #define qhDEFuser 1 @@ -571,7 +573,8 @@ stop after qh_JOGGLEmaxretry attempts qh_QHpointer = 1 access globals via a pointer to allocated memory enables qh_saveqhull() and qh_restoreqhull() - costs about 8% in time and 2% in space + [2010, gcc] costs about 4% in time and 4% in space + [2003, msvc] costs about 8% in time and 2% in space = 0 qh_qh and qh_qhstat are static data structures only one instance of qhull() can be active at a time @@ -582,13 +585,14 @@ stop after qh_JOGGLEmaxretry attempts qh is defined in libqhull.h qhmem is defined in mem.h qhstat is defined in stat.h + C++ build defines qh_QHpointer [libqhullp.pro, libqhullcpp.pro] see: user_eg.c for an example FIXUP need to override for C++ (-Dqh_QHpointer=1) */ #ifndef qh_QHpointer -#define qh_QHpointer 1 +#define qh_QHpointer 0 #endif #if 0 /* sample code */ qhT *oldqhA, *oldqhB; -- GitLab