thrust
Functions

Functions

template<typename DerivedPolicy , typename ForwardIterator , typename T >
__host__ __device__ void thrust::fill (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, const T &value)
 
template<typename ForwardIterator , typename T >
__host__ __device__ void thrust::fill (ForwardIterator first, ForwardIterator last, const T &value)
 
template<typename DerivedPolicy , typename OutputIterator , typename Size , typename T >
__host__ __device__ OutputIterator thrust::fill_n (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, OutputIterator first, Size n, const T &value)
 
template<typename OutputIterator , typename Size , typename T >
__host__ __device__ OutputIterator thrust::fill_n (OutputIterator first, Size n, const T &value)
 
template<typename DerivedPolicy , typename ForwardIterator , typename T >
__host__ __device__ void thrust::uninitialized_fill (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, const T &x)
 
template<typename ForwardIterator , typename T >
void thrust::uninitialized_fill (ForwardIterator first, ForwardIterator last, const T &x)
 
template<typename DerivedPolicy , typename ForwardIterator , typename Size , typename T >
__host__ __device__ ForwardIterator thrust::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 thrust::uninitialized_fill_n (ForwardIterator first, Size n, const T &x)
 

Detailed Description

Function Documentation

template<typename DerivedPolicy , typename ForwardIterator , typename T >
__host__ __device__ void thrust::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.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the sequence.
lastThe end of the sequence.
valueThe value to be copied.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator, and ForwardIterator is mutable.
Tis a model of Assignable, and T's value_type is convertible to ForwardIterator's value_type.

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>
...
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
See Also
http://www.sgi.com/tech/stl/fill.html
fill_n
uninitialized_fill
template<typename ForwardIterator , typename T >
__host__ __device__ void thrust::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.

Parameters
firstThe beginning of the sequence.
lastThe end of the sequence.
valueThe value to be copied.
Template Parameters
ForwardIteratoris a model of Forward Iterator, and ForwardIterator is mutable.
Tis a model of Assignable, and T's value_type is convertible to ForwardIterator's value_type.

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>
...
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
See Also
http://www.sgi.com/tech/stl/fill.html
fill_n
uninitialized_fill
template<typename DerivedPolicy , typename OutputIterator , typename Size , typename T >
__host__ __device__ OutputIterator thrust::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.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the sequence.
nThe size of the sequence.
valueThe value to be copied.
Returns
first + n
Template Parameters
DerivedPolicyThe name of the derived execution policy.
OutputIteratoris a model of Output Iterator.
Tis a model of Assignable, and T's value_type is convertible to a type in OutputIterator's set of value_type.

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>
...
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
See Also
http://www.sgi.com/tech/stl/fill_n.html
fill
uninitialized_fill_n
template<typename OutputIterator , typename Size , typename T >
__host__ __device__ OutputIterator thrust::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.

Parameters
firstThe beginning of the sequence.
nThe size of the sequence.
valueThe value to be copied.
Returns
first + n
Template Parameters
OutputIteratoris a model of Output Iterator.
Tis a model of Assignable, and T's value_type is convertible to a type in OutputIterator's set of value_type.

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>
...
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
See Also
http://www.sgi.com/tech/stl/fill_n.html
fill
uninitialized_fill_n
template<typename DerivedPolicy , typename ForwardIterator , typename T >
__host__ __device__ void thrust::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 unitialized memory, then unitialized_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.

Parameters
execThe execution policy to use for parallelization.
firstThe first element of the range of interest.
lastThe last element of the range of interest.
xThe value to use as the exemplar of the copy constructor.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator, ForwardIterator is mutable, and ForwardIterator's value_type has a constructor that takes a single argument of type T.

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:

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);
// Int x = array[i];
// x.val == 46 for all 0 <= i < N
See Also
http://www.sgi.com/tech/stl/uninitialized_fill.html
uninitialized_fill_n
fill
uninitialized_copy
device_new
device_malloc
template<typename ForwardIterator , typename T >
void thrust::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 unitialized memory, then unitialized_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.

Parameters
firstThe first element of the range of interest.
lastThe last element of the range of interest.
xThe value to use as the exemplar of the copy constructor.
Template Parameters
ForwardIteratoris a model of Forward Iterator, ForwardIterator is mutable, and ForwardIterator's value_type has a constructor that takes a single argument of type T.

The following code snippet demonstrates how to use uninitialized_fill to initialize a range of uninitialized memory.

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
See Also
http://www.sgi.com/tech/stl/uninitialized_fill.html
uninitialized_fill_n
fill
uninitialized_copy
device_new
device_malloc
template<typename DerivedPolicy , typename ForwardIterator , typename Size , typename T >
__host__ __device__ ForwardIterator thrust::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 unitialized memory, then unitialized_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.

Parameters
execThe execution policy to use for parallelization.
firstThe first element of the range of interest.
nThe size of the range of interest.
xThe value to use as the exemplar of the copy constructor.
Returns
first+n
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator, ForwardIterator is mutable, and ForwardIterator's value_type has a constructor that takes a single argument of type T.

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:

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);
// Int x = array[i];
// x.val == 46 for all 0 <= i < N
See Also
http://www.sgi.com/tech/stl/uninitialized_fill.html
uninitialized_fill
fill
uninitialized_copy_n
device_new
device_malloc
template<typename ForwardIterator , typename Size , typename T >
ForwardIterator thrust::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 unitialized memory, then unitialized_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.

Parameters
firstThe first element of the range of interest.
nThe size of the range of interest.
xThe value to use as the exemplar of the copy constructor.
Returns
first+n
Template Parameters
ForwardIteratoris a model of Forward Iterator, ForwardIterator is mutable, and ForwardIterator's value_type has a constructor that takes a single argument of type T.

The following code snippet demonstrates how to use uninitialized_fill to initialize a range of uninitialized memory.

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);
// Int x = array[i];
// x.val == 46 for all 0 <= i < N
See Also
http://www.sgi.com/tech/stl/uninitialized_fill.html
uninitialized_fill
fill
uninitialized_copy_n
device_new
device_malloc