<commit_before>#include <unittest/unittest.h>
#include <thrust/uninitialized_copy.h>
#include <thrust/device_malloc_allocator.h>


template<typename InputIterator, typename ForwardIterator>
ForwardIterator uninitialized_copy(my_system &system,
                                   InputIterator,
                                   InputIterator,
                                   ForwardIterator result)
{
    system.validate_dispatch();
    return result;
}

void TestUninitializedCopyDispatchExplicit()
{
    thrust::device_vector<int> vec(1);

    my_system sys(0);
    thrust::uninitialized_copy(sys,
                               vec.begin(),
                               vec.begin(),
                               vec.begin());

    ASSERT_EQUAL(true, sys.is_valid());
}
DECLARE_UNITTEST(TestUninitializedCopyDispatchExplicit);


template<typename InputIterator, typename ForwardIterator>
ForwardIterator uninitialized_copy(my_tag,
                                   InputIterator,
                                   InputIterator,
                                   ForwardIterator result)
{
    *result = 13;
    return result;
}

void TestUninitializedCopyDispatchImplicit()
{
    thrust::device_vector<int> vec(1);

    thrust::uninitialized_copy(thrust::retag<my_tag>(vec.begin()),
                               thrust::retag<my_tag>(vec.begin()),
                               thrust::retag<my_tag>(vec.begin()));

    ASSERT_EQUAL(13, vec.front());
}
DECLARE_UNITTEST(TestUninitializedCopyDispatchImplicit);


template<typename InputIterator, typename Size, typename ForwardIterator>
ForwardIterator uninitialized_copy_n(my_system &system,
                                     InputIterator,
                                     Size,
                                     ForwardIterator result)
{
    system.validate_dispatch();
    return result;
}

void TestUninitializedCopyNDispatchExplicit()
{
    thrust::device_vector<int> vec(1);

    my_system sys(0);
    thrust::uninitialized_copy_n(sys,
                                 vec.begin(),
                                 vec.size(),
                                 vec.begin());

    ASSERT_EQUAL(true, sys.is_valid());
}
DECLARE_UNITTEST(TestUninitializedCopyNDispatchExplicit);


template<typename InputIterator, typename Size, typename ForwardIterator>
ForwardIterator uninitialized_copy_n(my_tag,
                                     InputIterator,
                                     Size,
                                     ForwardIterator result)
{
    *result = 13;
    return result;
}

void TestUninitializedCopyNDispatchImplicit()
{
    thrust::device_vector<int> vec(1);

    thrust::uninitialized_copy_n(thrust::retag<my_tag>(vec.begin()),
                                 vec.size(),
                                 thrust::retag<my_tag>(vec.begin()));

    ASSERT_EQUAL(13, vec.front());
}
DECLARE_UNITTEST(TestUninitializedCopyNDispatchImplicit);


template <class Vector>
void TestUninitializedCopySimplePOD(void)
{
    typedef typename Vector::value_type T;

    Vector v1(5);
    v1[0] = 0; v1[1] = 1; v1[2] = 2; v1[3] = 3; v1[4] = 4;

    // copy to Vector
    Vector v2(5);
    thrust::uninitialized_copy(v1.begin(), v1.end(), v2.begin());
    ASSERT_EQUAL(v2[0], 0);
    ASSERT_EQUAL(v2[1], 1);
    ASSERT_EQUAL(v2[2], 2);
    ASSERT_EQUAL(v2[3], 3);
    ASSERT_EQUAL(v2[4], 4);
}
DECLARE_VECTOR_UNITTEST(TestUninitializedCopySimplePOD);


template<typename Vector>
void TestUninitializedCopyNSimplePOD(void)
{
    typedef typename Vector::value_type T;

    Vector v1(5);
    v1[0] = 0; v1[1] = 1; v1[2] = 2; v1[3] = 3; v1[4] = 4;

    // copy to Vector
    Vector v2(5);
    thrust::uninitialized_copy_n(v1.begin(), v1.size(), v2.begin());
    ASSERT_EQUAL(v2[0], 0);
    ASSERT_EQUAL(v2[1], 1);
    ASSERT_EQUAL(v2[2], 2);
    ASSERT_EQUAL(v2[3], 3);
    ASSERT_EQUAL(v2[4], 4);
}
DECLARE_VECTOR_UNITTEST(TestUninitializedCopyNSimplePOD);


struct CopyConstructTest
{
  CopyConstructTest(void)
    :copy_constructed_on_host(false),
     copy_constructed_on_device(false)
  {}

  __host__ __device__
  CopyConstructTest(const CopyConstructTest &exemplar)
  {
#if __CUDA_ARCH__
    copy_constructed_on_device = true;
    copy_constructed_on_host   = false;
#else
    copy_constructed_on_device = false;
    copy_constructed_on_device = true;
#endif
  }

  CopyConstructTest &operator=(const CopyConstructTest &x)
  {
    copy_constructed_on_host   = x.copy_constructed_on_host;
    copy_constructed_on_device = x.copy_constructed_on_device;
    return *this;
  }

  bool copy_constructed_on_host;
  bool copy_constructed_on_device;
};
<commit_msg>Add __host__ __device__ to CopyConstructTest's constructor.<commit_after>#include <unittest/unittest.h>
#include <thrust/uninitialized_copy.h>
#include <thrust/device_malloc_allocator.h>


