Implement a kernel to perform an inclusive prefix scan on a 1D list using Thrust.
Given an input
= [x0, x1, x2, ...] x
Produce an output
= [y0, y1, y2, ...] y
where
[0] = 0
y[1] = 0 + x[0]
y[2] = 0 + x[0] + x[1]
y[i] = y[i-1] + x[i-1] y
The prefix scan should produce y
given x
and use the thrust::inclusive_scan
function. The input and
output will both be float
arrays of equal length.
Before starting this lab, make sure that:
Edit the code in the code tab to perform the following:
thrust::dev_ptr<float>
for host input
arraysthrust::inclusive_scan
Instructions about where to place each part of the code is demarcated
by the //@@
comment lines.
The most recent version of source code for this lab along with the build-scripts can be found on the Bitbucket repository. A description on how to use the CMake tool in along with how to build the labs for local development found in the README document in the root of the repository.
The executable generated as a result of compiling the lab can be run using the following command:
./ThrustListScan_Template -e <expected.raw> \
-i <input.raw> -o <output.raw> -t vector
where <expected.raw>
is the expected output,
<input.raw>
is the input dataset, and
<output.raw>
is an optional path to store the
results. The datasets can be generated using the dataset generator built
as part of the compilation process.