Skip to content

Commit 697469f

Browse files
authored
[SYCL][FPGA] Update LSU builtins template to allow multi_ptr (#3321)
Updated LSU headers to allow multi_ptr instead of global_ptr. Added address space checks to builtins.
1 parent b5aa33d commit 697469f

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

sycl/include/CL/sycl/INTEL/fpga_lsu.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ template <class... _mem_access_params> class lsu final {
4747
public:
4848
lsu() = delete;
4949

50-
template <typename _T> static _T load(sycl::global_ptr<_T> Ptr) {
50+
template <typename _T, access::address_space _space>
51+
static _T load(sycl::multi_ptr<_T, _space> Ptr) {
52+
check_space<_space>();
5153
check_load();
5254
#if defined(__SYCL_DEVICE_ONLY__) && __has_builtin(__builtin_intel_fpga_mem)
5355
return *__builtin_intel_fpga_mem((_T *)Ptr,
@@ -59,7 +61,9 @@ template <class... _mem_access_params> class lsu final {
5961
#endif
6062
}
6163

62-
template <typename _T> static void store(sycl::global_ptr<_T> Ptr, _T Val) {
64+
template <typename _T, access::address_space _space>
65+
static void store(sycl::multi_ptr<_T, _space> Ptr, _T Val) {
66+
check_space<_space>();
6367
check_store();
6468
#if defined(__SYCL_DEVICE_ONLY__) && __has_builtin(__builtin_intel_fpga_mem)
6569
*__builtin_intel_fpga_mem((_T *)Ptr,
@@ -92,6 +96,14 @@ template <class... _mem_access_params> class lsu final {
9296

9397
static_assert(_cache_val >= 0, "cache size parameter must be non-negative");
9498

99+
template <access::address_space _space> static void check_space() {
100+
static_assert(_space == access::address_space::global_space ||
101+
_space == access::address_space::global_device_space ||
102+
_space == access::address_space::global_host_space,
103+
"lsu controls are only supported for global_ptr, "
104+
"device_ptr, and host_ptr objects");
105+
}
106+
95107
static void check_load() {
96108
static_assert(_cache == 0 || _burst_coalesce == BURST_COALESCE,
97109
"unable to implement a cache without a burst coalescer");

sycl/test/extensions/fpga.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,14 @@ int main() {
5959
/*Check LSU interface*/
6060
{
6161
cl::sycl::buffer<int, 1> output_buffer(1);
62-
cl::sycl::buffer<int, 1> input_buffer(1);
62+
auto *in_ptr = cl::sycl::malloc_host<int>(1, Queue.get_context());
6363

6464
Queue.submit([&](cl::sycl::handler &cgh) {
6565
auto output_accessor =
6666
output_buffer.get_access<cl::sycl::access::mode::write>(cgh);
67-
auto input_accessor =
68-
input_buffer.get_access<cl::sycl::access::mode::read>(cgh);
6967

7068
cgh.single_task<class kernel>([=] {
71-
auto input_ptr = input_accessor.get_pointer();
69+
cl::sycl::host_ptr<int> input_ptr(in_ptr);
7270
auto output_ptr = output_accessor.get_pointer();
7371

7472
using PrefetchingLSU =

0 commit comments

Comments
 (0)