IterationGenerator.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. template<typename T>
  14. class NaiveIRGenerator;
  15. class CompiledGenerator;
  16. class CompiledClGenerator;
  17. class CompiledClGeneratorDouble;
  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, const mnd::Real& prec);
  29. };
  30. class mnd::NaiveGenerator : public mnd::IterationGenerator
  31. {
  32. public:
  33. NaiveGenerator(IterationFormula z0, IterationFormula zi, const mnd::Real& prec);
  34. NaiveGenerator(NaiveGenerator&&) = default;
  35. virtual void generate(const MandelInfo& info, float* data);
  36. private:
  37. std::complex<double> iterate(std::complex<double> z, std::complex<double> c);
  38. std::complex<double> calc(mnd::Expression& expr, std::complex<double> z, std::complex<double> c);
  39. };
  40. template<typename T>
  41. class mnd::NaiveIRGenerator : public mnd::MandelGenerator
  42. {
  43. const ir::Formula& form;
  44. public:
  45. NaiveIRGenerator(const ir::Formula& irf, const mnd::Real& prec);
  46. NaiveIRGenerator(NaiveIRGenerator&&) = default;
  47. virtual void generate(const MandelInfo& info, float* data);
  48. double calc(ir::Node* expr, double a, double b, double x, double y);
  49. };
  50. #if defined(__x86_64__) || defined(_M_X64)
  51. class mnd::CompiledGenerator : public mnd::MandelGenerator
  52. {
  53. std::unique_ptr<ExecData> execData;
  54. public:
  55. CompiledGenerator(std::unique_ptr<ExecData> execData);
  56. CompiledGenerator(CompiledGenerator&&);
  57. virtual ~CompiledGenerator(void);
  58. virtual void generate(const MandelInfo& info, float* data);
  59. std::string dump(void) const;
  60. };
  61. #endif
  62. #ifdef WITH_OPENCL
  63. class mnd::CompiledClGenerator : public mnd::ClGeneratorFloat
  64. {
  65. public:
  66. CompiledClGenerator(MandelDevice& device, const std::string& code);
  67. CompiledClGenerator(CompiledClGenerator&&) = default;
  68. virtual void generate(const MandelInfo& info, float* data);
  69. };
  70. class mnd::CompiledClGeneratorDouble : public mnd::ClGeneratorDouble
  71. {
  72. public:
  73. CompiledClGeneratorDouble(MandelDevice& device, const std::string& code);
  74. CompiledClGeneratorDouble(CompiledClGeneratorDouble&&) = default;
  75. virtual void generate(const MandelInfo& info, float* data);
  76. };
  77. #endif // WITH_OPENCL
  78. #endif // MANDEL_ITERATIONGENERATOR_H