settings.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. 
  2. // This header collects hardcoded settings for the entire framework in one place.
  3. // Either modify this header for all your projects, or define macros using compiler flags for a specific project.
  4. #ifndef DFPSR_SETTINGS
  5. #define DFPSR_SETTINGS
  6. // If you are not using try-catch, you can let the default error handler call heap_hardExitCleaning and std::exit instead of throwing std::exception.
  7. // This may reduce some runtime overhead from stack unwinding.
  8. #ifndef __EXCEPTIONS
  9. // If compiling with -fno-exceptions, hard exit must be enabled.
  10. #define DSR_HARD_EXIT_ON_ERROR
  11. #endif
  12. // If EXTRA_SAFE_POINTER_CHECKS is defined, debug mode will let SafePointer perform thread and allocation identity checks.
  13. // Makes sure that the accessed memory has not been freed, recycled or shared with the wrong thread.
  14. // This will make memory access super slow but catch more memory errors when basic bound checks are not enough.
  15. // If EXTRA_SAFE_POINTER_CHECKS is not defined, debug mode will
  16. // Has no effect in release mode, because it is only active when SAFE_POINTER_CHECKS is also defined.
  17. //#define EXTRA_SAFE_POINTER_CHECKS
  18. // Enable this macro to disable multi-threading.
  19. // Can be used to quickly rule out concurrency problems when debugging, by recreating the same error without extra threads.
  20. //#define DISABLE_MULTI_THREADING
  21. // Identify operating systems in a somewhat future-proof way.
  22. // More will have to be added later.
  23. #if defined(_WIN32) || defined(_WIN64) || defined(_WIN128) || defined(_WIN256) || defined(_WIN512) || defined(_WIN1024) || defined(_WIN2048)
  24. #define USE_MICROSOFT_WINDOWS
  25. #elif defined(__gnu_linux__) || defined(__linux__) || defined(__linux)
  26. #define USE_LINUX
  27. #define USE_POSIX
  28. #elif defined(__APPLE__) || defined(__MACH__)
  29. #define USE_MACOS
  30. #define USE_POSIX
  31. #elif defined(__unix) || defined(__unix__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__BSD__)
  32. // Trying to cover as many systems as possible using Posix for basic command line applications.
  33. #define USE_POSIX
  34. #else
  35. #error "Could not identify the operating system!\n"
  36. #endif
  37. // Identify processor types.
  38. #if defined(__INTEL__) || defined(__SSE2__)
  39. #define USE_INTEL
  40. #elif defined(__ARM__) || defined(__ARM_NEON)
  41. #define USE_ARM
  42. #endif
  43. // Determine which SIMD extensions to use in base/simd.h.
  44. // Use the standard compiler flags for enabling SIMD extensions.
  45. // If your compiler uses a different macro name to indicate the presence of a SIMD extension, you can add them here to enable the USE_* macros.
  46. // You can compile different versions of the program for different capabilities.
  47. // SSE2 and NEON are usually enabled by default on instruction sets where they are not optional, which is good if you just want one release that is fast enough.
  48. // AVX with 256-bit float SIMD is useful for sound and physics that can be computed without integers.
  49. // AVX2 with full 256-bit SIMD is useful for 3D graphics and heavy 2D filters where memory bandwidth is not the bottleneck.
  50. #if defined(__SSE2__)
  51. #define USE_SSE2 // Comment out this line to test without SSE2
  52. #ifdef USE_SSE2
  53. #ifdef __SSSE3__
  54. #define USE_SSSE3 // Comment out this line to test without SSSE3
  55. #endif
  56. #ifdef __AVX__
  57. #define USE_AVX // Comment out this line to test without AVX
  58. #ifdef USE_AVX
  59. #ifdef __AVX2__
  60. #define USE_AVX2 // Comment out this line to test without AVX2
  61. #endif
  62. #endif
  63. #endif
  64. #endif
  65. #elif defined(__ARM_NEON)
  66. #define USE_NEON // Comment out this line to test without NEON
  67. // TODO: Check if SVE is enabled once implemented in simd.h.
  68. #endif
  69. // Enable the EMULATE_X_256BIT_SIMD macro to force use of 256-bit vectors even when there is no hardware instructions supporting it.
  70. // To get real 256-bit SIMD on an Intel processor with AVX2 hardware instructions, enable the AVX2 compiler flag for the library and your project (which is -mavx2 in GCC).
  71. //#define EMULATE_256BIT_X_SIMD
  72. // Enable the EMULATE_F_256BIT_SIMD macro to force use of 256-bit float vectors even when there is no hardware instructions supporting it.
  73. // To get real 256-bit float SIMD on an Intel processor with AVX hardware instructions, enable the AVX compiler flag for the library and your project (which is -mavx in GCC).
  74. //#define EMULATE_256BIT_F_SIMD
  75. // A platform independent summary of which features are enabled.
  76. #ifdef USE_SSE2
  77. // We have hardware support for 128-bit SIMD, which is enough to make memory bandwidth the bottleneck for light computation.
  78. #define USE_BASIC_SIMD
  79. #ifdef USE_AVX
  80. // We have hardware support for 256-bit float SIMD, so that we get a performance boost from using F32x8 or its alias F32xF instead of F32x4
  81. #define USE_256BIT_F_SIMD
  82. #ifdef USE_AVX2
  83. // We also have hardware support for the other 256-bit SIMD types, pushing the size of an X vector and default alignment to 256 bits.
  84. // F32xX will now refer to F32x8
  85. // I32xX will now refer to I32x8
  86. // U32xX will now refer to U32x8
  87. // U16xX will now refer to U16x16
  88. // U8xX will now refer to U8x32
  89. #define USE_256BIT_X_SIMD
  90. #endif
  91. #endif
  92. #endif
  93. #ifdef USE_NEON
  94. #define USE_BASIC_SIMD
  95. #endif
  96. // Enable this flag if you are compiling for big-endian.
  97. //#define DSR_BIG_ENDIAN
  98. #endif