I'm learning the oneapi and I get wrong results when i try to do an exclusive_scan when I use the dpcpp parallel version.
It always assumes the first element to be zero.
Code:
#include <CL/sycl.hpp>
#include <oneapi/dpl/execution>
#include <oneapi/dpl/numeric>
#include <oneapi/dpl/iterator>
#include <iostream>
#include <vector>
int main(){
sycl::queue Q(sycl::cpu_selector{});
const u_int32_t n = 100;
std::vector<u_int32_t> data(n,1);
{
sycl::buffer b_data(data);
auto policy = oneapi::dpl::execution::make_device_policy<class mypolicy>(Q);
oneapi::dpl::exclusive_scan(
policy,
oneapi::dpl::begin(b_data),
oneapi::dpl::end(b_data),
oneapi::dpl::begin(b_data),
0);
}
for(auto i=0; i<10 ; i++){
std::cout << data[i] << std::endl;
}
}
Output:
0
0
1
2
3
4
5
6
7
8
Expected output:
0
1
2
3
4
5
6
7
8
9
Build command:
dpcpp -Wall main.cpp -o main