OneAPI Exclusive_scan 的错误行为
我正在学习 oneapi,当我使用 dpcpp 并行版本尝试进行 Exclusive_scan 时,我得到了错误的结果。
它始终假设第一个元素为零。
代码:
#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;
}
}
输出:
0
0
1
2
3
4
5
6
7
8
预期输出:
0
1
2
3
4
5
6
7
8
9
构建命令: dpcpp -Wall main.cpp -o main
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个已知的限制,如以下链接所述:
https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-library-guide/top/intel-oneapi-dpc-library-onedpl-overview.html
对于一元运算,建议使用初始值为 1,而不是 0。
谢谢&问候,
赫曼斯。
This is a known limitation as mentioned in the below link:
https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-library-guide/top/intel-oneapi-dpc-library-onedpl-overview.html
It is recommended to use initial value as 1 instead of 0 for unary operations.
Thanks & Regards,
Hemanth.