Permalink
Browse files

Eliminate instances of "using namespace thrust" at global scope, whic…

…h some versions of MSVC can't reconcile with TBB.
  • Loading branch information...
1 parent 7343638 commit dfbaadb61c8f9be9539caf44e123fe8c20eff5ab @jaredhoberock jaredhoberock committed Feb 16, 2012
@@ -4,10 +4,10 @@
#include <thrust/transform.h>
#include <thrust/reduce.h>
-using namespace thrust;
-
void TestConstantIteratorConstructFromConvertibleSystem(void)
{
+ using namespace thrust;
+
constant_iterator<int> default_system(13);
constant_iterator<int, use_default, host_system_tag> host_system = default_system;
@@ -20,6 +20,8 @@ DECLARE_UNITTEST(TestConstantIteratorConstructFromConvertibleSystem);
void TestConstantIteratorIncrement(void)
{
+ using namespace thrust;
+
constant_iterator<int> lhs(0,0);
constant_iterator<int> rhs(0,0);
@@ -46,6 +48,8 @@ DECLARE_UNITTEST(TestConstantIteratorIncrement);
void TestConstantIteratorComparison(void)
{
+ using namespace thrust;
+
constant_iterator<int> iter1(0);
constant_iterator<int> iter2(0);
@@ -73,6 +77,8 @@ DECLARE_UNITTEST(TestConstantIteratorComparison);
void TestMakeConstantIterator(void)
{
+ using namespace thrust;
+
// test one argument version
constant_iterator<int> iter0 = make_constant_iterator<int>(13);
@@ -90,6 +96,8 @@ DECLARE_UNITTEST(TestMakeConstantIterator);
template<typename Vector>
void TestConstantIteratorCopy(void)
{
+ using namespace thrust;
+
typedef typename Vector::value_type T;
typedef constant_iterator<int> ConstIter;
@@ -110,6 +118,8 @@ DECLARE_VECTOR_UNITTEST(TestConstantIteratorCopy);
template<typename Vector>
void TestConstantIteratorTransform(void)
{
+ using namespace thrust;
+
typedef typename Vector::value_type T;
typedef constant_iterator<T> ConstIter;
@@ -138,6 +148,8 @@ DECLARE_VECTOR_UNITTEST(TestConstantIteratorTransform);
void TestConstantIteratorReduce(void)
{
+ using namespace thrust;
+
typedef int T;
typedef constant_iterator<T> ConstIter;
@@ -1,12 +1,10 @@
#include <unittest/unittest.h>
#include <thrust/iterator/discard_iterator.h>
-using namespace thrust;
-
void TestDiscardIteratorIncrement(void)
{
- discard_iterator<> lhs(0);
- discard_iterator<> rhs(0);
+ thrust::discard_iterator<> lhs(0);
+ thrust::discard_iterator<> rhs(0);
ASSERT_EQUAL(0, lhs - rhs);
@@ -31,8 +29,8 @@ DECLARE_UNITTEST(TestDiscardIteratorIncrement);
void TestDiscardIteratorComparison(void)
{
- discard_iterator<> iter1(0);
- discard_iterator<> iter2(0);
+ thrust::discard_iterator<> iter1(0);
+ thrust::discard_iterator<> iter2(0);
ASSERT_EQUAL(0, iter1 - iter2);
ASSERT_EQUAL(true, iter1 == iter2);
@@ -57,11 +55,11 @@ DECLARE_UNITTEST(TestDiscardIteratorComparison);
void TestMakeDiscardIterator(void)
{
- discard_iterator<> iter0 = make_discard_iterator(13);
+ thrust::discard_iterator<> iter0 = thrust::make_discard_iterator(13);
*iter0 = 7;
- discard_iterator<> iter1 = make_discard_iterator(7);
+ thrust::discard_iterator<> iter1 = thrust::make_discard_iterator(7);
*iter1 = 13;
@@ -71,6 +69,8 @@ DECLARE_UNITTEST(TestMakeDiscardIterator);
void TestZippedDiscardIterator(void)
{
+ using namespace thrust;
+
// this test is just to make sure this can compile
typedef tuple<discard_iterator<> > IteratorTuple1;
typedef zip_iterator<IteratorTuple1> ZipIterator1;
View
@@ -3,13 +3,14 @@
#include <thrust/generate.h>
using namespace unittest;
-using namespace thrust;
template <typename T>
struct TestTupleConstructor
{
void operator()(void)
{
+ using namespace thrust;
+
host_vector<T> data = random_integers<T>(10);
tuple<T> t1(data[0]);
@@ -95,6 +96,8 @@ struct TestMakeTuple
{
void operator()(void)
{
+ using namespace thrust;
+
host_vector<T> data = random_integers<T>(10);
tuple<T> t1 = make_tuple(data[0]);
@@ -181,6 +184,8 @@ struct TestTupleGet
void operator()(void)
{
KNOWN_FAILURE
+
+ //using namespace thrust;
//host_vector<T> data = random_integers<T>(10);
//tuple<T> t1(data[0]);
@@ -268,6 +273,8 @@ struct TestTupleComparison
{
void operator()(void)
{
+ using namespace thrust;
+
tuple<T,T,T,T,T> lhs(0, 0, 0, 0, 0), rhs(0, 0, 0, 0, 0);
// equality
View
@@ -4,12 +4,13 @@
#include <thrust/transform.h>
using namespace unittest;
-using namespace thrust;
template <typename Tuple>
__host__ __device__
Tuple operator+(const Tuple &lhs, const Tuple &rhs)
{
+ using namespace thrust;
+
return make_tuple(get<0>(lhs) + get<0>(rhs),
get<1>(lhs) + get<1>(rhs));
}
@@ -18,9 +19,9 @@ struct MakeTupleFunctor
{
template<typename T1, typename T2>
__host__ __device__
- tuple<T1,T2> operator()(T1 &lhs, T2 &rhs)
+ thrust::tuple<T1,T2> operator()(T1 &lhs, T2 &rhs)
{
- return make_tuple(lhs, rhs);
+ return thrust::make_tuple(lhs, rhs);
}
};
@@ -29,25 +30,27 @@ struct TestTupleReduce
{
void operator()(const size_t n)
{
- thrust::host_vector<T> h_t1 = unittest::random_integers<T>(n);
- thrust::host_vector<T> h_t2 = unittest::random_integers<T>(n);
+ using namespace thrust;
+
+ host_vector<T> h_t1 = random_integers<T>(n);
+ host_vector<T> h_t2 = random_integers<T>(n);
// zip up the data
- thrust::host_vector< tuple<T,T> > h_tuples(n);
- thrust::transform(h_t1.begin(), h_t1.end(),
+ host_vector< tuple<T,T> > h_tuples(n);
+ transform(h_t1.begin(), h_t1.end(),
h_t2.begin(), h_tuples.begin(),
MakeTupleFunctor());
// copy to device
- thrust::device_vector< tuple<T,T> > d_tuples = h_tuples;
+ device_vector< tuple<T,T> > d_tuples = h_tuples;
tuple<T,T> zero(0,0);
// sum on host
- tuple<T,T> h_result = thrust::reduce(h_tuples.begin(), h_tuples.end(), zero);
+ tuple<T,T> h_result = reduce(h_tuples.begin(), h_tuples.end(), zero);
// sum on device
- tuple<T,T> d_result = thrust::reduce(d_tuples.begin(), d_tuples.end(), zero);
+ tuple<T,T> d_result = reduce(d_tuples.begin(), d_tuples.end(), zero);
ASSERT_EQUAL_QUIET(h_result, d_result);
}
View
@@ -4,12 +4,13 @@
#include <thrust/transform.h>
using namespace unittest;
-using namespace thrust;
template <typename Tuple>
__host__ __device__
Tuple operator+(const Tuple &lhs, const Tuple &rhs)
{
+ using namespace thrust;
+
return make_tuple(get<0>(lhs) + get<0>(rhs),
get<1>(lhs) + get<1>(rhs));
}
@@ -18,9 +19,9 @@ struct MakeTupleFunctor
{
template<typename T1, typename T2>
__host__ __device__
- tuple<T1,T2> operator()(T1 &lhs, T2 &rhs)
+ thrust::tuple<T1,T2> operator()(T1 &lhs, T2 &rhs)
{
- return make_tuple(lhs, rhs);
+ return thrust::make_tuple(lhs, rhs);
}
};
@@ -30,30 +31,32 @@ struct TestTupleScan
{
void operator()(const size_t n)
{
- thrust::host_vector<T> h_t1 = unittest::random_integers<T>(n);
- thrust::host_vector<T> h_t2 = unittest::random_integers<T>(n);
+ using namespace thrust;
+
+ host_vector<T> h_t1 = unittest::random_integers<T>(n);
+ host_vector<T> h_t2 = unittest::random_integers<T>(n);
// initialize input
- thrust::host_vector< tuple<T,T> > h_input(n);
- thrust::transform(h_t1.begin(), h_t1.end(),
- h_t2.begin(), h_input.begin(),
- MakeTupleFunctor());
- thrust::device_vector< tuple<T,T> > d_input = h_input;
+ host_vector< tuple<T,T> > h_input(n);
+ transform(h_t1.begin(), h_t1.end(),
+ h_t2.begin(), h_input.begin(),
+ MakeTupleFunctor());
+ device_vector< tuple<T,T> > d_input = h_input;
// allocate output
tuple<T,T> zero(0,0);
- thrust::host_vector < tuple<T,T> > h_output(n, zero);
- thrust::device_vector< tuple<T,T> > d_output(n, zero);
+ host_vector < tuple<T,T> > h_output(n, zero);
+ device_vector< tuple<T,T> > d_output(n, zero);
// exclusive_scan
- thrust::inclusive_scan(h_input.begin(), h_input.end(), h_output.begin());
- thrust::inclusive_scan(d_input.begin(), d_input.end(), d_output.begin());
+ inclusive_scan(h_input.begin(), h_input.end(), h_output.begin());
+ inclusive_scan(d_input.begin(), d_input.end(), d_output.begin());
ASSERT_EQUAL_QUIET(h_output, d_output);
// exclusive_scan
tuple<T,T> init(13,17);
- thrust::exclusive_scan(h_input.begin(), h_input.end(), h_output.begin(), init);
- thrust::exclusive_scan(d_input.begin(), d_input.end(), d_output.begin(), init);
+ exclusive_scan(h_input.begin(), h_input.end(), h_output.begin(), init);
+ exclusive_scan(d_input.begin(), d_input.end(), d_output.begin(), init);
ASSERT_EQUAL_QUIET(h_output, d_output);
}
View
@@ -4,15 +4,14 @@
#include <thrust/transform.h>
using namespace unittest;
-using namespace thrust;
struct MakeTupleFunctor
{
template<typename T1, typename T2>
__host__ __device__
- tuple<T1,T2> operator()(T1 &lhs, T2 &rhs)
+ thrust::tuple<T1,T2> operator()(T1 &lhs, T2 &rhs)
{
- return make_tuple(lhs, rhs);
+ return thrust::make_tuple(lhs, rhs);
}
};
@@ -21,12 +20,12 @@ struct GetFunctor
{
template<typename Tuple>
__host__ __device__
- typename access_traits<
- typename tuple_element<N, Tuple>::type
- >::const_type
+ typename thrust::access_traits<
+ typename thrust::tuple_element<N, Tuple>::type
+ >::const_type
operator()(const Tuple &t)
{
- return get<N>(t);
+ return thrust::get<N>(t);
}
};
@@ -35,37 +34,39 @@ struct TestTupleStableSort
{
void operator()(const size_t n)
{
- thrust::host_vector<T> h_keys = unittest::random_integers<T>(n);
- thrust::host_vector<T> h_values = unittest::random_integers<T>(n);
+ using namespace thrust;
+
+ host_vector<T> h_keys = random_integers<T>(n);
+ host_vector<T> h_values = random_integers<T>(n);
// zip up the data
- thrust::host_vector< tuple<T,T> > h_tuples(n);
- thrust::transform(h_keys.begin(), h_keys.end(),
- h_values.begin(), h_tuples.begin(),
- MakeTupleFunctor());
+ host_vector< tuple<T,T> > h_tuples(n);
+ transform(h_keys.begin(), h_keys.end(),
+ h_values.begin(), h_tuples.begin(),
+ MakeTupleFunctor());
// copy to device
- thrust::device_vector< tuple<T,T> > d_tuples = h_tuples;
+ device_vector< tuple<T,T> > d_tuples = h_tuples;
// sort on host
- thrust::stable_sort(h_tuples.begin(), h_tuples.end());
+ stable_sort(h_tuples.begin(), h_tuples.end());
// sort on device
- thrust::stable_sort(d_tuples.begin(), d_tuples.end());
+ stable_sort(d_tuples.begin(), d_tuples.end());
- ASSERT_EQUAL(true, thrust::is_sorted(d_tuples.begin(), d_tuples.end()));
+ ASSERT_EQUAL(true, is_sorted(d_tuples.begin(), d_tuples.end()));
// select keys
- thrust::transform(h_tuples.begin(), h_tuples.end(), h_keys.begin(), GetFunctor<0>());
+ transform(h_tuples.begin(), h_tuples.end(), h_keys.begin(), GetFunctor<0>());
- thrust::device_vector<T> d_keys(h_keys.size());
- thrust::transform(d_tuples.begin(), d_tuples.end(), d_keys.begin(), GetFunctor<0>());
+ device_vector<T> d_keys(h_keys.size());
+ transform(d_tuples.begin(), d_tuples.end(), d_keys.begin(), GetFunctor<0>());
// select values
- thrust::transform(h_tuples.begin(), h_tuples.end(), h_values.begin(), GetFunctor<1>());
+ transform(h_tuples.begin(), h_tuples.end(), h_values.begin(), GetFunctor<1>());
- thrust::device_vector<T> d_values(h_values.size());
- thrust::transform(d_tuples.begin(), d_tuples.end(), d_values.begin(), GetFunctor<1>());
+ device_vector<T> d_values(h_values.size());
+ transform(d_tuples.begin(), d_tuples.end(), d_values.begin(), GetFunctor<1>());
ASSERT_ALMOST_EQUAL(h_keys, d_keys);
ASSERT_ALMOST_EQUAL(h_values, d_values);
Oops, something went wrong.

0 comments on commit dfbaadb

Please sign in to comment.