Skip to content

Commit fa3f037

Browse files
authored
Small fixes (agenium-scale#527)
* ULP fixes on erf* scalar functions * Fix test when SIMD is not available. * Fix clang support for constant<T,B>()
1 parent 25e9d0d commit fa3f037

File tree

9 files changed

+57
-53
lines changed

9 files changed

+57
-53
lines changed

include/boost/simd/constant/definition/constant.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ namespace boost { namespace simd
4343
template<typename Type, detail::bits_t<dispatch::scalar_of_t<Type>> Bits>
4444
BOOST_FORCEINLINE Type Constant()
4545
{
46-
using cst_t = typename detail::constantify<boost::dispatch::scalar_of_t<Type>,Bits>::type;
46+
using cst_t = typename detail::constantify< boost::dispatch::scalar_of_t<Type>
47+
, std::uintmax_t(Bits)
48+
>::type;
49+
4750
return detail::constant( cst_t{}, boost::simd::as_<Type>{} );
4851
}
4952
} }

include/boost/simd/meta/has_native_storage.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace boost { namespace simd
3434
: nsm::bool_< std::is_same< typename detail::storage_status<T,N,abi_of_t<T,N>>::type
3535
, detail::native_status
3636
>::value
37+
&& !std::is_same<BOOST_SIMD_DEFAULT_SITE,boost::dispatch::cpu_>::value
3738
>
3839
#endif
3940
{};

test/api/memory/is_aligned.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ STF_CASE_TPL( "Check is_aligned on default architecture", STF_NUMERIC_TYPES )
1717
{
1818
T* ptr = allocate<T>( 7 );
1919

20-
STF_EXPECT ( is_aligned(ptr) );
21-
STF_EXPECT_NOT( is_aligned(ptr+1) );
20+
constexpr bool status = std::is_same<BOOST_SIMD_DEFAULT_SITE,boost::dispatch::cpu_>::value;
21+
22+
STF_EXPECT( is_aligned(ptr) );
23+
STF_EQUAL ( is_aligned(ptr+1), status );
2224

2325
deallocate(ptr);
2426
}

test/api/memory/preferred_alignment.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ using namespace boost::simd;
1515
STF_CASE_TPL( "Check preferred_alignment on Vectorizable types", STF_NUMERIC_TYPES )
1616
{
1717
static const std::size_t N = pack<T>::static_size;
18-
19-
using arch_t = BOOST_SIMD_DEFAULT_SITE;
20-
21-
STF_EQUAL( (preferred_alignment<T>::value ), std::size_t(limits<arch_t>::bytes));
18+
STF_EQUAL( (preferred_alignment<T>::value ), std::size_t(pack<T,N >::alignment) );
2219
STF_EQUAL( (preferred_alignment<T,N/2>::value), std::size_t(pack<T,N/2>::alignment) );
2320
STF_EQUAL( (preferred_alignment<T,N*2>::value), std::size_t(pack<T,N*2>::alignment) );
2421
}

test/architecture/has_native_storage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ struct check_native_storage
1717

1818
runtime.stream() << "\n With T = [" << ::stf::type_id<T>() << "]\n";
1919

20-
STF_EXPECT( ( has_native_storage<T >::value) );
20+
constexpr bool status = !std::is_same<BOOST_SIMD_DEFAULT_SITE,boost::dispatch::cpu_>::value;
21+
STF_EQUAL ( ( has_native_storage<T >::value), status );
2122
STF_EXPECT( (!has_native_storage<T,128>::value) );
2223
}
2324

test/function/scalar/erf.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ STF_CASE_TPL (" erf", STF_IEEE_TYPES)
3030

