 }
 DECLARE_UNITTEST(TestForEachWithLargeTypes);
 
+
+template <typename T, unsigned int N>
+void _TestForEachNWithLargeTypes(void)
+{
+    size_t n = (64 * 1024) / sizeof(FixedVector<T,N>);
+
+    thrust::host_vector< FixedVector<T,N> > h_data(n);
+
+    for(size_t i = 0; i < h_data.size(); i++)
+        h_data[i] = FixedVector<T,N>(i);
+
+    thrust::device_vector< FixedVector<T,N> > d_data = h_data;
+   
+    SetFixedVectorToConstant<T,N> func(123);
+
+    thrust::for_each_n(h_data.begin(), h_data.size(), func);
+    thrust::for_each_n(d_data.begin(), d_data.size(), func);
+
+    ASSERT_EQUAL_QUIET(h_data, d_data);
+}
+
+
+void TestForEachNWithLargeTypes(void)
+{
+    _TestForEachNWithLargeTypes<int,    1>();
+    _TestForEachNWithLargeTypes<int,    2>();
+    _TestForEachNWithLargeTypes<int,    4>();
+    _TestForEachNWithLargeTypes<int,    8>();
+    _TestForEachNWithLargeTypes<int,   16>();
+
+    KNOWN_FAILURE;
+
+    //_TestForEachNWithLargeTypes<int,   32>();  // fails on Linux 32 w/ gcc 4.1
+    //_TestForEachNWithLargeTypes<int,   64>();
+    //_TestForEachNWithLargeTypes<int,  128>();
+    //_TestForEachNWithLargeTypes<int,  256>();
+    //_TestForEachNWithLargeTypes<int,  512>();
+    //_TestForEachNWithLargeTypes<int, 1024>();  // fails on Vista 64 w/ VS2008
+}
+DECLARE_UNITTEST(TestForEachNWithLargeTypes);
+
 __THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END

    ASSERT_EQUAL_QUIET(d_result, d_input.end());
}
DECLARE_VARIABLE_UNITTEST(TestForEach);


template <size_t N> __host__ __device__ void f   (int * x) { int temp = *x; f<N - 1>(x + 1); *x = temp;};

DECLARE_UNITTEST(TestForEachSimpleAnySpace);


void TestForEachNSimpleAnySpace(void)
{
    thrust::device_vector<int> output(7, 0);

    mark_present_for_each<int> f;
    f.ptr = thrust::raw_pointer_cast(output.data());

    thrust::counting_iterator<int> result = thrust::for_each_n(thrust::make_counting_iterator(0), 5, f);

    ASSERT_EQUAL(output[0], 1);
    ASSERT_EQUAL(output[1], 1);
    ASSERT_EQUAL(output[2], 1);
    ASSERT_EQUAL(output[3], 1);
    ASSERT_EQUAL(output[4], 1);
    ASSERT_EQUAL(output[5], 0);
    ASSERT_EQUAL(output[6], 0);
    ASSERT_EQUAL_QUIET(result, thrust::make_counting_iterator(5));
}
DECLARE_UNITTEST(TestForEachNSimpleAnySpace);


template <typename T>
void TestForEach(const size_t n)
{
