state.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "default.h"
  5. namespace embree
  6. {
  7. /* mutex to make printing to cout thread safe */
  8. extern MutexSys g_printMutex;
  9. struct State : public RefCount
  10. {
  11. public:
  12. /*! state construction */
  13. State ();
  14. /*! state destruction */
  15. ~State();
  16. /*! verifies that state is correct */
  17. void verify();
  18. /*! parses state from a configuration file */
  19. bool parseFile(const FileName& fileName);
  20. /*! parses the state from a string */
  21. void parseString(const char* cfg);
  22. /*! parses the state from a stream */
  23. void parse(Ref<TokenStream> cin);
  24. /*! prints the state */
  25. void print();
  26. /*! checks if verbosity level is at least N */
  27. bool verbosity(size_t N);
  28. /*! checks if some particular ISA is enabled */
  29. bool hasISA(const int isa);
  30. /*! check whether selected ISA is supported by the HW */
  31. bool checkISASupport();
  32. public:
  33. std::string tri_accel; //!< acceleration structure to use for triangles
  34. std::string tri_builder; //!< builder to use for triangles
  35. std::string tri_traverser; //!< traverser to use for triangles
  36. public:
  37. std::string tri_accel_mb; //!< acceleration structure to use for motion blur triangles
  38. std::string tri_builder_mb; //!< builder to use for motion blur triangles
  39. std::string tri_traverser_mb; //!< traverser to use for triangles
  40. public:
  41. std::string quad_accel; //!< acceleration structure to use for quads
  42. std::string quad_builder; //!< builder to use for quads
  43. std::string quad_traverser; //!< traverser to use for quads
  44. public:
  45. std::string quad_accel_mb; //!< acceleration structure to use for motion blur quads
  46. std::string quad_builder_mb; //!< builder to use for motion blur quads
  47. std::string quad_traverser_mb; //!< traverser to use for motion blur quads
  48. public:
  49. std::string line_accel; //!< acceleration structure to use for line segments
  50. std::string line_builder; //!< builder to use for line segments
  51. std::string line_traverser; //!< traverser to use for line segments
  52. public:
  53. std::string line_accel_mb; //!< acceleration structure to use for motion blur line segments
  54. std::string line_builder_mb; //!< builder to use for motion blur line segments
  55. std::string line_traverser_mb; //!< traverser to use for motion blur line segments
  56. public:
  57. std::string hair_accel; //!< hair acceleration structure to use
  58. std::string hair_builder; //!< builder to use for hair
  59. std::string hair_traverser; //!< traverser to use for hair
  60. public:
  61. std::string hair_accel_mb; //!< acceleration structure to use for motion blur hair
  62. std::string hair_builder_mb; //!< builder to use for motion blur hair
  63. std::string hair_traverser_mb; //!< traverser to use for motion blur hair
  64. public:
  65. std::string object_accel; //!< acceleration structure for user geometries
  66. std::string object_builder; //!< builder for user geometries
  67. int object_accel_min_leaf_size; //!< minimum leaf size for object acceleration structure
  68. int object_accel_max_leaf_size; //!< maximum leaf size for object acceleration structure
  69. public:
  70. std::string object_accel_mb; //!< acceleration structure for user geometries
  71. std::string object_builder_mb; //!< builder for user geometries
  72. int object_accel_mb_min_leaf_size; //!< minimum leaf size for mblur object acceleration structure
  73. int object_accel_mb_max_leaf_size; //!< maximum leaf size for mblur object acceleration structure
  74. public:
  75. std::string subdiv_accel; //!< acceleration structure to use for subdivision surfaces
  76. std::string subdiv_accel_mb; //!< acceleration structure to use for subdivision surfaces
  77. public:
  78. std::string grid_accel; //!< acceleration structure to use for grids
  79. std::string grid_builder; //!< builder for grids
  80. std::string grid_accel_mb; //!< acceleration structure to use for motion blur grids
  81. std::string grid_builder_mb; //!< builder for motion blur grids
  82. public:
  83. float max_spatial_split_replications; //!< maximally replications*N many primitives in accel for spatial splits
  84. bool useSpatialPreSplits; //!< use spatial pre-splits instead of the full spatial split builder
  85. size_t tessellation_cache_size; //!< size of the shared tessellation cache
  86. public:
  87. size_t instancing_open_min; //!< instancing opens tree to minimally that number of subtrees
  88. size_t instancing_block_size; //!< instancing opens tree up to average block size of primitives
  89. float instancing_open_factor; //!< instancing opens tree up to x times the number of instances
  90. size_t instancing_open_max_depth; //!< maximum open depth for geometries
  91. size_t instancing_open_max; //!< instancing opens tree to maximally that number of subtrees
  92. public:
  93. bool float_exceptions; //!< enable floating point exceptions
  94. int quality_flags;
  95. int scene_flags;
  96. size_t verbose; //!< verbosity of output
  97. size_t benchmark; //!< true
  98. public:
  99. size_t numThreads; //!< number of threads to use in builders
  100. size_t numUserThreads; //!< number of user provided threads to use in builders
  101. bool set_affinity; //!< sets affinity for worker threads
  102. bool start_threads; //!< true when threads should be started at device creation time
  103. int enabled_cpu_features; //!< CPU ISA features to use
  104. int enabled_builder_cpu_features; //!< CPU ISA features to use for builders only
  105. enum FREQUENCY_LEVEL {
  106. FREQUENCY_SIMD128,
  107. FREQUENCY_SIMD256,
  108. FREQUENCY_SIMD512
  109. } frequency_level; //!< frequency level the app wants to run on (default is SIMD256)
  110. bool enable_selockmemoryprivilege; //!< configures the SeLockMemoryPrivilege under Windows to enable huge pages
  111. bool hugepages; //!< true if huge pages should get used
  112. bool hugepages_success; //!< status for enabling huge pages
  113. public:
  114. size_t alloc_main_block_size; //!< main allocation block size (shared between threads)
  115. int alloc_num_main_slots; //!< number of such shared blocks to be used to allocate
  116. size_t alloc_thread_block_size; //!< size of thread local allocator block size
  117. int alloc_single_thread_alloc; //!< in single mode nodes and leaves use same thread local allocator
  118. public:
  119. /*! checks if we can use AVX */
  120. bool canUseAVX() {
  121. return hasISA(AVX) && frequency_level != FREQUENCY_SIMD128;
  122. }
  123. /*! checks if we can use AVX2 */
  124. bool canUseAVX2() {
  125. return hasISA(AVX2) && frequency_level != FREQUENCY_SIMD128;
  126. }
  127. struct ErrorHandler
  128. {
  129. public:
  130. ErrorHandler();
  131. ~ErrorHandler();
  132. RTCError* error();
  133. public:
  134. tls_t thread_error;
  135. std::vector<RTCError*> thread_errors;
  136. MutexSys errors_mutex;
  137. };
  138. ErrorHandler errorHandler;
  139. static ErrorHandler g_errorHandler;
  140. public:
  141. void setErrorFunction(RTCErrorFunction fptr, void* uptr)
  142. {
  143. error_function = fptr;
  144. error_function_userptr = uptr;
  145. }
  146. RTCErrorFunction error_function;
  147. void* error_function_userptr;
  148. public:
  149. void setMemoryMonitorFunction(RTCMemoryMonitorFunction fptr, void* uptr)
  150. {
  151. memory_monitor_function = fptr;
  152. memory_monitor_userptr = uptr;
  153. }
  154. RTCMemoryMonitorFunction memory_monitor_function;
  155. void* memory_monitor_userptr;
  156. };
  157. }