'Exception unhandled when using -fintelfpga

I am using Microsoft Visual Studio 2019 as the development environment for my DPC++ application. My target platform is FPGA emulation. When I did the following: project properties->configuration properties->DPC++->General->Enable FPGA workflows->Yes, The program throws an exception. I have included the codes below. I am not sure how to eliminate the exception. I need your help. Thank you.

#include <iostream>
#include<vector>
#include<random>
#include<omp.h>
#include<chrono>
#include <CL/sycl.hpp>
#include <ext/intel/fpga_extensions.hpp>
using namespace std;



void Oneapi_Fpga()
{
    vector<float>testData(1000000);
    vector<float>filterCoeff(10000);
    int convLen = testData.size() + filterCoeff.size() - 1;
    vector<float>convSeq(convLen);
    
    std::random_device                  rand;
    std::mt19937                        generator(rand());
    std::normal_distribution<float> ndist{ 0.0f, 1.0f };
    for (int i = 0; i < testData.size(); i++)
    {
        testData[i] = ndist(generator);
    }

    std::random_device                  randi;
    std::mt19937                        generatorr(randi());
    std::normal_distribution<float> ndisti{ 0.0f, 1.0f };
    for (int i = 0; i < filterCoeff.size(); i++)
    {
        filterCoeff[i] = ndisti(generator);
    }


    int lenA = 1000000;
    int lenB = 10000;
    int nconv;

    std::chrono::high_resolution_clock::time_point  t6, t7;
    std::chrono::duration<double, std::milli>  accum3;

    accum3 = std::chrono::milliseconds(0);

    nconv = lenA + lenB - 1;
    vector<float>C(nconv);

    //*********************************************************
    // FPGA oneapi implementation
    //*********************************************************
    sycl::buffer testBuff(testData);
    sycl::buffer filterBuff(filterCoeff);
    sycl::buffer convBuff(C);
    sycl::ext::intel::fpga_emulator_selector d_selector;
    try
    {
        cl::sycl::queue Q(d_selector);
        t6 = std::chrono::high_resolution_clock::now();
        Q.submit([&](sycl::handler& h)
            {
                sycl::accessor testAccess(testBuff, h, sycl::read_only);
                sycl::accessor filterAccess(filterBuff, h, sycl::read_only);
                sycl::accessor cAccess(convBuff, h, sycl::read_write);
                h.single_task([=]() {

                    for (int i = 0; i < nconv; i++)
                    {
                        int i1 = i;
                        float tmp = 0.0;
                        for (int j = 0; j < lenB; j++)
                        {
                            if (i1 >= 0 && i1 < lenA)
                                tmp = tmp + (testAccess[i1] * filterAccess[j]);

                            i1 = i1 - 1;
                            cAccess[i] = tmp;
                        }
                    }


                    });
            });
        t7 = std::chrono::high_resolution_clock::now();
        Q.wait_and_throw();
    }

    catch (sycl::exception const& e)
    {
        std::cout << "Caught a SYCL host exception:\n" << e.what() << "\n";
    }
    sycl::host_accessor cHost(convBuff);
    //*********************************************************



  
    accum3 = t7 - t6;

    cout << "time taken by FPGA oneapi implementation is" << accum3.count() << endl;

  
}
int main()
{

    Oneapi_Fpga();
    std::cout << "success\n";
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source