Skip to content

Commit 8909018

Browse files
[SYCL] [FPGA] Create DSP control E2E emulator test (intel/llvm-test-suite#591)
1 parent 81da80d commit 8909018

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// RUN: %clangxx -fsycl -fintelfpga %s -o %t.out
2+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
3+
//==---------- fpga_dsp_control.cpp - SYCL FPGA DSP control test -----------==//
4+
//
5+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6+
// See https://llvm.org/LICENSE.txt for license information.
7+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8+
//
9+
//===----------------------------------------------------------------------===//
10+
#include <CL/sycl.hpp>
11+
#include <sycl/ext/intel/fpga_extensions.hpp>
12+
13+
int test_dsp_control(cl::sycl::queue Queue) {
14+
std::vector<float> input_data = {1.23f, 2.34f};
15+
std::vector<float> output_data = {.0f, .0f};
16+
17+
{
18+
cl::sycl::buffer input_buffer(input_data);
19+
cl::sycl::buffer output_buffer(output_data);
20+
21+
Queue.submit([&](cl::sycl::handler &cgh) {
22+
auto input_accessor =
23+
input_buffer.get_access<cl::sycl::access::mode::read>(cgh);
24+
25+
auto output_accessor =
26+
output_buffer.get_access<cl::sycl::access::mode::write>(cgh);
27+
28+
cgh.single_task<class kernel>([=] {
29+
cl::sycl::ext::intel::math_dsp_control<
30+
cl::sycl::ext::intel::Preference::DSP>(
31+
[&] { output_accessor[0] = input_accessor[0] + 1.0f; });
32+
33+
cl::sycl::ext::intel::math_dsp_control<
34+
cl::sycl::ext::intel::Preference::DSP,
35+
cl::sycl::ext::intel::Propagate::Off>(
36+
[&] { output_accessor[0] -= 1.0f; });
37+
38+
cl::sycl::ext::intel::math_dsp_control<
39+
cl::sycl::ext::intel::Preference::Softlogic>(
40+
[&] { output_accessor[1] = input_accessor[1] + 1.0f; });
41+
42+
cl::sycl::ext::intel::math_dsp_control<
43+
cl::sycl::ext::intel::Preference::Softlogic,
44+
cl::sycl::ext::intel::Propagate::Off>(
45+
[&] { output_accessor[1] -= 1.0f; });
46+
});
47+
});
48+
}
49+
50+
for (int i = 0; i < 2; i++) {
51+
if (output_data[i] != input_data[i]) {
52+
std::cout << "Unexpected read from output_data: " << output_data[i]
53+
<< ", v.s. expected " << input_data[i] << std::endl;
54+
55+
return -1;
56+
}
57+
}
58+
return 0;
59+
}
60+
61+
int main() {
62+
cl::sycl::queue Queue{cl::sycl::ext::intel::fpga_emulator_selector{}};
63+
64+
return test_dsp_control(Queue);
65+
}

SYCL/Basic/fpga_tests/fpga_lsu.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsycl %s -o %t.out
2-
// RUNx: %ACC_RUN_PLACEHOLDER %t.out
1+
// RUN: %clangxx -fsycl -fintelfpga %s -o %t.out
2+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
33
//==----------------- fpga_lsu.cpp - SYCL FPGA LSU test --------------------==//
44
//
55
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -10,9 +10,6 @@
1010
#include <CL/sycl.hpp>
1111
#include <sycl/ext/intel/fpga_extensions.hpp>
1212

13-
// TODO: run is disabled, since no support added in FPGA backend yet. Check
14-
// implementation correctness from CXX and SYCL languages perspective.
15-
1613
int test_lsu(cl::sycl::queue Queue) {
1714
int output_data[2];
1815
for (size_t i = 0; i < 2; i++) {

0 commit comments

Comments
 (0)