okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ad33b8074
main
1//==---- lib_common_utils.hpp ---------------------*- C++ -*----------------==// 2// 3// Copyright (C) Intel Corporation 4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5// See https://llvm.org/LICENSE.txt for license information. 6// 7//===----------------------------------------------------------------------===// 8 9#ifndef __DPCT_LIB_COMMON_UTILS_HPP__ 10#define __DPCT_LIB_COMMON_UTILS_HPP__ 11 12#include "compat_service.hpp" 13 14#if defined(__has_include )&& __has_include (< oneapi /math .hpp > ) 15#include <oneapi/math.hpp> 16#include <oneapi/mkl/namespace_alias.hpp> 17#elif defined(__has_include )&& __has_include (< oneapi /mkl .hpp > ) 18#include <oneapi/mkl.hpp> 19#elif defined(__has_include ) 20#error "SYCLomatic runtime requires oneMath/oneMKL support" 21#else 22#error "SYCLomatic runtime requires __has_include support" 23#endif 24 25namespace dpct { 26 27enum class version_field :int {major ,minor ,update ,patch }; 28 29/// Returns the requested field of Intel(R) oneAPI Math Kernel Library version. 30/// \param field The version information field (major, minor, update or patch). 31/// \param result The result value. 32inline void mkl_get_version (version_field field ,int * result ) { 33#ifndef __INTEL_MKL__ 34throw std::runtime_error ("The oneAPI Math Kernel Library (oneMKL) Interfaces " 35"Project does not support this API." ); 36#else 37MKLVersion version ; 38mkl_get_version (& version ); 39if (version_field::major == field ) { 40* result = version .MajorVersion ; 41 }else if (version_field::minor == field ) { 42* result = version .MinorVersion ; 43 }else if (version_field::update == field ) { 44* result = version .UpdateVersion ; 45 }else if (version_field::patch == field ) { 46* result = 0 ; 47 }else { 48throw std::runtime_error ("unknown field" ); 49 } 50#endif 51} 52 53enum class library_data_t :unsigned char { 54real_float = 0 , 55complex_float , 56real_double , 57complex_double , 58real_half , 59complex_half , 60real_bfloat16 , 61complex_bfloat16 , 62real_int4 , 63complex_int4 , 64real_uint4 , 65complex_uint4 , 66real_int8 , 67complex_int8 , 68real_uint8 , 69complex_uint8 , 70real_int16 , 71complex_int16 , 72real_uint16 , 73complex_uint16 , 74real_int32 , 75complex_int32 , 76real_uint32 , 77complex_uint32 , 78real_int64 , 79complex_int64 , 80real_uint64 , 81complex_uint64 , 82real_int8_4 , 83real_int8_32 , 84real_uint8_4 , 85real_f8_e4m3 , 86real_f8_e5m2 , 87library_data_t_size 88}; 89 90enum class compute_type :int { 91f16 , 92f16_standard , 93f32 , 94f32_standard , 95f32_fast_bf16 , 96f32_fast_tf32 , 97f64 , 98f64_standard , 99i32 , 100i32_standard , 101}; 102 103#ifdef DPCT_USM_LEVEL_NONE 104/// Cast a "rvalue reference to a temporary object" to an "lvalue reference to 105/// that temporary object". 106/// CAUTION: 107/// The returned lvalue reference is available only before the last step in 108/// evaluating the full-expression that contains this function call. 109/// \param [in] temporary_object The rvalue reference to a temporary object. 110/// \returns The lvalue reference to that temporary object. 111template < typename T > 112inline typename std::enable_if_t < std::is_rvalue_reference_v < T &&> ,T &> 113rvalue_ref_to_lvalue_ref (T && temporary_object ) { 114return temporary_object ; 115} 116#endif 117}// namespace dpct 118 119#include "detail/lib_common_utils_detail.hpp" 120 121#endif // __DPCT_LIB_COMMON_UTILS_HPP__