Mandel.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_AVX512,
  27. FLOAT_NEON,
  28. DOUBLE,
  29. DOUBLE_SSE2,
  30. DOUBLE_AVX,
  31. DOUBLE_AVX512,
  32. DOUBLE_NEON,
  33. DOUBLE_DOUBLE,
  34. DOUBLE_DOUBLE_AVX,
  35. DOUBLE_DOUBLE_AVX_FMA,
  36. QUAD_DOUBLE,
  37. FLOAT128,
  38. FLOAT256,
  39. FIXED512
  40. };
  41. class mnd::MandelDevice
  42. {
  43. private:
  44. friend class MandelContext;
  45. std::string vendor;
  46. std::string name;
  47. std::map<GeneratorType, std::unique_ptr<Generator>> generators;
  48. MandelDevice(void);
  49. public:
  50. MandelDevice(const MandelDevice&) = delete;
  51. MandelDevice(MandelDevice&&) = default;
  52. MandelDevice& operator=(const MandelDevice&) = delete;
  53. MandelDevice& operator=(MandelDevice&&) = default;
  54. inline const std::string& getVendor(void) const { return vendor; }
  55. inline const std::string& getName(void) const { return name; }
  56. Generator* getGenerator(GeneratorType type) const;
  57. std::vector<GeneratorType> getSupportedTypes(void) const;
  58. };
  59. class mnd::MandelContext
  60. {
  61. private:
  62. friend MandelContext mnd::initializeContext(void);
  63. CpuInfo cpuInfo;
  64. std::map<GeneratorType, std::unique_ptr<Generator>> cpuGenerators;
  65. std::unique_ptr<AdaptiveGenerator> adaptiveGenerator;
  66. std::vector<MandelDevice> devices;
  67. MandelContext(void);
  68. std::unique_ptr<AdaptiveGenerator> createAdaptiveGenerator(void);
  69. std::vector<MandelDevice> createDevices(void);
  70. public:
  71. MandelContext(const MandelContext&) = delete;
  72. MandelContext(MandelContext&&) = default;
  73. MandelContext& operator=(const MandelContext&) = delete;
  74. MandelContext& operator=(MandelContext&&) = default;
  75. AdaptiveGenerator& getDefaultGenerator(void);
  76. const std::vector<MandelDevice>& getDevices(void);
  77. Generator* getCpuGenerator(mnd::GeneratorType type);
  78. std::vector<GeneratorType> getSupportedTypes(void) const;
  79. const CpuInfo& getCpuInfo(void) const { return cpuInfo; }
  80. };
  81. #endif // MANDEL_MANDEL_H