Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

How can I solve this problem?

Darius_Nicholas
New Contributor I
649 Views

This is my code !

#include <vector>
#include <iostream>
#include <CL/sycl.hpp>  // DPC++ header

std::vector<std::vector<double>> filter2d(const std::vector<double>& b, double a, const std::vector<std::vector<double>>& x) {
    int rows = x.size();
    int cols = x[0].size();
    std::vector<std::vector<double>> y(x.size(), std::vector<double>(x[0].size()));

    sycl::queue q(sycl::gpu_selector{});


    sycl::buffer b_buffer(b);
    sycl::buffer y_buffer(x);
    sycl::buffer x_buffer(y);

    q.submit([&](sycl::handler& h) {
        sycl::accessor x_acc(x_buffer,h,sycl::read_only);
        sycl::accessor b_acc(b_buffer,h,sycl::read_only);

        sycl::accessor y_acc(y_buffer, h, sycl::write_only,sycl::no_init);

        h.parallel_for(sycl::range<2>(rows, cols), [=](sycl::id<2> idx) {
            int i = idx[0];
            int j = idx[1];
            y_acc[i][j] = 0.0;
            for (int k = 0; k < b.size(); k++) {
                if (i - k >= 0) {
                    y_acc[i][j] += b_acc[k] * x_acc[(i - k) ][j];
                }
            }
            y_acc[i][j] /= a;
        });
    });

    q.wait();
 
    return y;
}
 
0 Kudos
1 Reply
VaishnaviV_Intel
Moderator
624 Views

Hi,

 

Thanks for posting on Intel communities.

Since this is a duplicate thread of https://community.intel.com/t5/Intel-oneAPI-Data-Parallel-C/oneapi/m-p/1508594#M3185, we will no longer monitor this thread. We will continue addressing this issue in the other thread.

 

Thanks & Regards,

Vankudothu Vaishnavi.

 

0 Kudos
Reply