Filling
template <typename DerivedPolicy, typename ForwardIterator, typename T> _CCCL_HOST_DEVICE void fill(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, ForwardIterator first, ForwardIterator last, const T & value);
template <typename ForwardIterator, typename T> _CCCL_HOST_DEVICE void fill(ForwardIterator first, ForwardIterator last, const T & value);
template <typename DerivedPolicy, typename OutputIterator, typename Size, typename T> _CCCL_HOST_DEVICE OutputIterator fill_n(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, OutputIterator first, Size n, const T & value);
template <typename OutputIterator, typename Size, typename T> _CCCL_HOST_DEVICE OutputIterator fill_n(OutputIterator first, Size n, const T & value);
template <typename DerivedPolicy, typename ForwardIterator, typename T> _CCCL_HOST_DEVICE void uninitialized_fill(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, ForwardIterator first, ForwardIterator last, const T & x);
template <typename ForwardIterator, typename T> void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T & x);
template <typename DerivedPolicy, typename ForwardIterator, typename Size, typename T> _CCCL_HOST_DEVICE ForwardIterator uninitialized_fill_n(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, ForwardIterator first, Size n, const T & x);
template <typename ForwardIterator, typename Size, typename T> ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T & x);
Functions
Function fill
template <typename DerivedPolicy, typename ForwardIterator, typename T> _CCCL_HOST_DEVICE void fill(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, ForwardIterator first, ForwardIterator last, const T & value);
fill
assigns the value value
to every element in the range [first, last)
. That is, for every iterator i
in [first, last)
, it performs the assignment *i = value
.
The algorithm’s execution is parallelized as determined by exec
.
The following code snippet demonstrates how to use fill
to set a thrust::device_vector’s elements to a given value using the thrust::device
execution policy for parallelization:
#include <thrust/fill.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
...
thrust::device_vector<int> v(4);
thrust::fill(thrust::device, v.begin(), v.end(), 137);
// v[0] == 137, v[1] == 137, v[2] == 137, v[3] == 137
Template Parameters:
DerivedPolicy
The name of the derived execution policy.ForwardIterator
is a model of Forward Iterator, andForwardIterator
is mutable.T
is a model of Assignable, andT's
value_type
is convertible toForwardIterator's
value_type
.
Function Parameters:
exec
The execution policy to use for parallelization.first
The beginning of the sequence.last
The end of the sequence.value
The value to be copied.
See:
- https://en.cppreference.com/w/cpp/algorithm/fill
fill_n
uninitialized_fill
Function fill
template <typename ForwardIterator, typename T> _CCCL_HOST_DEVICE void fill(ForwardIterator first, ForwardIterator last, const T & value);
fill
assigns the value value
to every element in the range [first, last)
. That is, for every iterator i
in [first, last)
, it performs the assignment *i = value
.
The following code snippet demonstrates how to use fill
to set a thrust::device_vector’s elements to a given value.
#include <thrust/fill.h>
#include <thrust/device_vector.h>
...
thrust::device_vector<int> v(4);
thrust::fill(v.begin(), v.end(), 137);
// v[0] == 137, v[1] == 137, v[2] == 137, v[3] == 137
Template Parameters:
ForwardIterator
is a model of Forward Iterator, andForwardIterator
is mutable.T
is a model of Assignable, andT's
value_type
is convertible toForwardIterator's
value_type
.
Function Parameters:
first
The beginning of the sequence.last
The end of the sequence.value
The value to be copied.
See:
- https://en.cppreference.com/w/cpp/algorithm/fill
fill_n
uninitialized_fill
Function fill_n
template <typename DerivedPolicy, typename OutputIterator, typename Size, typename T> _CCCL_HOST_DEVICE OutputIterator fill_n(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, OutputIterator first, Size n, const T & value);
fill_n
assigns the value value
to every element in the range [first, first+n)
. That is, for every iterator i
in [first, first+n)
, it performs the assignment *i = value
.
The algorithm’s execution is parallelized as determined by exec
.
The following code snippet demonstrates how to use fill
to set a thrust::device_vector’s elements to a given value using the thrust::device
execution policy for parallelization:
#include <thrust/fill.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
...
thrust::device_vector<int> v(4);
thrust::fill_n(thrust::device, v.begin(), v.size(), 137);
// v[0] == 137, v[1] == 137, v[2] == 137, v[3] == 137
Template Parameters:
DerivedPolicy
The name of the derived execution policy.OutputIterator
is a model of Output Iterator.T
is a model of Assignable, andT's
value_type
is convertible to a type inOutputIterator's
set ofvalue_type
.
Function Parameters:
exec
The execution policy to use for parallelization.first
The beginning of the sequence.n
The size of the sequence.value
The value to be copied.
Returns: first + n
See:
- https://en.cppreference.com/w/cpp/algorithm/fill_n
fill
uninitialized_fill_n
Function fill_n
template <typename OutputIterator, typename Size, typename T> _CCCL_HOST_DEVICE OutputIterator fill_n(OutputIterator first, Size n, const T & value);
fill_n
assigns the value value
to every element in the range [first, first+n)
. That is, for every iterator i
in [first, first+n)
, it performs the assignment *i = value
.
The following code snippet demonstrates how to use fill
to set a thrust::device_vector’s elements to a given value.
#include <thrust/fill.h>
#include <thrust/device_vector.h>
...
thrust::device_vector<int> v(4);
thrust::fill_n(v.begin(), v.size(), 137);
// v[0] == 137, v[1] == 137, v[2] == 137, v[3] == 137
Template Parameters:
OutputIterator
is a model of Output Iterator.T
is a model of Assignable, andT's
value_type
is convertible to a type inOutputIterator's
set ofvalue_type
.
Function Parameters:
first
The beginning of the sequence.n
The size of the sequence.value
The value to be copied.
Returns: first + n
See:
- https://en.cppreference.com/w/cpp/algorithm/fill_n
fill
uninitialized_fill_n
Function uninitialized_fill
template <typename DerivedPolicy, typename ForwardIterator, typename T> _CCCL_HOST_DEVICE void uninitialized_fill(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, ForwardIterator first, ForwardIterator last, const T & x);
In thrust
, the function thrust::device_new
allocates memory for an object and then creates an object at that location by calling a constructor. Occasionally, however, it is useful to separate those two operations. If each iterator in the range [first, last)
points to uninitialized memory, then uninitialized_fill
creates copies of x
in that range. That is, for each iterator i
in the range [first, last)
, uninitialized_fill
creates a copy of x
in the location pointed to i
by calling ForwardIterator's
value_type's
copy constructor.
The algorithm’s execution is parallelized as determined by exec
.
The following code snippet demonstrates how to use uninitialized_fill
to initialize a range of uninitialized memory using the thrust::device
execution policy for parallelization:
#include <thrust/uninitialized_fill.h>
#include <thrust/device_malloc.h>
#include <thrust/execution_policy.h>
struct Int
{
__host__ __device__
Int(int x) : val(x) {}
int val;
};
...
const int N = 137;
Int val(46);
thrust::device_ptr<Int> array = thrust::device_malloc<Int>(N);
thrust::uninitialized_fill(thrust::device, array, array + N, val);
// Int x = array[i];
// x.val == 46 for all 0 <= i < N
Template Parameters:
DerivedPolicy
The name of the derived execution policy.ForwardIterator
is a model of Forward Iterator,ForwardIterator
is mutable, andForwardIterator's
value_type
has a constructor that takes a single argument of typeT
.
Function Parameters:
exec
The execution policy to use for parallelization.first
The first element of the range of interest.last
The last element of the range of interest.x
The value to use as the exemplar of the copy constructor.
See:
- https://en.cppreference.com/w/cpp/memory/uninitialized_fill
uninitialized_fill_n
fill
uninitialized_copy
device_new
device_malloc
Function uninitialized_fill
template <typename ForwardIterator, typename T> void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T & x);
In thrust
, the function thrust::device_new
allocates memory for an object and then creates an object at that location by calling a constructor. Occasionally, however, it is useful to separate those two operations. If each iterator in the range [first, last)
points to uninitialized memory, then uninitialized_fill
creates copies of x
in that range. That is, for each iterator i
in the range [first, last)
, uninitialized_fill
creates a copy of x
in the location pointed to i
by calling ForwardIterator's
value_type's
copy constructor.
The following code snippet demonstrates how to use uninitialized_fill
to initialize a range of uninitialized memory.
#include <thrust/uninitialized_fill.h>
#include <thrust/device_malloc.h>
struct Int
{
__host__ __device__
Int(int x) : val(x) {}
int val;
};
...
const int N = 137;
Int val(46);
thrust::device_ptr<Int> array = thrust::device_malloc<Int>(N);
thrust::uninitialized_fill(array, array + N, val);
// Int x = array[i];
// x.val == 46 for all 0 <= i < N
Template Parameters: ForwardIterator
: is a model of Forward Iterator, ForwardIterator
is mutable, and ForwardIterator's
value_type
has a constructor that takes a single argument of type T
.
Function Parameters:
first
The first element of the range of interest.last
The last element of the range of interest.x
The value to use as the exemplar of the copy constructor.
See:
- https://en.cppreference.com/w/cpp/memory/uninitialized_fill
uninitialized_fill_n
fill
uninitialized_copy
device_new
device_malloc
Function uninitialized_fill_n
template <typename DerivedPolicy, typename ForwardIterator, typename Size, typename T> _CCCL_HOST_DEVICE ForwardIterator uninitialized_fill_n(const thrust::detail::execution_policy_base< DerivedPolicy > & exec, ForwardIterator first, Size n, const T & x);
In thrust
, the function thrust::device_new
allocates memory for an object and then creates an object at that location by calling a constructor. Occasionally, however, it is useful to separate those two operations. If each iterator in the range [first, first+n)
points to uninitialized memory, then uninitialized_fill
creates copies of x
in that range. That is, for each iterator i
in the range [first, first+n)
, uninitialized_fill
creates a copy of x
in the location pointed to i
by calling ForwardIterator's
value_type's
copy constructor.
The algorithm’s execution is parallelized as determined by exec
.
The following code snippet demonstrates how to use uninitialized_fill
to initialize a range of uninitialized memory using the thrust::device
execution policy for parallelization:
#include <thrust/uninitialized_fill.h>
#include <thrust/device_malloc.h>
#include <thrust/execution_policy.h>
struct Int
{
__host__ __device__
Int(int x) : val(x) {}
int val;
};
...
const int N = 137;
Int val(46);
thrust::device_ptr<Int> array = thrust::device_malloc<Int>(N);
thrust::uninitialized_fill_n(thrust::device, array, N, val);
// Int x = array[i];
// x.val == 46 for all 0 <= i < N
Template Parameters:
DerivedPolicy
The name of the derived execution policy.ForwardIterator
is a model of Forward Iterator,ForwardIterator
is mutable, andForwardIterator's
value_type
has a constructor that takes a single argument of typeT
.
Function Parameters:
exec
The execution policy to use for parallelization.first
The first element of the range of interest.n
The size of the range of interest.x
The value to use as the exemplar of the copy constructor.
Returns: first+n
See:
- https://en.cppreference.com/w/cpp/memory/uninitialized_fill
uninitialized_fill
fill
uninitialized_copy_n
device_new
device_malloc
Function uninitialized_fill_n
template <typename ForwardIterator, typename Size, typename T> ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T & x);
In thrust
, the function thrust::device_new
allocates memory for an object and then creates an object at that location by calling a constructor. Occasionally, however, it is useful to separate those two operations. If each iterator in the range [first, first+n)
points to uninitialized memory, then uninitialized_fill
creates copies of x
in that range. That is, for each iterator i
in the range [first, first+n)
, uninitialized_fill
creates a copy of x
in the location pointed to i
by calling ForwardIterator's
value_type's
copy constructor.
The following code snippet demonstrates how to use uninitialized_fill
to initialize a range of uninitialized memory.
#include <thrust/uninitialized_fill.h>
#include <thrust/device_malloc.h>
struct Int
{
__host__ __device__
Int(int x) : val(x) {}
int val;
};
...
const int N = 137;
Int val(46);
thrust::device_ptr<Int> array = thrust::device_malloc<Int>(N);
thrust::uninitialized_fill_n(array, N, val);
// Int x = array[i];
// x.val == 46 for all 0 <= i < N
Template Parameters: ForwardIterator
: is a model of Forward Iterator, ForwardIterator
is mutable, and ForwardIterator's
value_type
has a constructor that takes a single argument of type T
.
Function Parameters:
first
The first element of the range of interest.n
The size of the range of interest.x
The value to use as the exemplar of the copy constructor.
Returns: first+n
See:
- https://en.cppreference.com/w/cpp/memory/uninitialized_fill
uninitialized_fill
fill
uninitialized_copy_n
device_new
device_malloc