Loading [MathJax]/extensions/tex2jax.js
Parallel numerical verification of the σ_odd problem  October 6, 2018
All Classes Namespaces Files Functions Variables Typedefs Macros
helper.hpp
Go to the documentation of this file.
1 /* -*- coding: latin-1 -*- */
2 /** \file opencl/opencl/helper.hpp (December 17, 2017)
3  * \brief
4  * Helper functions for the OpenCL.
5  *
6  * GPLv3 --- Copyright (C) 2017 Olivier Pirson
7  * http://www.opimedia.be/
8  */
9 
10 #ifndef PROGS_SRC_OPENCL_OPENCL_HELPER_HPP_
11 #define PROGS_SRC_OPENCL_OPENCL_HELPER_HPP_
12 
13 // \cond
14 // #define __CL_ENABLE_EXCEPTIONS
15 #include <CL/cl.hpp>
16 
17 #include <iostream>
18 #include <string>
19 #include <map>
20 // \endcond
21 
22 #include "../../common/sigmaodd/helper.hpp"
23 #include "../../common/sigmaodd/primes.hpp"
24 
25 
26 namespace opencl {
27 
30 
31 
32  /* **********
33  * Constant *
34  ************/
35 
36  /** \brief
37  * Table associating error codes to error names.
38  *
39  * https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/errors.html
40  */
41  extern const std::map<int32_t, std::string> errors_map;
42 
43 
44 
45  /* ************
46  * Prototypes *
47  **************/
48 
49  /** \brief
50  * Return the corresponding information about the device.
51  */
52  cl_bool
53  get_device_info_cl_bool(const cl::Device &device, cl_device_info info);
54 
55 
56  /** \brief
57  * Return the corresponding information about the device.
58  */
59  cl_device_fp_config
60  get_device_info_cl_device_fp_config(const cl::Device &device, cl_device_info info);
61 
62 
63  /** \brief
64  * Return the corresponding information about the device.
65  */
66  cl_device_local_mem_type
67  get_device_info_cl_device_local_mem_type(const cl::Device &device, cl_device_info info);
68 
69 
70  /** \brief
71  * Return the corresponding information about the device.
72  */
73  cl_device_mem_cache_type
74  get_device_info_cl_device_mem_cache_type(const cl::Device &device, cl_device_info info);
75 
76 
77  /** \brief
78  * Return the corresponding information about the device.
79  */
80  cl_device_type
81  get_device_info_cl_device_type(const cl::Device &device, cl_device_info info);
82 
83 
84  /** \brief
85  * Return the corresponding information about the device.
86  */
87  cl_uint
88  get_device_info_cl_uint(const cl::Device &device, cl_device_info info);
89 
90 
91  /** \brief
92  * Return the corresponding information about the device.
93  */
94  cl_ulong
95  get_device_info_cl_ulong(const cl::Device &device, cl_device_info info);
96 
97 
98  /** \brief
99  * Return the corresponding information about the device.
100  */
101  size_t
102  get_device_info_size_t(const cl::Device &device, cl_device_info info);
103 
104 
105  /** \brief
106  * Return the corresponding information about the device.
107  */
108  std::string
109  get_device_info_string(const cl::Device &device, cl_device_info info);
110 
111 
112  /** \brief
113  * Return the corresponding information about the device.
114  */
115  VECTOR_CLASS<::size_t>
116  get_device_info_vector_size_t(const cl::Device &device, cl_device_info info);
117 
118 
119  /** \brief
120  * Return the first GPU device found.
121  * If not found then print an error message and exit.
122  */
123  cl::Device
125 
126 
127  /** \brief
128  * Return the error name corresponding to the error code.
129  */
130  std::string
131  error_name(cl_int code);
132 
133 
134  /** \brief
135  * Print information on this device.
136  */
137  void
138  print_device(const cl::Device &device);
139 
140 
141  /** \brief
142  * Print an error message corresponding to the error code.
143  *
144  * If only_if_error
145  * then print only if != 0,
146  * else print same if code == 0.
147  *
148  * If exit_if_error and (code != 0)
149  * then exit.
150  */
151  void
152  print_error(cl_int code, std::string message = "",
153  bool only_if_error = true, bool exit_if_error = true);
154 
155 
156  /** \brief
157  * Print information on this platform.
158  */
159  void
160  print_platform(const cl::Platform &platform);
161 
162 
163  /** \brief
164  * Print information on all platforms.
165  */
166  void
167  print_platforms();
168 
169 } // namespace opencl
170 
171 #endif // PROGS_SRC_OPENCL_OPENCL_HELPER_HPP_
cl_ulong get_device_info_cl_ulong(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
cl::Device get_first_device_gpu()
Return the first GPU device found. If not found then print an error message and exit.
Definition: helper.cpp:194
cl_device_type get_device_info_cl_device_type(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
Definition: helper.hpp:33
std::string get_device_info_string(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
Definition: helper.cpp:169
cl_uint get_device_info_cl_uint(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
std::string error_name(cl_int code)
Return the error name corresponding to the error code.
Definition: helper.cpp:215
uint32_t prime_type
Type for prime number, particularly for the table of primes.
Definition: primes.hpp:49
sigmaodd::nat_type nat_type
Definition: helper.hpp:28
cl_device_local_mem_type get_device_info_cl_device_local_mem_type(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
cl_device_fp_config get_device_info_cl_device_fp_config(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
void print_device(const cl::Device &device)
Print information on this device.
Definition: helper.cpp:225
void print_platform(const cl::Platform &platform)
Print information on this platform.
Definition: helper.cpp:373
void print_error(cl_int code, std::string message, bool only_if_error, bool exit_if_error)
Print an error message corresponding to the error code.
Definition: helper.cpp:352
size_t get_device_info_size_t(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
void print_platforms()
Print information on all platforms.
Definition: helper.cpp:407
cl_bool get_device_info_cl_bool(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
sigmaodd::prime_type prime_type
Definition: helper.hpp:29
cl_device_mem_cache_type get_device_info_cl_device_mem_cache_type(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.
const std::map< int32_t, std::string > errors_map
Table associating error codes to error names.
Definition: helper.cpp:28
VECTOR_CLASS<::size_t > get_device_info_vector_size_t(const cl::Device &device, cl_device_info info)
Return the corresponding information about the device.