Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit b3dfd11

Browse files
[SYCL] [FPGA] Create latency control E2E emulator tests (#596)
1 parent 2334571 commit b3dfd11

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// REQUIRES: aoc, accelerator
2+
// RUN: %clangxx -fsycl -fintelfpga %s -o %t.out
3+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
4+
//== fpga_latency_control_pipe.cpp - SYCL FPGA latency control on pipe 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 Pipe1 = ext::intel::experimental::pipe<class PipeClass1, int, 8>;
17+
using Pipe2 = ext::intel::experimental::pipe<class PipeClass2, int, 8>;
18+
19+
int test_latency_control(queue Queue) {
20+
std::vector<int> input_data = {1};
21+
std::vector<int> output_data = {0};
22+
23+
{
24+
buffer input_buffer(input_data);
25+
buffer output_buffer(output_data);
26+
27+
Queue.submit([&](handler &cgh) {
28+
auto input_accessor = input_buffer.get_access<access::mode::read>(cgh);
29+
30+
auto output_accessor = output_buffer.get_access<access::mode::write>(cgh);
31+
32+
cgh.single_task<class kernel>([=] {
33+
Pipe1::write(input_accessor[0]);
34+
35+
int value =
36+
Pipe1::read<ext::intel::experimental::latency_anchor_id<0>>();
37+
38+
Pipe2::write<ext::intel::experimental::latency_anchor_id<1>,
39+
ext::intel::experimental::latency_constraint<
40+
0, ext::intel::experimental::type::exact, 2>>(value);
41+
42+
output_accessor[0] = Pipe2::read();
43+
});
44+
});
45+
}
46+
47+
if (output_data[0] != input_data[0]) {
48+
std::cout << "Unexpected read from output_data: " << output_data[0]
49+
<< ", v.s. expected " << input_data[0] << std::endl;
50+
51+
return -1;
52+
}
53+
return 0;
54+
}
55+
56+
int main() {
57+
queue Queue{ext::intel::fpga_emulator_selector{}};
58+
59+
return test_latency_control(Queue);
60+
}

0 commit comments

Comments
 (0)