1 /* devices.h - OpenCL device type definition.
2 
3    Copyright (c) 2011 Universidad Rey Juan Carlos and
4                  2011-2012 Pekka Jääskeläinen / Tampere University of Technology
5 
6    Permission is hereby granted, free of charge, to any person obtaining a copy
7    of this software and associated documentation files (the "Software"), to deal
8    in the Software without restriction, including without limitation the rights
9    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10    copies of the Software, and to permit persons to whom the Software is
11    furnished to do so, subject to the following conditions:
12 
13    The above copyright notice and this permission notice shall be included in
14    all copies or substantial portions of the Software.
15 
16    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22    THE SOFTWARE.
23 */
24 
25 #ifndef POCL_DEVICES_H
26 #define POCL_DEVICES_H
27 
28 #include "../pocl_cl.h"
29 #include "config.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /* The number of available devices. */
36 extern unsigned int pocl_num_devices;
37 
38 /**
39  * Populates the pocl_devices with the wanted device types.
40  *
41  * Should be called before accessing the device list. Can be called repeatedly.
42  * The devices are shared across contexts, thus must implement resource
43  * management internally also across multiple contexts.
44  */
45 cl_int pocl_init_devices();
46 
47 cl_int pocl_uninit_devices ();
48 
49 /**
50  * \brief Get the count of devices for a specific type
51  * \param device_type the device type for which we want the count of devices
52  * \return the count of devices for this type
53  */
54 unsigned int pocl_get_device_type_count(cl_device_type device_type);
55 
56 /**
57  * \brief Get a certain amount of devices for a specific type
58  * \param type Type of devices wanted
59  * \param devices Array of pointer to devices
60  * \param num_devices Number of devices queried
61  * \return The real number of devices added to devices array which match the specified type
62  */
63 unsigned int pocl_get_devices(cl_device_type device_type, struct _cl_device_id **devices, unsigned int num_devices);
64 
65 /**
66  * \brief Return the count of a specific device in the env var POCL_DEVICES
67  * \param dev_type a string describing the device ("basic" for instance)
68  * \return If the env var was not set, return -1, if the env var is specified, return 0
69  * or the number of occurrence of dev_type in the env var
70  */
71 POCL_EXPORT
72 int pocl_device_get_env_count(const char *dev_type);
73 
74 
75 /* the environment variable that lists the enabled devices */
76 #define POCL_DEVICES_ENV "POCL_DEVICES"
77 
78 #ifdef __cplusplus
79 } /* extern "C" */
80 #endif
81 
82 #endif /* POCL_DEVICES_H */
83