Mandel.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef WITH_ASMJIT
  7. // if no asmjit, use dummy implementation
  8. namespace asmjit { class JitRuntime{}; }
  9. #endif // WITH_ASMJITH
  10. #include <vector>
  11. #include <map>
  12. #include <string>
  13. #include <memory>
  14. #include "MandelUtil.h"
  15. #include "Generators.h"
  16. #include "IterationGenerator.h"
  17. #include "CpuGenerators.h"
  18. #include "Hardware.h"
  19. //#include "Fixedp.h"
  20. namespace mnd
  21. {
  22. class MandelContext;
  23. class MandelDevice;
  24. struct ClDeviceWrapper;
  25. extern MandelContext initializeContext(void);
  26. const std::string& getGeneratorName(mnd::GeneratorType);
  27. GeneratorType getTypeFromName(const std::string& name);
  28. }
  29. class mnd::MandelDevice
  30. {
  31. private:
  32. friend class MandelContext;
  33. std::string vendor;
  34. std::string name;
  35. std::string extensions;
  36. std::unique_ptr<ClDeviceWrapper> clDevice;
  37. std::map<GeneratorType, std::unique_ptr<MandelGenerator>> mandelGenerators;
  38. public:
  39. MandelDevice(ClDeviceWrapper);
  40. MandelDevice(const MandelDevice&) = delete;
  41. MandelDevice(MandelDevice&&) = default;
  42. MandelDevice& operator=(const MandelDevice&) = delete;
  43. MandelDevice& operator=(MandelDevice&&) = default;
  44. inline const std::string& getVendor(void) const { return vendor; }
  45. inline const std::string& getName(void) const { return name; }
  46. MandelGenerator* getGenerator(GeneratorType type) const;
  47. inline ClDeviceWrapper& getClDevice(void) { return *clDevice; }
  48. inline const ClDeviceWrapper& getClDevice(void) const { return *clDevice; }
  49. std::vector<GeneratorType> getSupportedTypes(void) const;
  50. bool supportsDouble(void) const;
  51. };
  52. class mnd::MandelContext
  53. {
  54. private:
  55. friend MandelContext mnd::initializeContext(void);
  56. CpuInfo cpuInfo;
  57. std::unique_ptr<asmjit::JitRuntime> jitRuntime;
  58. std::map<GeneratorType, std::unique_ptr<MandelGenerator>> cpuGenerators;
  59. std::unique_ptr<AdaptiveGenerator> adaptiveGenerator;
  60. std::vector<std::unique_ptr<mnd::MandelDevice>> devices;
  61. MandelContext(void);
  62. std::unique_ptr<AdaptiveGenerator> createAdaptiveGenerator(void);
  63. std::vector<std::unique_ptr<mnd::MandelDevice>> createDevices(void);
  64. public:
  65. ~MandelContext(void);
  66. MandelContext(const MandelContext&) = delete;
  67. MandelContext(MandelContext&&) = default;
  68. MandelContext& operator=(const MandelContext&) = delete;
  69. MandelContext& operator=(MandelContext&&) = default;
  70. AdaptiveGenerator& getDefaultGenerator(void);
  71. std::vector<std::unique_ptr<mnd::MandelDevice>>& getDevices(void);
  72. asmjit::JitRuntime& getJitRuntime(void);
  73. MandelGenerator* getCpuGenerator(mnd::GeneratorType type);
  74. std::vector<GeneratorType> getSupportedTypes(void) const;
  75. const CpuInfo& getCpuInfo(void) const { return cpuInfo; }
  76. };
  77. #endif // MANDEL_MANDEL_H