IterationGenerator.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. // 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,
  28. mnd::Precision prec,
  29. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  30. };
  31. class mnd::NaiveGenerator : public mnd::IterationGenerator
  32. {
  33. public:
  34. NaiveGenerator(IterationFormula z0, IterationFormula zi,
  35. mnd::Precision prec,
  36. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  37. NaiveGenerator(NaiveGenerator&&) = default;
  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. CompiledClGenerator(CompiledClGenerator&&) = default;
  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. CompiledClGeneratorDouble(CompiledClGeneratorDouble&&) = default;
  83. };
  84. #endif // WITH_OPENCL
  85. #endif // MANDEL_ITERATIONGENERATOR_H