@@ -613,47 +613,7 @@ Use 64 bits as memory_bus_width default value."
613613 /// sycl::aspect.
614614 void has_capability_or_fail(
615615 const std::initializer_list<sycl::aspect> &props) const {
616- for (const auto &it : props) {
617- if (has(it))
618- continue;
619- switch (it) {
620- case sycl::aspect::fp64:
621- throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
622- " [SYCLcompat] ' double' is not supported in ' " +
623- get_info<sycl::info::device::name>() +
624- "' device" );
625- break;
626- case sycl::aspect::fp16:
627- throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
628- " [SYCLcompat] ' half' is not supported in ' " +
629- get_info<sycl::info::device::name>() +
630- "' device" );
631- break;
632- default:
633- #define __SYCL_ASPECT(ASPECT, ID) \
634- case sycl::aspect::ASPECT: \
635- return #ASPECT;
636- #define __SYCL_ASPECT_DEPRECATED(ASPECT, ID, MESSAGE) __SYCL_ASPECT(ASPECT, ID)
637- #define __SYCL_ASPECT_DEPRECATED_ALIAS(ASPECT, ID, MESSAGE)
638- auto getAspectNameStr = [](sycl::aspect AspectNum) -> std::string {
639- switch (AspectNum) {
640- #include <sycl/info/aspects.def>
641- #include <sycl/info/aspects_deprecated.def>
642- default:
643- return " unknown aspect" ;
644- }
645- };
646- #undef __SYCL_ASPECT_DEPRECATED_ALIAS
647- #undef __SYCL_ASPECT_DEPRECATED
648- #undef __SYCL_ASPECT
649- throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
650- " [SYCLcompat] ' " + getAspectNameStr(it) +
651- "' is not supported in ' " +
652- get_info<sycl::info::device::name>() +
653- "' device" );
654- }
655- break;
656- }
616+ ::syclcompat::has_capability_or_fail(*this, props);
657617 }
658618
659619private:
@@ -963,6 +923,45 @@ static inline unsigned int device_count() {
963923static inline void
964924has_capability_or_fail(const sycl::device &dev,
965925 const std::initializer_list<sycl::aspect> &props) {
966- get_device(get_device_id(dev)).has_capability_or_fail(props);
926+ for (const auto &it : props) {
927+ if (dev.has(it))
928+ continue;
929+ switch (it) {
930+ case sycl::aspect::fp64:
931+ throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
932+ " [SYCLcompat] ' double' is not supported in ' " +
933+ dev.get_info<sycl::info::device::name>() +
934+ "' device" );
935+ break;
936+ case sycl::aspect::fp16:
937+ throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
938+ " [SYCLcompat] ' half' is not supported in ' " +
939+ dev.get_info<sycl::info::device::name>() +
940+ "' device" );
941+ break;
942+ default:
943+ #define __SYCL_ASPECT(ASPECT, ID) \
944+ case sycl::aspect::ASPECT: \
945+ return #ASPECT;
946+ #define __SYCL_ASPECT_DEPRECATED(ASPECT, ID, MESSAGE) __SYCL_ASPECT(ASPECT, ID)
947+ #define __SYCL_ASPECT_DEPRECATED_ALIAS(ASPECT, ID, MESSAGE)
948+ auto getAspectNameStr = [](sycl::aspect AspectNum) -> std::string {
949+ switch (AspectNum) {
950+ #include <sycl/info/aspects.def>
951+ #include <sycl/info/aspects_deprecated.def>
952+ default:
953+ return " unknown aspect" ;
954+ }
955+ };
956+ #undef __SYCL_ASPECT_DEPRECATED_ALIAS
957+ #undef __SYCL_ASPECT_DEPRECATED
958+ #undef __SYCL_ASPECT
959+ throw sycl::exception(
960+ sycl::make_error_code(sycl::errc::runtime),
961+ " [SYCLcompat] ' " + getAspectNameStr(it) + "' is not supported in ' " +
962+ dev.get_info<sycl::info::device::name>() + "' device" );
963+ }
964+ break;
965+ }
967966}
968967} // namespace syclcompat
0 commit comments