Skip to content

[SYCL][FPGA] Allow use_stall_enable_clusters attribute to kernel #4031

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

Merged
merged 5 commits into from
Jul 6, 2021

Conversation

smanna12
Copy link
Contributor

@smanna12 smanna12 commented Jun 30, 2021

This patch collects and applies the FPGA attribute intel::use_stall_enable_clusters to the callers/SYCL kernel if directly applied through functors/lambda function.

The attribute has to be applicable to all functions, which can include the SYCL kernels and ​must not be propagated up to the caller/SYCL kernel when called from a function.

This patch fixes FPGA emulator bug that was introduced on #3900.

Signed-off-by: Soumi Manna [email protected]

@smanna12
Copy link
Contributor Author

smanna12 commented Jul 1, 2021

I have conversation with @mendell27. The attribute intel::use_stall_enable_clusters needs to be applied to the callers/SYCL kernel if directly applied through functors/lambda function.

@smanna12 smanna12 marked this pull request as ready for review July 1, 2021 00:10
@smanna12 smanna12 requested a review from erichkeane July 1, 2021 00:10
Copy link
Contributor

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please include a test that shows that your comment in AttrDocs.td is true?

@smanna12
Copy link
Contributor Author

smanna12 commented Jul 1, 2021

Can you please include a test that shows that your comment in AttrDocs.td is true?

@erichkeane, Thanks for the review. I have already a test for this for both CodeGen and SemaSYCL:

[[intel::use_stall_enable_clusters]] void test() {}

SemaSYCL:
// Test attribute is not propagated to the kernel.
    // CHECK-LABEL: FunctionDecl {{.*}}test_kernel3
    // CHECK-NOT:   SYCLIntelUseStallEnableClustersAttr {{.*}}
    h.single_task<class test_kernel3>(
        []() { test(); });

CodeGenSYCL:
// CHECK: define {{.*}}spir_kernel void @{{.*}}test_kernel3() #0 !kernel_arg_buffer_location ![[NUM5]]
    // CHECK: define {{.*}}spir_func void @_Z4testv() #3 !stall_enable ![[NUM4]]
    h.single_task<class test_kernel3>(
        []() { test(); });
// CHECK: ![[NUM4]] = !{i32 1}
// CHECK: ![[NUM5]] = !{}

@erichkeane
Copy link
Contributor

erichkeane commented Jul 1, 2021

Can you please include a test that shows that your comment in AttrDocs.td is true?

@erichkeane, Thanks for the review. I have already a test for this for both CodeGen and SemaSYCL:

[[intel::use_stall_enable_clusters]] void test() {}

SemaSYCL:
// Test attribute is not propagated to the kernel.
    // CHECK-LABEL: FunctionDecl {{.*}}test_kernel3
    // CHECK-NOT:   SYCLIntelUseStallEnableClustersAttr {{.*}}
    h.single_task<class test_kernel3>(
        []() { test(); });

CodeGenSYCL:
// CHECK: define {{.*}}spir_kernel void @{{.*}}test_kernel3() #0 !kernel_arg_buffer_location ![[NUM5]]
    // CHECK: define {{.*}}spir_func void @_Z4testv() #3 !stall_enable ![[NUM4]]
    h.single_task<class test_kernel3>(
        []() { test(); });
// CHECK: ![[NUM4]] = !{i32 1}
// CHECK: ![[NUM5]] = !{}

Based on the diff, you removed at least the sema one!

The test is not showing on the diff because it is an existing test in sema. I did not add any new one for the current diff. So Sema test is still there.

Also, the codegen one is testing that it IS there, what about when it is ignored?

[[intel::use_stall_enable_clusters]] void test() {}

No, it is ignored. The attribute does not get propagated to the kernel below, i.e. spir_kernel.
// CHECK: define {{.*}}spir_kernel void @{{.*}}test_kernel3() #0 !kernel_arg_buffer_location ![[NUM5]]

Here the metadata is attached to the functionDecl that the attribute is applied to test().
 // CHECK: define {{.*}}spir_func void @_Z4testv() #3 !stall_enable ![[NUM4]]

 h.single_task<class test_kernel3>(
      []() { test(); });
// CHECK: ![[NUM5]] = !{}
// CHECK: ![[NUM4]] = !{i32 1}

smanna12 added 2 commits July 1, 2021 18:08
Signed-off-by: Soumi Manna <[email protected]>
Signed-off-by: Soumi Manna <[email protected]>
@smanna12
Copy link
Contributor Author

smanna12 commented Jul 2, 2021

Can you please include a test that shows that your comment in AttrDocs.td is true?

@erichkeane, Thanks for the review. I have already a test for this for both CodeGen and SemaSYCL:

[[intel::use_stall_enable_clusters]] void test() {}

SemaSYCL:
// Test attribute is not propagated to the kernel.
    // CHECK-LABEL: FunctionDecl {{.*}}test_kernel3
    // CHECK-NOT:   SYCLIntelUseStallEnableClustersAttr {{.*}}
    h.single_task<class test_kernel3>(
        []() { test(); });

CodeGenSYCL:
// CHECK: define {{.*}}spir_kernel void @{{.*}}test_kernel3() #0 !kernel_arg_buffer_location ![[NUM5]]
    // CHECK: define {{.*}}spir_func void @_Z4testv() #3 !stall_enable ![[NUM4]]
    h.single_task<class test_kernel3>(
        []() { test(); });
// CHECK: ![[NUM4]] = !{i32 1}
// CHECK: ![[NUM5]] = !{}

Based on the diff, you removed at least the sema one!

The test is not showing on the diff because it is an existing test in sema. I did not add any new one for the current diff. So Sema test is still there.

Also, the codegen one is testing that it IS there, what about when it is ignored?

[[intel::use_stall_enable_clusters]] void test() {}

No, it is ignored. The attribute does not get propagated to the kernel below, i.e. spir_kernel.
// CHECK: define {{.*}}spir_kernel void @{{.*}}test_kernel3() #0 !kernel_arg_buffer_location ![[NUM5]]

Here the metadata is attached to the functionDecl that the attribute is applied to test().
 // CHECK: define {{.*}}spir_func void @_Z4testv() #3 !stall_enable ![[NUM4]]

 h.single_task<class test_kernel3>(
      []() { test(); });
// CHECK: ![[NUM5]] = !{}
// CHECK: ![[NUM4]] = !{i32 1}

@erichkeane, i have updated tests. Added comments and showed that If intel::use_stall_enable_clusters is applied to a function called from a device kernel, the attribute is ignored and it is not propagated to the kernel.

@smanna12 smanna12 requested a review from erichkeane July 2, 2021 01:20
@smanna12
Copy link
Contributor Author

smanna12 commented Jul 6, 2021

Thanks @erichkeane for the review.

Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AaronBallman AaronBallman merged commit 06e4ebc into intel:sycl Jul 6, 2021
@smanna12
Copy link
Contributor Author

smanna12 commented Jul 6, 2021

Thanks @AaronBallman for the review and merge.

@AaronBallman
Copy link
Contributor

Sorry for merging before the review from @elizabethandrews arrived! Please address those concerns in a follow-up PR.

@smanna12
Copy link
Contributor Author

smanna12 commented Jul 6, 2021

Thanks @elizabethandrews for the reviews. I will address all your comments in a follow-up patch (they are mostly NFC changes).

@smanna12
Copy link
Contributor Author

smanna12 commented Jul 6, 2021

Thanks @elizabethandrews for the reviews. I will address all your comments in a follow-up patch (they are mostly NFC changes).

@elizabethandrews, i have addressed all your review comments and created PR is here: #4060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants