#include <CL/sycl.hpp> #include <iostream> #define SIZE 10 using namespace cl::sycl; int main() { float input[SIZE]; float output[SIZE]; // Initialize input array for (int i = 0; i < SIZE; i++) { input[i] = i + 1; } // Create SYCL queue queue q; // Submit command group for execution q.submit([&](handler& cgh) { // Create accessors for input and output buffers accessor inputAccessor(input, range<1>(SIZE), cgh); accessor outputAccessor(output, range<1>(SIZE), cgh); // Define the kernel cgh.parallel_for(range<1>(SIZE), [=](id<1> idx) { outputAccessor[idx] = inputAccessor[idx] * inputAccessor[idx]; }); }); // Wait for the command group to finish q.wait(); // Print the result for (int i = 0; i < SIZE; i++) { std::cout << output[i] << " "; } std::cout << std::endl; return 0; }