3131
// specific values tests
3232
#ifndef BOOST_SIMD_NO_INVALIDS
33-
STF_ULP_EQUAL(erf(bs::Minf<T>()), T(-1), 0);
34-
STF_ULP_EQUAL(erf(bs::Inf<T>()), T(1), 0);
35-
STF_ULP_EQUAL(erf(bs::Nan<T>()), bs::Nan<T>(), 0);
33+
STF_IEEE_EQUAL(erf(bs::Minf<T>()), T(-1));
34+
STF_IEEE_EQUAL(erf(bs::Inf<T>()), T(1));
35+
STF_IEEE_EQUAL(erf(bs::Nan<T>()), bs::Nan<T>());
3636
#endif
3737

38-
STF_ULP_EQUAL(erf(T(0.1)), T(0.112462916018284892203275071744), 0);
38+
STF_ULP_EQUAL(erf(T(0.1)), T(0.112462916018284892203275071744), 0.5);
3939

40-
STF_ULP_EQUAL(erf(bs::Mzero<T>()), T(0), 0);
40+
STF_ULP_EQUAL(erf(bs::Mzero<T>()), T(0), 0.5);
4141
STF_ULP_EQUAL(erf(T(0.5)), T(0.520499877813046537682746653892), 0.5);
4242
STF_ULP_EQUAL(erf(T(1)), T(0.842700792949714869341220635083), 0.5);
43-
STF_ULP_EQUAL(erf(T(2)), T(0.995322265018952734162069256367), 0);
44-
STF_ULP_EQUAL(erf(T(0)), T(0), 0);
45-
STF_ULP_EQUAL(erf(bs::Halfeps<T>()), bs::Eps<T>()*bs::rsqrt(bs::Pi<T>()), 0);
46-
STF_ULP_EQUAL(erf(T(5)), T(0.99999999999846254020557196515), 0);
47-
STF_ULP_EQUAL(erf(T(27)), T(1), 0);
43+
STF_ULP_EQUAL(erf(T(2)), T(0.995322265018952734162069256367), 0.5);
44+
STF_ULP_EQUAL(erf(T(0)), T(0), 0.5);
45+
STF_ULP_EQUAL(erf(bs::Halfeps<T>()), bs::Eps<T>()*bs::rsqrt(bs::Pi<T>()), 0.5);
46+
STF_ULP_EQUAL(erf(T(5)), T(0.99999999999846254020557196515), 0.5);
47+
STF_ULP_EQUAL(erf(T(27)), T(1), 0.5);
4848

49-
STF_ULP_EQUAL(erf(T(-0.1)), -T(0.112462916018284892203275071744), 0);
49+
STF_ULP_EQUAL(erf(T(-0.1)), -T(0.112462916018284892203275071744), 0.5);
5050
STF_ULP_EQUAL(erf(-T(0.5)), -T(0.520499877813046537682746653892), 0.5);
5151
STF_ULP_EQUAL(erf(-T(1)), -T(0.842700792949714869341220635083), 0.5);
52-
STF_ULP_EQUAL(erf(-T(2)), -T(0.995322265018952734162069256367), 0);
53-
STF_ULP_EQUAL(erf(-bs::Halfeps<T>()), -bs::Eps<T>()*bs::rsqrt(bs::Pi<T>()), 0);
54-
STF_ULP_EQUAL(erf(-T(5)), -T(0.99999999999846254020557196515), 0);
55-
STF_ULP_EQUAL(erf(T(-27)), -T(1), 0);
52+
STF_ULP_EQUAL(erf(-T(2)), -T(0.995322265018952734162069256367), 0.5);
53+
STF_ULP_EQUAL(erf(-bs::Halfeps<T>()), -bs::Eps<T>()*bs::rsqrt(bs::Pi<T>()), 0.5);
54+
STF_ULP_EQUAL(erf(-T(5)), -T(0.99999999999846254020557196515), 0.5);
55+
STF_ULP_EQUAL(erf(T(-27)), -T(1), 0.5);
5656
}

test/function/scalar/erfc.regular.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ STF_CASE_TPL (" erfc", STF_IEEE_TYPES)
3535

