Skip to content

Commit 20b49f7

Browse files
authored
[SYCLomatic #947] Update the verification code in test cases for migration of thrust::uninitialized_copy and thrust::uninitialized_copy_n (#377)
Signed-off-by: chenwei.sun <[email protected]>
1 parent 46b19be commit 20b49f7

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

features/feature_case/thrust/thrust_uninitialized_copy.cu

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
struct 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
}

features/feature_case/thrust/thrust_uninitialized_copy_n.cu

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
struct Int {
1717
__host__ __device__ Int(int x) : val(x) {}
18+
Int() {}
1819
int val;
1920
};
2021

@@ -27,10 +28,11 @@ void test_1() {
2728

2829
thrust::uninitialized_copy_n(input.begin(), N, array);
2930

30-
thrust::host_vector<Int> hostVec(array, array + N);
31+
Int host_array[N];
32+
cudaMemcpy(host_array, array.get(), N * sizeof(Int), cudaMemcpyDeviceToHost);
3133

3234
for (int i = 0; i < N; i++) {
33-
if (hostVec[i].val != 46) {
35+
if (host_array[i].val != 46) {
3436
printf("test_1 run failed\n");
3537
exit(-1);
3638
}
@@ -67,10 +69,11 @@ void test_3() {
6769
thrust::device_ptr<Int> array = thrust::device_malloc<Int>(N);
6870
thrust::uninitialized_copy_n(thrust::device, input.begin(), N, array);
6971

70-
thrust::host_vector<Int> hostVec(array, array + N);
72+
Int host_array[N];
73+
cudaMemcpy(host_array, array.get(), N * sizeof(Int), cudaMemcpyDeviceToHost);
7174

7275
for (int i = 0; i < N; i++) {
73-
if (hostVec[i].val != 46) {
76+
if (host_array[i].val != 46) {
7477
printf("test_3 run failed\n");
7578
exit(-1);
7679
}

features/features.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
<test testName="thrust_stable_partition" configFile="config/TEMPLATE_thrust_api.xml" />
3838
<test testName="thrust_reverse" configFile="config/TEMPLATE_thrust_api.xml" />
3939
<test testName="thrust_transform_inclusive_scan" configFile="config/TEMPLATE_thrust_api.xml" />
40-
<test testName="thrust_uninitialized_copy_n" configFile="config/TEMPLATE_thrust_api.xml" />
41-
<test testName="thrust_uninitialized_copy" configFile="config/TEMPLATE_thrust_api.xml" />
40+
<test testName="thrust_uninitialized_copy_n" configFile="config/TEMPLATE_thrust_api_disable_noneusm.xml" />
41+
<test testName="thrust_uninitialized_copy" configFile="config/TEMPLATE_thrust_api_disable_noneusm.xml" />
4242
<test testName="thrust_raw_reference_cast" configFile="config/TEMPLATE_thrust_api_disable_noneusm.xml" />
4343
<test testName="thrust_partition_copy" configFile="config/TEMPLATE_thrust_api_disable_noneusm.xml" />
4444
<test testName="thrust_stable_partition_copy" configFile="config/TEMPLATE_thrust_api_disable_noneusm.xml" />

0 commit comments

Comments
 (0)