From 3b8c490d3da3b733ce8d35eece1a8719c21a8e62 Mon Sep 17 00:00:00 2001 From: Alexander Batashev Date: Tue, 14 Apr 2020 10:19:10 +0300 Subject: [PATCH 1/2] [SYCL] Move get_info_host implementation to header Signed-off-by: Alexander Batashev --- sycl/source/CMakeLists.txt | 9 +- sycl/source/detail/device_info.cpp | 534 ------------------------- sycl/source/detail/device_info.hpp | 569 ++++++++++++++++++++++++++- sycl/source/detail/kernel_info.cpp | 54 --- sycl/source/detail/kernel_info.hpp | 40 +- sycl/source/detail/platform_info.cpp | 40 -- sycl/source/detail/platform_info.hpp | 27 +- 7 files changed, 607 insertions(+), 666 deletions(-) delete mode 100644 sycl/source/detail/device_info.cpp delete mode 100644 sycl/source/detail/kernel_info.cpp delete mode 100644 sycl/source/detail/platform_info.cpp diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index a7e14abc108fb..d4619bfff785b 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -54,9 +54,9 @@ function(add_sycl_rt_library LIB_NAME) endif() target_include_directories( - ${LIB_OBJ_NAME} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} + ${LIB_OBJ_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} "${sycl_inc_dir}" ${OpenCL_INCLUDE_DIRS} ) @@ -91,7 +91,6 @@ set(SYCL_SOURCES "detail/config.cpp" "detail/context_impl.cpp" "detail/device_impl.cpp" - "detail/device_info.cpp" "detail/error_handling/enqueue_kernel.cpp" "detail/event_impl.cpp" "detail/force_device.cpp" @@ -99,11 +98,9 @@ set(SYCL_SOURCES "detail/image_accessor_util.cpp" "detail/image_impl.cpp" "detail/kernel_impl.cpp" - "detail/kernel_info.cpp" "detail/kernel_program_cache.cpp" "detail/memory_manager.cpp" "detail/platform_impl.cpp" - "detail/platform_info.cpp" "detail/program_impl.cpp" "detail/program_manager/program_manager.cpp" "detail/queue_impl.cpp" diff --git a/sycl/source/detail/device_info.cpp b/sycl/source/detail/device_info.cpp deleted file mode 100644 index 9135f0b1c9c92..0000000000000 --- a/sycl/source/detail/device_info.cpp +++ /dev/null @@ -1,534 +0,0 @@ -//==----------- device_info.cpp --------------------------------*- C ++-*---==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef __GNUG__ -#define GCC_VERSION \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#endif - -__SYCL_INLINE_NAMESPACE(cl) { -namespace sycl { -namespace detail { - -// Specialization for parent device -template <> -device get_device_info::get( - RT::PiDevice dev, const plugin &Plugin) { - - typename sycl_to_pi::type result; - Plugin.call( - dev, pi::cast(info::device::parent_device), - sizeof(result), &result, nullptr); - if (result == nullptr) - throw invalid_object_error( - "No parent for device because it is not a subdevice", - PI_INVALID_DEVICE); - - return createSyclObjFromImpl( - std::make_shared(result, Plugin)); -} - -vector_class read_fp_bitfield(cl_device_fp_config bits) { - vector_class result; - if (bits & CL_FP_DENORM) - result.push_back(info::fp_config::denorm); - if (bits & CL_FP_INF_NAN) - result.push_back(info::fp_config::inf_nan); - if (bits & CL_FP_ROUND_TO_NEAREST) - result.push_back(info::fp_config::round_to_nearest); - if (bits & CL_FP_ROUND_TO_ZERO) - result.push_back(info::fp_config::round_to_zero); - if (bits & CL_FP_ROUND_TO_INF) - result.push_back(info::fp_config::round_to_inf); - if (bits & CL_FP_FMA) - result.push_back(info::fp_config::fma); - if (bits & CL_FP_SOFT_FLOAT) - result.push_back(info::fp_config::soft_float); - if (bits & CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT) - result.push_back(info::fp_config::correctly_rounded_divide_sqrt); - return result; -} - -vector_class -read_domain_bitfield(cl_device_affinity_domain bits) { - vector_class result; - if (bits & CL_DEVICE_AFFINITY_DOMAIN_NUMA) - result.push_back(info::partition_affinity_domain::numa); - if (bits & CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE) - result.push_back(info::partition_affinity_domain::L4_cache); - if (bits & CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE) - result.push_back(info::partition_affinity_domain::L3_cache); - if (bits & CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE) - result.push_back(info::partition_affinity_domain::L2_cache); - if (bits & CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE) - result.push_back(info::partition_affinity_domain::L1_cache); - if (bits & CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE) - result.push_back(info::partition_affinity_domain::next_partitionable); - return result; -} - -vector_class -read_execution_bitfield(cl_device_exec_capabilities bits) { - vector_class result; - if (bits & CL_EXEC_KERNEL) - result.push_back(info::execution_capability::exec_kernel); - if (bits & CL_EXEC_NATIVE_KERNEL) - result.push_back(info::execution_capability::exec_native_kernel); - return result; -} - -template <> -info::device_type get_device_info_host() { - return info::device_type::host; -} - -template <> cl_uint get_device_info_host() { - return 0x8086; -} - -template <> cl_uint get_device_info_host() { - return std::thread::hardware_concurrency(); -} - -template <> -cl_uint get_device_info_host() { - return 3; -} - -template <> id<3> get_device_info_host() { - // current value is the required minimum - return {1, 1, 1}; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 1; -} - -template <> -cl_uint get_device_info_host() { - // TODO update when appropriate - return 1; -} - -template <> -cl_uint get_device_info_host() { - // TODO update when appropriate - return 1; -} - -template <> -cl_uint get_device_info_host() { - // TODO update when appropriate - return 1; -} - -template <> -cl_uint get_device_info_host() { - // TODO update when appropriate - return 1; -} - -template <> -cl_uint get_device_info_host() { - // TODO update when appropriate - return 1; -} - -template <> -cl_uint get_device_info_host() { - // TODO update when appropriate - return 1; -} - -template <> -cl_uint get_device_info_host() { - // TODO update when appropriate - return 0; -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Char); -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Short); -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Int); -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Long); -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Float); -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Double); -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Half); -} - -template <> cl_uint get_device_info_host() { - return PlatformUtil::getMaxClockFrequency(); -} - -template <> cl_uint get_device_info_host() { - return sizeof(void *) * 8; -} - -template <> cl_ulong get_device_info_host() { - return static_cast(OSUtil::getOSMemSize()); -} - -template <> cl_ulong get_device_info_host() { - // current value is the required minimum - const cl_ulong a = get_device_info_host() / 4; - const cl_ulong b = 128ul * 1024 * 1024; - return (a > b) ? a : b; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> cl_uint get_device_info_host() { - // current value is the required minimum - return 128; -} - -template <> cl_uint get_device_info_host() { - // current value is the required minimum - return 8; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 8192; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 8192; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 2048; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 2048; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 2048; -} - -template <> size_t get_device_info_host() { - // Not supported in SYCL - return 0; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 2048; -} - -template <> cl_uint get_device_info_host() { - // current value is the required minimum - return 16; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 1024; -} - -template <> cl_uint get_device_info_host() { - return 1024; -} - -template <> -vector_class -get_device_info_host() { - // current value is the required minimum - return {}; -} - -template <> -vector_class -get_device_info_host() { - // current value is the required minimum - return {info::fp_config::round_to_nearest, info::fp_config::inf_nan}; -} - -template <> -vector_class -get_device_info_host() { - // current value is the required minimum - return {info::fp_config::fma, info::fp_config::round_to_nearest, - info::fp_config::round_to_zero, info::fp_config::round_to_inf, - info::fp_config::inf_nan, info::fp_config::denorm}; -} - -template <> -info::global_mem_cache_type -get_device_info_host() { - return info::global_mem_cache_type::read_write; -} - -template <> -cl_uint get_device_info_host() { - return PlatformUtil::getMemCacheLineSize(); -} - -template <> -cl_ulong get_device_info_host() { - return PlatformUtil::getMemCacheSize(); -} - -template <> -cl_ulong get_device_info_host() { - // current value is the required minimum - return 64 * 1024; -} - -template <> cl_uint get_device_info_host() { - // current value is the required minimum - return 8; -} - -template <> -info::local_mem_type get_device_info_host() { - return info::local_mem_type::global; -} - -template <> cl_ulong get_device_info_host() { - // current value is the required minimum - return 32 * 1024; -} - -template <> -bool get_device_info_host() { - return false; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> -size_t get_device_info_host() { - typedef std::ratio_divide - ns_period; - return ns_period::num / ns_period::den; -} - -template <> bool get_device_info_host() { - union { - uint16_t a; - uint8_t b[2]; - } u = {0x0100}; - - return u.b[1]; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> -vector_class -get_device_info_host() { - return {info::execution_capability::exec_kernel}; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> -vector_class -get_device_info_host() { - return {}; -} - -template <> platform get_device_info_host() { - return platform(); -} - -template <> string_class get_device_info_host() { - return "SYCL host device"; -} - -template <> string_class get_device_info_host() { - return ""; -} - -template <> string_class get_device_info_host() { - return "1.2"; -} - -template <> string_class get_device_info_host() { - return "FULL PROFILE"; -} - -template <> string_class get_device_info_host() { - return "1.2"; -} - -template <> -string_class get_device_info_host() { - return "not applicable"; -} - -template <> -vector_class get_device_info_host() { - // TODO update when appropriate - return {}; -} - -template <> size_t get_device_info_host() { - // current value is the required minimum - return 1024 * 1024; -} - -template <> -bool get_device_info_host() { - return false; -} - -template <> device get_device_info_host() { - // TODO: implement host device partitioning - throw runtime_error( - "Partitioning to subdevices of the host device is not implemented yet", - PI_INVALID_DEVICE); -} - -template <> -cl_uint get_device_info_host() { - // TODO update once subdevice creation is enabled - return 1; -} - -template <> -vector_class -get_device_info_host() { - // TODO update once subdevice creation is enabled - return {}; -} - -template <> -vector_class -get_device_info_host() { - // TODO update once subdevice creation is enabled - return {}; -} - -template <> -info::partition_property -get_device_info_host() { - return info::partition_property::no_partition; -} - -template <> -info::partition_affinity_domain -get_device_info_host() { - // TODO update once subdevice creation is enabled - return info::partition_affinity_domain::not_applicable; -} - -template <> cl_uint get_device_info_host() { - // TODO update once subdevice creation is enabled - return 1; -} - -template <> cl_uint get_device_info_host() { - // TODO update once subgroups are enabled - throw runtime_error("Sub-group feature is not supported on HOST device.", - PI_INVALID_DEVICE); -} - -template <> vector_class -get_device_info_host() { - // TODO update once subgroups are enabled - throw runtime_error("Sub-group feature is not supported on HOST device.", - PI_INVALID_DEVICE); -} - -template <> -bool get_device_info_host< - info::device::sub_group_independent_forward_progress>() { - // TODO update once subgroups are enabled - throw runtime_error("Sub-group feature is not supported on HOST device.", - PI_INVALID_DEVICE); -} - -template <> -bool get_device_info_host() { - return false; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> bool get_device_info_host() { - return true; -} - -template <> -bool get_device_info_host() { - return true; -} - -template <> bool get_device_info_host() { - return true; -} - -} // namespace detail -} // namespace sycl -} // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 322201fe242a8..b3acbb86ed299 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -9,22 +9,76 @@ #pragma once #include #include +#include #include +#include #include #include +#include +#include #include +#include +#include + +#ifdef __GNUG__ +#define GCC_VERSION \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#endif + __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { -vector_class read_fp_bitfield(cl_device_fp_config bits); - -vector_class -read_domain_bitfield(cl_device_affinity_domain bits); - -vector_class -read_execution_bitfield(cl_device_exec_capabilities bits); +inline vector_class +read_fp_bitfield(cl_device_fp_config bits) { + vector_class result; + if (bits & CL_FP_DENORM) + result.push_back(info::fp_config::denorm); + if (bits & CL_FP_INF_NAN) + result.push_back(info::fp_config::inf_nan); + if (bits & CL_FP_ROUND_TO_NEAREST) + result.push_back(info::fp_config::round_to_nearest); + if (bits & CL_FP_ROUND_TO_ZERO) + result.push_back(info::fp_config::round_to_zero); + if (bits & CL_FP_ROUND_TO_INF) + result.push_back(info::fp_config::round_to_inf); + if (bits & CL_FP_FMA) + result.push_back(info::fp_config::fma); + if (bits & CL_FP_SOFT_FLOAT) + result.push_back(info::fp_config::soft_float); + if (bits & CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT) + result.push_back(info::fp_config::correctly_rounded_divide_sqrt); + return result; +} + +inline vector_class +read_domain_bitfield(cl_device_affinity_domain bits) { + vector_class result; + if (bits & CL_DEVICE_AFFINITY_DOMAIN_NUMA) + result.push_back(info::partition_affinity_domain::numa); + if (bits & CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE) + result.push_back(info::partition_affinity_domain::L4_cache); + if (bits & CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE) + result.push_back(info::partition_affinity_domain::L3_cache); + if (bits & CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE) + result.push_back(info::partition_affinity_domain::L2_cache); + if (bits & CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE) + result.push_back(info::partition_affinity_domain::L1_cache); + if (bits & CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE) + result.push_back(info::partition_affinity_domain::next_partitionable); + return result; +} + +inline vector_class +read_execution_bitfield(cl_device_exec_capabilities bits) { + vector_class result; + if (bits & CL_EXEC_KERNEL) + result.push_back(info::execution_capability::exec_kernel); + if (bits & CL_EXEC_NATIVE_KERNEL) + result.push_back(info::execution_capability::exec_native_kernel); + return result; +} // Mapping expected SYCL return types to those returned by PI calls template struct sycl_to_pi { using type = T; }; @@ -345,20 +399,511 @@ template <> struct get_device_info, info::device::max_work_item_sizes> { } }; +// Specialization for parent device +template <> struct get_device_info { + static device get(RT::PiDevice dev, const plugin &Plugin) { + typename sycl_to_pi::type result; + Plugin.call( + dev, pi::cast(info::device::parent_device), + sizeof(result), &result, nullptr); + if (result == nullptr) + throw invalid_object_error( + "No parent for device because it is not a subdevice", + PI_INVALID_DEVICE); + + return createSyclObjFromImpl( + std::make_shared(result, Plugin)); + } +}; + // SYCL host device information // Default template is disabled, all possible instantiations are // specified explicitly. template -typename info::param_traits::return_type +inline typename info::param_traits::return_type get_device_info_host() = delete; -#define PARAM_TRAITS_SPEC(param_type, param, ret_type) \ - template <> ret_type get_device_info_host(); +template <> +inline info::device_type get_device_info_host() { + return info::device_type::host; +} + +template <> inline cl_uint get_device_info_host() { + return 0x8086; +} + +template <> +inline cl_uint get_device_info_host() { + return std::thread::hardware_concurrency(); +} + +template <> +inline cl_uint get_device_info_host() { + return 3; +} + +template <> +inline id<3> get_device_info_host() { + // current value is the required minimum + return {1, 1, 1}; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 1; +} + +template <> +inline cl_uint +get_device_info_host() { + // TODO update when appropriate + return 1; +} + +template <> +inline cl_uint +get_device_info_host() { + // TODO update when appropriate + return 1; +} + +template <> +inline cl_uint +get_device_info_host() { + // TODO update when appropriate + return 1; +} + +template <> +inline cl_uint +get_device_info_host() { + // TODO update when appropriate + return 1; +} + +template <> +inline cl_uint +get_device_info_host() { + // TODO update when appropriate + return 1; +} + +template <> +inline cl_uint +get_device_info_host() { + // TODO update when appropriate + return 1; +} + +template <> +inline cl_uint +get_device_info_host() { + // TODO update when appropriate + return 0; +} + +template <> +inline cl_uint get_device_info_host() { + return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Char); +} + +template <> +inline cl_uint get_device_info_host() { + return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Short); +} + +template <> +inline cl_uint get_device_info_host() { + return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Int); +} + +template <> +inline cl_uint get_device_info_host() { + return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Long); +} + +template <> +inline cl_uint get_device_info_host() { + return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Float); +} + +template <> +inline cl_uint +get_device_info_host() { + return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Double); +} + +template <> +inline cl_uint get_device_info_host() { + return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Half); +} + +template <> +inline cl_uint get_device_info_host() { + return PlatformUtil::getMaxClockFrequency(); +} + +template <> inline cl_uint get_device_info_host() { + return sizeof(void *) * 8; +} + +template <> +inline cl_ulong get_device_info_host() { + return static_cast(OSUtil::getOSMemSize()); +} + +template <> +inline cl_ulong get_device_info_host() { + // current value is the required minimum + const cl_ulong a = get_device_info_host() / 4; + const cl_ulong b = 128ul * 1024 * 1024; + return (a > b) ? a : b; +} + +template <> inline bool get_device_info_host() { + return true; +} + +template <> +inline cl_uint get_device_info_host() { + // current value is the required minimum + return 128; +} + +template <> +inline cl_uint get_device_info_host() { + // current value is the required minimum + return 8; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 8192; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 8192; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 2048; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 2048; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 2048; +} + +template <> +inline size_t get_device_info_host() { + // Not supported in SYCL + return 0; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 2048; +} -#include +template <> inline cl_uint get_device_info_host() { + // current value is the required minimum + return 16; +} -#undef PARAM_TRAITS_SPEC +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 1024; +} + +template <> +inline cl_uint get_device_info_host() { + return 1024; +} + +template <> +inline vector_class +get_device_info_host() { + // current value is the required minimum + return {}; +} + +template <> +inline vector_class +get_device_info_host() { + // current value is the required minimum + return {info::fp_config::round_to_nearest, info::fp_config::inf_nan}; +} + +template <> +inline vector_class +get_device_info_host() { + // current value is the required minimum + return {info::fp_config::fma, info::fp_config::round_to_nearest, + info::fp_config::round_to_zero, info::fp_config::round_to_inf, + info::fp_config::inf_nan, info::fp_config::denorm}; +} + +template <> +inline info::global_mem_cache_type +get_device_info_host() { + return info::global_mem_cache_type::read_write; +} + +template <> +inline cl_uint +get_device_info_host() { + return PlatformUtil::getMemCacheLineSize(); +} + +template <> +inline cl_ulong get_device_info_host() { + return PlatformUtil::getMemCacheSize(); +} + +template <> +inline cl_ulong get_device_info_host() { + // current value is the required minimum + return 64 * 1024; +} + +template <> +inline cl_uint get_device_info_host() { + // current value is the required minimum + return 8; +} + +template <> +inline info::local_mem_type +get_device_info_host() { + return info::local_mem_type::global; +} + +template <> +inline cl_ulong get_device_info_host() { + // current value is the required minimum + return 32 * 1024; +} + +template <> +inline bool get_device_info_host() { + return false; +} + +template <> +inline bool get_device_info_host() { + return true; +} + +template <> +inline size_t get_device_info_host() { + typedef std::ratio_divide + ns_period; + return ns_period::num / ns_period::den; +} + +template <> inline bool get_device_info_host() { + union { + uint16_t a; + uint8_t b[2]; + } u = {0x0100}; + + return u.b[1]; +} + +template <> inline bool get_device_info_host() { + return true; +} + +template <> +inline bool get_device_info_host() { + return true; +} + +template <> +inline bool get_device_info_host() { + return true; +} + +template <> +inline vector_class +get_device_info_host() { + return {info::execution_capability::exec_kernel}; +} + +template <> inline bool get_device_info_host() { + return true; +} + +template <> +inline vector_class +get_device_info_host() { + return {}; +} + +template <> inline platform get_device_info_host() { + return platform(); +} + +template <> inline string_class get_device_info_host() { + return "SYCL host device"; +} + +template <> inline string_class get_device_info_host() { + return ""; +} + +template <> +inline string_class get_device_info_host() { + return "1.2"; +} + +template <> inline string_class get_device_info_host() { + return "FULL PROFILE"; +} + +template <> inline string_class get_device_info_host() { + return "1.2"; +} + +template <> +inline string_class get_device_info_host() { + return "not applicable"; +} + +template <> +inline vector_class +get_device_info_host() { + // TODO update when appropriate + return {}; +} + +template <> +inline size_t get_device_info_host() { + // current value is the required minimum + return 1024 * 1024; +} + +template <> +inline bool get_device_info_host() { + return false; +} + +template <> inline device get_device_info_host() { + // TODO: implement host device partitioning + throw runtime_error( + "Partitioning to subdevices of the host device is not implemented yet", + PI_INVALID_DEVICE); +} + +template <> +inline cl_uint get_device_info_host() { + // TODO update once subdevice creation is enabled + return 1; +} + +template <> +inline vector_class +get_device_info_host() { + // TODO update once subdevice creation is enabled + return {}; +} + +template <> +inline vector_class +get_device_info_host() { + // TODO update once subdevice creation is enabled + return {}; +} + +template <> +inline info::partition_property +get_device_info_host() { + return info::partition_property::no_partition; +} + +template <> +inline info::partition_affinity_domain +get_device_info_host() { + // TODO update once subdevice creation is enabled + return info::partition_affinity_domain::not_applicable; +} + +template <> +inline cl_uint get_device_info_host() { + // TODO update once subdevice creation is enabled + return 1; +} + +template <> +inline cl_uint get_device_info_host() { + // TODO update once subgroups are enabled + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); +} + +template <> +inline vector_class +get_device_info_host() { + // TODO update once subgroups are enabled + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); +} + +template <> +inline bool +get_device_info_host() { + // TODO update once subgroups are enabled + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); +} + +template <> +inline bool get_device_info_host() { + return false; +} + +template <> +inline bool get_device_info_host() { + return true; +} + +template <> +inline bool get_device_info_host() { + return true; +} + +template <> +inline bool get_device_info_host() { + return true; +} + +template <> +inline bool +get_device_info_host() { + return true; +} + +template <> +inline bool get_device_info_host() { + return true; +} cl_uint get_native_vector_width(size_t idx); diff --git a/sycl/source/detail/kernel_info.cpp b/sycl/source/detail/kernel_info.cpp deleted file mode 100644 index bced197de0cb6..0000000000000 --- a/sycl/source/detail/kernel_info.cpp +++ /dev/null @@ -1,54 +0,0 @@ -//==-------- kernel_info.cpp - SYCL kernel info methods --------------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include - -__SYCL_INLINE_NAMESPACE(cl) { -namespace sycl { -namespace detail { -template <> -cl::sycl::range<3> -get_kernel_work_group_info_host( - const cl::sycl::device &Dev) { - throw invalid_object_error("This instance of kernel is a host instance", - PI_INVALID_KERNEL); -} - -template <> -size_t -get_kernel_work_group_info_host( - const cl::sycl::device &Dev) { - return Dev.get_info(); -} - -template <> -cl::sycl::range<3> get_kernel_work_group_info_host< - info::kernel_work_group::compile_work_group_size>( - const cl::sycl::device &Dev) { - return {0, 0, 0}; -} - -template <> -size_t get_kernel_work_group_info_host< - info::kernel_work_group::preferred_work_group_size_multiple>( - const cl::sycl::device &Dev) { - return get_kernel_work_group_info_host< - info::kernel_work_group::work_group_size>(Dev); -} - -template <> -cl_ulong -get_kernel_work_group_info_host( - const cl::sycl::device &Dev) { - return 0; -} - -} // namespace detail -} // namespace sycl -} // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index 66a65bafec6aa..e5a8adf242ddd 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -58,8 +59,8 @@ struct get_kernel_work_group_info { T Result; // TODO catch an exception and put it to list of asynchronous exceptions Plugin.call( - Kernel, Device, pi::cast(Param), sizeof(T), &Result, - nullptr); + Kernel, Device, pi::cast(Param), sizeof(T), + &Result, nullptr); return Result; } }; @@ -78,34 +79,45 @@ struct get_kernel_work_group_info, Param> { }; template -typename info::param_traits::return_type +inline typename info::param_traits::return_type get_kernel_work_group_info_host(const cl::sycl::device &Device); template <> -cl::sycl::range<3> +inline cl::sycl::range<3> get_kernel_work_group_info_host( - const cl::sycl::device &Device); + const cl::sycl::device &Dev) { + throw invalid_object_error("This instance of kernel is a host instance", + PI_INVALID_KERNEL); +} template <> -size_t +inline size_t get_kernel_work_group_info_host( - const cl::sycl::device &Device); + const cl::sycl::device &Dev) { + return Dev.get_info(); +} template <> -cl::sycl::range<3> get_kernel_work_group_info_host< +inline cl::sycl::range<3> get_kernel_work_group_info_host< info::kernel_work_group::compile_work_group_size>( - const cl::sycl::device &Device); + const cl::sycl::device &Dev) { + return {0, 0, 0}; +} template <> -size_t get_kernel_work_group_info_host< +inline size_t get_kernel_work_group_info_host< info::kernel_work_group::preferred_work_group_size_multiple>( - const cl::sycl::device &Device); + const cl::sycl::device &Dev) { + return get_kernel_work_group_info_host< + info::kernel_work_group::work_group_size>(Dev); +} template <> -cl_ulong +inline cl_ulong get_kernel_work_group_info_host( - const cl::sycl::device &Device); - + const cl::sycl::device &Dev) { + return 0; +} // The kernel sub-group methods template diff --git a/sycl/source/detail/platform_info.cpp b/sycl/source/detail/platform_info.cpp deleted file mode 100644 index 8f32d50432561..0000000000000 --- a/sycl/source/detail/platform_info.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//==----------- platform_info.cpp -----------------------------------------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -__SYCL_INLINE_NAMESPACE(cl) { -namespace sycl { -namespace detail { - -template <> string_class get_platform_info_host() { - return "FULL PROFILE"; -} - -template <> string_class get_platform_info_host() { - return "1.2"; -} - -template <> string_class get_platform_info_host() { - return "SYCL host platform"; -} - -template <> string_class get_platform_info_host() { - return ""; -} - -template <> -vector_class -get_platform_info_host() { - // TODO update when appropriate - return {}; -} - -} // namespace detail -} // namespace sycl -} // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/platform_info.hpp b/sycl/source/detail/platform_info.hpp index e9caa58db140d..1ba1c970e8fe4 100644 --- a/sycl/source/detail/platform_info.hpp +++ b/sycl/source/detail/platform_info.hpp @@ -52,19 +52,34 @@ struct get_platform_info, // Host platform information methods template -typename info::param_traits::return_type +inline typename info::param_traits::return_type get_platform_info_host() = delete; -template <> string_class get_platform_info_host(); +template <> +inline string_class get_platform_info_host() { + return "FULL PROFILE"; +} -template <> string_class get_platform_info_host(); +template <> +inline string_class get_platform_info_host() { + return "1.2"; +} -template <> string_class get_platform_info_host(); +template <> inline string_class get_platform_info_host() { + return "SYCL host platform"; +} -template <> string_class get_platform_info_host(); +template <> +inline string_class get_platform_info_host() { + return ""; +} template <> -vector_class get_platform_info_host(); +inline vector_class +get_platform_info_host() { + // TODO update when appropriate + return {}; +} } // namespace detail } // namespace sycl From dd946d8f860ae82809cdcfa52eb7d2970df5a7f0 Mon Sep 17 00:00:00 2001 From: Alexander Batashev Date: Tue, 14 Apr 2020 14:07:35 +0300 Subject: [PATCH 2/2] Remove unused macro Signed-off-by: Alexander Batashev --- sycl/source/detail/device_info.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index b3acbb86ed299..5391d538c4b3e 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -21,11 +21,6 @@ #include #include -#ifdef __GNUG__ -#define GCC_VERSION \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#endif - __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail {