Skip to content

[SYCL] Define templates used in multiple Sema TUs in a common .h file #1164

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 1 commit into from
Feb 28, 2020

Conversation

premanandrao
Copy link
Contributor

Signed-off-by: Premanand M Rao premanand.m.rao@intel.com

@@ -8,6 +8,8 @@
// This file implements C++ template instantiation for declarations.
//
//===----------------------------------------------------------------------===/
#include "SemaTemplateImpl.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are template methods from new header are used in this source file?
If not, please, remove this include.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alexey, they are. The first one - AddOneConstantValueAttr - is used at around lines 528 and 539. The second one - AddOneConstantPowerTwoValueAttr - is used at around lines 506 and 517.

Copy link
Contributor

Choose a reason for hiding this comment

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

How is this working today if these are defined in other source file?
Are we instantiating the same specializations in both files?
How did this code pass code review?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works today because when the files are linked together, the definition is found from the other file. The declaration is seen from Sema.h, so it compiles fine. The reason the issue was found is that we have a more optimizing build where the template definition got completely inlined, and the other file couldn't find the definition and failed at link-time.

Yes, we are instantiating the same specialization in both files.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not define these methods in Sema.h then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think there is a technical reason. I would rather not have implementations there to reduce the clutter in that file.

Do you feel strongly about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be hard to debug cases when Sema.h is included and methods defined in a separate header is used.
Reducing clutter in Sema.h shouldn't be resolved by this PR. Let's handle it separately.

@MrSidims
Copy link
Contributor

Please note: that is not the only place where templated declarations are handled. Are you sure, that you want to process this refactoring?

@premanandrao
Copy link
Contributor Author

Please note: that is not the only place where templated declarations are handled. Are you sure, that you want to process this refactoring?

This was the only place that we found an issue with definitions in source files (which were used in another source file), which is what motivated this particular refactoring.

AlexeySachkov
AlexeySachkov previously approved these changes Feb 25, 2020
Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

LGTM

@bader bader self-assigned this Feb 26, 2020
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

@premanandrao, please, move Sema member function templates definitions to Sema.h header file.

Signed-off-by: Premanand M Rao <premanand.m.rao@intel.com>
@bader bader merged commit dcbdcfd into intel:sycl Feb 28, 2020
AlexeySachkov referenced this pull request Mar 30, 2020
…ttributes (#811)

Signed-off-by: Viktoria Maksimova <viktoria.maksimova@intel.com>
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Feb 23, 2023
intel#6601 increases number of captured
variable and thus number of kernel arguments for reductions. Modify the
CHECKs accordingly.
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