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:
63
66 : m_Id(0)
67 , m_Version(0)
68 {}
69
72 OpenCLDevice(cl_device_id id)
73 : m_Id(id)
74 , m_Version(0)
75 {}
76
86 {
87 Default = (1 << 0),
88 CPU = (1 << 1),
89 GPU = (1 << 2),
90 Accelerator = (1 << 3),
91 Custom = (1 << 4),
92 All = 0xFFFFFFFF
93 };
94
95 enum Endian
96 {
98 LittleEndian
99 };
100
102 bool
103 IsNull() const
104 {
105 return this->m_Id == 0;
106 }
107
109 cl_device_id
111 {
112 return this->m_Id;
113 }
114
119
125 std::string
126 GetVersion() const;
127
132
135 GetPlatform() const;
136
138 unsigned int
139 GetVendorId() const;
140
142 bool
143 IsAvailable() const;
144
146 bool
147 HasCompiler() const;
148
151 bool
153
157 bool
159
162 bool
163 HasDouble() const;
164
171 bool
173
176 bool
178
181 bool
183
185 unsigned int
187
189 unsigned int
191
194 unsigned int
196
201
206
210 std::size_t
212
214 bool
215 HasImage2D() const;
216
218 bool
219 HasImage3D() const;
220
223 bool
225
231
237
240 unsigned int
242
246 unsigned int
248
252 unsigned int
254
258 unsigned int
260
264 unsigned int
266
270 unsigned int
272
277 unsigned int
279
284 unsigned int
286
293 unsigned int
295
303 unsigned int
305
310 unsigned int
312
317 unsigned int
319
324 unsigned int
326
331 unsigned int
333
338 unsigned int
340
347 unsigned int
349
356 unsigned int
358
371 {
372 NotSupported = 0x0000,
373 Denorm = 0x0001,
374 InfinityNaN = 0x0002,
375 RoundNearest = 0x0004,
376 RoundZero = 0x0008,
377 RoundInfinity = 0x0010,
378 FusedMultiplyAdd = 0x0020
379 };
380
383 FloatCapability
385
393
401
404 std::size_t
406
409 unsigned long
411
414 unsigned long
416
424 {
425 NoCache = 0,
426 ReadOnlyCache = 1,
427 ReadWriteCache = 2
428 };
429
432 CacheType
434
437 unsigned long
439
442 unsigned int
444
447 unsigned long
449
454 bool
456
459 unsigned long
461
465 unsigned int
467
470 unsigned int
472
475 unsigned int
477
480 std::size_t
482
485 bool
487
490 bool
492
496 std::string
497 GetProfile() const;
498
501 std::string
503
505 std::string
506 GetName() const;
507
509 std::string
510 GetVendor() const;
511
514 std::list<std::string>
516
519 std::string
521
527 bool
528 HasExtension(const std::string & name) const;
529
532 static std::list<OpenCLDevice>
534
539 static std::list<OpenCLDevice>
541
545 static std::list<OpenCLDevice>
547
550 static OpenCLDevice
551 GetMaximumFlopsDevice(const std::list<OpenCLDevice> & devices, const OpenCLDevice::DeviceType type);
552
555 static OpenCLDevice
557
561 static OpenCLDevice
563
567 static OpenCLDevice
569 const OpenCLPlatform & platform = OpenCLPlatform());
570
575 static std::list<OpenCLDevice>
577
578private:
579 cl_device_id m_Id;
580 mutable int m_Version;
581};
582
587 operator==(const OpenCLDevice & lhs, const OpenCLDevice & rhs);
588
593 operator!=(const OpenCLDevice & lhs, const OpenCLDevice & rhs);
594
596template <typename charT, typename traits>
597inline std::basic_ostream<charT, traits> &
598operator<<(std::basic_ostream<charT, traits> & strm, const OpenCLDevice & device)
599{
600 if (device.IsNull())
601 {
602 strm << "OpenCLDevice(null)";
603 return strm;
604 }
605
606 const char indent = ' ';
607
608 strm << "OpenCLDevice\n" << indent << "Id: " << device.GetDeviceId() << std::endl;
609
610 strm << indent << "OpenCL version: ";
611 switch (device.GetOpenCLVersion())
612 {
613 case VERSION_1_0:
614 strm << "1.0";
615 break;
616 case VERSION_1_1:
617 strm << "1.1";
618 break;
619 case VERSION_1_2:
620 strm << "1.2";
621 break;
622 case VERSION_2_0:
623 strm << "2.0";
624 break;
625 case VERSION_2_1:
626 strm << "2.1";
627 break;
628 default:
629 strm << "Unknown";
630 break;
631 }
632
633 strm << '\n' << indent << "Version: " << device.GetVersion() << std::endl;
634
635 strm << indent << "Device type: ";
636 switch (device.GetDeviceType())
637 {
639 strm << "Default";
640 break;
642 strm << "CPU";
643 break;
645 strm << "GPU";
646 break;
648 strm << "Accelerator";
649 break;
651 strm << "All";
652 break;
653 default:
654 strm << "Unknown";
655 break;
656 }
657
658 // strm << device.GetPlatform() << std::endl;
659 strm << '\n'
660 << indent << "Vendor Id: " << device.GetVendorId() << '\n'
661 << indent << "Available: " << (device.IsAvailable() ? "Yes" : "No") << '\n'
662 << indent << "Has compiler: " << (device.HasCompiler() ? "Yes" : "No") << '\n'
663 << indent << "Has native kernels: " << (device.HasNativeKernels() ? "Yes" : "No") << '\n'
664 << indent << "Has out of order execution: " << (device.HasOutOfOrderExecution() ? "Yes" : "No") << '\n'
665 << indent << "Has double: " << (device.HasDouble() ? "Yes" : "No") << '\n'
666 << indent << "Has half float: " << (device.HasHalfFloat() ? "Yes" : "No") << '\n'
667 << indent << "Has error correcting memory: " << (device.HasErrorCorrectingMemory() ? "Yes" : "No") << '\n'
668 << indent << "Has unified memory: " << (device.HasUnifiedMemory() ? "Yes" : "No") << '\n'
669 << indent << "Compute units: " << device.GetComputeUnits() << '\n'
670 << indent << "Clock frequency: " << device.GetClockFrequency() << '\n'
671 << indent << "Address bits: " << device.GetAddressBits() << std::endl;
672
673 strm << indent << "Byte order: ";
674 switch (device.GetByteOrder())
675 {
677 strm << "Big Endian";
678 break;
680 strm << "Little Endian";
681 break;
682 default:
683 strm << "Unknown";
684 break;
685 }
686
687 strm << '\n'
688 << indent << "Maximum work item size: " << device.GetMaximumWorkItemSize() << '\n'
689 << indent << "Maximum work items per group: " << device.GetMaximumWorkItemsPerGroup() << '\n'
690 << indent << "Maximum work items per group: " << device.GetMaximumWorkItemsPerGroup() << std::endl;
691
692 // Has Image 2D
693 const bool hasImage2D = device.HasImage2D();
694 strm << indent << "Has image 2D: " << (hasImage2D ? "Yes" : "No") << std::endl;
695 if (hasImage2D)
696 {
697 strm << indent << "Maximum image 2D size: " << device.GetMaximumImage2DSize() << std::endl;
698 }
699
700 // Has Image 3D
701 const bool hasImage3D = device.HasImage3D();
702 strm << indent << "Has image 3D: " << (hasImage3D ? "Yes" : "No") << std::endl;
703 if (hasImage3D)
704 {
705 strm << indent << "Maximum image 3D size: " << device.GetMaximumImage3DSize() << std::endl;
706 }
707
708 strm << indent << "Has writable image 3D: " << (device.HasWritableImage3D() ? "Yes" : "No") << '\n'
709 << indent << "Maximum samplers: " << device.GetMaximumSamplers() << '\n'
710 << indent << "Maximum read images: " << device.GetMaximumReadImages() << '\n'
711 << indent << "Maximum write images: " << device.GetMaximumWriteImages() << '\n'
712
713 << indent << "Preferred char vector size: " << device.GetPreferredCharVectorSize() << '\n'
714 << indent << "Preferred short vector size: " << device.GetPreferredShortVectorSize() << '\n'
715 << indent << "Preferred int vector size: " << device.GetPreferredIntVectorSize() << '\n'
716 << indent << "Preferred long vector size: " << device.GetPreferredLongVectorSize() << '\n'
717 << indent << "Preferred float vector size: " << device.GetPreferredFloatVectorSize() << '\n'
718 << indent << "Preferred double vector size: " << device.GetPreferredDoubleVectorSize() << '\n'
719 << indent << "Preferred half float vector size: " << device.GetPreferredHalfFloatVectorSize() << '\n'
720
721 << indent << "Native char vector size: " << device.GetNativeCharVectorSize() << '\n'
722 << indent << "Native short vector size: " << device.GetNativeShortVectorSize() << '\n'
723 << indent << "Native int vector size: " << device.GetNativeIntVectorSize() << '\n'
724 << indent << "Native long vector size: " << device.GetNativeLongVectorSize() << '\n'
725 << indent << "Native float vector size: " << device.GetNativeFloatVectorSize() << '\n'
726 << indent << "Native double vector size: " << device.GetNativeDoubleVectorSize() << '\n'
727 << indent << "Native half float vector size: " << device.GetNativeHalfFloatVectorSize() << std::endl;
728
729 strm << indent << "Float capabilities: ";
730 switch (device.GetFloatCapabilities())
731 {
733 strm << "Not supported";
734 break;
736 strm << "Denorm";
737 break;
739 strm << "Infinity nan";
740 break;
742 strm << "Round nearest";
743 break;
745 strm << "Round zero";
746 break;
748 strm << "Round infinity";
749 break;
751 strm << "Fused multiply add";
752 break;
753 default:
754 strm << "Unknown";
755 break;
756 }
757
758 strm << '\n' << indent << "Double capabilities: ";
759 switch (device.GetDoubleCapabilities())
760 {
762 strm << "Not supported";
763 break;
765 strm << "Denorm";
766 break;
768 strm << "Infinity NaN";
769 break;
771 strm << "Round nearest";
772 break;
774 strm << "Round zero";
775 break;
777 strm << "Round infinity";
778 break;
780 strm << "Fused multiply add";
781 break;
782 default:
783 strm << "Unknown";
784 break;
785 }
786
787 strm << '\n' << indent << "Half float capabilities: ";
788 switch (device.GetHalfFloatCapabilities())
789 {
791 strm << "Not supported";
792 break;
794 strm << "Denorm";
795 break;
797 strm << "Infinity NaN";
798 break;
800 strm << "Round nearest";
801 break;
803 strm << "Round zero";
804 break;
806 strm << "Round infinity";
807 break;
809 strm << "Fused multiply add";
810 break;
811 default:
812 strm << "Unknown";
813 break;
814 }
815
816 strm << '\n'
817 << indent << "Profiling timer resolution: " << device.GetProfilingTimerResolution() << '\n'
818 << indent << "Maximum allocation size: " << device.GetMaximumAllocationSize() << '\n'
819 << indent << "Global memory size: " << device.GetGlobalMemorySize() << std::endl;
820
821 strm << indent << "Global memory cache type: ";
822 switch (device.GetGlobalMemoryCacheType())
823 {
825 strm << "No cache";
826 break;
828 strm << "Read only cache";
829 break;
831 strm << "Read write cache";
832 break;
833 default:
834 strm << "Unknown";
835 break;
836 }
837
838 strm << '\n'
839 << indent << "Global memory cache size: " << device.GetGlobalMemoryCacheSize() << '\n'
840 << indent << "Global memory cache line size: " << device.GetGlobalMemoryCacheLineSize() << '\n'
841 << indent << "Local memory size: " << device.GetLocalMemorySize() << '\n'
842 << indent << "Local memory separated: " << (device.IsLocalMemorySeparate() ? "Yes" : "No") << '\n'
843 << indent << "Maximum constant buffer size: " << device.GetMaximumConstantBufferSize() << '\n'
844 << indent << "Maximum constant arguments: " << device.GetMaximumConstantArguments() << '\n'
845 << indent << "Default alignment: " << device.GetDefaultAlignment() << '\n'
846 << indent << "Minimum alignment: " << device.GetMinimumAlignment() << '\n'
847 << indent << "Maximum parameter bytes: " << device.GetMaximumParameterBytes() << '\n'
848 << indent << "Full profile: " << (device.IsFullProfile() ? "Yes" : "No") << '\n'
849 << indent << "Embedded profile: " << (device.IsEmbeddedProfile() ? "Yes" : "No") << '\n'
850 << indent << "Profile: " << device.GetProfile() << '\n'
851 << indent << "Driver version: " << device.GetDriverVersion() << '\n'
852 << indent << "Name: " << device.GetName() << '\n'
853 << indent << "Vendor: " << device.GetVendor() << '\n'
854 << indent << "Language Version: " << device.GetLanguageVersion() << std::endl;
855
856 const std::list<std::string> extensions = device.GetExtensions();
857 const std::size_t extensionsSize = extensions.size();
858 strm << indent << "Extensions(" << extensionsSize << "): ";
859 if (extensionsSize == 0)
860 {
861 strm << "none";
862 }
863 else
864 {
865 strm << std::endl;
866 for (std::list<std::string>::const_iterator it = extensions.begin(); it != extensions.end(); ++it)
867 {
868 strm << indent << indent << "- " << *it << std::endl;
869 }
870 }
871
872 return strm;
873}
874
875
876} // end namespace itk
877
878#endif /* itkOpenCLDevice_h */
The OpenCLDevice class represents the collection of OpenCL devices to be used by the host.
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())
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.
#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:46
@ VERSION_2_1
Definition itkOpenCL.h:51
@ VERSION_1_2
Definition itkOpenCL.h:49
@ VERSION_1_0
Definition itkOpenCL.h:47
@ VERSION_1_1
Definition itkOpenCL.h:48
@ VERSION_2_0
Definition itkOpenCL.h:50
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo