From abff9735090109898cf3168ce9ee9295912a65e5 Mon Sep 17 00:00:00 2001 From: Kris Rowe Date: Mon, 19 Dec 2022 21:18:25 +0000 Subject: [PATCH] Updates DPCPP polyfill and function calls. --- src/occa/internal/modes/dpcpp/device.cpp | 2 +- src/occa/internal/modes/dpcpp/polyfill.hpp | 686 +++++++----------- .../internal/modes/dpcpp/registration.cpp | 4 - 3 files changed, 274 insertions(+), 418 deletions(-) diff --git a/src/occa/internal/modes/dpcpp/device.cpp b/src/occa/internal/modes/dpcpp/device.cpp index 6b9b65f47..a34e2f5af 100644 --- a/src/occa/internal/modes/dpcpp/device.cpp +++ b/src/occa/internal/modes/dpcpp/device.cpp @@ -323,7 +323,7 @@ namespace occa dim device::maxInnerDims() const { - ::sycl::id<3> max_wi_sizes{dpcppDevice.get_info<::sycl::info::device::max_work_item_sizes>()}; + ::sycl::id<3> max_wi_sizes{dpcppDevice.get_info<::sycl::info::device::max_work_item_sizes<3>>()}; return dim{max_wi_sizes[occa::dpcpp::x_index], max_wi_sizes[occa::dpcpp::y_index], max_wi_sizes[occa::dpcpp::z_index]}; diff --git a/src/occa/internal/modes/dpcpp/polyfill.hpp b/src/occa/internal/modes/dpcpp/polyfill.hpp index 888239dde..6147c65cd 100644 --- a/src/occa/internal/modes/dpcpp/polyfill.hpp +++ b/src/occa/internal/modes/dpcpp/polyfill.hpp @@ -7,459 +7,319 @@ #include #else #include -namespace sycl -{ - class device; - class platform; - - template - struct id - { - std::size_t values_[N]; - - std::size_t operator[](int dimension) const - { - return values_[dimension]; - } - }; - - template - struct range - { - std::size_t values_[N]; - }; - - template - struct nd_range - { - range global_range_; - range local_range_; - }; - - class exception : std::exception - { - public: - inline const char *what() const noexcept - { - return "Error-DPC++ not enabled!"; - } - }; - - namespace info - { - enum class device - { - device_type, - max_compute_units, - global_mem_size, - local_mem_size, - platform, - name, - vendor, - version, - max_work_item_sizes, - max_work_group_size - }; - - enum class device_type - { - cpu, - gpu, - accelerator, - all = (cpu | gpu | accelerator) - }; - - enum class platform - { - profile, - version, - name, - vendor - }; - - enum class event_profiling - { - command_submit, - command_start, - command_end - }; - - template - class param_traits - { - }; - - template <> - class param_traits - { - public: - using return_type = uint32_t; - }; - - template <> - class param_traits - { - public: - using return_type = uint64_t; - }; - - template <> - class param_traits - { - public: - using return_type = uint64_t; - }; - - template <> - class param_traits - { - public: - using return_type = std::string; - }; - - template <> - class param_traits - { - public: - using return_type = std::string; - }; - - template <> - class param_traits - { - public: - using return_type = std::string; - }; - - template <> - class param_traits - { - public: - using return_type = id<3>; - }; - - template <> - class param_traits - { - public: - using return_type = std::size_t; - }; - - template <> - class param_traits - { - public: - using return_type = info::device_type; - }; - - template <> - class param_traits - { - public: - using return_type = std::string; - }; - - template <> - class param_traits - { - public: - using return_type = std::string; - }; - - template <> - class param_traits - { - public: - using return_type = std::string; - }; - - template - class param_traits - { - public: - using return_type = uint64_t; - }; - } // namespace info - - namespace property { - namespace queue { - class enable_profiling - { - }; - } +namespace sycl { + +class device; +class platform; + +template +struct id { + std::size_t values_[N]; + std::size_t operator[](int dimension) const {return values_[dimension];} +}; + +template +struct range { + std::size_t values_[N]; +}; + +template +struct nd_range { + range global_range_; + range local_range_; +}; + +class exception : std::exception { +public: + inline const char *what() const noexcept { + return "Error-DPC++ not enabled!"; } +}; - namespace property { - namespace queue { - class in_order - { - }; - } - } +namespace info { - class property_list { - public: - template property_list(propertyTN... props) - { - throw sycl::exception(); - } - }; +enum class device_type { + cpu, + gpu, + accelerator, + all = (cpu | gpu | accelerator) +}; - class device - { - public: - static std::vector get_devices() - { - throw sycl::exception(); - return std::vector(); - } - - template - typename info::param_traits::return_type get_info() const; - - bool is_cpu() const - { - throw sycl::exception(); - return false; - } - - bool is_gpu() const - { - throw sycl::exception(); - return false; - } - - bool is_accelerator() const - { - throw sycl::exception(); - return false; - } - - bool is_host() const - { - throw sycl::exception(); - return false; - } - - sycl::platform get_platform() const; - }; - - template <> - inline info::param_traits::return_type - device::get_info() const - { - throw sycl::exception(); - return uint32_t(0); - } +enum class event_profiling { + command_submit, + command_start, + command_end +}; - template <> - inline info::param_traits::return_type - device::get_info() const - { - throw sycl::exception(); - return uint64_t(0); - } +namespace device { - template <> - inline info::param_traits::return_type - device::get_info() const - { - throw sycl::exception(); - return uint64_t(0); - } +struct device_type { + using return_type = info::device_type; +}; - template <> - inline info::param_traits::return_type - device::get_info() const - { - throw sycl::exception(); - return "Error--DPC++ not enabled!"; - } +struct max_compute_units { + using return_type = uint32_t; +}; - template <> - inline info::param_traits::return_type - device::get_info() const - { - throw sycl::exception(); - return "Error--DPC++ not enabled!"; - } +struct global_mem_size { + using return_type = uint64_t; +}; - template <> - inline info::param_traits::return_type - device::get_info() const - { - throw sycl::exception(); - return "Error--DPC++ not enabled!"; - } +struct local_mem_size { + using return_type = uint64_t; +}; + +struct name { + using return_type = std::string; +}; + +struct vendor { + using return_type = std::string; +}; + +struct version { + using return_type = std::string; +}; + +template struct max_work_item_sizes; +template<> struct max_work_item_sizes<3> { + using return_type = id<3>; +}; - template <> - inline info::param_traits::return_type - device::get_info() const - { +struct max_work_group_size { + using return_type = std::size_t; +}; + +} // namespace device + +namespace platform { + +struct name { + using return_type = std::string; +}; + +struct vendor { + using return_type = std::string; +}; + +struct version { + using return_type = std::string; +}; + +} // namespace platform +} // namespace info + + +namespace property { +namespace queue { + +struct enable_profiling {}; +struct in_order {}; + +} // namespace queue +} // namespace property + +class property_list { +public: + template + property_list(propertyTN... props) { throw sycl::exception(); - return info::device_type::all; } +}; - template <> - inline info::param_traits::return_type - device::get_info() const - { +class device { +public: + static std::vector get_devices() { throw sycl::exception(); - return sycl::id<3>{0,0,0}; + return std::vector(); } - template <> - inline info::param_traits::return_type - device::get_info() const - { + template + typename T::return_type get_info() const; + + bool is_cpu() const { throw sycl::exception(); - return std::size_t(0); + return false; } - class platform - { - public: - static std::vector get_platforms() - { - throw sycl::exception(); - return std::vector(); - } - - std::vector get_devices(info::device_type = info::device_type::all) - { - throw sycl::exception(); - return std::vector(); - } - - template - typename info::param_traits::return_type get_info() const; - - bool is_host() const - { - throw sycl::exception(); - return false; - } - }; - - template <> - inline info::param_traits::return_type - platform::get_info() const - { + bool is_gpu() const { throw sycl::exception(); - return "Error--DPC++ not enabled!"; + return false; } - template <> - inline info::param_traits::return_type - platform::get_info() const - { + bool is_accelerator() const { throw sycl::exception(); - return "Error--DPC++ not enabled!"; + return false; } - - template <> - inline info::param_traits::return_type - platform::get_info() const - { + + sycl::platform get_platform() const; +}; + +template <> +inline info::device::max_compute_units::return_type +device::get_info() const { + throw sycl::exception(); + return uint32_t(0); +} + +template <> +inline info::device::global_mem_size::return_type +device::get_info() const { + throw sycl::exception(); + return uint64_t(0); +} + +template <> +inline info::device::local_mem_size::return_type +device::get_info() const { + throw sycl::exception(); + return uint64_t(0); +} + +template <> +inline info::device::name::return_type +device::get_info() const { + throw sycl::exception(); + return "Error--DPC++ not enabled!"; +} + +template <> +inline info::device::vendor::return_type +device::get_info() const { + throw sycl::exception(); + return "Error--DPC++ not enabled!"; +} + +template <> +inline info::device::version::return_type +device::get_info() const { + throw sycl::exception(); + return "Error--DPC++ not enabled!"; +} + +template <> +inline info::device::device_type::return_type +device::get_info() const { + throw sycl::exception(); + return info::device_type::all; +} + +template <> +inline info::device::max_work_item_sizes<3>::return_type +device::get_info>() const { + throw sycl::exception(); + return sycl::id<3>{0,0,0}; +} + +template <> +inline info::device::max_work_group_size::return_type +device::get_info() const { + throw sycl::exception(); + return std::size_t(0); +} + +class platform { + public: + static std::vector get_platforms() { throw sycl::exception(); - return "Error--DPC++ not enabled!"; + return std::vector(); } - inline platform device::get_platform() const - { - throw sycl::exception(); - return platform(); + std::vector get_devices(info::device_type = info::device_type::all) { + throw sycl::exception(); + return std::vector(); } - class context - { - public: - context() = default; - context(const device &syclDevice) - { - } - }; - - class event - { - public: - void wait_and_throw() - { - throw sycl::exception(); - } - - template - typename info::param_traits::return_type get_profiling_info() const - { - throw sycl::exception(); - return uint64_t(0); - } - }; - - // template - // inline info::param_traits::return_type - // event::get_profiling_info() const - // { - // throw sycl::exception(); - // return "Error--DPC++ not enabled!"; - // } - - - class queue - { - public: - queue(const context& syclContext, - const device &syclDevice, - const property_list &propList = {}) - { - throw sycl::exception(); - } - - void wait_and_throw() - { - throw sycl::exception(); - } - - sycl::event memcpy(void* dest,const void* src,size_t num_bytes) - { - return sycl::event(); - } - - sycl::event ext_oneapi_submit_barrier() - { - return sycl::event(); - } - }; - - - inline void* malloc_device(size_t num_bytes, - const device& syclDevice, - const context& syclContext) - { + template + typename T::return_type get_info() const; +}; + +template <> +inline info::platform::name::return_type +platform::get_info() const { + throw sycl::exception(); + return "Error--DPC++ not enabled!"; +} + +template <> +inline info::platform::vendor::return_type +platform::get_info() const { + throw sycl::exception(); + return "Error--DPC++ not enabled!"; +} + +template <> +inline info::platform::version::return_type +platform::get_info() const { + throw sycl::exception(); + return "Error--DPC++ not enabled!"; +} + +inline platform device::get_platform() const { + throw sycl::exception(); + return platform(); +} + +class context { +public: + context() = default; + context(const device &syclDevice){} +}; + +class event { +public: + void wait_and_throw() { throw sycl::exception(); - return nullptr; } - inline void* malloc_host(size_t num_bytes, - const context& syclContext) - { + template + uint64_t get_profiling_info() const { throw sycl::exception(); - return nullptr; + return uint64_t(0); } +}; - inline void* malloc_shared(size_t num_bytes, - const device& syclDevice, - const context& syclContext) - { +class queue { +public: + queue(const context& syclContext, + const device &syclDevice, + const property_list &propList = {}) { throw sycl::exception(); - return nullptr; } - inline void free(void* ptr,context& syclContext) - { - throw sycl::exception(); + void wait_and_throw() {throw sycl::exception();} + + sycl::event memcpy(void* dest,const void* src,size_t num_bytes) { + return sycl::event(); } + sycl::event ext_oneapi_submit_barrier() { return sycl::event();} +}; + +inline void* malloc_device(size_t num_bytes, + const device& syclDevice, + const context& syclContext) { + throw sycl::exception(); + return nullptr; +} + +inline void* malloc_host(size_t num_bytes, + const context& syclContext) { + throw sycl::exception(); + return nullptr; +} + +inline void* malloc_shared(size_t num_bytes, + const device& syclDevice, + const context& syclContext) { + throw sycl::exception(); + return nullptr; +} + +inline void free(void* ptr,context& syclContext) { + throw sycl::exception(); +} + } // namespace sycl #endif diff --git a/src/occa/internal/modes/dpcpp/registration.cpp b/src/occa/internal/modes/dpcpp/registration.cpp index a71d2fca0..0229a5a90 100644 --- a/src/occa/internal/modes/dpcpp/registration.cpp +++ b/src/occa/internal/modes/dpcpp/registration.cpp @@ -46,10 +46,6 @@ namespace occa { { device_type_str = "accelerator"; } - else if(d.is_host()) - { - device_type_str = "host"; - } else { device_type_str = "TYPE UNKNOWN";