Mandel.h 2.5 KB

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