1414
1515struct Int {
1616 __host__ __device__ Int (int x) : val(x) {}
17+ Int () {}
1718 int val;
1819};
1920
@@ -25,10 +26,11 @@ void test_1() {
2526 thrust::device_ptr<Int> array = thrust::device_malloc<Int>(N);
2627 thrust::uninitialized_copy (input.begin (), input.end (), array);
2728
28- thrust::host_vector<Int> hostVec (array, array + N);
29+ Int host_array[N];
30+ cudaMemcpy (host_array, array.get (), N * sizeof (Int), cudaMemcpyDeviceToHost);
2931
3032 for (int i = 0 ; i < N; i++) {
31- if (hostVec [i].val != 46 ) {
33+ if (host_array [i].val != 46 ) {
3234 printf (" test_1 run failed\n " );
3335 exit (-1 );
3436 }
@@ -65,10 +67,11 @@ void test_3() {
6567 thrust::device_ptr<Int> array = thrust::device_malloc<Int>(N);
6668 thrust::uninitialized_copy (thrust::device, input.begin (), input.end (), array);
6769
68- thrust::host_vector<Int> hostVec (array, array + N);
70+ Int host_array[N];
71+ cudaMemcpy (host_array, array.get (), N * sizeof (Int), cudaMemcpyDeviceToHost);
6972
7073 for (int i = 0 ; i < N; i++) {
71- if (hostVec [i].val != 46 ) {
74+ if (host_array [i].val != 46 ) {
7275 printf (" test_3 run failed\n " );
7376 exit (-1 );
7477 }
0 commit comments