Skip to content

[SYCL] Rename cuda, hip and fix renaming for level_zero backends #4785

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 35 commits into from Nov 11, 2021
Merged

[SYCL] Rename cuda, hip and fix renaming for level_zero backends #4785

merged 35 commits into from Nov 11, 2021

Conversation

ghost
Copy link

@ghost ghost commented Oct 19, 2021

According to SYCL spec, backend::cuda was renamed to backend::ext_oneapi_cuda,
and backend::hip was renamed to backend::ext_oneapi_hip. Old names were
marked as deprecated. The renaming is also applied in the sources, tests and
unit-tests. Renaming for the Level Zero backend was also applied for the sources,
tests and unit-tests.

The following properties were moved into namespaces reserved for extensions:

  • ext::oneapi::cuda::property::context::use_primary_context,
  • ext::oneapi::cuda::property::queue::use_default_stream.

The interop class template was re-defined in the sycl::detail namespace since
it is not an extension of the SYCL API but just an implementation detail. The parts
of CL/sycl/backend/opencl.hpp that contain specializations for the
sycl::detail::interop class template were moved into the new created
CL/sycl/detail/backend_traits_opencl.hpp header, as well as the same parts of the
sycl/ext/oneapi/backend/level_zero.hpp header. The whole
CL/sycl/backend/cuda.hpp header file was also renamed into the
CL/sycl/detail/backend_traits_cuda.hpp one since the file contains a number of
sycl::detail::interop class template specializations only. A warning was added into
the old file.

@ghost ghost requested a review from vladimirlaz October 19, 2021 11:08
@bader bader added cuda CUDA back-end hip Issues related to execution on HIP backend. labels Oct 19, 2021
@bader bader requested a review from AerialMantis October 19, 2021 11:10
@vladimirlaz vladimirlaz requested a review from pvchupin October 19, 2021 11:26
@vladimirlaz
Copy link
Contributor

please do renaming in https://github.com/intel/llvm-test-suite/ as well.

@ghost
Copy link
Author

ghost commented Oct 19, 2021

@bader Alexey what about namespaces? I see there are namespaces containing the "cuda" word: sycl::property::context::cuda and sycl::property::queue::cuda ones. Should these namespaces be renamed into something containing ext::openapi::cuda? In the spec I see the requirements for namespaces in monopoly use by the extension ("The namespace sycl::ext:: is reserved for use by extensions") but what about sub-namespaces for the standard namespaces?

@bader bader requested a review from gmlueck October 19, 2021 12:27
@ghost
Copy link
Author

ghost commented Oct 19, 2021

@vladimirlaz I've opened a PR with renamings: intel/llvm-test-suite#521 But as I understand, the tests will pass only after merging this PR.

@bader
Copy link
Contributor

bader commented Oct 19, 2021

According to SYCL spec, backend::cuda is renamed to backend::ext_oneapi_cuda,
backend::hip is renamed to backend::ext_oneapi_hip.

I was under impression that SYCL 2020 spec doesn't require additional extensions to implement it on top of non-OpenCL API. So this statement sounds surprising.
@AerialMantis, @gmlueck, do we really want to require non-standard extensions for back-end implementation (e.g. back-end interop) on top of CUDA, HIP or Level Zero?

@gmlueck
Copy link
Contributor

gmlueck commented Oct 19, 2021

@bader Alexey what about namespaces? I see there are namespaces containing the "cuda" word: sycl::property::context::cuda and sycl::property::queue::cuda ones. Should these namespaces be renamed into something containing ext::openapi::cuda?

If there are properties that are specific to the CUDA backend, the extension naming guideline would put them in the ext::oneapi::cuda namespace.

@ghost
Copy link
Author

ghost commented Oct 20, 2021

@gmlueck

If there are properties that are specific to the CUDA backend, the extension naming guideline would put them in the ext::oneapi::cuda namespace.

This properties are in the CL\sycl\properties\context_properties.hpp and CL\sycl\properties\queue_properties.hpp files. The first file has the following content:

namespace sycl {
namespace property {
namespace context {
namespace cuda {
class use_primary_context
    : public detail::DataLessProperty<detail::UsePrimaryContext> {};
} // namespace cuda
} // namespace context
} // namespace property
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)

So, there are cuda-related properties only. Should the use_primary_context class be moved into the sycl::ext::oneapi::cuda namespace or into the sycl::property::context::ext::oneapi::cuda one?

The second file is in a bit different situation: there are a cuda-related property as well as some generic ones:

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace property {
namespace queue {
class in_order : public detail::DataLessProperty<detail::InOrder> {};
class enable_profiling
    : public detail::DataLessProperty<detail::QueueEnableProfiling> {};
namespace cuda {
class use_default_stream
    : public detail::DataLessProperty<detail::UseDefaultStream> {};
} // namespace cuda
} // namespace queue
} // namespace property
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)

But the question is the same. In which namespace the sycl::property::queue::cuda::use_default_stream class should be moved?

Thank you.

