SkelCL
SkelCL is a high level multi GPU skeleton library developed at the university of Münster, Germany.
 All Classes Namespaces Files Functions Variables Typedefs Groups
DeviceProperties.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2011-2012 The SkelCL Team as listed in CREDITS.txt *
3  * http://skelcl.uni-muenster.de *
4  * *
5  * This file is part of SkelCL. *
6  * SkelCL is available under multiple licenses. *
7  * The different licenses are subject to terms and condition as provided *
8  * in the files specifying the license. See "LICENSE.txt" for details *
9  * *
10  *****************************************************************************
11  * *
12  * SkelCL is free software: you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation, either version 3 of the License, or *
15  * (at your option) any later version. See "LICENSE-gpl.txt" for details. *
16  * *
17  * SkelCL is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  *****************************************************************************
23  * *
24  * For non-commercial academic use see the license specified in the file *
25  * "LICENSE-academic.txt". *
26  * *
27  *****************************************************************************
28  * *
29  * If you are interested in other licensing models, including a commercial- *
30  * license, please contact the author at michel.steuwer@uni-muenster.de *
31  * *
32  *****************************************************************************/
33 
39 
40 #include <string>
41 #include <limits>
42 
43 #include "SkelCL/detail/DeviceProperties.h"
44 
45 namespace {
46 
47 } // namespace
48 
49 namespace skelcl {
50 
51 namespace detail {
52 
53 DeviceProperties DeviceProperties::nDevices(size_t n)
54 {
55  DeviceProperties dp;
56  dp._count = n;
57  return dp;
58 }
59 
60 DeviceProperties DeviceProperties::allDevices()
61 {
62  DeviceProperties dp;
63  dp._takeAll = true;
64  return dp;
65 }
66 
67 DeviceProperties::DeviceProperties()
68  : _deviceType(Device::Type::ALL),
69  _takeAll(false),
70  _count(0)//,
71 #if 0
72  _id(std::numeric_limits<Device::id_type>::max()),
73  _name(),
74  _vendorName(),
75  _maxClockFrequency(),
76  _minComputeUnits(0),
77  _maxWorkGroupSize(),
78  _minWorkGroupSize(0),
79  _maxWorkGroups(),
80  _minWorkGroups(0),
81  _globalMemSize(),
82  _localMemSize(),
83  _minGlobalMemSize(0),
84  _minLocalMemSize(0)
85 #endif
86 {
87 }
88 
89 DeviceProperties::~DeviceProperties()
90 {
91 }
92 
93 bool DeviceProperties::match(const cl::Device& device) const
94 {
95  if ( _deviceType != Device::Type::ALL
96  && _deviceType != device.getInfo<CL_DEVICE_TYPE>()) return false;
97  return true;
98 }
99 
100 bool DeviceProperties::matchAndTake(const cl::Device& device)
101 {
102  if (match(device)) {
103  if (_takeAll) return true;
104  // _takeAll == false
105  if (_count > 0) {
106  --_count; // take device out of set
107  return true;
108  }
109  }
110  return false;
111 }
112 
113 DeviceProperties& DeviceProperties::deviceType(Device::Type value)
114 {
115  _deviceType = value;
116  return *this;
117 }
118 
119 } // namespace detail
120 
121 } // namespace skelcl
SKELCL_DLL detail::DeviceProperties allDevices()
Creates a detail::DeviceProperties object representing all devices in the system. This object should ...
Definition: SkelCL.cpp:61
SKELCL_DLL detail::DeviceID device(size_t dID)
Creates an OpenCL device ID to be used as parameter of the init(detail::PlatformID, detail::DeviceID) function.
Definition: SkelCL.cpp:76
SKELCL_DLL detail::DeviceProperties nDevices(size_t n)
Creates a detail::DeviceProperties object representing n devices. This object should be used as param...
Definition: SkelCL.cpp:66