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. 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. virtual void generate(const MandelInfo& info, float* data);
  38. private:
  39. std::complex<double> iterate(std::complex<double> z, std::complex<double> c);
  40. std::complex<double> calc(mnd::Expression& expr, std::complex<double> z, std::complex<double> c);
  41. };
  42. #ifdef WITH_ASMJIT
  43. #if defined(__x86_64__) || defined(_M_X64)
  44. class mnd::CompiledGenerator : public mnd::MandelGenerator
  45. {
  46. protected:
  47. std::unique_ptr<ExecData> execData;
  48. public:
  49. CompiledGenerator(std::unique_ptr<ExecData> execData,
  50. mnd::Precision prec = mnd::Precision::DOUBLE,
  51. mnd::CpuExtension ex = mnd::CpuExtension::NONE);
  52. CompiledGenerator(const CompiledGenerator&) = delete;
  53. CompiledGenerator(CompiledGenerator&&);
  54. virtual ~CompiledGenerator(void);
  55. virtual void generate(const MandelInfo& info, float* data) override;
  56. std::string dump(void) const;
  57. };
  58. class mnd::CompiledGeneratorVec : public mnd::CompiledGenerator
  59. {
  60. public:
  61. CompiledGeneratorVec(std::unique_ptr<ExecData> execData);
  62. CompiledGeneratorVec(const CompiledGeneratorVec&) = delete;
  63. CompiledGeneratorVec(CompiledGeneratorVec&&);
  64. virtual ~CompiledGeneratorVec(void);
  65. virtual void generate(const MandelInfo& info, float* data) override;
  66. };
  67. #endif
  68. #endif // WITH_ASMJIT
  69. #ifdef WITH_OPENCL
  70. class mnd::CompiledClGenerator : public mnd::ClGeneratorFloat
  71. {
  72. public:
  73. CompiledClGenerator(MandelDevice& device, const std::string& code);
  74. virtual void generate(const MandelInfo& info, float* data) override;
  75. };
  76. class mnd::CompiledClGeneratorDouble : public mnd::ClGeneratorDouble
  77. {
  78. public:
  79. CompiledClGeneratorDouble(MandelDevice& device, const std::string& code);
  80. };
  81. #endif // WITH_OPENCL
  82. #endif // MANDEL_ITERATIONGENERATOR_H