43
43
#include < list>
44
44
#include < map>
45
45
#include < deque>
46
+ #include < set>
46
47
#include < string>
47
48
#include < sstream>
48
49
#include < iostream> // std::cerr
@@ -518,6 +519,7 @@ struct Device::Impl
518
519
519
520
name_ = getStrProp (CL_DEVICE_NAME);
520
521
version_ = getStrProp (CL_DEVICE_VERSION);
522
+ extensions_ = getStrProp (CL_DEVICE_EXTENSIONS);
521
523
doubleFPConfig_ = getProp<cl_device_fp_config, int >(CL_DEVICE_DOUBLE_FP_CONFIG);
522
524
hostUnifiedMemory_ = getBoolProp (CL_DEVICE_HOST_UNIFIED_MEMORY);
523
525
maxComputeUnits_ = getProp<cl_uint, int >(CL_DEVICE_MAX_COMPUTE_UNITS);
@@ -528,6 +530,20 @@ struct Device::Impl
528
530
String deviceVersion_ = getStrProp (CL_DEVICE_VERSION);
529
531
parseDeviceVersion (deviceVersion_, deviceVersionMajor_, deviceVersionMinor_);
530
532
533
+ size_t pos = 0 ;
534
+ while (pos < extensions_.size ())
535
+ {
536
+ size_t pos2 = extensions_.find (' ' , pos);
537
+ if (pos2 == String::npos)
538
+ pos2 = extensions_.size ();
539
+ if (pos2 > pos)
540
+ {
541
+ std::string extensionName = extensions_.substr (pos, pos2 - pos);
542
+ extensions_set_.insert (extensionName);
543
+ }
544
+ pos = pos2 + 1 ;
545
+ }
546
+
531
547
intelSubgroupsSupport_ = isExtensionSupported (" cl_intel_subgroups" );
532
548
533
549
vendorName_ = getStrProp (CL_DEVICE_VENDOR);
@@ -569,23 +585,19 @@ struct Device::Impl
569
585
sz < sizeof (buf) ? String (buf) : String ();
570
586
}
571
587
572
- bool isExtensionSupported (const String & extensionName) const
588
+ bool isExtensionSupported (const std::string & extensionName) const
573
589
{
574
- bool ret = false ;
575
- size_t pos = getStrProp (CL_DEVICE_EXTENSIONS).find (extensionName);
576
- if (pos != String::npos)
577
- {
578
- ret = true ;
579
- }
580
- return ret;
590
+ return extensions_set_.count (extensionName) > 0 ;
581
591
}
582
592
583
593
584
594
IMPLEMENT_REFCOUNTABLE ();
595
+
585
596
cl_device_id handle;
586
597
587
598
String name_;
588
599
String version_;
600
+ std::string extensions_;
589
601
int doubleFPConfig_;
590
602
bool hostUnifiedMemory_;
591
603
int maxComputeUnits_;
@@ -597,6 +609,8 @@ struct Device::Impl
597
609
String vendorName_;
598
610
int vendorID_;
599
611
bool intelSubgroupsSupport_;
612
+
613
+ std::set<std::string> extensions_set_;
600
614
};
601
615
602
616
@@ -651,7 +665,10 @@ String Device::name() const
651
665
{ return p ? p->name_ : String (); }
652
666
653
667
String Device::extensions () const
654
- { return p ? p->getStrProp (CL_DEVICE_EXTENSIONS) : String (); }
668
+ { return p ? String (p->extensions_ ) : String (); }
669
+
670
+ bool Device::isExtensionSupported (const String& extensionName) const
671
+ { return p ? p->isExtensionSupported (extensionName) : false ; }
655
672
656
673
String Device::version () const
657
674
{ return p ? p->version_ : String (); }
@@ -744,16 +761,7 @@ bool Device::imageSupport() const
744
761
745
762
bool Device::imageFromBufferSupport () const
746
763
{
747
- bool ret = false ;
748
- if (p)
749
- {
750
- size_t pos = p->getStrProp (CL_DEVICE_EXTENSIONS).find (" cl_khr_image2d_from_buffer" );
751
- if (pos != String::npos)
752
- {
753
- ret = true ;
754
- }
755
- }
756
- return ret;
764
+ return p ? p->isExtensionSupported (" cl_khr_image2d_from_buffer" ) : false ;
757
765
}
758
766
759
767
uint Device::imagePitchAlignment () const
0 commit comments