◆ host

const detail::host_t thrust::host

thrust::host is the default parallel execution policy associated with Thrust's host backend system configured by the THRUST_HOST_SYSTEM macro.

Instead of relying on implicit algorithm dispatch through iterator system tags, users may directly target algorithm dispatch at Thrust's host system by providing thrust::host as an algorithm parameter.

Explicit dispatch can be useful in avoiding the introduction of data copies into containers such as thrust::host_vector.

Note that even though thrust::host targets the host CPU, it is a parallel execution policy. That is, the order that an algorithm invokes functors or dereferences iterators is not defined.

The type of thrust::host is implementation-defined.

The following code snippet demonstrates how to use thrust::host to explicitly dispatch an invocation of thrust::for_each to the host backend system:

#include <cstdio>
struct printf_functor
__host__ __device__
void operator()(int x)
printf("%d\n", x);
int vec(3);
vec[0] = 0; vec[1] = 1; vec[2] = 2;
thrust::for_each(thrust::host, vec.begin(), vec.end(), printf_functor());
// 0 1 2 is printed to standard output in some unspecified order
See also