-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL][FPGA] Adding function wrapper for function-level loop fusion attributes #4716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ttributes The function attributes [[intel::loop_fuse(N)]] and [[intel::loop_fuse_independent(N)]] are being replaced by equivalent function wrappers by the inclusion of a header file. These attributes can be accessed now by sycl::ext::intel::fpga_loop_fuse<N>(F) and sycl::ext::intel::fpga_loop_fuse_independent<N>(F) for a function or lambda F.
namespace ext { | ||
namespace intel { | ||
|
||
template<int _N = 1, typename _F> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it used in real life with the default parameter in first position?
Do you have an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default first parameter mirrors the behaviour of HLS' #pragma loop_fuse (see here). Apparently, I cannot attach *.cpp files here, but I got the following code to compile:
#include <CL/sycl.hpp>
#include <sycl/ext/intel/fpga_extensions.hpp>
constexpr int v = 123456;
int foo() {
return 42;
}
int main() {
#if defined(FPGA_EMULATOR)
sycl::ext::intel::fpga_emulator_selector device_selector;
#else
sycl::ext::intel::fpga_selector device_selector;
#endif
sycl::queue Queue(device_selector);
sycl::buffer<int, 1> Buf{sycl::range{1}};
Queue.submit([&](sycl::handler &CGH) {
sycl::accessor Acc(Buf, CGH, sycl::write_only);
CGH.single_task<class Test>([=]() {
int foo_val = 0;
sycl::ext::intel::fpga_loop_fuse_independent([&]{ foo_val = foo(); });
sycl::ext::intel::fpga_loop_fuse<v>([&]{ Acc[0] = foo_val; });
});
});
Queue.wait();
auto Acc = Buf.template get_access<sycl::access::mode::read_write>();
assert(Acc[0] == 42 && "Value mismatch");
return 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good starting test for this feature.
Would it makes sense to have loops somewhere in the example, if it is about loops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this compiler, the loop_fuse and loop_fuse_independent attributes add function metadata but do not touch any loops. The implementation and testing of the loop fusion capabilities are in the FPGA compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch is LGTM, but I also wonder why and whether the first template parameter should be defaulted.
@s-kanaev could you please review from runtime-reviewers perspective? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit.
Should there be any sort of test for this feature?
Updated description. |
@MrSidims Would you mind taking another look at my changes? |
The function attributes [[intel::loop_fuse(N)]] and
[[intel::loop_fuse_independent(N)]] are being replaced by equivalent
function wrappers by the inclusion of a header file.
These attributes can be accessed now by
sycl::ext::intel::fpga_loop_fuse(F) and
sycl::ext::intel::fpga_loop_fuse_independent(F) for a function or
lambda F.
There is a lit test for the functionality of the loop fusion attributes. The attributes are tested on functions elsewhere (e.g. here and here).