- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I'm new to SYCL and am trying to run an example about reduction variables in the SYCL Specification. I revise the code a little and the final version is shown as follows:
#include <iostream>
#include <sycl/sycl.hpp>
#include <numeric>
using namespace sycl;
int main() {
buffer<int> valuesBuf{ 1024 };
{
host_accessor a{ valuesBuf };
// std::iota(a.begin(), a.end(), 0);
std::iota(&(a[0]), &(a[1023]), 0);
}
int sumResult = 0;
buffer<int> sumBuf{ &sumResult, 1 };
int maxResult = 0;
buffer<int> maxBuf{ &maxResult, 1 };
queue myQueue;
myQueue.submit([&](handler& cgh) {
auto inputValues = valuesBuf.get_access<access_mode::read>(cgh);
auto sumReduction = reduction(sumBuf, cgh, plus<>());
auto maxReduction = reduction(maxBuf, cgh, maximum<>());
/*
cgh.parallel_for(range<1> {2048, 1024}, sumReduction, maxReduction,
[=](nd_item<1> it, auto& sum, auto& max) {
sum += inputValues[it.get_local_id()];
max.combine(inputValues[it.get_global_id()]);
});
*/
cgh.parallel_for(nd_range<1> {2048, 1024}, sumReduction, maxReduction,
[=](nd_item<1> it, auto& sum, auto& max) {
sum += inputValues[it.get_local_id()];
max.combine(inputValues[it.get_global_id()]);
});
});
// assert(maxBuf.get_host_access()[0] == 1023 && sumBuf.get_host_access()[0] == 523776);
std::cout << maxBuf.get_host_access()[0] << std::endl;
std::cout << sumBuf.get_host_access()[0] << std::endl;
}
However, there is still something wrong with it which I cannot figure out the reasons. The problems are:
-
The code can be successfully compiled in cmd with command
while when compiled in Visual Studio 2022 with Intel(R) oneAPI DPC++ Compiler, it fails and pops out the erroricpx -fsycl src.cpp -o o.exe
I have seen a similar problem in Re: SYCL kernel cannot call an undefined function without SYCL_EXTERNAL attribute - Intel Communities and Re: SYCL kernel cannot call an undefined function without SYCL_EXTERNAL attribute - Intel Communities and believe that Line 38 functionSYCL kernel cannot call a variadic function SYCL kernel cannot call an undefined function without SYCL_EXTERNAL attribute
triggers the compilation error, but cannot find a suitable solution to my code.max.combine(inputValues[it.get_global_id()]);
- Even without the compilation problem above, the program cannot function as expected. For the program prints out nothing and exits with a meaningless value. The commands are shown below:
A similar result also occurs in Visual Studio 2022 environment and I have no idea about it.C:\Users\a1595\Desktop\dr\c>icpx -fsycl c.cpp -o c.exe C:\Users\a1595\Desktop\dr\c>c.exe C:\Users\a1595\Desktop\dr\c>echo %ERRORLEVEL% -1073740791
I am looking forward to any help. Thanks a lot.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in intel communities.
Since this is a duplicate thread of <https://community.intel.com/t5/Intel-oneAPI-Data-Parallel-C/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1454057#M2774>, we will no longer monitor this thread. We will continue addressing this issue in the other thread.
Thanks And Regards,
Aishwarya
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page