go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkOpenCLDevice.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 __itkOpenCLDevice_h
19#define __itkOpenCLDevice_h
20
21#include "itkOpenCLPlatform.h"
22#include "itkOpenCLSize.h"
23
24namespace itk
25{
59{
60public:
61
64
66 OpenCLDevice() : m_Id( 0 ), m_Version( 0 ) {}
67
70 OpenCLDevice( cl_device_id id ) : m_Id( id ), m_Version( 0 ) {}
71
81 Default = ( 1 << 0 ),
82 CPU = ( 1 << 1 ),
83 GPU = ( 1 << 2 ),
84 Accelerator = ( 1 << 3 ),
85 Custom = ( 1 << 4 ),
86 All = 0xFFFFFFFF
87 };
88
89 enum Endian {
91 LittleEndian
92 };
93
95 bool IsNull() const { return this->m_Id == 0; }
96
98 cl_device_id GetDeviceId() const { return this->m_Id; }
99
103
109 std::string GetVersion() const;
110
114
117
119 unsigned int GetVendorId() const;
120
122 bool IsAvailable() const;
123
125 bool HasCompiler() const;
126
129 bool HasNativeKernels() const;
130
135
138 bool HasDouble() const;
139
146 bool HasHalfFloat() const;
147
151
154 bool HasUnifiedMemory() const;
155
157 unsigned int GetComputeUnits() const;
158
160 unsigned int GetClockFrequency() const;
161
164 unsigned int GetAddressBits() const;
165
169
173
177 std::size_t GetMaximumWorkItemsPerGroup() const;
178
180 bool HasImage2D() const;
181
183 bool HasImage3D() const;
184
187 bool HasWritableImage3D() const;
188
193
198
201 unsigned int GetMaximumSamplers() const;
202
206 unsigned int GetMaximumReadImages() const;
207
211 unsigned int GetMaximumWriteImages() const;
212
216 unsigned int GetPreferredCharVectorSize() const;
217
221 unsigned int GetPreferredShortVectorSize() const;
222
226 unsigned int GetPreferredIntVectorSize() const;
227
232 unsigned int GetPreferredLongVectorSize() const;
233
238 unsigned int GetPreferredFloatVectorSize() const;
239
246 unsigned int GetPreferredDoubleVectorSize() const;
247
256
261 unsigned int GetNativeCharVectorSize() const;
262
267 unsigned int GetNativeShortVectorSize() const;
268
273 unsigned int GetNativeIntVectorSize() const;
274
279 unsigned int GetNativeLongVectorSize() const;
280
285 unsigned int GetNativeFloatVectorSize() const;
286
293 unsigned int GetNativeDoubleVectorSize() const;
294
301 unsigned int GetNativeHalfFloatVectorSize() const;
302
315 NotSupported = 0x0000,
316 Denorm = 0x0001,
317 InfinityNaN = 0x0002,
318 RoundNearest = 0x0004,
319 RoundZero = 0x0008,
320 RoundInfinity = 0x0010,
321 FusedMultiplyAdd = 0x0020
322 };
323
327
334
341
344 std::size_t GetProfilingTimerResolution() const;
345
348 unsigned long GetMaximumAllocationSize() const;
349
352 unsigned long GetGlobalMemorySize() const;
353
361 NoCache = 0,
362 ReadOnlyCache = 1,
363 ReadWriteCache = 2
364 };
365
369
372 unsigned long GetGlobalMemoryCacheSize() const;
373
376 unsigned int GetGlobalMemoryCacheLineSize() const;
377
380 unsigned long GetLocalMemorySize() const;
381
387
390 unsigned long GetMaximumConstantBufferSize() const;
391
395 unsigned int GetMaximumConstantArguments() const;
396
399 unsigned int GetDefaultAlignment() const;
400
403 unsigned int GetMinimumAlignment() const;
404
407 std::size_t GetMaximumParameterBytes() const;
408
411 bool IsFullProfile() const;
412
415 bool IsEmbeddedProfile() const;
416
420 std::string GetProfile() const;
421
424 std::string GetDriverVersion() const;
425
427 std::string GetName() const;
428
430 std::string GetVendor() const;
431
434 std::list< std::string > GetExtensions() const;
435
438 std::string GetLanguageVersion() const;
439
445 bool HasExtension( const std::string & name ) const;
446
449 static std::list< OpenCLDevice > GetAllDevices();
450
455 static std::list< OpenCLDevice > GetDevices( const OpenCLDevice::DeviceType types,
456 const OpenCLPlatform & platform = OpenCLPlatform() );
457
461 static std::list< OpenCLDevice > GetDevices( const OpenCLDevice::DeviceType type,
462 const OpenCLPlatform::VendorType vendor );
463
466 static OpenCLDevice GetMaximumFlopsDevice( const std::list< OpenCLDevice > & devices,
467 const OpenCLDevice::DeviceType type );
468
472
477 const OpenCLPlatform::VendorType vendor );
478
483 const OpenCLPlatform & platform = OpenCLPlatform() );
484
489 static std::list< OpenCLDevice > GetMaximumFlopsDevices( const OpenCLDevice::DeviceType type,
490 const OpenCLPlatform & platform = OpenCLPlatform() );
491
492private:
493
494 cl_device_id m_Id;
495 mutable int m_Version;
496};
497
501bool ITKOpenCL_EXPORT operator==( const OpenCLDevice & lhs, const OpenCLDevice & rhs );
502
506bool ITKOpenCL_EXPORT operator!=( const OpenCLDevice & lhs, const OpenCLDevice & rhs );
507
509template< typename charT, typename traits >
510inline
511std::basic_ostream< charT, traits > &
512operator<<( std::basic_ostream< charT, traits > & strm,
513 const OpenCLDevice & device )
514{
515 if( device.IsNull() )
516 {
517 strm << "OpenCLDevice(null)";
518 return strm;
519 }
520
521 const char indent = ' ';
522
523 strm << "OpenCLDevice" << std::endl
524 << indent << "Id: " << device.GetDeviceId() << std::endl;
525
526 strm << indent << "OpenCL version: ";
527 switch( device.GetOpenCLVersion() )
528 {
529 case VERSION_1_0:
530 strm << "1.0"; break;
531 case VERSION_1_1:
532 strm << "1.1"; break;
533 case VERSION_1_2:
534 strm << "1.2"; break;
535 case VERSION_2_0:
536 strm << "2.0"; break;
537 case VERSION_2_1:
538 strm << "2.1"; break;
539 default:
540 strm << "Unknown"; break;
541 }
542
543 strm << std::endl << indent << "Version: " << device.GetVersion() << std::endl;
544
545 strm << indent << "Device type: ";
546 switch( device.GetDeviceType() )
547 {
549 strm << "Default"; break;
551 strm << "CPU"; break;
553 strm << "GPU"; break;
555 strm << "Accelerator"; break;
557 strm << "All"; break;
558 default:
559 strm << "Unknown"; break;
560 }
561
562 // strm << device.GetPlatform() << std::endl;
563 strm << std::endl << indent << "Vendor Id: " << device.GetVendorId() << std::endl
564 << indent << "Available: " << ( device.IsAvailable() ? "Yes" : "No" ) << std::endl
565 << indent << "Has compiler: " << ( device.HasCompiler() ? "Yes" : "No" ) << std::endl
566 << indent << "Has native kernels: " << ( device.HasNativeKernels() ? "Yes" : "No" ) << std::endl
567 << indent << "Has out of order execution: " << ( device.HasOutOfOrderExecution() ? "Yes" : "No" ) << std::endl
568 << indent << "Has double: " << ( device.HasDouble() ? "Yes" : "No" ) << std::endl
569 << indent << "Has half float: " << ( device.HasHalfFloat() ? "Yes" : "No" ) << std::endl
570 << indent << "Has error correcting memory: " << ( device.HasErrorCorrectingMemory() ? "Yes" : "No" ) << std::endl
571 << indent << "Has unified memory: " << ( device.HasUnifiedMemory() ? "Yes" : "No" ) << std::endl
572 << indent << "Compute units: " << device.GetComputeUnits() << std::endl
573 << indent << "Clock frequency: " << device.GetClockFrequency() << std::endl
574 << indent << "Address bits: " << device.GetAddressBits() << std::endl;
575
576 strm << indent << "Byte order: ";
577 switch( device.GetByteOrder() )
578 {
580 strm << "Big Endian"; break;
582 strm << "Little Endian"; break;
583 default:
584 strm << "Unknown"; break;
585 }
586
587 strm << std::endl << indent << "Maximum work item size: " << device.GetMaximumWorkItemSize() << std::endl
588 << indent << "Maximum work items per group: " << device.GetMaximumWorkItemsPerGroup() << std::endl
589 << indent << "Maximum work items per group: " << device.GetMaximumWorkItemsPerGroup() << std::endl;
590
591 // Has Image 2D
592 const bool hasImage2D = device.HasImage2D();
593 strm << indent << "Has image 2D: " << ( hasImage2D ? "Yes" : "No" ) << std::endl;
594 if( hasImage2D )
595 {
596 strm << indent << "Maximum image 2D size: " << device.GetMaximumImage2DSize() << std::endl;
597 }
598
599 // Has Image 3D
600 const bool hasImage3D = device.HasImage3D();
601 strm << indent << "Has image 3D: " << ( hasImage3D ? "Yes" : "No" ) << std::endl;
602 if( hasImage3D )
603 {
604 strm << indent << "Maximum image 3D size: " << device.GetMaximumImage3DSize() << std::endl;
605 }
606
607 strm << indent << "Has writable image 3D: " << ( device.HasWritableImage3D() ? "Yes" : "No" ) << std::endl
608 << indent << "Maximum samplers: " << device.GetMaximumSamplers() << std::endl
609 << indent << "Maximum read images: " << device.GetMaximumReadImages() << std::endl
610 << indent << "Maximum write images: " << device.GetMaximumWriteImages() << std::endl
611
612 << indent << "Preferred char vector size: " << device.GetPreferredCharVectorSize() << std::endl
613 << indent << "Preferred short vector size: " << device.GetPreferredShortVectorSize() << std::endl
614 << indent << "Preferred int vector size: " << device.GetPreferredIntVectorSize() << std::endl
615 << indent << "Preferred long vector size: " << device.GetPreferredLongVectorSize() << std::endl
616 << indent << "Preferred float vector size: " << device.GetPreferredFloatVectorSize() << std::endl
617 << indent << "Preferred double vector size: " << device.GetPreferredDoubleVectorSize() << std::endl
618 << indent << "Preferred half float vector size: " << device.GetPreferredHalfFloatVectorSize() << std::endl
619
620 << indent << "Native char vector size: " << device.GetNativeCharVectorSize() << std::endl
621 << indent << "Native short vector size: " << device.GetNativeShortVectorSize() << std::endl
622 << indent << "Native int vector size: " << device.GetNativeIntVectorSize() << std::endl
623 << indent << "Native long vector size: " << device.GetNativeLongVectorSize() << std::endl
624 << indent << "Native float vector size: " << device.GetNativeFloatVectorSize() << std::endl
625 << indent << "Native double vector size: " << device.GetNativeDoubleVectorSize() << std::endl
626 << indent << "Native half float vector size: " << device.GetNativeHalfFloatVectorSize() << std::endl;
627
628 strm << indent << "Float capabilities: ";
629 switch( device.GetFloatCapabilities() )
630 {
632 strm << "Not supported"; break;
634 strm << "Denorm"; break;
636 strm << "Infinity nan"; break;
638 strm << "Round nearest"; break;
640 strm << "Round zero"; break;
642 strm << "Round infinity"; break;
644 strm << "Fused multiply add"; break;
645 default:
646 strm << "Unknown"; break;
647 }
648
649 strm << std::endl << indent << "Double capabilities: ";
650 switch( device.GetDoubleCapabilities() )
651 {
653 strm << "Not supported"; break;
655 strm << "Denorm"; break;
657 strm << "Infinity NaN"; break;
659 strm << "Round nearest"; break;
661 strm << "Round zero"; break;
663 strm << "Round infinity"; break;
665 strm << "Fused multiply add"; break;
666 default:
667 strm << "Unknown"; break;
668 }
669
670 strm << std::endl << indent << "Half float capabilities: ";
671 switch( device.GetHalfFloatCapabilities() )
672 {
674 strm << "Not supported"; break;
676 strm << "Denorm"; break;
678 strm << "Infinity NaN"; break;
680 strm << "Round nearest"; break;
682 strm << "Round zero"; break;
684 strm << "Round infinity"; break;
686 strm << "Fused multiply add"; break;
687 default:
688 strm << "Unknown"; break;
689 }
690
691 strm << std::endl << indent << "Profiling timer resolution: " << device.GetProfilingTimerResolution() << std::endl
692 << indent << "Maximum allocation size: " << device.GetMaximumAllocationSize() << std::endl
693 << indent << "Global memory size: " << device.GetGlobalMemorySize() << std::endl;
694
695 strm << indent << "Global memory cache type: ";
696 switch( device.GetGlobalMemoryCacheType() )
697 {
699 strm << "No cache"; break;
701 strm << "Read only cache"; break;
703 strm << "Read write cache"; break;
704 default:
705 strm << "Unknown"; break;
706 }
707
708 strm << std::endl << indent << "Global memory cache size: " << device.GetGlobalMemoryCacheSize() << std::endl
709 << indent << "Global memory cache line size: " << device.GetGlobalMemoryCacheLineSize() << std::endl
710 << indent << "Local memory size: " << device.GetLocalMemorySize() << std::endl
711 << indent << "Local memory separated: " << ( device.IsLocalMemorySeparate() ? "Yes" : "No" ) << std::endl
712 << indent << "Maximum constant buffer size: " << device.GetMaximumConstantBufferSize() << std::endl
713 << indent << "Maximum constant arguments: " << device.GetMaximumConstantArguments() << std::endl
714 << indent << "Default alignment: " << device.GetDefaultAlignment() << std::endl
715 << indent << "Minimum alignment: " << device.GetMinimumAlignment() << std::endl
716 << indent << "Maximum parameter bytes: " << device.GetMaximumParameterBytes() << std::endl
717 << indent << "Full profile: " << ( device.IsFullProfile() ? "Yes" : "No" ) << std::endl
718 << indent << "Embedded profile: " << ( device.IsEmbeddedProfile() ? "Yes" : "No" ) << std::endl
719 << indent << "Profile: " << device.GetProfile() << std::endl
720 << indent << "Driver version: " << device.GetDriverVersion() << std::endl
721 << indent << "Name: " << device.GetName() << std::endl
722 << indent << "Vendor: " << device.GetVendor() << std::endl
723 << indent << "Language Version: " << device.GetLanguageVersion() << std::endl;
724
725 const std::list< std::string > extensions = device.GetExtensions();
726 const std::size_t extensionsSize = extensions.size();
727 strm << indent << "Extensions(" << extensionsSize << "): ";
728 if( extensionsSize == 0 )
729 {
730 strm << "none";
731 }
732 else
733 {
734 strm << std::endl;
735 for( std::list< std::string >::const_iterator it = extensions.begin(); it != extensions.end(); ++it )
736 {
737 strm << indent << indent << "- " << *it << std::endl;
738 }
739 }
740
741 return strm;
742}
743
744
745} // end namespace itk
746
747#endif /* __itkOpenCLDevice_h */
The OpenCLDevice class represents the collection of OpenCL devices to be used by the host.
OpenCLDevice Self
bool HasHalfFloat() const
cl_device_id GetDeviceId() const
bool IsLocalMemorySeparate() const
unsigned int GetNativeDoubleVectorSize() const
bool IsFullProfile() const
static std::list< OpenCLDevice > GetDevices(const OpenCLDevice::DeviceType type, const OpenCLPlatform::VendorType vendor)
OpenCLDevice::DeviceType GetDeviceType() const
static OpenCLDevice GetMaximumFlopsDeviceByVendor(const OpenCLDevice::DeviceType type, const OpenCLPlatform::VendorType vendor)
std::string GetName() const
bool HasDouble() const
unsigned long GetGlobalMemorySize() const
unsigned int GetPreferredDoubleVectorSize() const
unsigned int GetClockFrequency() const
OpenCLVersion GetOpenCLVersion() const
unsigned int GetNativeFloatVectorSize() const
OpenCLPlatform GetPlatform() const
bool HasErrorCorrectingMemory() const
bool HasCompiler() const
FloatCapability GetHalfFloatCapabilities() const
unsigned int GetNativeCharVectorSize() const
OpenCLSize GetMaximumWorkItemSize() const
bool IsEmbeddedProfile() const
static OpenCLDevice GetMaximumFlopsDevice(const OpenCLDevice::DeviceType type)
std::string GetLanguageVersion() const
bool HasImage3D() const
unsigned int GetDefaultAlignment() const
unsigned int GetVendorId() const
FloatCapability GetDoubleCapabilities() const
unsigned int GetComputeUnits() const
OpenCLDevice(cl_device_id id)
std::vcl_size_t GetMaximumWorkItemsPerGroup() const
unsigned int GetPreferredHalfFloatVectorSize() const
bool IsAvailable() const
bool HasWritableImage3D() const
unsigned int GetMaximumConstantArguments() const
FloatCapability GetFloatCapabilities() const
bool HasOutOfOrderExecution() const
unsigned int GetPreferredShortVectorSize() const
static std::list< OpenCLDevice > GetAllDevices()
std::vcl_size_t GetMaximumParameterBytes() const
bool HasUnifiedMemory() const
unsigned int GetNativeLongVectorSize() const
static OpenCLDevice GetMaximumFlopsDevice(const std::list< OpenCLDevice > &devices, const OpenCLDevice::DeviceType type)
static OpenCLDevice GetMaximumFlopsDeviceByPlatform(const OpenCLDevice::DeviceType types, const OpenCLPlatform &platform=OpenCLPlatform())
unsigned int GetGlobalMemoryCacheLineSize() const
CacheType GetGlobalMemoryCacheType() const
OpenCLSize GetMaximumImage3DSize() const
std::vcl_size_t GetProfilingTimerResolution() const
unsigned long GetMaximumConstantBufferSize() const
bool HasExtension(const std::string &name) const
unsigned int GetNativeHalfFloatVectorSize() const
OpenCLSize GetMaximumImage2DSize() const
std::string GetDriverVersion() const
static std::list< OpenCLDevice > GetDevices(const OpenCLDevice::DeviceType types, const OpenCLPlatform &platform=OpenCLPlatform())
bool IsNull() const
static std::list< OpenCLDevice > GetMaximumFlopsDevices(const OpenCLDevice::DeviceType type, const OpenCLPlatform &platform=OpenCLPlatform())
unsigned int GetPreferredLongVectorSize() const
bool HasNativeKernels() const
unsigned int GetNativeShortVectorSize() const
unsigned int GetMinimumAlignment() const
unsigned int GetNativeIntVectorSize() const
bool HasImage2D() const
unsigned int GetPreferredCharVectorSize() const
unsigned int GetPreferredFloatVectorSize() const
unsigned int GetMaximumSamplers() const
std::list< std::string > GetExtensions() const
unsigned int GetMaximumWriteImages() const
unsigned int GetPreferredIntVectorSize() const
unsigned long GetMaximumAllocationSize() const
std::string GetProfile() const
unsigned int GetAddressBits() const
unsigned int GetMaximumReadImages() const
std::string GetVendor() const
std::string GetVersion() const
unsigned long GetLocalMemorySize() const
OpenCLDevice::Endian GetByteOrder() const
unsigned long GetGlobalMemoryCacheSize() const
The OpenCLPlatform represent platform model for OpenCL.
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
Definition: itkOpenCLSize.h:50
#define ITKOpenCL_EXPORT
bool ITKOpenCL_EXPORT operator==(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
bool ITKOpenCL_EXPORT operator!=(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
OpenCLVersion
Definition: itkOpenCL.h:41
@ VERSION_2_1
Definition: itkOpenCL.h:46
@ VERSION_1_2
Definition: itkOpenCL.h:44
@ VERSION_1_0
Definition: itkOpenCL.h:42
@ VERSION_1_1
Definition: itkOpenCL.h:43
@ VERSION_2_0
Definition: itkOpenCL.h:45
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo