1 // Copyright (c) 2007-2018 Hartmut Kaiser 2 // Copyright (c) 2011 Bryce Lelbach 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 7 #if !defined(HPX_CONFIG_MAR_24_2008_0943AM) 8 #define HPX_CONFIG_MAR_24_2008_0943AM 9 10 // We need to detect if user code include boost/config.hpp before 11 // including hpx/config.hpp 12 // Everything else might lead to hard compile errors and possible very subtile bugs. 13 #if defined(BOOST_CONFIG_HPP) 14 #error Boost.Config was included before the hpx config header. This might lead to subtile failures and compile errors. Please include <hpx/config.hpp> before any other boost header 15 #endif 16 17 #include <hpx/config/attributes.hpp> 18 #include <hpx/config/branch_hints.hpp> 19 #include <hpx/config/compiler_fence.hpp> 20 #include <hpx/config/compiler_native_tls.hpp> 21 #include <hpx/config/compiler_specific.hpp> 22 #include <hpx/config/constexpr.hpp> 23 #include <hpx/config/debug.hpp> 24 #include <hpx/config/defines.hpp> 25 #include <hpx/config/emulate_deleted.hpp> 26 #include <hpx/config/export_definitions.hpp> 27 #include <hpx/config/forceinline.hpp> 28 #include <hpx/config/lambda_capture.hpp> 29 #include <hpx/config/manual_profiling.hpp> 30 #include <hpx/config/threads_stack.hpp> 31 #include <hpx/config/version.hpp> 32 #include <hpx/config/weak_symbol.hpp> 33 34 #include <boost/version.hpp> 35 36 #if BOOST_VERSION < 105800 37 // Please update your Boost installation (see www.boost.org for details). 38 #error HPX cannot be compiled with a Boost version earlier than 1.58.0 39 #endif 40 41 #include <hpx/util/detail/pp/cat.hpp> 42 #include <hpx/util/detail/pp/stringize.hpp> 43 44 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) 45 // On Windows, make sure winsock.h is not included even if windows.h is 46 // included before winsock2.h 47 #define _WINSOCKAPI_ 48 #endif 49 50 /////////////////////////////////////////////////////////////////////////////// 51 /// This is the default ip/port number used by the parcel subsystem 52 #define HPX_INITIAL_IP_PORT 7910 53 #define HPX_CONNECTING_IP_PORT 7909 54 #define HPX_INITIAL_IP_ADDRESS "127.0.0.1" 55 56 /////////////////////////////////////////////////////////////////////////////// 57 /// This defines the maximum number of possible runtime instances in one 58 /// executable 59 #if !defined(HPX_RUNTIME_INSTANCE_LIMIT) 60 # define HPX_RUNTIME_INSTANCE_LIMIT 1 61 #endif 62 63 /////////////////////////////////////////////////////////////////////////////// 64 /// This defines the type of the parcelport to be used during application 65 /// bootstrap. This value can be changed at runtime by the configuration 66 /// parameter: 67 /// 68 /// hpx.parcel.bootstrap = ... 69 /// 70 /// (or by setting the corresponding environment variable HPX_PARCEL_BOOTSTRAP). 71 #if !defined(HPX_PARCEL_BOOTSTRAP) 72 # define HPX_PARCEL_BOOTSTRAP "tcp" 73 #endif 74 75 /////////////////////////////////////////////////////////////////////////////// 76 /// This defines the number of outgoing (parcel-) connections kept alive (to 77 /// all other localities). This value can be changed at runtime by setting 78 /// the configuration parameter: 79 /// 80 /// hpx.parcel.max_connections = ... 81 /// 82 /// (or by setting the corresponding environment variable 83 /// HPX_PARCEL_MAX_CONNECTIONS). 84 #if !defined(HPX_PARCEL_MAX_CONNECTIONS) 85 # define HPX_PARCEL_MAX_CONNECTIONS 512 86 #endif 87 88 /// This defines the number of outgoing ipc (parcel-) connections kept alive 89 /// (to each of the other localities on the same node). This value can be changed 90 /// at runtime by setting the configuration parameter: 91 /// 92 /// hpx.parcel.ipc.data_buffer_cache_size = ... 93 /// 94 /// (or by setting the corresponding environment variable 95 /// HPX_PARCEL_IPC_DATA_BUFFER_CACHE_SIZE). 96 #if !defined(HPX_PARCEL_IPC_DATA_BUFFER_CACHE_SIZE) 97 # define HPX_PARCEL_IPC_DATA_BUFFER_CACHE_SIZE 512 98 #endif 99 100 /// This defines the number of MPI requests in flight 101 /// This value can be changed at runtime by setting the configuration parameter: 102 /// 103 /// hpx.parcel.mpi.max_requests = ... 104 /// 105 /// (or by setting the corresponding environment variable 106 /// HPX_PARCEL_MPI_MAX_REQUESTS). 107 #if !defined(HPX_PARCEL_MPI_MAX_REQUESTS) 108 # define HPX_PARCEL_MPI_MAX_REQUESTS 2147483647 109 #endif 110 111 /////////////////////////////////////////////////////////////////////////////// 112 /// This defines the number of outgoing (parcel-) connections kept alive (to 113 /// each of the other localities). This value can be changed at runtime by 114 /// setting the configuration parameter: 115 /// 116 /// hpx.parcel.max_connections_per_locality = ... 117 /// 118 /// (or by setting the corresponding environment variable 119 /// HPX_PARCEL_MAX_CONNECTIONS_PER_LOCALITY). 120 #if !defined(HPX_PARCEL_MAX_CONNECTIONS_PER_LOCALITY) 121 # define HPX_PARCEL_MAX_CONNECTIONS_PER_LOCALITY 4 122 #endif 123 124 /////////////////////////////////////////////////////////////////////////////// 125 /// This defines the maximally allowed message size for messages transferred 126 /// between localities. This value can be changed at runtime by 127 /// setting the configuration parameter: 128 /// 129 /// hpx.parcel.max_message_size = ... 130 /// 131 /// (or by setting the corresponding environment variable 132 /// HPX_PARCEL_MAX_MESSAGE_SIZE). 133 #if !defined(HPX_PARCEL_MAX_MESSAGE_SIZE) 134 # define HPX_PARCEL_MAX_MESSAGE_SIZE 1000000000 135 #endif 136 137 /// This defines the maximally allowed outbound message size for coalescing 138 /// messages transferred between localities. This value can be changed at 139 /// runtime by setting the configuration parameter: 140 /// 141 /// hpx.parcel.max_outbound_message_size = ... 142 /// 143 /// (or by setting the corresponding environment variable 144 /// HPX_PARCEL_MAX_OUTBOUND_MESSAGE_SIZE). 145 #if !defined(HPX_PARCEL_MAX_OUTBOUND_MESSAGE_SIZE) 146 # define HPX_PARCEL_MAX_OUTBOUND_MESSAGE_SIZE 1000000 147 #endif 148 149 /////////////////////////////////////////////////////////////////////////////// 150 // This defines the number of bytes of overhead it takes to serialize a 151 // parcel. 152 #if !defined(HPX_PARCEL_SERIALIZATION_OVERHEAD) 153 # define HPX_PARCEL_SERIALIZATION_OVERHEAD 512 154 #endif 155 156 /// This defines the number of AGAS address translations kept in the local 157 /// cache. This is just the initial size which may be adjusted depending on the 158 /// load of the system (not implemented yet), etc. It must be a minimum of 3 for AGAS v3 159 /// bootstrapping. 160 /// 161 /// This value can be changes at runtime by setting the configuration parameter: 162 /// 163 /// hpx.agas.local_cache_size = ... 164 /// 165 /// (or by setting the corresponding environment variable 166 /// HPX_AGAS_LOCAL_CACHE_SIZE) 167 #if !defined(HPX_AGAS_LOCAL_CACHE_SIZE) 168 # define HPX_AGAS_LOCAL_CACHE_SIZE 4096 169 #endif 170 171 /////////////////////////////////////////////////////////////////////////////// 172 #if !defined(HPX_INITIAL_AGAS_MAX_PENDING_REFCNT_REQUESTS) 173 # define HPX_INITIAL_AGAS_MAX_PENDING_REFCNT_REQUESTS 4096 174 #endif 175 176 /////////////////////////////////////////////////////////////////////////////// 177 /// This defines the initial global reference count associated with any created 178 /// object. 179 #if !defined(HPX_GLOBALCREDIT_INITIAL) 180 # define HPX_GLOBALCREDIT_INITIAL 0x80000000ll // 2 ^ 31, i.e. 2 ^ 0b11111 181 #endif 182 183 /////////////////////////////////////////////////////////////////////////////// 184 /// This defines the default number of OS-threads created for the different 185 /// internal thread pools 186 #if !defined(HPX_NUM_IO_POOL_SIZE) 187 # define HPX_NUM_IO_POOL_SIZE 2 188 #endif 189 #if !defined(HPX_NUM_PARCEL_POOL_SIZE) 190 # define HPX_NUM_PARCEL_POOL_SIZE 2 191 #endif 192 #if !defined(HPX_NUM_TIMER_POOL_SIZE) 193 # define HPX_NUM_TIMER_POOL_SIZE 2 194 #endif 195 196 /////////////////////////////////////////////////////////////////////////////// 197 /// By default, enable minimal thread deadlock detection in debug builds only. 198 #if !defined(HPX_HAVE_THREAD_MINIMAL_DEADLOCK_DETECTION) 199 # if defined(HPX_DEBUG) 200 # define HPX_HAVE_THREAD_MINIMAL_DEADLOCK_DETECTION 201 # endif 202 #endif 203 #if !defined(HPX_HAVE_SPINLOCK_DEADLOCK_DETECTION) 204 # if defined(HPX_DEBUG) 205 //# define HPX_HAVE_SPINLOCK_DEADLOCK_DETECTION 206 # endif 207 #endif 208 #if !defined(HPX_SPINLOCK_DEADLOCK_DETECTION_LIMIT) 209 # define HPX_SPINLOCK_DEADLOCK_DETECTION_LIMIT 1000000 210 #endif 211 212 /////////////////////////////////////////////////////////////////////////////// 213 /// This defines the default number of coroutine heaps. 214 #if !defined(HPX_COROUTINE_NUM_HEAPS) 215 # define HPX_COROUTINE_NUM_HEAPS 7 216 #endif 217 218 /////////////////////////////////////////////////////////////////////////////// 219 /// By default, enable storing the parent thread information in debug builds 220 /// only. 221 #if !defined(HPX_HAVE_THREAD_PARENT_REFERENCE) 222 # if defined(HPX_DEBUG) 223 # define HPX_HAVE_THREAD_PARENT_REFERENCE 224 # endif 225 #endif 226 227 /////////////////////////////////////////////////////////////////////////////// 228 /// By default, enable storing the thread phase in debug builds only. 229 #if !defined(HPX_HAVE_THREAD_PHASE_INFORMATION) 230 # if defined(HPX_DEBUG) 231 # define HPX_HAVE_THREAD_PHASE_INFORMATION 232 # endif 233 #endif 234 235 /////////////////////////////////////////////////////////////////////////////// 236 /// By default, enable storing the thread description in debug builds only. 237 #if !defined(HPX_HAVE_THREAD_DESCRIPTION) 238 # if defined(HPX_DEBUG) 239 # define HPX_HAVE_THREAD_DESCRIPTION 240 # endif 241 #endif 242 243 /////////////////////////////////////////////////////////////////////////////// 244 /// By default, enable storing the target address of the data the thread is 245 /// accessing in debug builds only. 246 #if !defined(HPX_HAVE_THREAD_TARGET_ADDRESS) 247 # if defined(HPX_DEBUG) 248 # define HPX_HAVE_THREAD_TARGET_ADDRESS 249 # endif 250 #endif 251 252 /////////////////////////////////////////////////////////////////////////////// 253 /// By default we do not maintain stack back-traces on suspension. This is a 254 /// pure debugging aid to be able to see in the debugger where a suspended 255 /// thread got stuck. 256 #if defined(HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION) && \ 257 !defined(HPX_HAVE_STACKTRACES) 258 # error HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION reqires HPX_HAVE_STACKTRACES to be defined! 259 #endif 260 261 /// By default we capture only 5 levels of stack back trace on suspension 262 #if !defined(HPX_HAVE_THREAD_BACKTRACE_DEPTH) 263 # define HPX_HAVE_THREAD_BACKTRACE_DEPTH 5 264 #endif 265 266 /////////////////////////////////////////////////////////////////////////////// 267 // This defines the maximum number of connect retries to the AGAS service 268 // allowing for some leeway during startup of the localities 269 #if !defined(HPX_MAX_NETWORK_RETRIES) 270 # define HPX_MAX_NETWORK_RETRIES 1000 271 #endif 272 273 #if !defined(HPX_NETWORK_RETRIES_SLEEP) 274 # define HPX_NETWORK_RETRIES_SLEEP 100 275 #endif 276 277 /////////////////////////////////////////////////////////////////////////////// 278 // Characters used 279 // - to delimit several HPX ini paths 280 // - used as file extensions for shared libraries 281 // - used as path delimiters 282 #ifdef HPX_WINDOWS // windows 283 # define HPX_INI_PATH_DELIMITER ";" 284 # define HPX_SHARED_LIB_EXTENSION ".dll" 285 # define HPX_EXECUTABLE_EXTENSION ".exe" 286 # define HPX_PATH_DELIMITERS "\\/" 287 #else // unix like 288 # define HPX_INI_PATH_DELIMITER ":" 289 # define HPX_PATH_DELIMITERS "/" 290 # ifdef __APPLE__ // apple 291 # define HPX_SHARED_LIB_EXTENSION ".dylib" 292 # elif defined(HPX_HAVE_STATIC_LINKING) 293 # define HPX_SHARED_LIB_EXTENSION ".a" 294 # else // linux & co 295 # define HPX_SHARED_LIB_EXTENSION ".so" 296 # endif 297 # define HPX_EXECUTABLE_EXTENSION "" 298 #endif 299 300 /////////////////////////////////////////////////////////////////////////////// 301 #if !defined(HPX_WINDOWS) 302 # if defined(HPX_DEBUG) 303 # define HPX_MAKE_DLL_STRING(n) "lib" + n + "d" + HPX_SHARED_LIB_EXTENSION 304 # else 305 # define HPX_MAKE_DLL_STRING(n) "lib" + n + HPX_SHARED_LIB_EXTENSION 306 # endif 307 #elif defined(HPX_DEBUG) 308 # define HPX_MAKE_DLL_STRING(n) n + "d" + HPX_SHARED_LIB_EXTENSION 309 #else 310 # define HPX_MAKE_DLL_STRING(n) n + HPX_SHARED_LIB_EXTENSION 311 #endif 312 313 #if defined(HPX_DEBUG) 314 # define HPX_MANGLE_NAME(n) HPX_PP_CAT(n, d) 315 # define HPX_MANGLE_STRING(n) n + "d" 316 #else 317 # define HPX_MANGLE_NAME(n) n 318 # define HPX_MANGLE_STRING(n) n 319 #endif 320 321 /////////////////////////////////////////////////////////////////////////////// 322 #if !defined(HPX_COMPONENT_NAME) 323 # define HPX_COMPONENT_NAME hpx 324 #endif 325 326 #if !defined(HPX_COMPONENT_STRING) 327 # define HPX_COMPONENT_STRING HPX_PP_STRINGIZE(HPX_COMPONENT_NAME) 328 #endif 329 330 #if !defined(HPX_PLUGIN_COMPONENT_PREFIX) 331 # if defined(HPX_PLUGIN_NAME) 332 # define HPX_PLUGIN_COMPONENT_PREFIX HPX_MANGLE_NAME(HPX_PLUGIN_NAME) 333 # elif defined(HPX_COMPONENT_NAME) 334 # define HPX_PLUGIN_COMPONENT_PREFIX HPX_MANGLE_NAME(HPX_COMPONENT_NAME) 335 # endif 336 #endif 337 338 /////////////////////////////////////////////////////////////////////////////// 339 #if !defined(HPX_PLUGIN_NAME) 340 # define HPX_PLUGIN_NAME hpx 341 #endif 342 343 #if !defined(HPX_PLUGIN_STRING) 344 # define HPX_PLUGIN_STRING HPX_PP_STRINGIZE(HPX_PLUGIN_NAME) 345 #endif 346 347 #if !defined(HPX_PLUGIN_PLUGIN_PREFIX) 348 # define HPX_PLUGIN_PLUGIN_PREFIX HPX_MANGLE_NAME(HPX_PLUGIN_NAME) 349 #endif 350 351 /////////////////////////////////////////////////////////////////////////////// 352 #if !defined(HPX_APPLICATION_STRING) 353 # if defined(HPX_APPLICATION_NAME) 354 # define HPX_APPLICATION_STRING HPX_PP_STRINGIZE(HPX_APPLICATION_NAME) 355 # else 356 # define HPX_APPLICATION_STRING "unknown HPX application" 357 # endif 358 #endif 359 360 /////////////////////////////////////////////////////////////////////////////// 361 // Count number of empty (no HPX thread available) thread manager loop executions 362 #if !defined(HPX_IDLE_LOOP_COUNT_MAX) 363 # define HPX_IDLE_LOOP_COUNT_MAX 200000 364 #endif 365 366 /////////////////////////////////////////////////////////////////////////////// 367 // Count number of busy thread manager loop executions before forcefully 368 // cleaning up terminated thread objects 369 #if !defined(HPX_BUSY_LOOP_COUNT_MAX) 370 # define HPX_BUSY_LOOP_COUNT_MAX 2000 371 #endif 372 373 /////////////////////////////////////////////////////////////////////////////// 374 // Maximum sleep time for idle backoff in milliseconds. 375 #if defined(HPX_HAVE_THREAD_MANAGER_IDLE_BACKOFF) 376 # if !defined(HPX_IDLE_BACKOFF_TIME_MAX) 377 # define HPX_IDLE_BACKOFF_TIME_MAX 1000 378 # endif 379 #endif 380 381 /////////////////////////////////////////////////////////////////////////////// 382 #if !defined(HPX_WRAPPER_HEAP_STEP) 383 # define HPX_WRAPPER_HEAP_STEP 0xFFFFU 384 #endif 385 386 #if !defined(HPX_INITIAL_GID_RANGE) 387 # define HPX_INITIAL_GID_RANGE 0xFFFFU 388 #endif 389 390 /////////////////////////////////////////////////////////////////////////////// 391 // Enable lock verification code which allows to check whether there are locks 392 // held while HPX-threads are suspended and/or interrupted. 393 #if !defined(HPX_HAVE_VERIFY_LOCKS) 394 # if defined(HPX_DEBUG) 395 # define HPX_HAVE_VERIFY_LOCKS 396 # endif 397 #endif 398 399 #if !defined(HPX_HAVE_VERIFY_LOCKS_GLOBALLY) 400 # if defined(HPX_DEBUG) 401 # define HPX_HAVE_VERIFY_LOCKS_GLOBALLY 402 # endif 403 #endif 404 405 /////////////////////////////////////////////////////////////////////////////// 406 // This limits how deep the internal recursion of future continuations will go 407 // before a new operation is re-spawned. 408 #if !defined(HPX_CONTINUATION_MAX_RECURSION_DEPTH) 409 # if defined(__has_feature) 410 # if __has_feature(address_sanitizer) 411 // if we build under AddressSanitizer we set the max recursion depth to 1 to not 412 // run into stack overflows. 413 # define HPX_CONTINUATION_MAX_RECURSION_DEPTH 1 414 # endif 415 # endif 416 #endif 417 418 #if !defined(HPX_CONTINUATION_MAX_RECURSION_DEPTH) 419 #if defined(HPX_DEBUG) 420 #define HPX_CONTINUATION_MAX_RECURSION_DEPTH 14 421 #else 422 #define HPX_CONTINUATION_MAX_RECURSION_DEPTH 20 423 #endif 424 #endif 425 426 /////////////////////////////////////////////////////////////////////////////// 427 // Make sure we have support for more than 64 threads for Xeon Phi 428 #if defined(__MIC__) && !defined(HPX_HAVE_MORE_THAN_64_THREADS) 429 # define HPX_HAVE_MORE_THAN_64_THREADS 430 #endif 431 #if defined(__MIC__) && !defined(HPX_HAVE_MAX_CPU_COUNT) 432 # define HPX_HAVE_MAX_CPU_COUNT 256 433 #endif 434 435 /////////////////////////////////////////////////////////////////////////////// 436 #define HPX_AGAS_BOOTSTRAP_PREFIX 0U 437 438 #define HPX_AGAS_NS_MSB 0x0000000000000001ULL 439 440 #define HPX_AGAS_PRIMARY_NS_MSB 0x0000000100000001ULL 441 #define HPX_AGAS_PRIMARY_NS_LSB 0x0000000000000001ULL 442 #define HPX_AGAS_COMPONENT_NS_MSB 0x0000000100000001ULL 443 #define HPX_AGAS_COMPONENT_NS_LSB 0x0000000000000002ULL 444 #define HPX_AGAS_SYMBOL_NS_MSB 0x0000000100000001ULL 445 #define HPX_AGAS_SYMBOL_NS_LSB 0x0000000000000003ULL 446 #define HPX_AGAS_LOCALITY_NS_MSB 0x0000000100000001ULL 447 #define HPX_AGAS_LOCALITY_NS_LSB 0x0000000000000004ULL 448 449 #endif 450