@@ -1379,7 +1379,7 @@ ESIMD_NODEBUG
1379
1379
// //////////////////////////////////////////////////////////////////////////////
1380
1380
// ESIMD arithmetic intrinsics:
1381
1381
//
1382
- // inv, log, exp , sqrt, rsqrt, sin, cos
1382
+ // inv, log2, exp2 , sqrt, rsqrt, sin, cos
1383
1383
//
1384
1384
// share the same requirements.
1385
1385
//
@@ -1427,8 +1427,8 @@ ESIMD_NODEBUG
1427
1427
}
1428
1428
1429
1429
ESIMD_INTRINSIC_DEF (float , inv, inv)
1430
- ESIMD_INTRINSIC_DEF (float , log , log)
1431
- ESIMD_INTRINSIC_DEF (float , exp , exp)
1430
+ ESIMD_INTRINSIC_DEF (float , log2 , log)
1431
+ ESIMD_INTRINSIC_DEF (float , exp2 , exp)
1432
1432
ESIMD_INTRINSIC_DEF (float , sqrt, sqrt)
1433
1433
ESIMD_INTRINSIC_DEF (float , ieee_sqrt, sqrt_ieee)
1434
1434
ESIMD_INTRINSIC_DEF (float , rsqrt, rsqrt)
@@ -1592,6 +1592,41 @@ asin(T src0, int flag = saturation_off) {
1592
1592
return Result[0 ];
1593
1593
}
1594
1594
1595
+ // / Computes the natural logarithm of the given argument. This is an
1596
+ // / emulated version based on the H/W supported log2.
1597
+ // / @param the source operand to compute base-e logarithm of.
1598
+ // / @return the base-e logarithm of \p src0.
1599
+ template <int SZ>
1600
+ ESIMD_NODEBUG ESIMD_INLINE simd<float , SZ> log (simd<float , SZ> src0,
1601
+ int flag = saturation_off) {
1602
+ constexpr float ln2 = 0 .69314718f ; // std::numbers::ln2_v<float> in c++20
1603
+ simd<float , SZ> Result = esimd::log2<SZ>(src0) * ln2;
1604
+
1605
+ if (flag != saturation_on)
1606
+ return Result;
1607
+
1608
+ return esimd::saturate<float >(Result);
1609
+ }
1610
+
1611
+ ESIMD_NODEBUG ESIMD_INLINE float log (float src0, int flag = saturation_off) {
1612
+ return esimd::log<1 >(src0, flag)[0 ];
1613
+ }
1614
+
1615
+ // / Computes e raised to the power of the given argument. This is an
1616
+ // / emulated version based on the H/W supported exp2.
1617
+ // / @param the source operand to compute base-e exponential of.
1618
+ // / @return e raised to the power of \p src0.
1619
+ template <int SZ>
1620
+ ESIMD_NODEBUG ESIMD_INLINE simd<float , SZ> exp (simd<float , SZ> src0,
1621
+ int flag = saturation_off) {
1622
+ constexpr float log2e = 1 .442695f ; // std::numbers::log2e_v<float> in c++20
1623
+ return esimd::exp2<SZ>(src0 * log2e, flag);
1624
+ }
1625
+
1626
+ ESIMD_NODEBUG ESIMD_INLINE float exp (float src0, int flag = saturation_off) {
1627
+ return esimd::exp<1 >(src0, flag)[0 ];
1628
+ }
1629
+
1595
1630
// //////////////////////////////////////////////////////////////////////////////
1596
1631
// Rounding intrinsics.
1597
1632
// //////////////////////////////////////////////////////////////////////////////
0 commit comments