This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 131
[SYCL] [FPGA] Create latency control E2E emulator tests #596
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// REQUIRES: aoc, accelerator | ||
// RUN: %clangxx -fsycl -fintelfpga %s -o %t.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
//==- fpga_latency_control_lsu.cpp - SYCL FPGA latency control on LSU test -==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#include <CL/sycl.hpp> | ||
#include <sycl/ext/intel/fpga_extensions.hpp> | ||
|
||
using namespace sycl; | ||
|
||
using PrefetchingLSU = ext::intel::experimental::lsu< | ||
ext::intel::experimental::prefetch<true>, | ||
ext::intel::experimental::statically_coalesce<false>>; | ||
|
||
using BurstCoalescedLSU = ext::intel::experimental::lsu< | ||
ext::intel::experimental::burst_coalesce<true>, | ||
ext::intel::experimental::statically_coalesce<false>>; | ||
|
||
int test_latency_control(queue Queue) { | ||
std::vector<float> input_data = {1.23f}; | ||
std::vector<float> output_data = {.0f}; | ||
|
||
{ | ||
buffer input_buffer(input_data); | ||
buffer output_buffer(output_data); | ||
|
||
Queue.submit([&](handler &cgh) { | ||
auto input_accessor = input_buffer.get_access<access::mode::read>(cgh); | ||
|
||
auto output_accessor = output_buffer.get_access<access::mode::write>(cgh); | ||
|
||
cgh.single_task<class kernel>([=] { | ||
auto in_ptr = input_accessor.get_pointer(); | ||
auto out_ptr = output_accessor.get_pointer(); | ||
|
||
float value = PrefetchingLSU::load< | ||
ext::intel::experimental::latency_anchor_id<0>>(in_ptr); | ||
|
||
BurstCoalescedLSU::store<ext::intel::experimental::latency_constraint< | ||
0, ext::intel::experimental::type::exact, 5>>(out_ptr, value); | ||
}); | ||
}); | ||
} | ||
|
||
if (output_data[0] != input_data[0]) { | ||
std::cout << "Unexpected read from output_data: " << output_data[0] | ||
<< ", v.s. expected " << input_data[0] << std::endl; | ||
|
||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
int main() { | ||
queue Queue{ext::intel::fpga_emulator_selector{}}; | ||
|
||
return test_latency_control(Queue); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// REQUIRES: aoc, accelerator | ||
// RUN: %clangxx -fsycl -fintelfpga %s -o %t.out | ||
shuoniu-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
//== fpga_latency_control_pipe.cpp - SYCL FPGA latency control on pipe test ==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#include <CL/sycl.hpp> | ||
#include <sycl/ext/intel/fpga_extensions.hpp> | ||
|
||
using namespace sycl; | ||
|
||
using Pipe1 = ext::intel::experimental::pipe<class PipeClass1, int, 8>; | ||
using Pipe2 = ext::intel::experimental::pipe<class PipeClass2, int, 8>; | ||
|
||
int test_latency_control(queue Queue) { | ||
std::vector<int> input_data = {1}; | ||
std::vector<int> output_data = {0}; | ||
|
||
{ | ||
buffer input_buffer(input_data); | ||
buffer output_buffer(output_data); | ||
|
||
Queue.submit([&](handler &cgh) { | ||
auto input_accessor = input_buffer.get_access<access::mode::read>(cgh); | ||
|
||
auto output_accessor = output_buffer.get_access<access::mode::write>(cgh); | ||
|
||
cgh.single_task<class kernel>([=] { | ||
Pipe1::write(input_accessor[0]); | ||
|
||
int value = | ||
Pipe1::read<ext::intel::experimental::latency_anchor_id<0>>(); | ||
|
||
Pipe2::write<ext::intel::experimental::latency_anchor_id<1>, | ||
ext::intel::experimental::latency_constraint< | ||
0, ext::intel::experimental::type::exact, 2>>(value); | ||
|
||
output_accessor[0] = Pipe2::read(); | ||
}); | ||
}); | ||
} | ||
|
||
if (output_data[0] != input_data[0]) { | ||
std::cout << "Unexpected read from output_data: " << output_data[0] | ||
<< ", v.s. expected " << input_data[0] << std::endl; | ||
|
||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
int main() { | ||
queue Queue{ext::intel::fpga_emulator_selector{}}; | ||
|
||
return test_latency_control(Queue); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.