3636
// specific values tests
3737
#ifndef BOOST_SIMD_NO_INVALIDS
38-
STF_ULP_EQUAL(erfc(bs::Inf<T>()), bs::Zero<r_t>(), 0);
39-
STF_ULP_EQUAL(erfc(bs::Minf<T>()), bs::Two<r_t>(), 0);
40-
STF_ULP_EQUAL(erfc(bs::Nan<T>()), bs::Nan<r_t>(), 0);
38+
STF_IEEE_EQUAL(erfc(bs::Inf<T>()), bs::Zero<r_t>());
39+
STF_IEEE_EQUAL(erfc(bs::Minf<T>()), bs::Two<r_t>());
40+
STF_IEEE_EQUAL(erfc(bs::Nan<T>()), bs::Nan<r_t>());
4141
#endif
4242
STF_ULP_EQUAL(erfc(bs::Mzero<T>()), bs::One<r_t>(), 0.5);
43-
STF_ULP_EQUAL(erfc(T(0.1)), T(0.887537083981715107796724928256), 0);
43+
STF_ULP_EQUAL(erfc(T(0.1)), T(0.887537083981715107796724928256), 0.5);
4444
STF_ULP_EQUAL(erfc(T(0.4)), T(0.57160764495333154489639615468), 0.5);
4545
STF_ULP_EQUAL(erfc(bs::Half<T>()), T(0.479500122186953462317253346108), 1.5);
4646
STF_ULP_EQUAL(erfc(bs::One<T>()), T(0.157299207050285130658779364917), 0.5);
4747
STF_ULP_EQUAL(erfc(bs::Two<T>()), T(0.00467773498104726583793074363275), 1);
4848
STF_ULP_EQUAL(erfc(bs::Zero<T>()), bs::One<r_t>(), 0.5);
49-
STF_ULP_EQUAL(erfc(T(6)), T(0.0000000000000000215197367124989131165933503992), 0);
49+
STF_ULP_EQUAL(erfc(T(6)), T(0.0000000000000000215197367124989131165933503992), 0.5);
5050
STF_EXPECT(bs::is_less(erfc((bs::Ten<T>()- T(2.088487583762545e-45))), bs::Eps<T>()));
5151
STF_EXPECT(bs::is_less(erfc(T(15))- T(7.212994172451206e-100), bs::Eps<T>()));
5252

@@ -55,7 +55,7 @@ STF_CASE_TPL (" erfc", STF_IEEE_TYPES)
5555
STF_ULP_EQUAL(bs::std_(erfc)(-bs::Half<T>()), (erfc)(-bs::Half<T>()), 0.5);
5656
STF_ULP_EQUAL(erfc(-bs::One<T>()), bs::std_(erfc)(-bs::One<T>()), 0.5);
5757
STF_ULP_EQUAL(erfc(-bs::Two<T>()), bs::std_(erfc)(-bs::Two<T>()), 1);
58-
STF_ULP_EQUAL(erfc(T(-6)), T(2), 0);
58+
STF_ULP_EQUAL(erfc(T(-6)), T(2), 0.5);
5959
}
6060

6161

test/function/scalar/erfc.std.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ STF_CASE_TPL (" erfc std", STF_IEEE_TYPES)
3535

