Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit aa55ec2

Browse files
committed
Fix scan by key docs for in-place execution
1 parent 3838a0e commit aa55ec2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Diff for: testing/cuda/scan_by_key.cu

+19-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void TestScanByKeyDevice(ExecutionPolicy exec)
7878
}
7979
ASSERT_EQUAL(d_output, h_output);
8080

81-
// in-place scans
81+
// in-place scans: in/out values aliasing
8282
h_output = h_vals;
8383
d_output = d_vals;
8484
thrust::inclusive_scan_by_key(h_keys.begin(), h_keys.end(), h_output.begin(), h_output.begin());
@@ -98,6 +98,24 @@ void TestScanByKeyDevice(ExecutionPolicy exec)
9898
ASSERT_EQUAL(cudaSuccess, err);
9999
}
100100
ASSERT_EQUAL(d_output, h_output);
101+
102+
// in-place scans: keys/values aliasing
103+
thrust::inclusive_scan_by_key(h_keys.begin(), h_keys.end(), h_vals.begin(), h_output.begin());
104+
inclusive_scan_by_key_kernel<<<1,1>>>(exec, d_keys.begin(), d_keys.end(), d_vals.begin(), d_keys.begin());
105+
{
106+
cudaError_t const err = cudaDeviceSynchronize();
107+
ASSERT_EQUAL(cudaSuccess, err);
108+
}
109+
ASSERT_EQUAL(d_keys, h_output);
110+
111+
d_keys = h_keys;
112+
thrust::exclusive_scan_by_key(h_keys.begin(), h_keys.end(), h_vals.begin(), h_output.begin(), 11);
113+
exclusive_scan_by_key_kernel<<<1,1>>>(exec, d_keys.begin(), d_keys.end(), d_vals.begin(), d_keys.begin(), 11);
114+
{
115+
cudaError_t const err = cudaDeviceSynchronize();
116+
ASSERT_EQUAL(cudaSuccess, err);
117+
}
118+
ASSERT_EQUAL(d_keys, h_output);
101119
}
102120

103121

0 commit comments

Comments
 (0)