[AMDGPU] Mark AGPR tuple implicit in the first instr of AGPR spills. (#115285)
[llvm-project.git] / libcxx / test / std / algorithms / alg.nonmodifying / alg.foreach / pstl.for_each.pass.cpp
blobb0e77094f0a4242a0a15f39f67178aeca859009a
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // UNSUPPORTED: libcpp-has-no-incomplete-pstl
13 // <algorithm>
15 // template<class ExecutionPolicy, class ForwardIterator, class Function>
16 // void for_each(ExecutionPolicy&& exec,
17 // ForwardIterator first, ForwardIterator last,
18 // Function f);
20 #include <algorithm>
21 #include <atomic>
22 #include <cassert>
23 #include <vector>
25 #include "test_macros.h"
26 #include "test_execution_policies.h"
27 #include "test_iterators.h"
29 EXECUTION_POLICY_SFINAE_TEST(for_each);
31 static_assert(sfinae_test_for_each<int, int*, int*, bool (*)(int)>);
32 static_assert(!sfinae_test_for_each<std::execution::parallel_policy, int*, int*, bool (*)(int)>);
34 template <class Iter>
35 struct Test {
36 template <class Policy>
37 void operator()(Policy&& policy) {
38 int sizes[] = {0, 1, 2, 100};
39 for (auto size : sizes) {
40 std::vector<int> a(size);
41 std::vector<Bool> called(size);
42 std::for_each(policy, Iter(std::data(a)), Iter(std::data(a) + std::size(a)), [&](int& v) {
43 assert(!called[&v - a.data()]);
44 called[&v - a.data()] = true;
45 });
46 assert(std::all_of(std::begin(called), std::end(called), [](bool b) { return b; }));
51 int main(int, char**) {
52 types::for_each(types::forward_iterator_list<int*>{}, TestIteratorWithPolicies<Test>{});
54 return 0;