3636
// specific values tests
3737
#ifndef BOOST_SIMD_NO_INVALIDS
38-
STF_ULP_EQUAL(bs::std_(erfc)(bs::Inf<T>()), bs::Zero<r_t>(), 0);
39-
STF_ULP_EQUAL(bs::std_(erfc)(bs::Nan<T>()), bs::Nan<r_t>(), 0);
38+
STF_IEEE_EQUAL(bs::std_(erfc)(bs::Inf<T>()), bs::Zero<r_t>());
39+
STF_IEEE_EQUAL(bs::std_(erfc)(bs::Nan<T>()), bs::Nan<r_t>());
4040
#endif
41-
STF_ULP_EQUAL(bs::std_(erfc)(bs::Mzero<T>()), bs::One<r_t>(), 0);
42-
STF_ULP_EQUAL(bs::std_(erfc)(bs::Half<T>()), T(0.479500122186953462317253346108), 0);
41+
STF_ULP_EQUAL(bs::std_(erfc)(bs::Mzero<T>()), bs::One<r_t>(), 0.5);
42+
STF_ULP_EQUAL(bs::std_(erfc)(bs::Half<T>()), T(0.479500122186953462317253346108), 0.5);
4343
STF_ULP_EQUAL(bs::std_(erfc)(bs::One<T>()), T(0.157299207050285130658779364917), 0.5);
4444
STF_ULP_EQUAL(bs::std_(erfc)(bs::Two<T>()), T(0.00467773498104726583793074363275), 1.0);
45-
STF_ULP_EQUAL(bs::std_(erfc)(bs::Zero<T>()), bs::One<r_t>(), 0);
45+
STF_ULP_EQUAL(bs::std_(erfc)(bs::Zero<T>()), bs::One<r_t>(), 0.5);
4646
STF_ULP_EQUAL(bs::std_(erfc)(T(6)), T(0.0000000000000000215197367124989131165933503992), 0.5);
4747
STF_EXPECT(bs::is_less(bs::std_(erfc)(bs::Ten<T>())- T(2.088487583762545e-45), bs::Eps<T>()));
4848
STF_EXPECT(bs::is_less(bs::std_(erfc)(T(15))- T(7.212994172451206e-100), bs::Eps<T>()));
49-
STF_ULP_EQUAL(bs::std_(erfc)(T(-6)), T(2), 0);
49+
STF_ULP_EQUAL(bs::std_(erfc)(T(-6)), T(2), 0.5);
5050
}
5151

5252

test/function/scalar/erfcx.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,36 @@ STF_CASE_TPL (" erfcx", (double))//STF_IEEE_TYPES)
3636
STF_TYPE_IS(r_t, T);
3737

3838
// specific values tests
39-
STF_ULP_EQUAL(erfcx(bs::Mzero<T>()), bs::One<r_t>(), 0);
40-
STF_ULP_EQUAL(erfcx(bs::Zero<T>()), bs::One<r_t>(), 0);
41-
STF_ULP_EQUAL(erfcx(bs::Halfeps<T>()),T(0.999999999999999874724746818321), 0);
39+
STF_ULP_EQUAL(erfcx(bs::Mzero<T>()), bs::One<r_t>(), 0.5);
40+
STF_ULP_EQUAL(erfcx(bs::Zero<T>()), bs::One<r_t>(), 0.5);
41+
STF_ULP_EQUAL(erfcx(bs::Halfeps<T>()),T(0.999999999999999874724746818321), 0.5);
4242
STF_ULP_EQUAL(erfcx(T(0.1)), T(0.896456979969126641931883748644), 0.5);
43-
STF_ULP_EQUAL(erfcx(T(0.4)), T(0.670787785294761523329412474468), 0);
43+
STF_ULP_EQUAL(erfcx(T(0.4)), T(0.670787785294761523329412474468), 0.5);
4444