P.S. Hmm, as I see in the buffer.properties.hpp file, the use_pinned_host_memory class for oneapi is defined in the sycl::ext::oneapi::property::buffer namespace (the standard properties in this file are defined in the [cl]::sycl::property::buffer namespace.) This looks like the answer on my questions.

@gmlueck
Copy link
Contributor

gmlueck commented Oct 20, 2021

P.S. Hmm, as I see in the buffer.properties.hpp file, the use_pinned_host_memory class for oneapi is defined in the sycl::ext::oneapi::property::buffer namespace (the standard properties in this file are defined in the [cl]::sycl::property::buffer namespace.) This looks like the answer on my questions.

Yes, this is the pattern to follow:

  • ext::oneapi::cuda::property::context::use_primary_context
  • ext::oneapi::cuda::property::queue::use_default_stream

Pavel Samolysov added 13 commits October 22, 2021 12:00
According to SYCL spec, backend::cuda is renamed to backend::ext_oneapi_cuda,
backend::hip is renamed to backend::ext_oneapi_hip. Old namings were marked as
deprecated. The renaming is also applied in the sources, tests and unit-tests.
Renaming for the level_zero backend is also applied for the sources, tests
and unit-tests.
…d/cuda.hpp

According to SYCL spec, an extension may define new header files under the
"sycl" path. The path prefix "sycl/ext/<vendorstring>" is reserved for
this purpose. The "CL/sycl/backend/cuda.hpp" file is moved into the
"sycl/ext/oneapi/backend/cuda.hpp" one. The old file is marked as
deprecated.
…namespace

The class 'use_default_stream' has been moved from the non SYCL2020-conforming
namespace 'sycl::property::queue::cuda' into the
'sycl::ext::oneapi::cuda::property::queue' one where the namespace
'sycl::ext::oneapi::cuda' is reserved for new backends.

Also, the class 'use_primary_context' has been moved from the
'sycl::property::context::cuda' namespace into the
'sycl::ext::oneapi::cuda::property:context' one.
There are new symbols in the new library. It is a non-breaking change.
There are new symbols in the new library. It is a non-breaking change.
There are new symbols in the new library. It is a non-breaking change.
When the old cuda backend header (CL/sycl/backend/cuda.hpp) is included,
a deprecation warning is generated. When "to trait warning as errors"
compilation flag is enabled, the warning leads to a compilation error.
The new path to the cuda backend header (sycl/ext/oneapi/backend/cuda.hpp)
must be used to avoid the error.
The same sets for the level_zero backend are already marked as
deprecated so this is good idea to align the opencl backend with them.
The sycl::interop class template and all its specializations have been
moved to the sycl::detail namespace. The class template is not a part of
the sycl-API and we should not extend the API in headers except the
ones in the sycl/ext/<vendorstring>/... directories.

The sycl::detail::interop part of the opencl and level_zero backends
were moven into the new introduced detail/backend_traits_opencl.hpp and
detail/backend_traits_level_zero.hpp headers as well as the whole
sycl/ext/oneapi/backend/cuda.hpp file were renamed into the
detail/backend_traits_cuda.hpp one since there is no API extensions in
the CUDA backend.
@ghost ghost requested review from smaslov-intel and a team as code owners November 1, 2021 12:01
vladimirlaz
vladimirlaz previously approved these changes Nov 8, 2021
# Conflicts:
#	sycl/source/backend.cpp
vladimirlaz
vladimirlaz previously approved these changes Nov 8, 2021
@ghost
Copy link
Author

ghost commented Nov 9, 2021

@vladimirlaz @gmlueck @AerialMantis @bader @againull @smaslov-intel The PR is ready for review. Could you check, please? I've updated on the current sycl branch since there were conflicts due to the new property mechanism (implemented by @steffenlarsen as I get). @steffenlarsen Could you review the renaming of properties for CUDA as well?

steffenlarsen
steffenlarsen previously approved these changes Nov 9, 2021
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

@steffenlarsen Could you review the renaming of properties for CUDA as well?

Absolutely! LGTM.

AerialMantis
AerialMantis previously approved these changes Nov 9, 2021
Copy link
Contributor

@AerialMantis AerialMantis left a comment

Choose a reason for hiding this comment

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

LGTM

@vladimirlaz vladimirlaz self-requested a review November 9, 2021 16:23
vladimirlaz
vladimirlaz previously approved these changes Nov 9, 2021
againull
againull previously approved these changes Nov 11, 2021
Copy link
Contributor

@againull againull left a comment

Choose a reason for hiding this comment

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

PI and Level Zero part LGTM.

@againull againull dismissed stale reviews from vladimirlaz, AerialMantis, steffenlarsen, and themself via ae5780b November 11, 2021 01:38
@againull againull self-requested a review November 11, 2021 01:39
againull
againull previously approved these changes Nov 11, 2021
@againull againull self-requested a review November 11, 2021 06:47
@againull againull merged commit 97f916e into intel:sycl Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda CUDA back-end hip Issues related to execution on HIP backend.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants