Mandel.h 2.4 KB

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