45-
STF_ULP_EQUAL(erfcx(bs::Half<T>()), T(0.615690344192925874870793422684), 0);
45+
STF_ULP_EQUAL(erfcx(bs::Half<T>()), T(0.615690344192925874870793422684), 0.5);
4646
STF_ULP_EQUAL(erfcx(bs::One<T>()), T(0.427583576155807004410750344491), 0.5);
4747
STF_ULP_EQUAL(erfcx(bs::Two<T>()), T(0.255395676310505743865088580909), 0.5);
4848
STF_ULP_EQUAL(erfcx(bs::Four<T>()), T(0.1369994576250613898894451714), 0.5);
49-
STF_ULP_EQUAL(erfcx(bs::Five<T>()), T(0.110704637733068626370212086492), 0);
50-
STF_ULP_EQUAL(erfcx(T(27)), T(0.0208816079904209406740944901929), 0);
51-
STF_ULP_EQUAL(erfcx(T(100)), T(0.00564161378298943290355645700695), 0);
52-
STF_ULP_EQUAL(erfcx(bs::Valmax<T>()) ,bs::rsqrt(bs::Pi<T>())/bs::Valmax<T>(), 0);
49+
STF_ULP_EQUAL(erfcx(bs::Five<T>()), T(0.110704637733068626370212086492), 0.5);
50+
STF_ULP_EQUAL(erfcx(T(27)), T(0.0208816079904209406740944901929), 0.5);
51+
STF_ULP_EQUAL(erfcx(T(100)), T(0.00564161378298943290355645700695), 0.5);
52+
STF_ULP_EQUAL(erfcx(bs::Valmax<T>()) ,bs::rsqrt(bs::Pi<T>())/bs::Valmax<T>(), 0.5);
5353

54-
STF_ULP_EQUAL(erfcx(-bs::Halfeps<T>()), T(1.00000000000000012527525318168), 0);
54+
STF_ULP_EQUAL(erfcx(-bs::Halfeps<T>()), T(1.00000000000000012527525318168), 0.5);
5555
STF_ULP_EQUAL(erfcx(-T(0.1)) , T(1.12364335419920947315244716516), 0.5);
56-
STF_ULP_EQUAL(erfcx(-T(0.4)) , T(1.67623395668885894670780969932), 0);
56+
STF_ULP_EQUAL(erfcx(-T(0.4)) , T(1.67623395668885894670780969932), 0.5);
5757

5858
STF_ULP_EQUAL(erfcx(-bs::Half<T>()) , T(1.95236048918255709327604771344), 0.5);
5959
STF_ULP_EQUAL(erfcx(-bs::One<T>()) , T(5.00898008076228346630982459821), 0.5);
60-
STF_ULP_EQUAL(erfcx(-bs::Two<T>()) , T(108.940904389977972412355433825), 0);
60+
STF_ULP_EQUAL(erfcx(-bs::Two<T>()) , T(108.940904389977972412355433825), 0.5);
6161
STF_ULP_EQUAL(erfcx(-bs::Four<T>()) , T(17772220.9040162876484646575921) , 0.5);
62-
STF_ULP_EQUAL(erfcx(-bs::Five<T>()) , T(144009798674.661040410589634306), 0);
63-
STF_ULP_EQUAL(erfcx(-T(27)) , bs::Inf<T>(), 0);
64-
STF_ULP_EQUAL(erfcx(-T(100)) , bs::Inf<T>(), 0);
65-
STF_ULP_EQUAL(erfcx(-bs::Valmax<T>()) , bs::Inf<T>(), 0);
62+
STF_ULP_EQUAL(erfcx(-bs::Five<T>()) , T(144009798674.661040410589634306), 0.5);
63+
STF_ULP_EQUAL(erfcx(-T(27)) , bs::Inf<T>(), 0.5);
64+
STF_ULP_EQUAL(erfcx(-T(100)) , bs::Inf<T>(), 0.5);
65+
STF_ULP_EQUAL(erfcx(-bs::Valmax<T>()) , bs::Inf<T>(), 0.5);
6666

6767
#ifndef BOOST_SIMD_NO_INVALIDS
68-
STF_ULP_EQUAL(erfcx(bs::Inf<T>()), bs::Zero<r_t>(), 0);
69-
STF_ULP_EQUAL(erfcx(bs::Nan<T>()), bs::Nan<r_t>(), 0);
68+
STF_IEEE_EQUAL(erfcx(bs::Inf<T>()), bs::Zero<r_t>());
69+
STF_IEEE_EQUAL(erfcx(bs::Nan<T>()), bs::Nan<r_t>());
7070
#endif
7171
}

0 commit comments

Comments
 (0)