Skip to content

Commit

Permalink
Fix some rounding funtions implementation (agenium-scale#348)
Browse files Browse the repository at this point in the history
trunc, floor and ceil has been simplified/optimized
  • Loading branch information
jfalcou authored Dec 20, 2016
1 parent 82fc022 commit f68cc32
Show file tree
Hide file tree
Showing 40 changed files with 1,151 additions and 694 deletions.
4 changes: 3 additions & 1 deletion bench/function/scalar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ set(SOURCES
ffs.cpp
firstbitset.cpp
firstbitunset.cpp
floor.cpp
floor.regular.cpp
floor.std.cpp
fma.regular.cpp
fma.std.cpp
fms.cpp
Expand Down Expand Up @@ -340,6 +341,7 @@ set(SOURCES
toint.saturated.cpp
touint.regular.cpp
touint.saturated.cpp
trunc.raw.cpp
trunc.regular.cpp
trunc.std.cpp
two_add.cpp
Expand Down
20 changes: 10 additions & 10 deletions bench/function/scalar/ceil.regular.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// Copyright 2016 - NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// -------------------------------------------------------------------------------------------------
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <boost/simd/function/ceil.hpp>
#include <simd_bench.hpp>
#include <boost/simd/function/simd/ceil.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SCALAR_BENCH(scalar_ceil, bs::ceil);
DEFINE_SCALAR_BENCH(scalar_regular_ceil, bs::ceil);

DEFINE_BENCH_MAIN()
{
nsb::for_each<scalar_ceil, NS_BENCH_IEEE_TYPES>(-10, 10);
nsb::for_each<scalar_regular_ceil, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
19 changes: 10 additions & 9 deletions bench/function/scalar/ceil.std.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// -------------------------------------------------------------------------------------------------
// Copyright 2016 - NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// -------------------------------------------------------------------------------------------------
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <boost/simd/function/ceil.hpp>
#include <boost/simd/function/std.hpp>
#include <simd_bench.hpp>
#include <boost/simd/function/simd/ceil.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;
Expand All @@ -16,5 +17,5 @@ DEFINE_SCALAR_BENCH(scalar_std_ceil, bs::std_(bs::ceil));

DEFINE_BENCH_MAIN()
{
nsb::for_each<scalar_std_ceil, NS_BENCH_IEEE_TYPES>(-10, 10);
nsb::for_each<scalar_std_ceil, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
20 changes: 0 additions & 20 deletions bench/function/scalar/floor.cpp

This file was deleted.

20 changes: 20 additions & 0 deletions bench/function/scalar/floor.regular.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <boost/simd/function/floor.hpp>
#include <simd_bench.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SCALAR_BENCH(scalar_regular_floor, bs::floor);

DEFINE_BENCH_MAIN()
{
nsb::for_each<scalar_regular_floor, NS_BENCH_IEEE_TYPES>(-10, 10);
}
21 changes: 21 additions & 0 deletions bench/function/scalar/floor.std.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <boost/simd/function/floor.hpp>
#include <boost/simd/function/std.hpp>
#include <simd_bench.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SCALAR_BENCH(scalar_std_floor, bs::std_(bs::floor));

DEFINE_BENCH_MAIN()
{
nsb::for_each<scalar_std_floor, NS_BENCH_IEEE_TYPES>(-10, 10);
}
21 changes: 21 additions & 0 deletions bench/function/scalar/trunc.raw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <simd_bench.hpp>
#include <boost/simd/function/trunc.hpp>
#include <boost/simd/function/raw.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SCALAR_BENCH(scalar_raw_trunc, bs::raw_(bs::trunc));

DEFINE_BENCH_MAIN()
{
nsb::for_each<scalar_raw_trunc, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
18 changes: 9 additions & 9 deletions bench/function/scalar/trunc.regular.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// Copyright 2016 - NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// -------------------------------------------------------------------------------------------------
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <simd_bench.hpp>
#include <boost/simd/function/simd/trunc.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SCALAR_BENCH(scalar_trunc, bs::trunc);
DEFINE_SCALAR_BENCH(scalar_regular_trunc, bs::trunc);

DEFINE_BENCH_MAIN()
{
nsb::for_each<scalar_trunc, NS_BENCH_IEEE_TYPES>(-10, 10);
nsb::for_each<scalar_regular_trunc, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
2 changes: 1 addition & 1 deletion bench/function/scalar/trunc.std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ DEFINE_SCALAR_BENCH(scalar_std_trunc, bs::std_(bs::trunc));

DEFINE_BENCH_MAIN()
{
nsb::for_each<scalar_std_trunc, NS_BENCH_IEEE_TYPES>(-10, 10);
nsb::for_each<scalar_std_trunc, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
1 change: 1 addition & 0 deletions bench/function/simd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ set(SOURCES
touint.regular.cpp
touint.saturated.cpp
trunc.regular.cpp
trunc.raw.cpp
two_add.cpp
quadrant.cpp
twopower.cpp
Expand Down
22 changes: 11 additions & 11 deletions bench/function/simd/ceil.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// -------------------------------------------------------------------------------------------------
// Copyright 2016 - NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// -------------------------------------------------------------------------------------------------
//==================================================================================================
/**
Copyright 2016 NumScale SAS
#include <simd_bench.hpp>
#include <boost/simd/function/simd/ceil.hpp>
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <boost/simd/function/ceil.hpp>
#include <boost/simd/pack.hpp>
#include <simd_bench.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SIMD_BENCH(simd_ceil, bs::ceil);
DEFINE_SIMD_BENCH(simd_regular_ceil, bs::ceil);

DEFINE_BENCH_MAIN()
{
nsb::for_each<simd_ceil, NS_BENCH_IEEE_TYPES>(-10, 10);
nsb::for_each<simd_regular_ceil, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
2 changes: 1 addition & 1 deletion bench/function/simd/floor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ DEFINE_SIMD_BENCH(simd_floor, bs::floor);

DEFINE_BENCH_MAIN()
{
nsb::for_each<simd_floor, NS_BENCH_IEEE_TYPES>(-10, 10);
nsb::for_each<simd_floor, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
22 changes: 22 additions & 0 deletions bench/function/simd/trunc.raw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <boost/simd/function/trunc.hpp>
#include <boost/simd/function/raw.hpp>
#include <boost/simd/pack.hpp>
#include <simd_bench.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SIMD_BENCH(simd_raw_trunc, bs::raw_(bs::trunc));

DEFINE_BENCH_MAIN()
{
nsb::for_each<simd_raw_trunc, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
20 changes: 10 additions & 10 deletions bench/function/simd/trunc.regular.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// -------------------------------------------------------------------------------------------------
// Copyright 2016 - NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// -------------------------------------------------------------------------------------------------
//==================================================================================================
/**
Copyright 2016 NumScale SAS
#include <simd_bench.hpp>
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#include <boost/simd/function/simd/trunc.hpp>
#include <boost/simd/pack.hpp>
#include <simd_bench.hpp>

namespace nsb = ns::bench;
namespace bs = boost::simd;

DEFINE_SIMD_BENCH(simd_trunc, bs::trunc);
DEFINE_SIMD_BENCH(simd_regular_trunc, bs::trunc);

DEFINE_BENCH_MAIN()
{
nsb::for_each<simd_trunc, NS_BENCH_IEEE_TYPES>(-10, 10);
nsb::for_each<simd_regular_trunc, NS_BENCH_NUMERIC_TYPES>(-10, 10);
}
Loading

0 comments on commit f68cc32

Please sign in to comment.