IterationGenerator.h 2.5 KB

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