Skip to content

[SYCL] Refactor cl::sycl namespace. Part1 #4397

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

Closed
wants to merge 13 commits into from

Conversation

romanovvlad
Copy link
Contributor

The patch is the first in series of patches that implement support for
SYCL2020 namespace requirements - sycl:: instead of cl::sycl.

The patch replaces explicit uses of cl::sycl namespace with a configurable
macro which will be used in future patches.

@romanovvlad
Copy link
Contributor Author

@erichkeane Could you please take a look at SemaSYCL.cpp modifications? The patch replaces explicit usages of cl and sycl namespaces openings with macro which are defined in defines_elementary.hpp.

@erichkeane
Copy link
Contributor

Clang changes so far are seemingly fine. You might consider removing one set of '{' and '}' from it though so that the source looks something like:

__SYCL_OPEN_NS {

....
} __SYCL_CLOSE_NS

Or something. It would at least make the scoping a little easier to read.

alexbatashev
alexbatashev previously approved these changes Aug 30, 2021
@romanovvlad romanovvlad requested review from pvchupin and a team as code owners August 30, 2021 12:48
alexbatashev
alexbatashev previously approved these changes Aug 30, 2021
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.

I've reviewed half of the changed files and left a few comments.

Could you clarify how many parts of the refactoring is going to be and give an overview of the changes in other parts, please?

@romanovvlad
Copy link
Contributor Author

I've reviewed half of the changed files and left a few comments.

Could you clarify how many parts of the refactoring is going to be and give an overview of the changes in other parts, please?

I see it like this:

  1. Introduce namespace macro(this patch)
  2. Add aliases from the old ABI to the new one + switch to new namespaces by default
  3. Move files from CL/sycl to sycl
  4. Bugfixes if any

smaslov-intel
smaslov-intel previously approved these changes Aug 30, 2021
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.

Comments for the second half of the files.


#ifdef __SYCL_ENABLE_SYCL121_NAMESPACE
// Old SYCL1.2.1 namespace scheme
#define __SYCL_NS_OPEN_1 __SYCL_INLINE_NAMESPACE(cl)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove __SYCL_INLINE_NAMESPACE? I think it's not supposed to be used explicitly anymore. Right?

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 is still used for builtins declaration - https://github.com/intel/llvm/blob/sycl/sycl/include/CL/sycl/detail/builtins.hpp#L106 and will be used until we remove support for old namespaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will get rid of this macro in the second patch(by introducing a new one).

Copy link
Contributor

Choose a reason for hiding this comment

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

It is still used for builtins declaration - https://github.com/intel/llvm/blob/sycl/sycl/include/CL/sycl/detail/builtins.hpp#L106 and will be used until we remove support for old namespaces.

#ifndef __SYCL_DEVICE_ONLY__
__SYCL_INLINE_NAMESPACE(cl) {
namespace __host_std {

I think we should re-visit the design of this code.
It is unclear to me why we put built-in declarations to cl namespace. Another question: why do we inline cl namespace here? I understand that it's needed to allow users to use sycl namespace w/o cl:: qualifier, but __host_std namespace should not be exposed like this. Right?

Will get rid of this macro in the second patch(by introducing a new one).

Could you clarify what new macro is for?

If this is the only use, can we just use inline namespace instead of the macro here? I'm okay to make this change in follow-up patches.

MrSidims
MrSidims previously approved these changes Aug 31, 2021
Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

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

FPGA file changes are LGTM

@romanovvlad romanovvlad dismissed stale reviews from MrSidims and smaslov-intel via 53d3767 August 31, 2021 09:41
@romanovvlad romanovvlad requested a review from bader August 31, 2021 09:42
@romanovvlad
Copy link
Contributor Author

bfloat16 fail should be fixed by #4388

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.

FE changes LGTM

@@ -4788,8 +4788,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
FwdDeclEmitter.Visit(K.NameType);
O << "\n";

O << "__SYCL_INLINE_NAMESPACE(cl) {\n";
O << "namespace sycl {\n";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found a problem with this change.

Copy link
Contributor

@bader bader Aug 31, 2021

Choose a reason for hiding this comment

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

What is the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that the integration header includes defines_elementary.hpp which selects either SYCL 1.2.1 of SYCL2020 style of namespaces before we know which one should be used. So, it seems it was a bad idea to use the same macro in the integration header and for headers. Going to introduce a separate macro for integration header.

@erichkeane @premanandrao Does it sound OK?

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds like that should be alright... we just have to make sure the two stay in sync. Though, I'm not sure how you can get a macro here to work if it depends on a decision that isn't made yet. Should defines_elementary.hpp be doing all of the lifting for this set of namespaces?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just use inline namespace cl w/o any macro defined in DPC++ headers?

Copy link
Contributor Author

@romanovvlad romanovvlad Aug 31, 2021

Choose a reason for hiding this comment

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

That sounds like that should be alright... we just have to make sure the two stay in sync.
Though, I'm not sure how you can get a macro here to work if it depends on a decision that isn't made yet.
Should defines_elementary.hpp be doing all of the lifting for this set of namespaces?

I'm thinking about separating those namespaces. For integration header we could have a macro in the defines_elementary.hpp which, for example, defines to __sycl_int_header_ns (it's not quite suitable for the integration footer though). For headers we could you an additional header(defines_sycl_ns.hpp) which is not included from the integration header - when we include it we know which namespace version we should use.

Can we just use inline namespace cl w/o any macro defined in DPC++ headers?

We can, but we cannot use inline namespace cl, because user space will be still poluted. We can use a different namespace - __sycl_int_header_ns, but with a macro it would be easier to be in sync without FE modifications.

@bader
Copy link
Contributor

bader commented Aug 31, 2021

I've reviewed half of the changed files and left a few comments.
Could you clarify how many parts of the refactoring is going to be and give an overview of the changes in other parts, please?

I see it like this:

  1. Introduce namespace macro(this patch)
  2. Add aliases from the old ABI to the new one + switch to new namespaces by default
  3. Move files from CL/sycl to sycl
  4. Bugfixes if any

Please, update the PR title to something like "[SYCL] Refactor cl::sycl namespace [part 1 of 3]." and add the details from your comment to the description.

@romanovvlad romanovvlad closed this Sep 9, 2021
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.

8 participants