Mandel.h 2.8 KB

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