From 1482721716bb0aac3dc65c316802172b05f42a23 Mon Sep 17 00:00:00 2001 From: Anatoly Parshintsev Date: Mon, 17 May 2021 16:06:52 +0300 Subject: [PATCH] remove cm_emu header since we don't need it anymore and change interface version --- include/clang/FrontendWrapper/Interface.h | 2 +- lib/Headers/cm/include/CMakeLists.txt | 1 - lib/Headers/cm/include/cm/cm.h | 1 - lib/Headers/cm/include/cm/cm_emu.h | 293 ---------------------- 4 files changed, 1 insertion(+), 296 deletions(-) delete mode 100644 lib/Headers/cm/include/cm/cm_emu.h diff --git a/include/clang/FrontendWrapper/Interface.h b/include/clang/FrontendWrapper/Interface.h index 57e6b22b870f..715f6178f820 100644 --- a/include/clang/FrontendWrapper/Interface.h +++ b/include/clang/FrontendWrapper/Interface.h @@ -100,7 +100,7 @@ struct IDriverInvocation { }; // this number should be increased whenever the public interface changes -static const int InterfaceVersion = 9; +static const int InterfaceVersion = 10; } // namespace ClangFE } // namespace CM diff --git a/lib/Headers/cm/include/CMakeLists.txt b/lib/Headers/cm/include/CMakeLists.txt index 9691758ffc89..2fe5213c0ea2 100755 --- a/lib/Headers/cm/include/CMakeLists.txt +++ b/lib/Headers/cm/include/CMakeLists.txt @@ -3,7 +3,6 @@ set(CM_HEADERS cm/cm_atomic.h cm/cm_common.h cm/cm_dataport.h - cm/cm_emu.h cm/cm_gateway.h cm/cm.h cm/cm_internal.h diff --git a/lib/Headers/cm/include/cm/cm.h b/lib/Headers/cm/include/cm/cm.h index 858fa28579c2..e08cf4dfe6eb 100644 --- a/lib/Headers/cm/include/cm/cm.h +++ b/lib/Headers/cm/include/cm/cm.h @@ -31,7 +31,6 @@ #include "cm_send.h" #include "cm_atomic.h" #include "cm_dataport.h" -#include "cm_emu.h" #include "cm_internal.h" #include "cm_sampler.h" #include "cm_traits.h" diff --git a/lib/Headers/cm/include/cm/cm_emu.h b/lib/Headers/cm/include/cm/cm_emu.h deleted file mode 100644 index b2f9cedb03aa..000000000000 --- a/lib/Headers/cm/include/cm/cm_emu.h +++ /dev/null @@ -1,293 +0,0 @@ -/*===================== begin_copyright_notice ================================== - - Copyright (c) 2021, Intel Corporation - - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. -======================= end_copyright_notice ==================================*/ - -#pragma once -#ifndef _CLANG_CM_EMU_H_ -#define _CLANG_CM_EMU_H_ - -#include "cm_common.h" -#include "cm_internal.h" - -namespace details { - -CM_NODEBUG CM_INLINE -float __impl_hex2float(uint32_t val) { - vector su = val; - vector sf = su.format(); - return sf(0); -} - -template -CM_NODEBUG CM_INLINE -vector __impl_divrem(vector ia, vector ib, - vector_ref ir) { - // Exact conversions: 16-bit -> float - vector fa = ia; - vector fb = ib; - vector fy = 1.0f / fb; - - // s = 1 + 2^(-20) - vector sf = __impl_hex2float(0x3f800008U); - - // a * (1 + 2^(-20)) - fa = fa * sf; - - // a * (1 + 2^(-20)) * fy - vector fq = fa * fy; - - // quotient: truncate to signed 16-bit integer - vector iq = fq; - - // remainder - ir = ia - iq * ib; - - // return the quotient. - return iq; -} - -template -CM_NODEBUG CM_INLINE -vector __impl_divrem(vector ia, vector ib, - vector_ref ir) { - vector _ia = ia; - vector _ib = ib; - vector _ir; - vector _iq = __impl_divrem(_ia, _ib, _ir); - ir = _ir; - return _iq; -} - -// RTZ rounding mode is needed for some of the steps -// It is fine to use RTZ mode throughout the FP computation -template -CM_NODEBUG CM_INLINE -vector __impl_divrem(vector sla, vector slb, - vector_ref prem) { - vector ah, al, bh, bl; - vector y, Qh, Ql, Rh, Rl; - - vector la_h, lb_h, la_l, lb_l, lQh, lQl, lQ, lR; - vector la, lb, corr_mask; - vector sgn_a, sgn_b, sgn_q; - - // get signs and |sla|, |slb| - sgn_a = sla >> 31; - sgn_b = slb >> 31; - la = (sla + sgn_a) ^ sgn_a; - lb = (slb + sgn_b) ^ sgn_b; - - // uint32 -> single precision convert, with truncation (RZ mode) - bh = lb; - - // convert back to uint32, to get low part - lb_h = bh; - lb_l = lb - lb_h; - - // low part of input, in single precision - bl = lb_l; - - // uint32 -> single precision convert, with truncation (RZ mode) - ah = la; - - // convert back to uint32, to get low part - la_h = ah; - la_l = la - la_h; - - // low part of input, in single precision - al = la_l; - - // y = RCP(bh) - y = 1.0f / bh; - - // y = y*(1 - 3*2^(-23)) - // RZ mode not required, used for convenience - vector sf = __impl_hex2float(0xb4c00000u); - y += sf * y; - - // Qh = ah*y - Qh = ah * y; - - // Qh = (unsigned)Qh, with truncation - lQh = Qh; - - // convert lQh back to SP, any rounding mode is fine - Qh = lQh; - - // ah - bh*Qh - Rh = ah - bh * Qh; - - // al - bl*Qh - Rl = al - bl * Qh; - - // Ql = y * (Rh + Rl) - Rl = Rh + Rl; - Ql = y * Rl; - - // convert Ql to integer, with truncation - lQl = Ql; - - // integer quotient - lQ = lQh + lQl; - sgn_q = sgn_a ^ sgn_b; - - // integer remainder - lR = la - lb * lQ; - - // apply correction if needed - // if (lR >= lb) { lQ++; lR -= lb; } - corr_mask.merge(0xffffffff, 0, (lR >= lb)); - lQ += (corr_mask & 1); - lR -= (lb & corr_mask); - - // remainder - prem = (sgn_a + lR) ^ sgn_a; - lQ = (sgn_q + lQ) ^ sgn_q; - - return lQ; -} - -template -CM_NODEBUG CM_INLINE -vector -__impl_udivrem(vector ua, vector ub, - vector_ref ur) { - vector fa, fb, fy, fq; - vector uq; - - // exact conversions: unsigned 16-bit -> float - fb = ub; - fa = ua; - - fy = 1.0f / fb; - - // a*(1+2^(-20)) - fa = fa * __impl_hex2float(0x3f800008u); - - // a*(1+2^(-20))*fy - fq = fa * fy; - - // quotient: truncate to unsigned 16-bit integer - uq = fq; - - // remainder - ur = ua - uq * ub; - - return uq; -} - -template -CM_NODEBUG CM_INLINE -vector -__impl_udivrem(vector ua, vector ub, - vector_ref ur) { - vector _ua = ua; - vector _ub = ub; - vector _ur; - vector uq = __impl_udivrem(_ua, _ub, _ur); - ur = _ur; - return uq; -} - -// RZ rounding mode is needed for some of the steps -// It is fine to use RZ mode throughout the FP computation -template -CM_NODEBUG CM_INLINE -vector -__impl_udivrem(vector la, vector lb, - vector_ref prem) { - vector ah, al, bh, bl; - vector y, Qh, Ql, Rh, Rl; - vector la_h, lb_h, la_l, lb_l, lQh, lQl, lQ, lR, corr_mask; - - // uint32 -> single precision convert, with truncation (RZ mode) - bh = lb; - - // convert back to uint32, to get low part - lb_h = bh; - lb_l = lb - lb_h; - - // low part of input, in single precision - bl = lb_l; - - // uint32 -> single precision convert, with truncation (RZ mode) - ah = la; - - // convert back to uint32, to get low part - la_h = ah; - la_l = la - la_h; - - // low part of input, in single precision - al = la_l; - - // y = RCP(bh) - y = 1.0f / bh; - - // y = y*(1 - 3*2^(-23)) - // RZ mode not required, used for convenience - y += y * __impl_hex2float(0xb4c00000u); - - // Qh = ah*y - Qh = ah * y; - - // Qh = (unsigned)Qh, with truncation - lQh = Qh; - - // convert lQh back to SP, any rounding mode is fine - Qh = lQh; - - // ah - bh*Qh - Rh = ah - bh * Qh; - - // al - bl*Qh - Rl = al - bl * Qh; - - // Ql = y*(Rh+Rl) - Rl = Rh + Rl; - Ql = y * Rl; - - // convert Ql to integer, with truncation - lQl = Ql; - - // integer quotient - lQ = lQh + lQl; - - // integer remainder - lR = la - lb * lQ; - - // apply correction if needed - // if (lR >= lb) { lQ++; lR -= lb; } - corr_mask.merge(0xffffffff, 0, (lR >= lb)); - lQ += (corr_mask & 1); - lR -= (lb & corr_mask); - - // remainder - prem = lR; - - return lQ; -} - -} // namespace details - - -#endif // _CLANG_CM_EMU_H_