Skip to content

Commit 6597b5f

Browse files
committed
Fix issues with thrust benchmarks
1 parent b9668c9 commit 6597b5f

File tree

7 files changed

+22
-82
lines changed

7 files changed

+22
-82
lines changed

thrust/benchmarks/bench/find/basic.cu

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
//===----------------------------------------------------------------------===//
2-
//
3-
// Part of libcu++, the C++ Standard Library for your entire system,
4-
// under the Apache License v2.0 with LLVM Exceptions.
5-
// See https://llvm.org/LICENSE.txt for license information.
1+
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
62
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7-
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
8-
//
9-
//===----------------------------------------------------------------------===//
103

114
#include <thrust/device_vector.h>
125
#include <thrust/find.h>
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
// SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
#include <thrust/detail/internal_functional.h>
54
#include <thrust/device_vector.h>
6-
#include <thrust/fill.h>
75
#include <thrust/find.h>
86

7+
#include <cuda/functional>
8+
#include <cuda/memory_pool>
9+
#include <cuda/stream>
10+
911
#include "nvbench_helper.cuh"
1012

1113
template <typename T>
12-
void find_if(nvbench::state& state, nvbench::type_list<T>)
14+
static void basic(nvbench::state& state, nvbench::type_list<T>)
1315
{
1416
T val = 1;
1517
// set up input
@@ -24,13 +26,16 @@ void find_if(nvbench::state& state, nvbench::type_list<T>)
2426
state.add_global_memory_reads<T>(mismatch_point + 1);
2527
state.add_global_memory_writes<size_t>(1);
2628

27-
caching_allocator_t alloc;
28-
state.exec(nvbench::exec_tag::no_batch | nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
29-
thrust::find_if(policy(alloc, launch), dinput.begin(), dinput.end(), cuda::equal_to_value<T>(val));
30-
});
29+
caching_allocator_t alloc{};
30+
31+
state.exec(nvbench::exec_tag::gpu | nvbench::exec_tag::no_batch | nvbench::exec_tag::sync,
32+
[&](nvbench::launch& launch) {
33+
do_not_optimize(
34+
thrust::find_if(policy(alloc, launch), dinput.begin(), dinput.end(), cuda::equal_to_value<T>{val}));
35+
});
3136
}
3237

33-
NVBENCH_BENCH_TYPES(find_if, NVBENCH_TYPE_AXES(fundamental_types))
38+
NVBENCH_BENCH_TYPES(basic, NVBENCH_TYPE_AXES(fundamental_types))
3439
.set_name("base")
3540
.add_int64_power_of_two_axis("Elements", nvbench::range(16, 28, 4))
36-
.add_float64_axis("MismatchAt", std::vector{1.0, 0.5, 0.0});
41+
.add_float64_axis("MismatchAt", std::vector{1.0, 0.5, 0.01});

thrust/benchmarks/bench/find_if_not/basic.cu

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
//===----------------------------------------------------------------------===//
2-
//
3-
// Part of libcu++, the C++ Standard Library for your entire system,
4-
// under the Apache License v2.0 with LLVM Exceptions.
5-
// See https://llvm.org/LICENSE.txt for license information.
1+
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
62
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7-
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
8-
//
9-
//===----------------------------------------------------------------------===//
103

114
#include <thrust/device_vector.h>
125
#include <thrust/find.h>

thrust/benchmarks/bench/is_sorted/basic.cu

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
//===----------------------------------------------------------------------===//
2-
//
3-
// Part of libcu++, the C++ Standard Library for your entire system,
4-
// under the Apache License v2.0 with LLVM Exceptions.
5-
// See https://llvm.org/LICENSE.txt for license information.
1+
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
62
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7-
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
8-
//
9-
//===----------------------------------------------------------------------===//
103

114
#include <thrust/device_vector.h>
125
#include <thrust/sequence.h>

thrust/benchmarks/bench/is_sorted_until/basic.cu

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
//===----------------------------------------------------------------------===//
2-
//
3-
// Part of libcu++, the C++ Standard Library for your entire system,
4-
// under the Apache License v2.0 with LLVM Exceptions.
5-
// See https://llvm.org/LICENSE.txt for license information.
1+
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
62
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7-
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
8-
//
9-
//===----------------------------------------------------------------------===//
103

114
#include <thrust/device_vector.h>
125
#include <thrust/sequence.h>

thrust/benchmarks/bench/mismatch/basic.cu

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include <thrust/fill.h>
66
#include <thrust/mismatch.h>
77

8+
#include <cuda/iterator>
89
#include <cuda/memory_pool>
9-
#include <cuda/std/__pstl_algorithm>
1010
#include <cuda/stream>
1111

1212
#include "nvbench_helper.cuh"
@@ -40,39 +40,3 @@ NVBENCH_BENCH_TYPES(range_iter, NVBENCH_TYPE_AXES(fundamental_types))
4040
.set_name("base_range_iter")
4141
.add_int64_power_of_two_axis("Elements", nvbench::range(16, 28, 4))
4242
.add_float64_axis("MismatchAt", std::vector{1.0, 0.5, 0.01});
43-
44-
template <typename T>
45-
static void range_range(nvbench::state& state, nvbench::type_list<T>)
46-
{
47-
T val = 1;
48-
// set up input
49-
const auto elements = static_cast<std::size_t>(state.get_int64("Elements"));
50-
const auto common_prefix = state.get_float64("MismatchAt");
51-
const auto mismatch_point = static_cast<std::size_t>(elements * common_prefix);
52-
53-
thrust::device_vector<T> dinput(elements, thrust::no_init);
54-
thrust::fill(dinput.begin(), dinput.begin() + mismatch_point, T{0});
55-
thrust::fill(dinput.begin() + mismatch_point, dinput.end(), val);
56-
57-
state.add_global_memory_reads<T>(mismatch_point + 1);
58-
state.add_global_memory_writes<size_t>(1);
59-
60-
cuda::stream stream{cuda::device_ref{0}};
61-
cuda::device_memory_pool_ref alloc = cuda::device_default_memory_pool(stream.device());
62-
63-
auto policy = cuda::execution::__cub_par_unseq.with_stream(stream).with_memory_resource(alloc);
64-
state.exec(nvbench::exec_tag::gpu | nvbench::exec_tag::no_batch | nvbench::exec_tag::sync,
65-
[&](nvbench::launch& launch) {
66-
(void) cuda::std::mismatch(
67-
policy.with_stream(launch.get_stream().get_stream()),
68-
dinput.begin(),
69-
dinput.end(),
70-
cuda::constant_iterator<T>{0},
71-
cuda::constant_iterator<T>{0, elements});
72-
});
73-
}
74-
75-
NVBENCH_BENCH_TYPES(range_range, NVBENCH_TYPE_AXES(fundamental_types))
76-
.set_name("base_range_range")
77-
.add_int64_power_of_two_axis("Elements", nvbench::range(16, 28, 4))
78-
.add_float64_axis("MismatchAt", std::vector{1.0, 0.5, 0.01});

thrust/benchmarks/bench/transform/zip_transform.cu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
#include <thrust/device_vector.h>
55
#include <thrust/execution_policy.h>
6-
#include <thrust/iterator/zip_iterator.h>
7-
#include <thrust/zip_function.h>
86

9-
#include <cuda/__functional/address_stability.h>
7+
#include <cuda/functional>
8+
#include <cuda/iterator>
109

1110
#include <nvbench_helper.cuh>
1211

0 commit comments

Comments
 (0)