ClGenerators.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef MANDEL_CLGENERATORS_H
  2. #define MANDEL_CLGENERATORS_H
  3. #ifdef WITH_OPENCL
  4. #include "Generators.h"
  5. #include "OpenClCode.h"
  6. #define CL_TARGET_OPENCL_VERSION 120
  7. #define CL_HPP_TARGET_OPENCL_VERSION 120
  8. #define CL_HPP_MINIMUM_OPENCL_VERSION 120
  9. #ifdef __APPLE__
  10. #include <OpenCL/cl.hpp>
  11. #else
  12. #include <CL/cl2.hpp>
  13. #endif
  14. namespace mnd
  15. {
  16. class MandelDevice;
  17. class ClGenerator;
  18. class ClGeneratorFloat;
  19. class ClGeneratorDoubleFloat;
  20. class ClGeneratorDouble;
  21. class ClGeneratorDoubleDouble;
  22. class ClGeneratorQuadDouble;
  23. class ClGenerator128;
  24. class ClGenerator64;
  25. }
  26. class mnd::ClGenerator : public MandelGenerator
  27. {
  28. protected:
  29. MandelDevice& device;
  30. cl::Context& context;
  31. cl::Program program;
  32. cl::CommandQueue queue;
  33. cl::Kernel kernel;
  34. public:
  35. ClGenerator(MandelDevice& device, const std::string& source, mnd::Precision type);
  36. virtual ~ClGenerator(void);
  37. virtual void generate(const MandelInfo& info, float* data) = 0;
  38. virtual mnd::MandelDevice* getDevice(void);
  39. };
  40. class mnd::ClGeneratorFloat : public ClGenerator
  41. {
  42. bool useVec;
  43. public:
  44. ClGeneratorFloat(MandelDevice& device, const std::string& code = getFloat_cl());
  45. virtual ~ClGeneratorFloat(void) = default;
  46. virtual void generate(const MandelInfo& info, float* data) override;
  47. protected:
  48. virtual std::string getKernelCode(bool smooth) const;
  49. };
  50. class mnd::ClGeneratorDoubleFloat : public ClGenerator
  51. {
  52. public:
  53. ClGeneratorDoubleFloat(MandelDevice& device);
  54. virtual ~ClGeneratorDoubleFloat(void) = default;
  55. virtual void generate(const MandelInfo& info, float* data) override;
  56. protected:
  57. virtual std::string getKernelCode(bool smooth) const;
  58. };
  59. class mnd::ClGeneratorDouble : public ClGenerator
  60. {
  61. public:
  62. ClGeneratorDouble(mnd::MandelDevice& device, const std::string& source = getDouble_cl());
  63. virtual ~ClGeneratorDouble(void) = default;
  64. virtual void generate(const MandelInfo& info, float* data) override;
  65. protected:
  66. virtual std::string getKernelCode(bool smooth) const;
  67. };
  68. class mnd::ClGeneratorDoubleDouble : public ClGenerator
  69. {
  70. bool smooth;
  71. public:
  72. ClGeneratorDoubleDouble(mnd::MandelDevice& device);
  73. virtual ~ClGeneratorDoubleDouble(void) = default;
  74. virtual void generate(const MandelInfo& info, float* data) override;
  75. protected:
  76. virtual std::string getKernelCode(bool smooth) const;
  77. };
  78. class mnd::ClGeneratorQuadDouble : public ClGenerator
  79. {
  80. bool smooth;
  81. public:
  82. ClGeneratorQuadDouble(mnd::MandelDevice& device);
  83. virtual ~ClGeneratorQuadDouble(void) = default;
  84. virtual void generate(const MandelInfo& info, float* data) override;
  85. protected:
  86. virtual std::string getKernelCode(bool smooth) const;
  87. };
  88. class mnd::ClGenerator128 : public ClGenerator
  89. {
  90. public:
  91. ClGenerator128(mnd::MandelDevice& device);
  92. virtual ~ClGenerator128(void) = default;
  93. virtual void generate(const MandelInfo& info, float* data) override;
  94. protected:
  95. virtual std::string getKernelCode(bool smooth) const;
  96. };
  97. class mnd::ClGenerator64 : public ClGenerator
  98. {
  99. public:
  100. ClGenerator64(mnd::MandelDevice& device);
  101. virtual ~ClGenerator64(void) = default;
  102. virtual void generate(const MandelInfo& info, float* data) override;
  103. protected:
  104. virtual std::string getKernelCode(bool smooth) const;
  105. };
  106. #endif // WITH_OPENCL
  107. #endif // MANDEL_CLGENERATORS_H