I am trying to compile and run this sample code:
#include <CL/sycl.hpp>
#include <iostream>
#include <sycl/ext/intel/fpga_extensions.hpp>
using namespace cl::sycl;
int main() {
auto selector = sycl::ext::intel::fpga_selector_v;
queue q(selector);
const int N = 100;
int a[N], b[N], c[N];
// Initialize arrays on the host
for (int i = 0; i < N; i++) {
a[i] = i;
b[i] = i * 2;
}
buffer<int, 1> buf_a(a, range<1>(N)); // Create buffers for arrays
buffer<int, 1> buf_b(b, range<1>(N));
buffer<int, 1> buf_c(c, range<1>(N));
q.submit([&](handler& h) {
auto a_acc = buf_a.get_access<access::mode::read>(h);
auto b_acc = buf_b.get_access<access::mode::read>(h);
auto c_acc = buf_c.get_access<access::mode::write>(h);
h.parallel_for(range<1>(N), [=](id<1> i) {
c_acc[i] = a_acc[i] + b_acc[i]; // Perform element-wise addition
});
});
q.wait(); // Wait for completion
// Print results on the host
for (int i = 0; i < N; i++) {
std::cout << c[i] << " ";
}
std::cout << std::endl;
return 0;
}
following your link/suggestion I did add the proper flags (see below), I also made sure the board is seen by the OS but I still get the following runtime error:
tetto@ubuntuoffice:~/mytrial1$ jtagconfig
1) USB-BlasterII [1-1]
031820DD 10M08SA(.|ES)/10M08S(C|L)
02E120DD 10CX220Y
tetto@ubuntuoffice:~/mytrial1$ icpx -fsycl -fintelfpga fpga_add2.cpp -Xshardware -Xstarget=Cyclone10GX -o fpga_compile.>aoc: Compiling for FPGA. This process may take several hours to complete. Prior to performing this compile, be sure to>
tetto@ubuntuoffice:~/mytrial1$ ./fpga_compile.fpga
terminate called after throwing an instance of 'sycl::_V1::runtime_error'
what(): Invalid device program image: size is zero -30 (PI_ERROR_INVALID_VALUE)
Aborted (core dumped)