IterationGenerator.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef MANDEL_ITERATIONGENERATOR_H
  2. #define MANDEL_ITERATIONGENERATOR_H
  3. #include "Generators.h"
  4. #include "ClGenerators.h"
  5. #include "IterationFormula.h"
  6. #include "IterationIR.h"
  7. #include <utility>
  8. #include <complex>
  9. namespace mnd
  10. {
  11. class IterationGenerator;
  12. class NaiveGenerator;
  13. class CompiledGenerator;
  14. class CompiledGeneratorVec;
  15. class CompiledClGenerator;
  16. class CompiledClGeneratorDouble;
  17. class CompiledClGeneratorDoubleDouble;
  18. class CompiledClGeneratorQuadDouble;
  19. // forward declaration
  20. struct ExecData;
  21. class MandelDevice;
  22. }
  23. class mnd::IterationGenerator : public mnd::MandelGenerator
  24. {
  25. protected:
  26. IterationFormula z0;
  27. IterationFormula zi;
  28. public:
  29. IterationGenerator(IterationFormula z0, IterationFormula zi,
  30. mnd::Precision prec,
  31. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  32. };
  33. class mnd::NaiveGenerator : public mnd::IterationGenerator
  34. {
  35. public:
  36. NaiveGenerator(IterationFormula z0, IterationFormula zi,
  37. mnd::Precision prec,
  38. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  39. virtual void generate(const MandelInfo& info, float* data);
  40. private:
  41. std::complex<double> iterate(std::complex<double> z, std::complex<double> c);
  42. std::complex<double> calc(mnd::Expression& expr, std::complex<double> z, std::complex<double> c);
  43. };
  44. #ifdef WITH_ASMJIT
  45. #if defined(__x86_64__) || defined(_M_X64)
  46. class mnd::CompiledGenerator : public mnd::MandelGenerator
  47. {
  48. protected:
  49. std::unique_ptr<ExecData> execData;
  50. public:
  51. CompiledGenerator(std::unique_ptr<ExecData> execData,
  52. mnd::Precision prec = mnd::Precision::DOUBLE,
  53. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  54. CompiledGenerator(const CompiledGenerator&) = delete;
  55. CompiledGenerator(CompiledGenerator&&);
  56. virtual ~CompiledGenerator(void);
  57. virtual void generate(const MandelInfo& info, float* data) override;
  58. std::string dump(void) const;
  59. };
  60. class mnd::CompiledGeneratorVec : public mnd::CompiledGenerator
  61. {
  62. public:
  63. CompiledGeneratorVec(std::unique_ptr<ExecData> execData);
  64. CompiledGeneratorVec(const CompiledGeneratorVec&) = delete;
  65. CompiledGeneratorVec(CompiledGeneratorVec&&);
  66. virtual ~CompiledGeneratorVec(void);
  67. virtual void generate(const MandelInfo& info, float* data) override;
  68. };
  69. #endif
  70. #endif // WITH_ASMJIT
  71. #ifdef WITH_OPENCL
  72. class mnd::CompiledClGenerator : public mnd::ClGeneratorFloat
  73. {
  74. public:
  75. CompiledClGenerator(MandelDevice& device, const std::string& code);
  76. virtual void generate(const MandelInfo& info, float* data) override;
  77. };
  78. class mnd::CompiledClGeneratorDouble : public mnd::ClGeneratorDouble
  79. {
  80. public:
  81. CompiledClGeneratorDouble(MandelDevice& device, const std::string& code);
  82. };
  83. class mnd::CompiledClGeneratorDoubleDouble : public mnd::ClGeneratorDoubleDouble
  84. {
  85. public:
  86. CompiledClGeneratorDoubleDouble(MandelDevice& device, const std::string& code);
  87. };
  88. class mnd::CompiledClGeneratorQuadDouble : public mnd::ClGeneratorQuadDouble
  89. {
  90. public:
  91. inline CompiledClGeneratorQuadDouble(MandelDevice& device, const std::string& code) :
  92. ClGeneratorQuadDouble{ device, code } {}
  93. };
  94. #endif // WITH_OPENCL
  95. #endif // MANDEL_ITERATIONGENERATOR_H