1
0

ClGenerators.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 ClGeneratorTripleDouble;
  23. class ClGeneratorQuadDouble;
  24. class ClGenerator128;
  25. class ClGenerator64;
  26. }
  27. class mnd::ClGenerator : public MandelGenerator
  28. {
  29. protected:
  30. MandelDevice& device;
  31. cl::Context& context;
  32. cl::Program program;
  33. cl::CommandQueue queue;
  34. cl::Kernel kernel;
  35. public:
  36. ClGenerator(MandelDevice& device, const std::string& source, mnd::Precision type);
  37. virtual ~ClGenerator(void);
  38. virtual void generate(const MandelInfo& info, float* data) = 0;
  39. virtual mnd::MandelDevice* getDevice(void);
  40. };
  41. class mnd::ClGeneratorFloat : public ClGenerator
  42. {
  43. bool useVec;
  44. public:
  45. ClGeneratorFloat(MandelDevice& device, const std::string& code = getFloat_cl());
  46. virtual ~ClGeneratorFloat(void) = default;
  47. virtual void generate(const MandelInfo& info, float* data) override;
  48. protected:
  49. virtual std::string getKernelCode(bool smooth) const;
  50. };
  51. class mnd::ClGeneratorDoubleFloat : public ClGenerator
  52. {
  53. public:
  54. ClGeneratorDoubleFloat(MandelDevice& device);
  55. virtual ~ClGeneratorDoubleFloat(void) = default;
  56. virtual void generate(const MandelInfo& info, float* data) override;
  57. protected:
  58. virtual std::string getKernelCode(bool smooth) const;
  59. };
  60. class mnd::ClGeneratorDouble : public ClGenerator
  61. {
  62. public:
  63. ClGeneratorDouble(mnd::MandelDevice& device, const std::string& source = getDouble_cl());
  64. virtual ~ClGeneratorDouble(void) = default;
  65. virtual void generate(const MandelInfo& info, float* data) override;
  66. protected:
  67. virtual std::string getKernelCode(bool smooth) const;
  68. };
  69. class mnd::ClGeneratorDoubleDouble : public ClGenerator
  70. {
  71. bool smooth;
  72. public:
  73. ClGeneratorDoubleDouble(mnd::MandelDevice& device);
  74. virtual ~ClGeneratorDoubleDouble(void) = default;
  75. virtual void generate(const MandelInfo& info, float* data) override;
  76. protected:
  77. virtual std::string getKernelCode(bool smooth) const;
  78. };
  79. class mnd::ClGeneratorTripleDouble : public ClGenerator
  80. {
  81. bool smooth;
  82. public:
  83. ClGeneratorTripleDouble(mnd::MandelDevice& device);
  84. virtual ~ClGeneratorTripleDouble(void) = default;
  85. virtual void generate(const MandelInfo& info, float* data) override;
  86. protected:
  87. virtual std::string getKernelCode(bool smooth) const;
  88. };
  89. class mnd::ClGeneratorQuadDouble : public ClGenerator
  90. {
  91. bool smooth;
  92. public:
  93. ClGeneratorQuadDouble(mnd::MandelDevice& device);
  94. virtual ~ClGeneratorQuadDouble(void) = default;
  95. virtual void generate(const MandelInfo& info, float* data) override;
  96. protected:
  97. virtual std::string getKernelCode(bool smooth) const;
  98. };
  99. class mnd::ClGenerator128 : public ClGenerator
  100. {
  101. public:
  102. ClGenerator128(mnd::MandelDevice& device);
  103. virtual ~ClGenerator128(void) = default;
  104. virtual void generate(const MandelInfo& info, float* data) override;
  105. protected:
  106. virtual std::string getKernelCode(bool smooth) const;
  107. };
  108. class mnd::ClGenerator64 : public ClGenerator
  109. {
  110. public:
  111. ClGenerator64(mnd::MandelDevice& device);
  112. virtual ~ClGenerator64(void) = default;
  113. virtual void generate(const MandelInfo& info, float* data) override;
  114. protected:
  115. virtual std::string getKernelCode(bool smooth) const;
  116. };
  117. #endif // WITH_OPENCL
  118. #endif // MANDEL_CLGENERATORS_H