Skip to content

Commit

Permalink
Revert D63116101
Browse files Browse the repository at this point in the history
Summary:
This diff reverts D63116101
C++17 only required for cpp files.

Reviewed By: DenisYaroshevskiy

Differential Revision: D63559513

fbshipit-source-id: 88a930ab5b66ba2da2dba22e87a82ecc8992f0fb
  • Loading branch information
generatedunixname89002005232357 authored and facebook-github-bot committed Sep 27, 2024
1 parent b2d6e17 commit 513124f
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 336 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -649,13 +649,13 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
DIRECTORY algorithm/simd/detail/test/
TEST algorithm_simd_detail_simd_any_of_test SOURCES SimdAnyOfTest.cpp
TEST algorithm_simd_detail_simd_for_each_test SOURCES SimdForEachTest.cpp
TEST algorithm_simd_detail_simd_traits_test SOURCES TraitsTest.cpp
TEST algorithm_simd_detail_unroll_utils_test SOURCES UnrollUtilsTest.cpp
# disabled until C++20
# TEST algorithm_simd_detail_simd_traits_test SOURCES TraitsTest.cpp

DIRECTORY algorithm/simd/test/
TEST algorithm_simd_find_fixed_test SOURCES FindFixedTest.cpp
TEST algorithm_simd_movemask_test SOURCES MovemaskTest.cpp
TEST algorithm_simd_simd_contains_test SOURCES SimdContainsTest.cpp

DIRECTORY chrono/test/
TEST chrono_conv_test WINDOWS_DISABLED
Expand Down
13 changes: 0 additions & 13 deletions folly/algorithm/simd/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,3 @@ cpp_library(
"//folly/algorithm/simd/detail:traits",
],
)

cpp_library(
name = "contains",
srcs = ["Contains.cpp"],
headers = ["Contains.h"],
deps = [
"//folly/algorithm/simd/detail:simd_contains_impl",
],
exported_deps = [
"//folly:c_portability",
"//folly/algorithm/simd/detail:traits",
],
)
42 changes: 0 additions & 42 deletions folly/algorithm/simd/Contains.cpp

This file was deleted.

65 changes: 0 additions & 65 deletions folly/algorithm/simd/Contains.h

This file was deleted.

3 changes: 1 addition & 2 deletions folly/algorithm/simd/FindFixed.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ constexpr std::optional<std::size_t> findFixed(std::span<const T, N> where, U x)
return find_fixed_detail::findFixedConstexpr(std::span<const T>(where), x);
} else {
return find_fixed_detail::findFixedDispatch(
simd::detail::asSimdFriendlyUint(where),
simd::detail::asSimdFriendlyUint(x));
detail::asSimdFriendlyUint(where), detail::asSimdFriendlyUint(x));
}
}

Expand Down
12 changes: 0 additions & 12 deletions folly/algorithm/simd/detail/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ cpp_library(
],
)

cpp_library(
name = "simd_contains_impl",
headers = ["ContainsImpl.h"],
exported_deps = [
":simd_any_of",
":simd_char_platform",
"//folly:c_portability",
"//folly/container:span",
],
)

