From: <ole...@us...> - 2012-11-25 22:17:26
|
Revision: 1907 http://opende.svn.sourceforge.net/opende/?rev=1907&view=rev Author: oleh_derevenko Date: 2012-11-25 22:17:19 +0000 (Sun, 25 Nov 2012) Log Message: ----------- Added: Configuration option --disable-threading-intf added (--no-threading-intf for Windows/Premake) to allow eliminating use of atomics in steppers at a cost of disabling threading interface. Modified Paths: -------------- trunk/CHANGELOG.txt trunk/build/config-default.h trunk/build/premake4.lua trunk/configure.ac trunk/ode/src/ode.cpp trunk/ode/src/odeou.cpp trunk/ode/src/odeou.h trunk/ode/src/odetls.cpp trunk/ode/src/odetls.h trunk/ode/src/util.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/CHANGELOG.txt 2012-11-25 22:17:19 UTC (rev 1907) @@ -8,6 +8,13 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +11/25/12 Oleh Derevenko + * Configuration option --disable-threading-intf added + (--no-threading-intf for Windows/Premake). This allows disabling + threading interface support (external implementations may not be + assigned) but eliminates dependency on OU and use of atomics in + steppers. + 11/05/12 Oleh Derevenko * Fixed zero comparisons in OPCODE to use relative error instead of absolute epsilon value (found by Bill Sellers) Modified: trunk/build/config-default.h =================================================================== --- trunk/build/config-default.h 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/build/config-default.h 2012-11-25 22:17:19 UTC (rev 1907) @@ -22,13 +22,15 @@ * Use old implementation of trimesh-trimesh collider * (for backward compatibility only) * - * dOU_ENABLED - always enabled - * dATOMICS_ENABLED - always enabled + * dOU_ENABLED + * dATOMICS_ENABLED * dTLS_ENABLED - * Use generic features of OU library, atomic - * API and TLS API respectively. Using TLS for - * global variables allows calling ODE from - * multiple threads. + * Use generic features of OU library, atomic API + * and TLS API respectively. + * Generic features and atomic API are always enabled, + * unless threading interface support is disabled. + * Using TLS for global variables allows calling ODE + * collision detection functions from multiple threads. * * dBUILTIN_THREADING_IMPL_ENABLED * Include built-in multithreaded threading @@ -43,10 +45,11 @@ #define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 0 -#define dOU_ENABLED 1 -#define dATOMICS_ENABLED 1 +/* #define dOU_ENABLED 1 */ +/* #define dATOMICS_ENABLED 1 */ /* #define dTLS_ENABLED 1 */ +/* #define dTHREADING_INTF_DISABLED 1 */ /* #define dBUILTIN_THREADING_IMPL_ENABLED 1 */ Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/build/premake4.lua 2012-11-25 22:17:19 UTC (rev 1907) @@ -102,10 +102,15 @@ newoption { trigger = "with-builtin-threading-impl", - description = "Include built-in multithreaded threading implementation (still must be created and assigned to be used)." + description = "Include built-in multithreaded threading implementation (still must be created and assigned to be used)" } newoption { + trigger = "no-threading-intf", + description = "Disable threading interface support (external implementations may not be assigned; overrides with-builtin-threading-impl)" + } + + newoption { trigger = "16bit-indices", description = "Use 16-bit indices for trimeshes (default is 32-bit)" } @@ -282,7 +287,6 @@ "../ode/src/joints", "../OPCODE", "../GIMPACT/include", - "../ou/include", "../libccd/src" } @@ -299,10 +303,12 @@ "../ode/src/collision_std.cpp", } --- Include OU files by default to enable atomics --- configuration { "with-ou" } + if _OPTIONS["with-ou"] or not _OPTIONS["no-threading-intf"] then + includedirs { "../ou/include" } files { "../ou/**.h", "../ou/**.cpp" } defines { "_OU_NAMESPACE=odeou" } + end + configuration { "no-dif" } excludes { "../ode/src/export-dif.cpp" } @@ -384,11 +390,18 @@ text = string.gsub(text, "#define dTRIMESH_OPCODE 1", "#define dTRIMESH_GIMPACT 1") end + if _OPTIONS["with-ou"] or not _OPTIONS["no-threading-intf"] then + text = string.gsub(text, "/%* #define dOU_ENABLED 1 %*/", "#define dOU_ENABLED 1") + text = string.gsub(text, "/%* #define dATOMICS_ENABLED 1 %*/", "#define dATOMICS_ENABLED 1") + end + if _OPTIONS["with-ou"] then text = string.gsub(text, "/%* #define dTLS_ENABLED 1 %*/", "#define dTLS_ENABLED 1") end - if _OPTIONS["with-builtin-threading-impl"] then + if _OPTIONS["no-threading-intf"] then + text = string.gsub(text, "/%* #define dTHREADING_INTF_DISABLED 1 %*/", "#define dTHREADING_INTF_DISABLED 1") + elseif _OPTIONS["with-builtin-threading-impl"] then text = string.gsub(text, "/%* #define dBUILTIN_THREADING_IMPL_ENABLED 1 %*/", "#define dBUILTIN_THREADING_IMPL_ENABLED 1") end Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/configure.ac 2012-11-25 22:17:19 UTC (rev 1907) @@ -284,12 +284,21 @@ AC_CHECK_FUNCS([floor memmove memset sqrt sqrtf sinf cosf fabsf atan2f fmodf copysignf copysign snprintf vsnprintf gettimeofday isnan isnanf _isnan _isnanf __isnan __isnanf strchr strstr pthread_attr_setstacklazy]) AC_FUNC_ALLOCA -use_ou="yes" +AC_ARG_ENABLE([threading-intf], + AS_HELP_STRING([--disable-threading-intf], + [disable threading interface support (external implementations may not be assigned; overrides --enable-builtin-threading-impl)] + ), + threading_intf=$enableval,threading_intf=yes) AC_ARG_ENABLE([ou], AS_HELP_STRING([--enable-ou], - [use TLS for global caches (allows threaded collision checks for separated spaces)] + [use TLS for global caches (allows threaded collision checks for isolated spaces)] ), use_ou_tls=$enableval,use_ou_tls=no) +use_ou="no" +if test x$use_ou_tls = xyes -o x$threading_intf = xyes +then + use_ou="yes" +fi if test x$use_ou = xyes then OU_NAMESPACE=odeou @@ -342,14 +351,20 @@ AC_CONFIG_SUBDIRS([ou]) AM_CONDITIONAL(ENABLE_OU, test x$use_ou = xyes) -AC_ARG_ENABLE([builtin-threading-impl], +if test x$threading_intf = xyes +then + AC_ARG_ENABLE([builtin-threading-impl], AS_HELP_STRING([--enable-builtin-threading-impl], [include built-in multithreaded threading implementation (still must be created and assigned to be used)] ), use_builtin_threading_impl=$enableval,use_builtin_threading_impl=no) -if test x$use_builtin_threading_impl = xyes -then - AC_DEFINE([dBUILTIN_THREADING_IMPL_ENABLED],[1],[Built-in multithreaded threading implementation included]) + if test x$use_builtin_threading_impl = xyes + then + AC_DEFINE([dBUILTIN_THREADING_IMPL_ENABLED],[1],[Built-in multithreaded threading implementation included]) + fi +else + AC_DEFINE([dTHREADING_INTF_DISABLED],[1],[Threading interface is disabled]) + use_builtin_threading_impl=no fi col_cylinder_cylinder=none @@ -537,6 +552,7 @@ echo " Is target x86-64: $cpu64" echo " Use old opcode trimesh collider: $old_trimesh" echo " TLS for global caches: $use_ou_tls" +echo " Threading intf enabled: $threading_intf" echo " Built-in threading included: $use_builtin_threading_impl" echo " Enable debug error check: $asserts" echo " Headers will be installed in $includedir/ode" Modified: trunk/ode/src/ode.cpp =================================================================== --- trunk/ode/src/ode.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/ode.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -1781,12 +1781,16 @@ } void dWorldSetStepThreadingImplementation(dWorldID w, - const dxThreadingFunctionsInfo *functions_info, dThreadingImplementationID threading_impl) + const dxThreadingFunctionsInfo *functions_info, dThreadingImplementationID threading_impl) { dUASSERT (w,"bad world argument"); dUASSERT (!functions_info || functions_info->struct_size >= sizeof(*functions_info), "Bad threading functions info"); +#if dTHREADING_INTF_DISABLED + dUASSERT(functions_info == NULL && threading_impl == NULL, "Threading interface is not available"); +#else w->AssignThreadingImpl(functions_info, threading_impl); +#endif } @@ -2223,11 +2227,13 @@ REGISTER_EXTENSION( ODE_EXT_mt_collisions ) #endif // dTLS_ENABLED +#if !dTHREADING_INTF_DISABLED REGISTER_EXTENSION( ODE_EXT_threading ) #if dBUILTIN_THREADING_IMPL_ENABLED REGISTER_EXTENSION( ODE_THR_builtin_impl ) #endif // #if dBUILTIN_THREADING_IMPL_ENABLED +#endif // #if !dTHREADING_INTF_DISABLED //********************************** // EXTENSION LIST END Modified: trunk/ode/src/odeou.cpp =================================================================== --- trunk/ode/src/odeou.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odeou.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -41,6 +41,13 @@ #if dOU_ENABLED + +using _OU_NAMESPACE::EASSERTIONFAILURESEVERITY; +using _OU_NAMESPACE::AFS__MAX; +using _OU_NAMESPACE::CMemoryManagerCustomization; +using _OU_NAMESPACE::CAssertionCheckCustomization; + + BEGIN_NAMESPACE_OU(); template<> const char *const CEnumUnsortedElementArray<EASSERTIONFAILURESEVERITY, AFS__MAX, const char *>::m_aetElementArray[] = Modified: trunk/ode/src/odeou.h =================================================================== --- trunk/ode/src/odeou.h 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odeou.h 2012-11-25 22:17:19 UTC (rev 1907) @@ -1,29 +1,29 @@ /************************************************************************* - * * - * OU library interface file for Open Dynamics Engine, * - * Copyright (C) 2008 Oleh Derevenko. All rights reserved. * - * Email: od...@el... (change all "a" to "e") * - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: ru...@q1... Web: www.q12.org * - * * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ +* * +* OU library interface file for Open Dynamics Engine, * +* Copyright (C) 2008 Oleh Derevenko. All rights reserved. * +* Email: od...@el... (change all "a" to "e") * +* * +* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * +* All rights reserved. Email: ru...@q1... Web: www.q12.org * +* * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of EITHER: * +* (1) The GNU Lesser General Public License as published by the Free * +* Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. The text of the GNU Lesser * +* General Public License is included with this library in the * +* file LICENSE.TXT. * +* (2) The BSD-style license that is included with this library in * +* the file LICENSE-BSD.TXT. * +* * +* This library is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * +* LICENSE.TXT and LICENSE-BSD.TXT for more details. * +* * +*************************************************************************/ /* @@ -56,9 +56,20 @@ #endif -using namespace _OU_NAMESPACE; +using _OU_NAMESPACE::CEnumUnsortedElementArray; +#if dATOMICS_ENABLED +using _OU_NAMESPACE::atomicord32; +using _OU_NAMESPACE::atomicptr; +using _OU_NAMESPACE::InitializeAtomicAPI; +using _OU_NAMESPACE::FinalizeAtomicAPI; +using _OU_NAMESPACE::AtomicCompareExchange; +using _OU_NAMESPACE::AtomicExchange; +using _OU_NAMESPACE::AtomicCompareExchangePointer; +using _OU_NAMESPACE::AtomicExchangePointer; +#endif + class COdeOu { public: @@ -72,9 +83,49 @@ }; -#if dATOMICS_ENABLED +#else // !dOU_ENABLED +typedef unsigned int atomicord32; +typedef size_t atomicptr; + + +#endif // dOU_ENABLED + + +#if !dATOMICS_ENABLED + static inline +bool AtomicCompareExchange(volatile atomicord32 *paoDestination, atomicord32 aoComparand, atomicord32 aoExchange) +{ + return (*paoDestination == aoComparand) ? ((*paoDestination = aoExchange), true) : false; +} + +static inline +atomicord32 AtomicExchange(volatile atomicord32 *paoDestination, atomicord32 aoExchange) +{ + atomicord32 aoDestinationValue = *paoDestination; + *paoDestination = aoExchange; + return aoDestinationValue; +} + +static inline +bool AtomicCompareExchangePointer(volatile atomicptr *papDestination, atomicptr apComparand, atomicptr apExchange) +{ + return (*papDestination == apComparand) ? ((*papDestination = apExchange), true) : false; +} + +static inline +atomicptr AtomicExchangePointer(volatile atomicptr *papDestination, atomicptr apExchange) +{ + atomicptr apDestinationValue = *papDestination; + *papDestination = apExchange; + return apDestinationValue; +} + +#endif // #if !dATOMICS_ENABLED + + +static inline unsigned int AtomicIncrementIntUpToLimit(volatile unsigned int *storagePointer, unsigned int limitValue) { unsigned int resultValue; @@ -107,10 +158,4 @@ } -#endif // #if dATOMICS_ENABLED - - -#endif // dOU_ENABLED - - #endif // _ODE_ODEOU_H_ Modified: trunk/ode/src/odetls.cpp =================================================================== --- trunk/ode/src/odetls.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odetls.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -41,6 +41,10 @@ #if dTLS_ENABLED + +using _OU_NAMESPACE::CTLSInitialization; + + ////////////////////////////////////////////////////////////////////////// // Class static fields Modified: trunk/ode/src/odetls.h =================================================================== --- trunk/ode/src/odetls.h 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odetls.h 2012-11-25 22:17:19 UTC (rev 1907) @@ -42,6 +42,11 @@ #if dTLS_ENABLED +using _OU_NAMESPACE::tlsvaluetype; +using _OU_NAMESPACE::HTLSKEY; +using _OU_NAMESPACE::CThreadLocalStorage; + + struct TrimeshCollidersCache; Modified: trunk/ode/src/util.cpp =================================================================== --- trunk/ode/src/util.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/util.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -304,12 +304,12 @@ bool dxWorldProcessContext::TryExtractingStepperArenasHead(dxWorldProcessMemArena *pmaHeadInstance) { dxWorldProcessMemArena *pmaNextInstance = pmaHeadInstance->GetNextMemArena(); - return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, pmaHeadInstance, pmaNextInstance); + return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaHeadInstance, (atomicptr)pmaNextInstance); } bool dxWorldProcessContext::TryInsertingStepperArenasHead(dxWorldProcessMemArena *pmaArenaInstance, dxWorldProcessMemArena *pmaExistingHead) { - return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, pmaExistingHead, pmaArenaInstance); + return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaExistingHead, (atomicptr)pmaArenaInstance); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |