18 #ifndef __itkOpenCLDevice_h 19 #define __itkOpenCLDevice_h 84 Accelerator = ( 1 << 3 ),
95 bool IsNull()
const {
return this->m_Id == 0; }
109 std::string GetVersion()
const;
119 unsigned int GetVendorId()
const;
122 bool IsAvailable()
const;
125 bool HasCompiler()
const;
129 bool HasNativeKernels()
const;
134 bool HasOutOfOrderExecution()
const;
138 bool HasDouble()
const;
146 bool HasHalfFloat()
const;
150 bool HasErrorCorrectingMemory()
const;
154 bool HasUnifiedMemory()
const;
157 unsigned int GetComputeUnits()
const;
160 unsigned int GetClockFrequency()
const;
164 unsigned int GetAddressBits()
const;
177 std::size_t GetMaximumWorkItemsPerGroup()
const;
180 bool HasImage2D()
const;
183 bool HasImage3D()
const;
187 bool HasWritableImage3D()
const;
201 unsigned int GetMaximumSamplers()
const;
206 unsigned int GetMaximumReadImages()
const;
211 unsigned int GetMaximumWriteImages()
const;
216 unsigned int GetPreferredCharVectorSize()
const;
221 unsigned int GetPreferredShortVectorSize()
const;
226 unsigned int GetPreferredIntVectorSize()
const;
232 unsigned int GetPreferredLongVectorSize()
const;
238 unsigned int GetPreferredFloatVectorSize()
const;
246 unsigned int GetPreferredDoubleVectorSize()
const;
255 unsigned int GetPreferredHalfFloatVectorSize()
const;
261 unsigned int GetNativeCharVectorSize()
const;
267 unsigned int GetNativeShortVectorSize()
const;
273 unsigned int GetNativeIntVectorSize()
const;
279 unsigned int GetNativeLongVectorSize()
const;
285 unsigned int GetNativeFloatVectorSize()
const;
293 unsigned int GetNativeDoubleVectorSize()
const;
301 unsigned int GetNativeHalfFloatVectorSize()
const;
315 NotSupported = 0x0000,
317 InfinityNaN = 0x0002,
318 RoundNearest = 0x0004,
320 RoundInfinity = 0x0010,
321 FusedMultiplyAdd = 0x0020
344 std::size_t GetProfilingTimerResolution()
const;
348 unsigned long GetMaximumAllocationSize()
const;
352 unsigned long GetGlobalMemorySize()
const;
368 CacheType GetGlobalMemoryCacheType()
const;
372 unsigned long GetGlobalMemoryCacheSize()
const;
376 unsigned int GetGlobalMemoryCacheLineSize()
const;
380 unsigned long GetLocalMemorySize()
const;
386 bool IsLocalMemorySeparate()
const;
390 unsigned long GetMaximumConstantBufferSize()
const;
395 unsigned int GetMaximumConstantArguments()
const;
399 unsigned int GetDefaultAlignment()
const;
403 unsigned int GetMinimumAlignment()
const;
407 std::size_t GetMaximumParameterBytes()
const;
411 bool IsFullProfile()
const;
415 bool IsEmbeddedProfile()
const;
420 std::string GetProfile()
const;
424 std::string GetDriverVersion()
const;
427 std::string GetName()
const;
430 std::string GetVendor()
const;
434 std::list< std::string > GetExtensions()
const;
438 std::string GetLanguageVersion()
const;
445 bool HasExtension(
const std::string & name )
const;
449 static std::list< OpenCLDevice > GetAllDevices();
466 static OpenCLDevice GetMaximumFlopsDevice(
const std::list< OpenCLDevice > & devices,
509 template<
typename charT,
typename traits >
511 std::basic_ostream< charT, traits > &
512 operator<<( std::basic_ostream< charT, traits > & strm,
515 if( device.IsNull() )
517 strm <<
"OpenCLDevice(null)";
521 const char indent =
' ';
523 strm <<
"OpenCLDevice" << std::endl
524 << indent <<
"Id: " << device.
GetDeviceId() << std::endl;
526 strm << indent <<
"OpenCL version: ";
527 switch( device.GetOpenCLVersion() )
530 strm <<
"1.0";
break;
532 strm <<
"1.1";
break;
534 strm <<
"1.2";
break;
536 strm <<
"2.0";
break;
538 strm <<
"Unknown";
break;
541 strm << std::endl << indent <<
"Version: " << device.GetVersion() << std::endl;
543 strm << indent <<
"Device type: ";
544 switch( device.GetDeviceType() )
547 strm <<
"Default";
break;
549 strm <<
"CPU";
break;
551 strm <<
"GPU";
break;
553 strm <<
"Accelerator";
break;
555 strm <<
"All";
break;
557 strm <<
"Unknown";
break;
561 strm << std::endl << indent <<
"Vendor Id: " << device.GetVendorId() << std::endl
562 << indent <<
"Available: " << ( device.IsAvailable() ?
"Yes" :
"No" ) << std::endl
563 << indent <<
"Has compiler: " << ( device.HasCompiler() ?
"Yes" :
"No" ) << std::endl
564 << indent <<
"Has native kernels: " << ( device.HasNativeKernels() ?
"Yes" :
"No" ) << std::endl
565 << indent <<
"Has out of order execution: " << ( device.HasOutOfOrderExecution() ?
"Yes" :
"No" ) << std::endl
566 << indent <<
"Has double: " << ( device.HasDouble() ?
"Yes" :
"No" ) << std::endl
567 << indent <<
"Has half float: " << ( device.HasHalfFloat() ?
"Yes" :
"No" ) << std::endl
568 << indent <<
"Has error correcting memory: " << ( device.HasErrorCorrectingMemory() ?
"Yes" :
"No" ) << std::endl
569 << indent <<
"Has unified memory: " << ( device.HasUnifiedMemory() ?
"Yes" :
"No" ) << std::endl
570 << indent <<
"Compute units: " << device.GetComputeUnits() << std::endl
571 << indent <<
"Clock frequency: " << device.GetClockFrequency() << std::endl
572 << indent <<
"Address bits: " << device.GetAddressBits() << std::endl;
574 strm << indent <<
"Byte order: ";
575 switch( device.GetByteOrder() )
578 strm <<
"Big Endian";
break;
580 strm <<
"Little Endian";
break;
582 strm <<
"Unknown";
break;
585 strm << std::endl << indent <<
"Maximum work item size: " << device.GetMaximumWorkItemSize() << std::endl
586 << indent <<
"Maximum work items per group: " << device.GetMaximumWorkItemsPerGroup() << std::endl
587 << indent <<
"Maximum work items per group: " << device.GetMaximumWorkItemsPerGroup() << std::endl;
590 const bool hasImage2D = device.HasImage2D();
591 strm << indent <<
"Has image 2D: " << ( hasImage2D ?
"Yes" :
"No" ) << std::endl;
594 strm << indent <<
"Maximum image 2D size: " << device.GetMaximumImage2DSize() << std::endl;
598 const bool hasImage3D = device.HasImage3D();
599 strm << indent <<
"Has image 3D: " << ( hasImage3D ?
"Yes" :
"No" ) << std::endl;
602 strm << indent <<
"Maximum image 3D size: " << device.GetMaximumImage3DSize() << std::endl;
605 strm << indent <<
"Has writable image 3D: " << ( device.HasWritableImage3D() ?
"Yes" :
"No" ) << std::endl
606 << indent <<
"Maximum samplers: " << device.GetMaximumSamplers() << std::endl
607 << indent <<
"Maximum read images: " << device.GetMaximumReadImages() << std::endl
608 << indent <<
"Maximum write images: " << device.GetMaximumWriteImages() << std::endl
610 << indent <<
"Preferred char vector size: " << device.GetPreferredCharVectorSize() << std::endl
611 << indent <<
"Preferred short vector size: " << device.GetPreferredShortVectorSize() << std::endl
612 << indent <<
"Preferred int vector size: " << device.GetPreferredIntVectorSize() << std::endl
613 << indent <<
"Preferred long vector size: " << device.GetPreferredLongVectorSize() << std::endl
614 << indent <<
"Preferred float vector size: " << device.GetPreferredFloatVectorSize() << std::endl
615 << indent <<
"Preferred double vector size: " << device.GetPreferredDoubleVectorSize() << std::endl
616 << indent <<
"Preferred half float vector size: " << device.GetPreferredHalfFloatVectorSize() << std::endl
618 << indent <<
"Native char vector size: " << device.GetNativeCharVectorSize() << std::endl
619 << indent <<
"Native short vector size: " << device.GetNativeShortVectorSize() << std::endl
620 << indent <<
"Native int vector size: " << device.GetNativeIntVectorSize() << std::endl
621 << indent <<
"Native long vector size: " << device.GetNativeLongVectorSize() << std::endl
622 << indent <<
"Native float vector size: " << device.GetNativeFloatVectorSize() << std::endl
623 << indent <<
"Native double vector size: " << device.GetNativeDoubleVectorSize() << std::endl
624 << indent <<
"Native half float vector size: " << device.GetNativeHalfFloatVectorSize() << std::endl;
626 strm << indent <<
"Float capabilities: ";
627 switch( device.GetFloatCapabilities() )
630 strm <<
"Not supported";
break;
632 strm <<
"Denorm";
break;
634 strm <<
"Infinity nan";
break;
636 strm <<
"Round nearest";
break;
638 strm <<
"Round zero";
break;
640 strm <<
"Round infinity";
break;
642 strm <<
"Fused multiply add";
break;
644 strm <<
"Unknown";
break;
647 strm << std::endl << indent <<
"Double capabilities: ";
648 switch( device.GetDoubleCapabilities() )
651 strm <<
"Not supported";
break;
653 strm <<
"Denorm";
break;
655 strm <<
"Infinity NaN";
break;
657 strm <<
"Round nearest";
break;
659 strm <<
"Round zero";
break;
661 strm <<
"Round infinity";
break;
663 strm <<
"Fused multiply add";
break;
665 strm <<
"Unknown";
break;
668 strm << std::endl << indent <<
"Half float capabilities: ";
669 switch( device.GetHalfFloatCapabilities() )
672 strm <<
"Not supported";
break;
674 strm <<
"Denorm";
break;
676 strm <<
"Infinity NaN";
break;
678 strm <<
"Round nearest";
break;
680 strm <<
"Round zero";
break;
682 strm <<
"Round infinity";
break;
684 strm <<
"Fused multiply add";
break;
686 strm <<
"Unknown";
break;
689 strm << std::endl << indent <<
"Profiling timer resolution: " << device.GetProfilingTimerResolution() << std::endl
690 << indent <<
"Maximum allocation size: " << device.GetMaximumAllocationSize() << std::endl
691 << indent <<
"Global memory size: " << device.GetGlobalMemorySize() << std::endl;
693 strm << indent <<
"Global memory cache type: ";
694 switch( device.GetGlobalMemoryCacheType() )
697 strm <<
"No cache";
break;
699 strm <<
"Read only cache";
break;
701 strm <<
"Read write cache";
break;
703 strm <<
"Unknown";
break;
706 strm << std::endl << indent <<
"Global memory cache size: " << device.GetGlobalMemoryCacheSize() << std::endl
707 << indent <<
"Global memory cache line size: " << device.GetGlobalMemoryCacheLineSize() << std::endl
708 << indent <<
"Local memory size: " << device.GetLocalMemorySize() << std::endl
709 << indent <<
"Local memory separated: " << ( device.IsLocalMemorySeparate() ?
"Yes" :
"No" ) << std::endl
710 << indent <<
"Maximum constant buffer size: " << device.GetMaximumConstantBufferSize() << std::endl
711 << indent <<
"Maximum constant arguments: " << device.GetMaximumConstantArguments() << std::endl
712 << indent <<
"Default alignment: " << device.GetDefaultAlignment() << std::endl
713 << indent <<
"Minimum alignment: " << device.GetMinimumAlignment() << std::endl
714 << indent <<
"Maximum parameter bytes: " << device.GetMaximumParameterBytes() << std::endl
715 << indent <<
"Full profile: " << ( device.IsFullProfile() ?
"Yes" :
"No" ) << std::endl
716 << indent <<
"Embedded profile: " << ( device.IsEmbeddedProfile() ?
"Yes" :
"No" ) << std::endl
717 << indent <<
"Profile: " << device.GetProfile() << std::endl
718 << indent <<
"Driver version: " << device.GetDriverVersion() << std::endl
719 << indent <<
"Name: " << device.GetName() << std::endl
720 << indent <<
"Vendor: " << device.GetVendor() << std::endl
721 << indent <<
"Language Version: " << device.GetLanguageVersion() << std::endl;
723 const std::list< std::string > extensions = device.GetExtensions();
724 const std::size_t extensionsSize = extensions.size();
725 strm << indent <<
"Extensions(" << extensionsSize <<
"): ";
726 if( extensionsSize == 0 )
733 for( std::list< std::string >::const_iterator it = extensions.begin(); it != extensions.end(); ++it )
735 strm << indent << indent <<
"- " << *it << std::endl;
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
OpenCLDevice(cl_device_id id)
bool ITKOpenCL_EXPORT operator==(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
bool ITKOpenCL_EXPORT operator!=(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
The OpenCLDevice class represents the collection of OpenCL devices to be used by the host...
cl_device_id GetDeviceId() const