Skip to content
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

[FPGA][SYCL] Add support for memory attributes on device_global variables #12785

Merged
merged 17 commits into from
Mar 4, 2024

Conversation

smanna12
Copy link
Contributor

@smanna12 smanna12 commented Feb 21, 2024

Currently we allow FPGA memory attributes on const variables. This patch relaxes the restriction that permits the attributes when applied on non-const device_global variables and updates the error message to properly convey which types of variables are allowed to have attributes. Also this patch relaxes the restriction that permits the private_copies attribute when applied on const variables. Previously we had restriction that the private_copies attribute would work with local non-const variables only.

…bles

Signed-off-by: Soumi Manna <soumi.manna@intel.com>
@smanna12 smanna12 changed the title [FPGA][SYCL] Allow memory attributes on non-const device_global varia… [FPGA][SYCL] Allow memory attributes on non-const device_global variables Feb 21, 2024
clang/include/clang/Basic/DiagnosticSemaKinds.td Outdated Show resolved Hide resolved
clang/include/clang/Basic/DiagnosticSemaKinds.td Outdated Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Outdated Show resolved Hide resolved
clang/test/CodeGenSYCL/device_global.cpp Outdated Show resolved Hide resolved
clang/test/SemaSYCL/intel-fpga-device-global.cpp Outdated Show resolved Hide resolved
clang/test/SemaSYCL/intel-fpga-device-global.cpp Outdated Show resolved Hide resolved
clang/test/SemaSYCL/intel-fpga-device-global.cpp Outdated Show resolved Hide resolved
@smanna12
Copy link
Contributor Author

Thanks @premanandrao for reviews and feedbacks!

@smanna12 smanna12 changed the title [FPGA][SYCL] Allow memory attributes on non-const device_global variables [FPGA][SYCL] Allow memory attributes on device_global variables Feb 27, 2024
@smanna12 smanna12 changed the title [FPGA][SYCL] Allow memory attributes on device_global variables [FPGA][SYCL] Allow memory attributes on non-const device_global variables Feb 27, 2024
@smanna12 smanna12 changed the title [FPGA][SYCL] Allow memory attributes on non-const device_global variables [FPGA][SYCL] Add support for memory attributes on device_global variables Feb 27, 2024
@premanandrao
Copy link
Contributor

@premanandrao, I checked with @artemrad about this. The ask, was always to allow all FPGA memory attributes on non-const device_globals. The scope has not changed.

Okay, I am fine if that is the case. We just need to make sure that only the exact restrictions are called for each attribute.

I could not able to add support for non const global_variables without refactoring common codes since isTypeDecoratedWithDeclAttribute() is available in sema. Also while working on this, i notice that we have few test coverages for memory attributes when they apply for const/local/static etc. So This PR ends up adding more tests cases to make sure I do not create any regression.

Sounds good. I will review again after the restriction difference is fixed.

@smanna12
Copy link
Contributor Author

smanna12 commented Feb 29, 2024

@premanandrao, I checked with @artemrad about this. The ask, was always to allow all FPGA memory attributes on non-const device_globals. The scope has not changed.

Okay, I am fine if that is the case. We just need to make sure that only the exact restrictions are called for each attribute.

I could not able to add support for non const global_variables without refactoring common codes since isTypeDecoratedWithDeclAttribute() is available in sema. Also while working on this, i notice that we have few test coverages for memory attributes when they apply for const/local/static etc. So This PR ends up adding more tests cases to make sure I do not create any regression.

Sounds good. I will review again after the restriction difference is fixed.

@premanandrao, I have updated patch to fix restriction difference (a314482). Does this address your concerns? The new commit makes sure that only the exact restrictions are called for each attribute with addition of non-const device global.

clang/lib/Sema/SemaDeclAttr.cpp Outdated Show resolved Hide resolved
clang/include/clang/Basic/Attr.td Show resolved Hide resolved
clang/lib/Sema/SemaDeclAttr.cpp Outdated Show resolved Hide resolved
@smanna12 smanna12 marked this pull request as ready for review March 1, 2024 22:16
@smanna12 smanna12 requested a review from a team as a code owner March 1, 2024 22:16
Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

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

LGTM @smanna12

@smanna12
Copy link
Contributor Author

smanna12 commented Mar 1, 2024

Thank you @premanandrao for the reviews!

@smanna12
Copy link
Contributor Author

smanna12 commented Mar 2, 2024

latest commit was just format fixes (4a4a016).

@intel/llvm-gatekeepers, This PR is ready. Could you please merge this PR? This feature is very important for FPGA team.

@ldrumm ldrumm merged commit 3fc6708 into intel:sycl Mar 4, 2024
12 checks passed
@smanna12 smanna12 deleted the FixFPGABug branch March 4, 2024 16:04
againull pushed a commit that referenced this pull request Mar 6, 2024
…evice compilation (#12930)

#12785 added support for non-const
device_global variables on all FPGA memory attributes. FPGA memory
attributes should only work for device codes. They should have no effect
on host code. This patch fixes bug where we emitted error when
attributes are applied to device_globals variables for host compilation.

---------

Signed-off-by: Soumi Manna <soumi.manna@intel.com>
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.

3 participants