driver-opencl.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef BFG_DRIVER_OPENCL
  2. #define BFG_DRIVER_OPENCL
  3. #include <stdbool.h>
  4. #include "CL/cl.h"
  5. #ifdef HAVE_SENSORS
  6. #include <sensors/sensors.h>
  7. #endif
  8. #include "miner.h"
  9. enum opencl_binary_usage {
  10. OBU_DEFAULT = 0,
  11. OBU_LOAD = 1,
  12. OBU_SAVE = 2,
  13. OBU_LOADSAVE = 3,
  14. OBU_NONE = 4,
  15. };
  16. struct opencl_device_data {
  17. bool mapped;
  18. int virtual_gpu;
  19. int virtual_adl;
  20. unsigned long oclthreads;
  21. char *_init_intensity;
  22. bool dynamic;
  23. cl_uint vwidth;
  24. size_t work_size;
  25. char *kernel_file;
  26. cl_ulong max_alloc;
  27. enum opencl_binary_usage opt_opencl_binaries;
  28. #ifdef USE_SCRYPT
  29. int opt_lg, lookup_gap;
  30. size_t opt_tc, thread_concurrency;
  31. size_t shaders;
  32. #endif
  33. struct timeval tv_gpustart;
  34. int intervals;
  35. #ifdef HAVE_ADL
  36. bool has_adl;
  37. struct gpu_adl adl;
  38. int gpu_engine;
  39. int min_engine;
  40. int gpu_fan;
  41. int min_fan;
  42. int gpu_memclock;
  43. int gpu_memdiff;
  44. int gpu_powertune;
  45. float gpu_vddc;
  46. #endif
  47. #ifdef HAVE_SENSORS
  48. const sensors_chip_name *sensor;
  49. #endif
  50. };
  51. extern double oclthreads_to_intensity(unsigned long oclthreads, bool is_sha256d);
  52. extern unsigned long intensity_to_oclthreads(double intensity, bool is_sha256d);
  53. extern unsigned long xintensity_to_oclthreads(double xintensity, cl_uint max_compute_units);
  54. extern bool opencl_set_intensity_from_str(struct cgpu_info *, const char *newvalue);
  55. struct opencl_work_data {
  56. cl_uint ctx_a; cl_uint ctx_b; cl_uint ctx_c; cl_uint ctx_d;
  57. cl_uint ctx_e; cl_uint ctx_f; cl_uint ctx_g; cl_uint ctx_h;
  58. cl_uint cty_a; cl_uint cty_b; cl_uint cty_c; cl_uint cty_d;
  59. cl_uint cty_e; cl_uint cty_f; cl_uint cty_g; cl_uint cty_h;
  60. cl_uint merkle; cl_uint ntime; cl_uint nbits;
  61. cl_uint fW0; cl_uint fW1; cl_uint fW2; cl_uint fW3; cl_uint fW15;
  62. cl_uint fW01r; cl_uint fcty_e; cl_uint fcty_e2;
  63. cl_uint W16; cl_uint W17; cl_uint W2;
  64. cl_uint PreVal4; cl_uint T1;
  65. cl_uint C1addK5; cl_uint D1A; cl_uint W2A; cl_uint W17_2;
  66. cl_uint PreVal4addT1; cl_uint T1substate0;
  67. cl_uint PreVal4_2;
  68. cl_uint PreVal0;
  69. cl_uint PreW18;
  70. cl_uint PreW19;
  71. cl_uint PreW31;
  72. cl_uint PreW32;
  73. /* For diakgcn */
  74. cl_uint B1addK6, PreVal0addK7, W16addK16, W17addK17;
  75. cl_uint zeroA, zeroB;
  76. cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
  77. #ifdef USE_SCRYPT
  78. struct work *work;
  79. #endif
  80. };
  81. extern void opencl_early_init();
  82. extern char *print_ndevs_and_exit(int *ndevs);
  83. extern void *reinit_gpu(void *userdata);
  84. extern char *set_gpu_map(char *arg);
  85. extern const char *set_gpu_engine(char *arg);
  86. extern const char *set_gpu_fan(char *arg);
  87. extern const char *set_gpu_memclock(char *arg);
  88. extern const char *set_gpu_memdiff(char *arg);
  89. extern const char *set_gpu_powertune(char *arg);
  90. extern const char *set_gpu_threads(char *arg);
  91. extern const char *set_gpu_vddc(char *arg);
  92. extern const char *set_temp_overheat(char *arg);
  93. extern const char *set_intensity(char *arg);
  94. extern const char *set_vector(char *arg);
  95. extern const char *set_worksize(char *arg);
  96. #ifdef USE_SCRYPT
  97. extern const char *set_shaders(char *arg);
  98. extern const char *set_lookup_gap(char *arg);
  99. extern const char *set_thread_concurrency(char *arg);
  100. #endif
  101. extern enum cl_kernels select_kernel(const char *);
  102. extern const char *opencl_get_kernel_interface_name(const enum cl_kernels);
  103. extern const char *opencl_get_default_kernel_filename(const enum cl_kernels);
  104. extern const char *set_kernel(char *arg);
  105. extern void write_config_opencl(FILE *);
  106. void manage_gpu(void);
  107. extern void opencl_dynamic_cleanup();
  108. extern void pause_dynamic_threads(int gpu);
  109. extern bool have_opencl;
  110. extern int opt_platform_id;
  111. extern bool opt_opencl_binaries;
  112. extern struct device_drv opencl_api;
  113. #endif /* __DEVICE_GPU_H__ */