|
| 1 | +// REQUIRES: aoc, accelerator |
| 2 | +// RUN: %clangxx -fsycl -fintelfpga %s -o %t.out |
| 3 | +// RUN: %ACC_RUN_PLACEHOLDER %t.out |
| 4 | +//==- fpga_latency_control_lsu.cpp - SYCL FPGA latency control on LSU test -==// |
| 5 | +// |
| 6 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 7 | +// See https://llvm.org/LICENSE.txt for license information. |
| 8 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 9 | +// |
| 10 | +//===----------------------------------------------------------------------===// |
| 11 | +#include <CL/sycl.hpp> |
| 12 | +#include <sycl/ext/intel/fpga_extensions.hpp> |
| 13 | + |
| 14 | +using namespace sycl; |
| 15 | + |
| 16 | +using PrefetchingLSU = ext::intel::experimental::lsu< |
| 17 | + ext::intel::experimental::prefetch<true>, |
| 18 | + ext::intel::experimental::statically_coalesce<false>>; |
| 19 | + |
| 20 | +using BurstCoalescedLSU = ext::intel::experimental::lsu< |
| 21 | + ext::intel::experimental::burst_coalesce<true>, |
| 22 | + ext::intel::experimental::statically_coalesce<false>>; |
| 23 | + |
| 24 | +int test_latency_control(queue Queue) { |
| 25 | + std::vector<float> input_data = {1.23f}; |
| 26 | + std::vector<float> output_data = {.0f}; |
| 27 | + |
| 28 | + { |
| 29 | + buffer input_buffer(input_data); |
| 30 | + buffer output_buffer(output_data); |
| 31 | + |
| 32 | + Queue.submit([&](handler &cgh) { |
| 33 | + auto input_accessor = input_buffer.get_access<access::mode::read>(cgh); |
| 34 | + |
| 35 | + auto output_accessor = output_buffer.get_access<access::mode::write>(cgh); |
| 36 | + |
| 37 | + cgh.single_task<class kernel>([=] { |
| 38 | + auto in_ptr = input_accessor.get_pointer(); |
| 39 | + auto out_ptr = output_accessor.get_pointer(); |
| 40 | + |
| 41 | + float value = PrefetchingLSU::load< |
| 42 | + ext::intel::experimental::latency_anchor_id<0>>(in_ptr); |
| 43 | + |
| 44 | + BurstCoalescedLSU::store<ext::intel::experimental::latency_constraint< |
| 45 | + 0, ext::intel::experimental::type::exact, 5>>(out_ptr, value); |
| 46 | + }); |
| 47 | + }); |
| 48 | + } |
| 49 | + |
| 50 | + if (output_data[0] != input_data[0]) { |
| 51 | + std::cout << "Unexpected read from output_data: " << output_data[0] |
| 52 | + << ", v.s. expected " << input_data[0] << std::endl; |
| 53 | + |
| 54 | + return -1; |
| 55 | + } |
| 56 | + return 0; |
| 57 | +} |
| 58 | + |
| 59 | +int main() { |
| 60 | + queue Queue{ext::intel::fpga_emulator_selector{}}; |
| 61 | + |
| 62 | + return test_latency_control(Queue); |
| 63 | +} |
0 commit comments