driver-opencl.h 3.2 KB

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