Skip to content

[SYCL] Allow fpga_reg only for PODs and Trivially-copyable structs #3643

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Jun 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions sycl/include/CL/sycl/INTEL/fpga_reg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,31 @@
#pragma once

#include <CL/sycl/detail/defines.hpp>
#include <type_traits>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace INTEL {

template <typename _T> _T fpga_reg(const _T &t) {
// Returns a registered copy of the input
// This function is intended for FPGA users to instruct the compiler to insert
// at least one register stage between the input and the return value.
template <typename _T>
typename std::enable_if<std::is_trivially_copyable<_T>::value, _T>::type
fpga_reg(_T t) {
#if __has_builtin(__builtin_intel_fpga_reg)
return __builtin_intel_fpga_reg(t);
#else
return t;
#endif
}

template <typename _T>
[[deprecated("INTEL::fpga_reg will only support trivially_copyable types in a "
"future release. The type used here will be disallowed.")]]
typename std::enable_if<std::is_trivially_copyable<_T>::value == false,
_T>::type
fpga_reg(_T t) {
#if __has_builtin(__builtin_intel_fpga_reg)
return __builtin_intel_fpga_reg(t);
#else
Expand All @@ -29,7 +48,9 @@ template <typename _T> _T fpga_reg(const _T &t) {
// Keep it consistent with FPGA attributes like intelfpga::memory()
// Currently clang does not support nested namespace for attributes
namespace intelfpga {
template <typename _T> _T fpga_reg(const _T &t) {
template <typename _T>
[[deprecated("intelfpga::fpga_reg will be removed in a future release.")]] _T
fpga_reg(const _T &t) {
return cl::sycl::INTEL::fpga_reg(t);
}
} // namespace intelfpga