stdgpu/numeric.h Source File

stdgpu/numeric.h Source File#

stdgpu: stdgpu/numeric.h Source File
stdgpu Latest
Efficient STL-like Data Structures on the GPU
numeric.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Patrick Stotko
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef STDGPU_NUMERIC_H
17#define STDGPU_NUMERIC_H
18
28#include <stdgpu/execution.h>
29
30namespace stdgpu
31{
32
33#ifdef STDGPU_RUN_DOXYGEN
34
46template <typename ExecutionPolicy,
47 typename Iterator,
48 typename T,
49 STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v<remove_cvref_t<ExecutionPolicy>>)>
50void
51iota(ExecutionPolicy&& policy, Iterator begin, Iterator end, T value);
52
53#endif
54
56namespace adl_barrier
57{
58
59template <typename ExecutionPolicy,
60 typename Iterator,
61 typename T,
62 STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v<remove_cvref_t<ExecutionPolicy>>)>
63void
64iota(ExecutionPolicy&& policy, Iterator begin, Iterator end, T value);
65
66} // namespace adl_barrier
67
68using namespace adl_barrier;
70
85template <typename IndexType,
86 typename ExecutionPolicy,
87 typename T,
88 typename BinaryFunction,
89 typename UnaryFunction,
90 STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v<remove_cvref_t<ExecutionPolicy>>)>
91T
92transform_reduce_index(ExecutionPolicy&& policy, IndexType size, T init, BinaryFunction reduce, UnaryFunction f);
93
94} // namespace stdgpu
95
96#include <stdgpu/impl/numeric_detail.h>
97
98#endif // STDGPU_NUMERIC_H
index64_t size(T *array)
Finds the size (number of elements) of the given dynamically allocated array.
T transform_reduce_index(ExecutionPolicy &&policy, IndexType size, T init, BinaryFunction reduce, UnaryFunction f)
Calls the given unary function with an index from the range [0, size) and performs a reduction afterw...
void iota(ExecutionPolicy &&policy, Iterator begin, Iterator end, T value)
Writes ascending values {values + i} to the i-th position of the given range.