2
* Copyright 2008-2012 NVIDIA Corporation
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
#include <thrust/detail/config.h>
20
#include <thrust/system/cuda/detail/execution_policy.h>
21
#include <thrust/system/cuda/detail/assign_value.h>
22
#include <thrust/detail/raw_pointer_cast.h>
23
#include <thrust/iterator/iterator_traits.h>
39
template<typename DerivedPolicy, typename Pointer>
40
inline __host__ __device__
41
typename thrust::iterator_value<Pointer>::type
42
get_value_msvc2005_war(execution_policy<DerivedPolicy> &exec, Pointer ptr)
44
typedef typename thrust::iterator_value<Pointer>::type result_type;
46
// XXX war nvbugs/881631
47
struct war_nvbugs_881631
49
__host__ inline static result_type host_path(execution_policy<DerivedPolicy> &exec, Pointer ptr)
51
// when called from host code, implement with assign_value
52
// note that this requires a type with default constructor
55
thrust::host_system_tag host_tag;
56
cross_system<thrust::host_system_tag, DerivedPolicy> systems(host_tag, exec);
57
assign_value(systems, &result, ptr);
62
__device__ inline static result_type device_path(execution_policy<DerivedPolicy> &, Pointer ptr)
64
// when called from device code, just do simple deref
65
return *thrust::raw_pointer_cast(ptr);
70
return war_nvbugs_881631::host_path(exec, ptr);
72
return war_nvbugs_881631::device_path(exec, ptr);
73
#endif // __CUDA_ARCH__
74
} // end get_value_msvc2005_war()
77
} // end anon namespace
80
template<typename DerivedPolicy, typename Pointer>
81
inline __host__ __device__
82
typename thrust::iterator_value<Pointer>::type
83
get_value(execution_policy<DerivedPolicy> &exec, Pointer ptr)
85
return get_value_msvc2005_war(exec,ptr);