IterationGenerator.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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,
  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. NaiveGenerator(NaiveGenerator&&) = default;
  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. template<typename T>
  45. class mnd::NaiveIRGenerator : public mnd::MandelGenerator
  46. {
  47. const ir::Formula& form;
  48. public:
  49. NaiveIRGenerator(const ir::Formula& irf, mnd::Precision prec);
  50. NaiveIRGenerator(NaiveIRGenerator&&) = default;
  51. virtual void generate(const MandelInfo& info, float* data);
  52. double calc(ir::Node* expr, double a, double b, double x, double y);
  53. };
  54. #if defined(__x86_64__) || defined(_M_X64)
  55. class mnd::CompiledGenerator : public mnd::MandelGenerator
  56. {
  57. std::unique_ptr<ExecData> execData;
  58. public:
  59. CompiledGenerator(std::unique_ptr<ExecData> execData);
  60. CompiledGenerator(CompiledGenerator&&);
  61. virtual ~CompiledGenerator(void);
  62. virtual void generate(const MandelInfo& info, float* data);
  63. std::string dump(void) const;
  64. };
  65. #endif
  66. #ifdef WITH_OPENCL
  67. class mnd::CompiledClGenerator : public mnd::ClGeneratorFloat
  68. {
  69. public:
  70. CompiledClGenerator(MandelDevice& device, const std::string& code);
  71. CompiledClGenerator(CompiledClGenerator&&) = default;
  72. virtual void generate(const MandelInfo& info, float* data) override;
  73. };
  74. class mnd::CompiledClGeneratorDouble : public mnd::ClGeneratorDouble
  75. {
  76. public:
  77. CompiledClGeneratorDouble(MandelDevice& device, const std::string& code);
  78. CompiledClGeneratorDouble(CompiledClGeneratorDouble&&) = default;
  79. };
  80. #endif // WITH_OPENCL
  81. #endif // MANDEL_ITERATIONGENERATOR_H