From 3466d6f87bc5e0f720dd9a538cd491c5439fe893 Mon Sep 17 00:00:00 2001 From: nscipione Date: Fri, 6 Sep 2024 09:52:25 +0100 Subject: [PATCH] Move generic_device support pragma Moved pragma and simplified if-statement to increase code readability --- src/include/function_table_initializer.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/include/function_table_initializer.hpp b/src/include/function_table_initializer.hpp index 880035759..afa831750 100644 --- a/src/include/function_table_initializer.hpp +++ b/src/include/function_table_initializer.hpp @@ -67,6 +67,12 @@ class table_initializer { } private: +#ifdef ENABLE_PORTBLAS_BACKEND + static constexpr bool is_generic_device_supported = true; +#else + static constexpr bool is_generic_device_supported = false; +#endif + #ifdef _WIN64 // Create a string with last error message std::string GetLastErrorStdStr() { @@ -99,17 +105,14 @@ class table_initializer { break; } if (!handle) { -#ifndef ENABLE_PORTBLAS_BACKEND - if (key == oneapi::mkl::device::generic_device) { + if constexpr (!is_generic_device_supported && + key == oneapi::mkl::device::generic_device) { throw mkl::unsupported_device("", "", q.get_device()); } else { -#endif std::cerr << ERROR_MSG << '\n'; throw mkl::backend_not_found(); -#ifndef ENABLE_PORTBLAS_BACKEND } -#endif } auto t = reinterpret_cast(::GET_FUNC(handle.get(), table_names[domain_id]));