go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkOpenCLPlatform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkOpenCLPlatform_h
19 #define __itkOpenCLPlatform_h
20 
21 #include "itkOpenCL.h"
22 
23 #include <string>
24 #include <list>
25 
26 namespace itk
27 {
45 {
46 public:
47 
50 
52  OpenCLPlatform() : m_Id( 0 ), m_Version( 0 ) {}
53 
56  OpenCLPlatform( cl_platform_id id ) : m_Id( id ), m_Version( 0 ) {}
57 
65  enum VendorType {
69  AMD,
70  IBM
71  };
72 
74  bool IsNull() const { return this->m_Id == 0; }
75 
77  cl_platform_id GetPlatformId() const { return this->m_Id; }
78 
81  OpenCLVersion GetOpenCLVersion() const;
82 
86  std::string GetVersion() const;
87 
90  bool IsFullProfile() const;
91 
94  bool IsEmbeddedProfile() const;
95 
99  std::string GetProfile() const;
100 
102  std::string GetName() const;
103 
105  std::string GetVendor() const;
106 
109  std::string GetExtensionSuffix() const;
110 
113  std::list< std::string > GetExtensions() const;
114 
121  bool HasExtension( const std::string & name ) const;
122 
124  static std::list< OpenCLPlatform > GetAllPlatforms();
125 
127  static OpenCLPlatform GetPlatform( const OpenCLPlatform::VendorType vendor );
128 
129 private:
130 
131  cl_platform_id m_Id;
132  mutable int m_Version;
133 };
134 
138 bool ITKOpenCL_EXPORT operator==( const OpenCLPlatform & lhs, const OpenCLPlatform & rhs );
139 
143 bool ITKOpenCL_EXPORT operator!=( const OpenCLPlatform & lhs, const OpenCLPlatform & rhs );
144 
146 template< typename charT, typename traits >
147 inline
148 std::basic_ostream< charT, traits > &
149 operator<<( std::basic_ostream< charT, traits > & strm,
150  const OpenCLPlatform & platform )
151 {
152  if( platform.IsNull() )
153  {
154  strm << "OpenCLPlatform(null)";
155  return strm;
156  }
157 
158  const char indent = ' ';
159 
160  strm << "OpenCLPlatform" << std::endl
161  << indent << "Id: " << platform.GetPlatformId() << std::endl;
162 
163  strm << indent << "OpenCL version: ";
164  switch( platform.GetOpenCLVersion() )
165  {
166  case VERSION_1_0:
167  strm << "1.0"; break;
168  case VERSION_1_1:
169  strm << "1.1"; break;
170  case VERSION_1_2:
171  strm << "1.2"; break;
172  case VERSION_2_0:
173  strm << "2.0"; break;
174  default:
175  strm << "Unknown"; break;
176  }
177 
178  strm << std::endl << indent << "Full profile: " << ( platform.IsFullProfile() ? "On" : "Off" ) << std::endl
179  << indent << "Embedded profile: " << ( platform.IsEmbeddedProfile() ? "On" : "Off" ) << std::endl
180  << indent << "Profile: " << platform.GetProfile() << std::endl
181  << indent << "Version: " << platform.GetVersion() << std::endl
182  << indent << "Name: " << platform.GetName() << std::endl
183  << indent << "Vendor: " << platform.GetVendor() << std::endl
184  << indent << "Extension suffix: " << platform.GetExtensionSuffix() << std::endl;
185 
186  const std::list< std::string > extensions = platform.GetExtensions();
187  const std::size_t extensionsSize = extensions.size();
188  strm << indent << "Extensions(" << extensionsSize << "): ";
189  if( extensions.empty() )
190  {
191  strm << "none";
192  }
193  else
194  {
195  strm << std::endl;
196  for( std::list< std::string >::const_iterator it = extensions.begin(); it != extensions.end(); ++it )
197  {
198  strm << indent << indent << "- " << *it << std::endl;
199  }
200  }
201 
202  return strm;
203 }
204 
205 
206 } // end namespace itk
207 
208 #endif /* __itkOpenCLPlatform_h */
OpenCLVersion
Definition: itkOpenCL.h:40
bool ITKOpenCL_EXPORT operator==(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
bool ITKOpenCL_EXPORT operator!=(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
The OpenCLPlatform represent platform model for OpenCL.
cl_platform_id GetPlatformId() const
OpenCLPlatform(cl_platform_id id)
#define ITKOpenCL_EXPORT


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo