-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
392 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
#ifndef EVE_FUNCTION_SIMD_LOGICAL_NOT_HPP_INCLUDED | ||
#define EVE_FUNCTION_SIMD_LOGICAL_NOT_HPP_INCLUDED | ||
|
||
#include <eve/function/scalar/logical_not.hpp> | ||
#include <eve/module/core/function/simd/logical_not.hpp> | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Copyright 2019 Joel FALCOU | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
#ifndef EVE_MODULE_CORE_FUNCTION_SCALAR_LOGICAL_NOT_HPP_INCLUDED | ||
#define EVE_MODULE_CORE_FUNCTION_SCALAR_LOGICAL_NOT_HPP_INCLUDED | ||
|
||
#include <eve/detail/overload.hpp> | ||
#include <eve/detail/meta.hpp> | ||
#include <eve/detail/abi.hpp> | ||
#include <eve/as_logical.hpp> | ||
#include <eve/function/scalar/bitwise_cast.hpp> | ||
#include <type_traits> | ||
|
||
namespace eve::detail | ||
{ | ||
// ----------------------------------------------------------------------------------------------- | ||
// Regular case | ||
template<typename T> | ||
EVE_FORCEINLINE constexpr as_logical_t<T> logical_not_(EVE_SUPPORTS(cpu_) | ||
, T const &a) noexcept | ||
{ | ||
return !a; | ||
} | ||
} | ||
|
||
#endif |
80 changes: 80 additions & 0 deletions
80
include/eve/module/core/function/simd/common/logical_not.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Copyright 2019 Joel FALCOU | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
#ifndef EVE_MODULE_CORE_FUNCTION_SIMD_COMMON_LOGICAL_NOT_HPP_INCLUDED | ||
#define EVE_MODULE_CORE_FUNCTION_SIMD_COMMON_LOGICAL_NOT_HPP_INCLUDED | ||
|
||
#include <eve/detail/overload.hpp> | ||
#include <eve/detail/skeleton.hpp> | ||
#include <eve/detail/meta.hpp> | ||
#include <eve/detail/abi.hpp> | ||
#include <eve/logical.hpp> | ||
#include <eve/function/bitwise_cast.hpp> | ||
#include <eve/function/is_equal.hpp> | ||
#include <eve/function/bitwise_xor.hpp> | ||
#include <eve/constant/zero.hpp> | ||
#include <eve/forward.hpp> | ||
#include <type_traits> | ||
|
||
namespace eve::detail | ||
{ | ||
// ----------------------------------------------------------------------------------------------- | ||
// Basic | ||
template<typename T, typename N, typename ABI> | ||
EVE_FORCEINLINE auto logical_not_(EVE_SUPPORTS(simd_), | ||
wide<T, N, ABI> const &v) noexcept | ||
{ | ||
using t_t = wide<T, N, ABI>; | ||
return eve::is_equal(v, eve::Zero<t_t>()); | ||
} | ||
|
||
// ----------------------------------------------------------------------------------------------- | ||
// logical | ||
template<typename T, typename N, typename ABI> | ||
EVE_FORCEINLINE auto logical_not_(EVE_SUPPORTS(simd_), | ||
wide<logical<T>, N, ABI> const &v) noexcept | ||
{ | ||
using l_t = wide<eve::logical<T>, N, ABI>; | ||
using t_t = wide<T, N, ABI>; | ||
return eve::bitwise_cast<l_t>(eve::bitwise_not(eve::bitwise_cast<t_t>(v))); | ||
} | ||
|
||
// ----------------------------------------------------------------------------------------------- | ||
// Aggregation | ||
template<typename T, typename N> | ||
EVE_FORCEINLINE auto logical_not_(EVE_SUPPORTS(simd_), | ||
wide<T, N, aggregated_> const &v) noexcept | ||
{ | ||
return aggregate(eve::logical_not, v); | ||
} | ||
|
||
// ----------------------------------------------------------------------------------------------- | ||
// Emulation with auto-splat inside map for performance purpose | ||
template<typename T, typename N> | ||
EVE_FORCEINLINE auto logical_not_(EVE_SUPPORTS(simd_) | ||
, wide<T, N, emulated_> const &v0) noexcept | ||
{ | ||
return map(eve::logical_not, v0); | ||
} | ||
|
||
} | ||
|
||
// ------------------------------------------------------------------------------------------------- | ||
// Infix operator support | ||
namespace eve | ||
{ | ||
template<typename T, typename N, typename ABI> | ||
EVE_FORCEINLINE auto operator!(wide<T, N, ABI> const &v) noexcept | ||
{ | ||
return eve::logical_not(v); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
#ifndef EVE_MODULE_CORE_FUNCTION_SIMD_LOGICAL_NOT_HPP_INCLUDED | ||
#define EVE_MODULE_CORE_FUNCTION_SIMD_LOGICAL_NOT_HPP_INCLUDED | ||
|
||
#include <eve/arch.hpp> | ||
#include <eve/module/core/function/simd/common/logical_not.hpp> | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
#include <eve/function/scalar/logical_not.hpp> | ||
#include <eve/logical.hpp> | ||
#include <eve/constant/true.hpp> | ||
#include <eve/constant/false.hpp> | ||
#include <tts/tts.hpp> | ||
#include <tts/tests/relation.hpp> | ||
#include <tts/tests/types.hpp> | ||
#include <cstddef> | ||
|
||
TTS_CASE("Check logical_not return type") | ||
{ | ||
using eve::logical; | ||
using eve::True; | ||
using eve::False; | ||
|
||
TTS_EXPR_IS(eve::logical_not(0.f), logical<float>); | ||
TTS_EXPR_IS(eve::logical_not(0.), logical<double>); | ||
|
||
TTS_EXPR_IS(eve::logical_not(std::int8_t()), logical<std::int8_t>); | ||
TTS_EXPR_IS(eve::logical_not(std::int16_t()), logical<std::int16_t>); | ||
TTS_EXPR_IS(eve::logical_not(std::int32_t()), logical<std::int32_t>); | ||
TTS_EXPR_IS(eve::logical_not(std::int64_t()), logical<std::int64_t>); | ||
|
||
TTS_EXPR_IS(eve::logical_not(std::uint8_t()), logical<std::uint8_t>); | ||
TTS_EXPR_IS(eve::logical_not(std::uint16_t()), logical<std::uint16_t>); | ||
TTS_EXPR_IS(eve::logical_not(std::uint32_t()), logical<std::uint32_t>); | ||
TTS_EXPR_IS(eve::logical_not(std::uint64_t()), logical<std::uint64_t>); | ||
} | ||
|
||
TTS_CASE("Check logical_not behavior") | ||
{ | ||
using eve::logical; | ||
using eve::True; | ||
using eve::False; | ||
|
||
TTS_EQUAL(eve::logical_not(std::uint8_t(0)), True<logical<std::uint8_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::uint16_t(0)), True<logical<std::uint16_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::uint32_t(0)), True<logical<std::uint32_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::uint64_t(0)), True<logical<std::uint64_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int8_t(0)), True<logical<std::int8_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int16_t(0)), True<logical<std::int16_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int32_t(0)), True<logical<std::int32_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int64_t(0)), True<logical<std::int64_t>>()); | ||
TTS_EQUAL(eve::logical_not(double(0)), True<logical<double>>()); | ||
TTS_EQUAL(eve::logical_not(float(0)), True<logical<float>>()); | ||
TTS_EQUAL(eve::logical_not(-double(0)), True<logical<double>>()); | ||
TTS_EQUAL(eve::logical_not(-float(0)), True<logical<float>>()); | ||
|
||
TTS_EQUAL(eve::logical_not(std::uint8_t(1)), False<logical<std::uint8_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::uint16_t(1)), False<logical<std::uint16_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::uint32_t(1)), False<logical<std::uint32_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::uint64_t(1)), False<logical<std::uint64_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int8_t(1)), False<logical<std::int8_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int16_t(1)), False<logical<std::int16_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int32_t(1)), False<logical<std::int32_t>>()); | ||
TTS_EQUAL(eve::logical_not(std::int64_t(1)), False<logical<std::int64_t>>()); | ||
TTS_EQUAL(eve::logical_not(double(1)), False<logical<double>>()); | ||
TTS_EQUAL(eve::logical_not(float(1)), False<logical<float>>()); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
using Type = double; | ||
#include "logical_not.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
using Type = float; | ||
#include "logical_not.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
#include <cstdint> | ||
using Type = std::int16_t; | ||
#include "logical_not.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
#include <cstdint> | ||
using Type = std::int32_t; | ||
#include "logical_not.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
#include <cstdint> | ||
using Type = std::int64_t; | ||
#include "logical_not.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
#include <cstdint> | ||
using Type = std::int8_t; | ||
#include "logical_not.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
#ifndef LOGICAL_NOT_HPP | ||
#define LOGICAL_NOT_HPP | ||
|
||
#include "test.hpp" | ||
#include <tts/tests/relation.hpp> | ||
#include <eve/logical.hpp> | ||
#include <eve/function/simd/logical_not.hpp> | ||
#include <eve/wide.hpp> | ||
|
||
using eve::fixed; | ||
|
||
TTS_CASE_TPL("Check logical_not behavior on wide", | ||
fixed<1>, | ||
fixed<2>, | ||
fixed<4>, | ||
fixed<8>, | ||
fixed<16>, | ||
fixed<32>, | ||
fixed<64>) | ||
{ | ||
using eve::wide; | ||
|
||
TTS_SETUP("A correctly initialized wide") | ||
{ | ||
wide<Type, T> lhs([](int i, int) { return i%2; }); | ||
|
||
wide < eve::logical < Type >, T> ref([](int i, int) { return eve::logical_not(Type(i%2)); }); | ||
|
||
TTS_SECTION("supports eve::logical_not") { TTS_EQUAL(ref, eve::logical_not(lhs)); } | ||
TTS_SECTION("supports operator!") { TTS_EQUAL(ref, !lhs); } | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
#include <cstdint> | ||
using Type = std::uint16_t; | ||
#include "logical_not.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright 2019 Jean-Thierry Lapreste | ||
Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
|
||
#include <cstdint> | ||
using Type = std::uint32_t; | ||
#include "logical_not.hpp" |
Oops, something went wrong.