template<typename InputIterator, typename ForwardIterator>
ForwardIterator uninitialized_copy(my_system &system,
                                   InputIterator,
                                   InputIterator,
                                   ForwardIterator result)
{
    system.validate_dispatch();
    return result;
}

void TestUninitializedCopyDispatchExplicit()
{
    thrust::device_vector<int> vec(1);

    my_system sys(0);
    thrust::uninitialized_copy(sys,
                               vec.begin(),
                               vec.begin(),
                               vec.begin());

    ASSERT_EQUAL(true, sys.is_valid());
}
DECLARE_UNITTEST(TestUninitializedCopyDispatchExplicit);


template<typename InputIterator, typename ForwardIterator>
ForwardIterator uninitialized_copy(my_tag,
                                   InputIterator,
                                   InputIterator,
                                   ForwardIterator result)
{
    *result = 13;
    return result;
}

void TestUninitializedCopyDispatchImplicit()
{
    thrust::device_vector<int> vec(1);

    thrust::uninitialized_copy(thrust::retag<my_tag>(vec.begin()),
                               thrust::retag<my_tag>(vec.begin()),
                               thrust::retag<my_tag>(vec.begin()));

    ASSERT_EQUAL(13, vec.front());
}
DECLARE_UNITTEST(TestUninitializedCopyDispatchImplicit);


template<typename InputIterator, typename Size, typename ForwardIterator>
ForwardIterator uninitialized_copy_n(my_system &system,
                                     InputIterator,
                                     Size,
                                     ForwardIterator result)
{
    system.validate_dispatch();
    return result;
}

void TestUninitializedCopyNDispatchExplicit()
{
    thrust::device_vector<int> vec(1);

    my_system sys(0);
    thrust::uninitialized_copy_n(sys,
                                 vec.begin(),
                                 vec.size(),
                                 vec.begin());

    ASSERT_EQUAL(true, sys.is_valid());
}
DECLARE_UNITTEST(TestUninitializedCopyNDispatchExplicit);


template<typename InputIterator, typename Size, typename ForwardIterator>
ForwardIterator uninitialized_copy_n(my_tag,
                                     InputIterator,
                                     Size,
                                     ForwardIterator result)
{
    *result = 13;
    return result;
}

void TestUninitializedCopyNDispatchImplicit()
{
    thrust::device_vector<int> vec(1);

    thrust::uninitialized_copy_n(thrust::retag<my_tag>(vec.begin()),
                                 vec.size(),
                                 thrust::retag<my_tag>(vec.begin()));

    ASSERT_EQUAL(13, vec.front());
}
DECLARE_UNITTEST(TestUninitializedCopyNDispatchImplicit);


template <class Vector>
void TestUninitializedCopySimplePOD(void)
{
    typedef typename Vector::value_type T;

    Vector v1(5);
    v1[0] = 0; v1[1] = 1; v1[2] = 2; v1[3] = 3; v1[4] = 4;

    // copy to Vector
    Vector v2(5);
    thrust::uninitialized_copy(v1.begin(), v1.end(), v2.begin());
    ASSERT_EQUAL(v2[0], 0);
    ASSERT_EQUAL(v2[1], 1);
    ASSERT_EQUAL(v2[2], 2);
    ASSERT_EQUAL(v2[3], 3);
    ASSERT_EQUAL(v2[4], 4);
}
DECLARE_VECTOR_UNITTEST(TestUninitializedCopySimplePOD);


template<typename Vector>
void TestUninitializedCopyNSimplePOD(void)
{
    typedef typename Vector::value_type T;

    Vector v1(5);
    v1[0] = 0; v1[1] = 1; v1[2] = 2; v1[3] = 3; v1[4] = 4;

    // copy to Vector
    Vector v2(5);
    thrust::uninitialized_copy_n(v1.begin(), v1.size(), v2.begin());
    ASSERT_EQUAL(v2[0], 0);
    ASSERT_EQUAL(v2[1], 1);
    ASSERT_EQUAL(v2[2], 2);
    ASSERT_EQUAL(v2[3], 3);
    ASSERT_EQUAL(v2[4], 4);
}
DECLARE_VECTOR_UNITTEST(TestUninitializedCopyNSimplePOD);


struct CopyConstructTest
{
  __host__ __device__
  CopyConstructTest(void)
    :copy_constructed_on_host(false),
     copy_constructed_on_device(false)
  {}

  __host__ __device__
  CopyConstructTest(const CopyConstructTest &exemplar)
  {
#if __CUDA_ARCH__
    copy_constructed_on_device = true;
    copy_constructed_on_host   = false;
#else
    copy_constructed_on_device = false;
    copy_constructed_on_device = true;
#endif
  }

  CopyConstructTest &operator=(const CopyConstructTest &x)
  {
    copy_constructed_on_host   = x.copy_constructed_on_host;
    copy_constructed_on_device = x.copy_constructed_on_device;
    return *this;
  }

  bool copy_constructed_on_host;
  bool copy_constructed_on_device;
};

{'fraction_non_alphanumeric': 0.10352187833511206, 'fraction_numerical': 0.018783351120597654, 'mean_word_length': 2.497946995147443, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7532146', 'n_tokens_mistral': 2926, 'n_tokens_neox': 2840, 'n_words': 461}