Mandel.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 : int;
  19. class MandelContext;
  20. class MandelDevice;
  21. struct ClDeviceWrapper;
  22. extern MandelContext initializeContext(void);
  23. const std::string& getGeneratorName(mnd::GeneratorType);
  24. GeneratorType getTypeFromName(const std::string& name);
  25. }
  26. enum class mnd::GeneratorType : int
  27. {
  28. FLOAT,
  29. FLOAT_SSE2,
  30. FLOAT_AVX,
  31. FLOAT_AVX_FMA,
  32. FLOAT_AVX512,
  33. FLOAT_NEON,
  34. DOUBLE_FLOAT,
  35. DOUBLE,
  36. DOUBLE_SSE2,
  37. DOUBLE_AVX,
  38. DOUBLE_AVX_FMA,
  39. DOUBLE_AVX512,
  40. DOUBLE_NEON,
  41. DOUBLE_DOUBLE,
  42. DOUBLE_DOUBLE_AVX,
  43. DOUBLE_DOUBLE_AVX_FMA,
  44. QUAD_DOUBLE,
  45. FLOAT128,
  46. FLOAT256,
  47. FIXED64,
  48. FIXED128,
  49. FIXED512
  50. };
  51. class mnd::MandelDevice
  52. {
  53. private:
  54. friend class MandelContext;
  55. std::string vendor;
  56. std::string name;
  57. std::unique_ptr<ClDeviceWrapper> clDevice;
  58. std::map<GeneratorType, std::unique_ptr<MandelGenerator>> mandelGenerators;
  59. MandelDevice(ClDeviceWrapper);
  60. public:
  61. MandelDevice(const MandelDevice&) = delete;
  62. MandelDevice(MandelDevice&&) = default;
  63. MandelDevice& operator=(const MandelDevice&) = delete;
  64. MandelDevice& operator=(MandelDevice&&) = default;
  65. inline const std::string& getVendor(void) const { return vendor; }
  66. inline const std::string& getName(void) const { return name; }
  67. MandelGenerator* getGenerator(GeneratorType type) const;
  68. inline ClDeviceWrapper& getClDevice(void) { return *clDevice; }
  69. inline const ClDeviceWrapper& getClDevice(void) const { return *clDevice; }
  70. std::vector<GeneratorType> getSupportedTypes(void) const;
  71. };
  72. class mnd::MandelContext
  73. {
  74. private:
  75. friend MandelContext mnd::initializeContext(void);
  76. CpuInfo cpuInfo;
  77. std::unique_ptr<asmjit::JitRuntime> jitRuntime;
  78. std::map<GeneratorType, std::unique_ptr<MandelGenerator>> cpuGenerators;
  79. std::unique_ptr<AdaptiveGenerator> adaptiveGenerator;
  80. std::unique_ptr<JuliaGenerator> juliaGenerator;
  81. std::vector<MandelDevice> devices;
  82. MandelContext(void);
  83. std::unique_ptr<AdaptiveGenerator> createAdaptiveGenerator(void);
  84. std::vector<MandelDevice> createDevices(void);
  85. public:
  86. ~MandelContext(void);
  87. MandelContext(const MandelContext&) = delete;
  88. MandelContext(MandelContext&&) = default;
  89. MandelContext& operator=(const MandelContext&) = delete;
  90. MandelContext& operator=(MandelContext&&) = default;
  91. AdaptiveGenerator& getDefaultGenerator(void);
  92. const std::vector<MandelDevice>& getDevices(void);
  93. asmjit::JitRuntime& getJitRuntime(void);
  94. MandelGenerator* getCpuGenerator(mnd::GeneratorType type);
  95. std::vector<GeneratorType> getSupportedTypes(void) const;
  96. const CpuInfo& getCpuInfo(void) const { return cpuInfo; }
  97. JuliaGenerator& getJuliaGenerator(void);
  98. };
  99. #endif // MANDEL_MANDEL_H