cpp_library(
name = "simd_for_each",
headers = ["SimdForEach.h"],
Expand All @@ -51,7 +40,6 @@ cpp_library(
name = "traits",
headers = ["Traits.h"],
exported_deps = [
"//folly:c_portability",
"//folly:memory",
"//folly:traits",
"//folly/container:span",
Expand Down
91 changes: 0 additions & 91 deletions folly/algorithm/simd/detail/ContainsImpl.h

This file was deleted.

40 changes: 28 additions & 12 deletions folly/algorithm/simd/detail/Traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

#pragma once

#include <folly/CPortability.h>
#include <folly/Memory.h>
#include <folly/Traits.h>
#include <folly/container/span.h>

#include <concepts>
#include <type_traits>

namespace folly::simd::detail {
namespace folly::detail {

template <typename T>
auto findSimdFriendlyEquivalent() {
Expand All @@ -37,9 +36,25 @@ auto findSimdFriendlyEquivalent() {
return double{};
}
} else if constexpr (std::is_signed_v<T>) {
return int_bits_t<sizeof(T) * 8>{};
if constexpr (sizeof(T) == 1) {
return std::int8_t{};
} else if constexpr (sizeof(T) == 2) {
return std::int16_t{};
} else if constexpr (sizeof(T) == 4) {
return std::int32_t{};
} else if constexpr (sizeof(T) == 8) {
return std::int64_t{};
}
} else if constexpr (std::is_unsigned_v<T>) {
return uint_bits_t<sizeof(T) * 8>{};
if constexpr (sizeof(T) == 1) {
return std::uint8_t{};
} else if constexpr (sizeof(T) == 2) {
return std::uint16_t{};
} else if constexpr (sizeof(T) == 4) {
return std::uint32_t{};
} else if constexpr (sizeof(T) == 8) {
return std::uint64_t{};
}
}
}

Expand All @@ -48,7 +63,7 @@ concept has_simd_friendly_equivalent =
!std::is_same_v<void, decltype(findSimdFriendlyEquivalent<T>())>;

template <has_simd_friendly_equivalent T>
using simd_friendly_equivalent_t = like_t< //
using simd_friendly_equivalent_t = folly::like_t< //
T,
decltype(findSimdFriendlyEquivalent<std::remove_const_t<T>>())>;

Expand All @@ -62,23 +77,24 @@ template <has_integral_simd_friendly_equivalent T>
using integral_simd_friendly_equivalent = simd_friendly_equivalent_t<T>;

template <has_simd_friendly_equivalent T, std::size_t Extend>
FOLLY_ERASE auto asSimdFriendly(folly::span<T, Extend> s) {
return reinterpret_span_cast<simd_friendly_equivalent_t<T>>(s);
auto asSimdFriendly(folly::span<T, Extend> s) {
return folly::reinterpret_span_cast<simd_friendly_equivalent_t<T>>(s);
}

template <has_simd_friendly_equivalent T>
FOLLY_ERASE constexpr auto asSimdFriendly(T x) {
constexpr auto asSimdFriendly(T x) {
return static_cast<simd_friendly_equivalent_t<T>>(x);
}

template <has_simd_friendly_equivalent T, std::size_t Extend>
FOLLY_ERASE auto asSimdFriendlyUint(folly::span<T, Extend> s) {
return reinterpret_span_cast<like_t<T, uint_bits_t<sizeof(T) * 8>>>(s);
auto asSimdFriendlyUint(folly::span<T, Extend> s) {
return folly::reinterpret_span_cast<
folly::like_t<T, uint_bits_t<sizeof(T) * 8>>>(s);
}

template <has_simd_friendly_equivalent T>
FOLLY_ERASE constexpr auto asSimdFriendlyUint(T x) {
constexpr auto asSimdFriendlyUint(T x) {
return static_cast<uint_bits_t<sizeof(T) * 8>>(x);
}

} // namespace folly::simd::detail
} // namespace folly::detail
10 changes: 5 additions & 5 deletions folly/algorithm/simd/detail/test/TraitsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>

namespace folly::simd::detail {
namespace folly::detail {

struct SimdTraitsTest : testing::Test {};
struct FollySimdTraitsTest : testing::Test {};

namespace simd_friendly_equivalent_test {

Expand Down Expand Up @@ -98,7 +98,7 @@ static_assert(Overloading{}(SomeInt{}) == 2);

} // namespace integral_simd_friendly_equivalent_test

TEST_F(SimdTraitsTest, AsSimdFriendly) {
TEST_F(FollySimdTraitsTest, AsSimdFriendly) {
enum SomeEnum : int { Foo = 1, Bar, Baz };

static_assert(asSimdFriendly(SomeEnum::Foo) == 1);
Expand All @@ -122,7 +122,7 @@ void asSimdFriendlyUintTypeTest() {
asSimdFriendlyUint(std::span<const From>{}), std::span<const To>{});
}

TEST_F(SimdTraitsTest, AsSimdFriendlyUint) {
TEST_F(FollySimdTraitsTest, AsSimdFriendlyUint) {
enum SomeEnum : int { Foo = 1, Bar, Baz };

static_assert(asSimdFriendlyUint(SomeEnum::Foo) == 1U);
Expand All @@ -136,4 +136,4 @@ TEST_F(SimdTraitsTest, AsSimdFriendlyUint) {
asSimdFriendlyUintTypeTest<double, std::uint64_t>();
}

} // namespace folly::simd::detail
} // namespace folly::detail
Loading

0 comments on commit 513124f

Please sign in to comment.