IterationGenerator.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. // forward declaration
  19. struct ExecData;
  20. class MandelDevice;
  21. }
  22. class mnd::IterationGenerator : public mnd::MandelGenerator
  23. {
  24. protected:
  25. IterationFormula z0;
  26. IterationFormula zi;
  27. public:
  28. IterationGenerator(IterationFormula z0, IterationFormula zi,
  29. mnd::Precision prec,
  30. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  31. };
  32. class mnd::NaiveGenerator : public mnd::IterationGenerator
  33. {
  34. public:
  35. NaiveGenerator(IterationFormula z0, IterationFormula zi,
  36. mnd::Precision prec,
  37. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  38. virtual void generate(const MandelInfo& info, float* data);
  39. private:
  40. std::complex<double> iterate(std::complex<double> z, std::complex<double> c);
  41. std::complex<double> calc(mnd::Expression& expr, std::complex<double> z, std::complex<double> c);
  42. };
  43. #ifdef WITH_ASMJIT
  44. #if defined(__x86_64__) || defined(_M_X64)
  45. class mnd::CompiledGenerator : public mnd::MandelGenerator
  46. {
  47. protected:
  48. std::unique_ptr<ExecData> execData;
  49. public:
  50. CompiledGenerator(std::unique_ptr<ExecData> execData,
  51. mnd::Precision prec = mnd::Precision::DOUBLE,
  52. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  53. CompiledGenerator(const CompiledGenerator&) = delete;
  54. CompiledGenerator(CompiledGenerator&&);
  55. virtual ~CompiledGenerator(void);
  56. virtual void generate(const MandelInfo& info, float* data) override;
  57. std::string dump(void) const;
  58. };
  59. class mnd::CompiledGeneratorVec : public mnd::CompiledGenerator
  60. {
  61. public:
  62. CompiledGeneratorVec(std::unique_ptr<ExecData> execData);
  63. CompiledGeneratorVec(const CompiledGeneratorVec&) = delete;
  64. CompiledGeneratorVec(CompiledGeneratorVec&&);
  65. virtual ~CompiledGeneratorVec(void);
  66. virtual void generate(const MandelInfo& info, float* data) override;
  67. };
  68. #endif
  69. #endif // WITH_ASMJIT
  70. #ifdef WITH_OPENCL
  71. class mnd::CompiledClGenerator : public mnd::ClGeneratorFloat
  72. {
  73. public:
  74. CompiledClGenerator(MandelDevice& device, const std::string& code);
  75. virtual void generate(const MandelInfo& info, float* data) override;
  76. };
  77. class mnd::CompiledClGeneratorDouble : public mnd::ClGeneratorDouble
  78. {
  79. public:
  80. CompiledClGeneratorDouble(MandelDevice& device, const std::string& code);
  81. };
  82. class mnd::CompiledClGeneratorDoubleDouble : public mnd::ClGeneratorDoubleDouble
  83. {
  84. public:
  85. CompiledClGeneratorDoubleDouble(MandelDevice& device, const std::string& code);
  86. };
  87. #endif // WITH_OPENCL
  88. #endif // MANDEL_ITERATIONGENERATOR_H