opencl_boinc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // This file is part of BOINC.
  2. // http://boinc.berkeley.edu
  3. // Copyright (C) 2013 University of California
  4. //
  5. // BOINC is free software; you can redistribute it and/or modify it
  6. // under the terms of the GNU Lesser General Public License
  7. // as published by the Free Software Foundation,
  8. // either version 3 of the License, or (at your option) any later version.
  9. //
  10. // BOINC is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. // See the GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with BOINC. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef BOINC_OPENCL_BOINC_H
  18. #define BOINC_OPENCL_BOINC_H
  19. #include "cl_boinc.h"
  20. #include "miofile.h"
  21. #include "parse.h"
  22. #define MAX_OPENCL_PLATFORMS 16
  23. #define MAX_OPENCL_CPU_PLATFORMS 4
  24. enum COPROC_USAGE {
  25. COPROC_IGNORED,
  26. COPROC_UNUSED,
  27. COPROC_USED
  28. };
  29. // there's some duplication between the values in
  30. // the OPENCL_DEVICE_PROP struct and the NVIDIA/ATI structs
  31. //
  32. struct OPENCL_DEVICE_PROP {
  33. cl_device_id device_id;
  34. char name[256]; // Device name
  35. char vendor[256]; // Device vendor (NVIDIA, ATI, AMD, etc.)
  36. cl_uint vendor_id; // Vendor's unique ID for this device on this host
  37. cl_bool available; // Is this device available?
  38. cl_device_fp_config half_fp_config; // Half precision capabilities
  39. cl_device_fp_config single_fp_config; // Single precision
  40. cl_device_fp_config double_fp_config; // Double precision
  41. cl_bool endian_little; // TRUE if little-endian
  42. cl_device_exec_capabilities execution_capabilities;
  43. char extensions[2048]; // List of device extensions
  44. cl_ulong global_mem_size; // in bytes (OpenCL can report 4GB Max)
  45. cl_ulong local_mem_size;
  46. cl_uint max_clock_frequency; // in MHz
  47. cl_uint max_compute_units;
  48. //
  49. // cl_nv_device_attribute_query
  50. //
  51. cl_uint nv_compute_capability_major;
  52. cl_uint nv_compute_capability_minor;
  53. //
  54. // cl_amd_device_attribute_query
  55. //
  56. cl_uint amd_simd_per_compute_unit;
  57. cl_uint amd_simd_width;
  58. cl_uint amd_simd_instruction_width;
  59. char opencl_platform_version[64]; // Version of OpenCL supported
  60. // the device's platform
  61. char opencl_device_version[128]; // OpenCL version supported by device;
  62. // example: "OpenCL 1.1 beta"
  63. int opencl_device_version_int; // same, encoded as e.g. 101
  64. int get_device_version_int(); // call this to encode
  65. int opencl_driver_revision; // OpenCL runtime revision is available
  66. int get_opencl_driver_revision(); // call this to encode
  67. char opencl_driver_version[32]; // For example: "CLH 1.0"
  68. int device_num; // temp used in scan process
  69. double peak_flops; // temp used in scan process
  70. COPROC_USAGE is_used; // temp used in scan process
  71. double opencl_available_ram; // temp used in scan process
  72. int opencl_device_index; // zero-based device number within this OpenCL platform
  73. bool warn_bad_cuda; // If true, warn we can't use GPU due to CUDA version
  74. #ifndef _USING_FCGI_
  75. void write_xml(MIOFILE&, const char* tag, bool temp_file=false);
  76. #endif
  77. int parse(XML_PARSER&, const char* end_tag);
  78. void description(char* buf, int buflen, const char* type);
  79. OPENCL_DEVICE_PROP(){}
  80. void clear() {
  81. static const OPENCL_DEVICE_PROP x;
  82. *this = x;
  83. }
  84. };
  85. // NOTE: OpenCL has only 32 bits for global_mem_size, so
  86. // it can report a max of only 4GB.
  87. // Get the CPU RAM size from gstate.hostinfo.m_nbytes.
  88. //
  89. struct OPENCL_CPU_PROP {
  90. char platform_vendor[256];
  91. OPENCL_DEVICE_PROP opencl_prop;
  92. OPENCL_CPU_PROP() {
  93. clear();
  94. }
  95. void clear();
  96. void write_xml(MIOFILE&);
  97. int parse(XML_PARSER&);
  98. void description(char* buf, int buflen);
  99. };
  100. #endif