Generators.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #ifndef MANDEL_GENERATORS_H
  2. #define MANDEL_GENERATORS_H
  3. #include "MandelUtil.h"
  4. #include "CalcPlugin.h"
  5. #include <vector>
  6. #include <map>
  7. #include <utility>
  8. namespace mnd
  9. {
  10. class MandelGenerator;
  11. class AdaptiveGenerator;
  12. enum class Precision : int
  13. {
  14. FLOAT,
  15. DOUBLE_FLOAT,
  16. TRIPLE_FLOAT,
  17. DOUBLE,
  18. DOUBLE_DOUBLE,
  19. TRIPLE_DOUBLE,
  20. QUAD_DOUBLE,
  21. HEX_DOUBLE,
  22. OCTA_DOUBLE,
  23. FLOAT128,
  24. FLOAT256,
  25. FLOAT512,
  26. FIXED64,
  27. FIXED128,
  28. FIXED512,
  29. INF_PREC,
  30. };
  31. enum HardwareFeature : int
  32. {
  33. NONE,
  34. X86_SSE2,
  35. X86_AVX,
  36. X86_AVX_FMA,
  37. X86_AVX_512,
  38. ARM_NEON,
  39. };
  40. std::string toString(Precision);
  41. std::string toString(HardwareFeature);
  42. Real getPrecision(Precision p);
  43. template<typename T>
  44. Real getPrecision(void);
  45. template<typename T>
  46. Precision getType(void);
  47. class MandelDevice;
  48. }
  49. class MANDEL_EXPORT mnd::MandelGenerator
  50. {
  51. protected:
  52. Real precision;
  53. Precision type;
  54. HardwareFeature extension;
  55. public:
  56. MandelGenerator(void);
  57. inline MandelGenerator(Precision type) :
  58. precision{ mnd::getPrecision(type) },
  59. type{ type },
  60. extension{ mnd::HardwareFeature::NONE }
  61. {
  62. }
  63. inline MandelGenerator(Precision type, HardwareFeature extension) :
  64. precision{ mnd::getPrecision(type) },
  65. type{ type },
  66. extension{ extension }
  67. {
  68. }
  69. inline MandelGenerator(Precision type, HardwareFeature extension, const Real& precision) :
  70. precision{ precision },
  71. type{ type },
  72. extension{ extension }
  73. {
  74. }
  75. virtual ~MandelGenerator(void) = default;
  76. MandelGenerator(const MandelGenerator&) = default;
  77. MandelGenerator& operator=(const MandelGenerator&) = default;
  78. MandelGenerator(MandelGenerator&&) = default;
  79. MandelGenerator& operator=(MandelGenerator&&) = default;
  80. virtual void generate(const MandelInfo& info, float* data) = 0;
  81. virtual mnd::MandelDevice* getDevice(void);
  82. virtual Real getPrecision(void) const;
  83. virtual Precision getType(void) const;
  84. virtual HardwareFeature getExtension(void) const;
  85. };
  86. class mnd::AdaptiveGenerator : public MandelGenerator
  87. {
  88. std::map<Real, MandelGenerator*, std::greater<Real>> generators;
  89. public:
  90. AdaptiveGenerator(void);
  91. AdaptiveGenerator(AdaptiveGenerator&) = delete;
  92. AdaptiveGenerator(AdaptiveGenerator&&) = default;
  93. AdaptiveGenerator(MandelGenerator* floatGen, MandelGenerator* doubleGen);
  94. virtual ~AdaptiveGenerator(void) = default;
  95. void addGenerator(const Real& precision, MandelGenerator& generator);
  96. void addGenerator(Precision p, MandelGenerator& generator);
  97. void addGenerator(MandelGenerator& generator);
  98. const std::map<Real, MandelGenerator*, std::greater<Real>>& getGenerators(void) const { return generators; }
  99. inline void clear(void) { generators.clear(); }
  100. virtual void generate(const MandelInfo& info, float* data) override;
  101. };
  102. #endif // MANDEL_GENERATORS_H