Mandel.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef MANDEL_MANDEL_H
  2. #define MANDEL_MANDEL_H
  3. // don't expose this library interface as it clashes with qt
  4. //#include <asmjit/asmjit.h>
  5. namespace asmjit { class JitRuntime; }
  6. #include <vector>
  7. #include <map>
  8. #include <string>
  9. #include <memory>
  10. #include "MandelUtil.h"
  11. #include "Generators.h"
  12. #include "IterationGenerator.h"
  13. #include "CpuGenerators.h"
  14. #include "Hardware.h"
  15. //#include "Fixedp.h"
  16. namespace mnd
  17. {
  18. enum class GeneratorType;
  19. class MandelContext;
  20. class MandelDevice;
  21. extern MandelContext initializeContext(void);
  22. const std::string& getGeneratorName(mnd::GeneratorType);
  23. GeneratorType getTypeFromName(const std::string& name);
  24. }
  25. enum class mnd::GeneratorType
  26. {
  27. FLOAT,
  28. FLOAT_SSE2,
  29. FLOAT_AVX,
  30. FLOAT_AVX_FMA,
  31. FLOAT_AVX512,
  32. FLOAT_NEON,
  33. DOUBLE_FLOAT,
  34. DOUBLE,
  35. DOUBLE_SSE2,
  36. DOUBLE_AVX,
  37. DOUBLE_AVX_FMA,
  38. DOUBLE_AVX512,
  39. DOUBLE_NEON,
  40. DOUBLE_DOUBLE,
  41. DOUBLE_DOUBLE_AVX,
  42. DOUBLE_DOUBLE_AVX_FMA,
  43. QUAD_DOUBLE,
  44. FLOAT128,
  45. FLOAT256,
  46. FIXED64,
  47. FIXED128,
  48. FIXED512
  49. };
  50. class mnd::MandelDevice
  51. {
  52. private:
  53. friend class MandelContext;
  54. std::string vendor;
  55. std::string name;
  56. std::map<GeneratorType, std::unique_ptr<MandelGenerator>> mandelGenerators;
  57. MandelDevice(void);
  58. public:
  59. MandelDevice(const MandelDevice&) = delete;
  60. MandelDevice(MandelDevice&&) = default;
  61. MandelDevice& operator=(const MandelDevice&) = delete;
  62. MandelDevice& operator=(MandelDevice&&) = default;
  63. inline const std::string& getVendor(void) const { return vendor; }
  64. inline const std::string& getName(void) const { return name; }
  65. MandelGenerator* getGenerator(GeneratorType type) const;
  66. std::vector<GeneratorType> getSupportedTypes(void) const;
  67. };
  68. class mnd::MandelContext
  69. {
  70. private:
  71. friend MandelContext mnd::initializeContext(void);
  72. CpuInfo cpuInfo;
  73. std::unique_ptr<asmjit::JitRuntime> jitRuntime;
  74. std::map<GeneratorType, std::unique_ptr<MandelGenerator>> cpuGenerators;
  75. std::unique_ptr<AdaptiveGenerator> adaptiveGenerator;
  76. std::unique_ptr<JuliaGenerator> juliaGenerator;
  77. std::vector<MandelDevice> devices;
  78. MandelContext(void);
  79. std::unique_ptr<AdaptiveGenerator> createAdaptiveGenerator(void);
  80. std::vector<MandelDevice> createDevices(void);
  81. public:
  82. ~MandelContext(void);
  83. MandelContext(const MandelContext&) = delete;
  84. MandelContext(MandelContext&&) = default;
  85. MandelContext& operator=(const MandelContext&) = delete;
  86. MandelContext& operator=(MandelContext&&) = default;
  87. AdaptiveGenerator& getDefaultGenerator(void);
  88. const std::vector<MandelDevice>& getDevices(void);
  89. asmjit::JitRuntime& getJitRuntime(void);
  90. MandelGenerator* getCpuGenerator(mnd::GeneratorType type);
  91. std::vector<GeneratorType> getSupportedTypes(void) const;
  92. const CpuInfo& getCpuInfo(void) const { return cpuInfo; }
  93. JuliaGenerator& getJuliaGenerator(void);
  94. };
  95. #endif // MANDEL_MANDEL_H