Mandel.h 2.3 KB

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