folly/folly/algorithm/simd/detail/SimdAnyOf.h

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <folly/CPortability.h>
#include <folly/algorithm/simd/detail/SimdForEach.h>
#include <folly/algorithm/simd/detail/UnrollUtils.h>

namespace folly {
namespace simd_detail {

/**
 * AnyOfDelegate
 *
 * Implementation detail of simdAnyOf
 * This is a delegate to simdForEach
 *
 * Based on
 * https://github.com/jfalcou/eve/blob/9309d6d17a35004adb371099d79082c8cc75d3a6/include/eve/module/algo/algo/any_of.hpp#L23
 */
template <typename Platform, typename I, typename P>
struct AnyOfDelegate {};

/**
 * simdAnyOf<Platform, unrolling = 4>(f, l, p);
 *
 * Like std::any_of but with vectorized predicates.
 * Predicate shoud accept Platform::reg_t and return Platform::logical_t.
 *
 * By default is unrolled 4 ways but for expensive predicates you might want to
 * use an unroll factor of 1.
 *
 * Function is marked as FOLLY_ALWAYS_INLINE because we don't want the end users
 * to include this directly, we want to implement a specific function and hide
 * that code behind a compile time boundary.
 */
template <typename Platform, int unrolling = 4, typename T, typename P>
FOLLY_ALWAYS_INLINE bool simdAnyOf(T* f, T* l, P p) {}

} // namespace simd_detail
} // namespace folly