Skip to content

Support buffer location for usm allocations #5661

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

Conversation

sherry-yuan
Copy link
Contributor

@sherry-yuan sherry-yuan commented Feb 24, 2022

The solution for supporting runtime & compile time properties for usm allocation requires buffer_locaiton property to be passed into the malloc APIs.

CC: @gmlueck @steffenlarsen

@sherry-yuan sherry-yuan marked this pull request as ready for review February 24, 2022 20:11
@sherry-yuan sherry-yuan requested a review from a team as a code owner February 24, 2022 20:11
@@ -45,7 +45,7 @@ The use of this extension requires a target that supports SPV_INTEL_fpga_buffer_
== Overview

On targets that provide more than one type of global memory, knowing that a particular pointer can only access one of those memory types at compile time can enable compiler optimizations.
This extension adds an accessor property to indicate to the runtime in which of these memories the buffer corresponding to this accessor should be allocated and to inform the compiler that all accesses made through that accessor can only ever interact with the given memory.
This extension adds an accessor property to indicate to the runtime in which of these memories the buffer corresponding to this accessor should be allocated and to inform the compiler that all accesses made through that accessor can only ever interact with the given memory or it can be used to inform the usm alocation (`malloc_device`, `malloc_shared`, `malloc_host`) to allocate on a given memory.
This information is not a hint; it is a functional requirement of the program that must be respected.

== Modifications to the SYCL 2020 Pre-Provisional Specification
Copy link
Contributor

Choose a reason for hiding this comment

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

The description of the property (below) is currently very specific to accessors:

The buffer_location property notifies the SYCL device compiler that the given accessor will only ever point to the memory identified by the int template parameter of its instance class. It also notifies the SYCL runtime to store the given accessor in that memory.

Can you update this so it makes sense also for USM allocations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! The specifics of how this is going to interact with the malloc api depend on the which workaround we choose.

Given that we are only choosing between 1 and 3, malloc api will be updated to align with #5656

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I have added some more examples, and description for passing this property into usm allocation APIs.

@@ -45,7 +45,7 @@ The use of this extension requires a target that supports SPV_INTEL_fpga_buffer_
== Overview

On targets that provide more than one type of global memory, knowing that a particular pointer can only access one of those memory types at compile time can enable compiler optimizations.
This extension adds an accessor property to indicate to the runtime in which of these memories the buffer corresponding to this accessor should be allocated and to inform the compiler that all accesses made through that accessor can only ever interact with the given memory.
This extension adds an accessor property to indicate to the runtime in which of these memories the buffer corresponding to this accessor should be allocated and to inform the compiler that all accesses made through that accessor can only ever interact with the given memory or it can be used to inform the usm alocation (`malloc_device`, `malloc_shared`, `malloc_host`) to allocate on a given memory.
This information is not a hint; it is a functional requirement of the program that must be respected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add a section definition the feature-test macro for this extension? You can use the wording in the specification template in #5663. The name of the macro should be SYCL_EXT_INTEL_BUFFER_LOCATION.

Since there was no feature-test macro before, the value will always be 1. If any further changes are made to this extension, we'll bump the feature-test macro at that time.

Of course, the implementation in #5634 should also add a definition for this macro.

@gmlueck
Copy link
Contributor

gmlueck commented Mar 3, 2022

I don't understand this PR. The existing extension "sycl_ext_intel_buffer_location" is a runtime property that can be passed to the sycl::accessor constructor. However, the changes in this PR seem to use that property as though it was a compile-time property. That doesn't make sense. I think you need to create some new compile-time constant property for that purpose. I'm not sure if this should be in this extension, or if there should be a new one.

@sherry-yuan
Copy link
Contributor Author

I don't understand this PR. The existing extension "sycl_ext_intel_buffer_location" is a runtime property that can be passed to the sycl::accessor constructor. However, the changes in this PR seem to use that property as though it was a compile-time property. That doesn't make sense. I think you need to create some new compile-time constant property for that purpose. I'm not sure if this should be in this extension, or if there should be a new one.

The existing sycl_ext_intel_buffer_location is a compile time property that is passed to clang to generate correct SPIRV (At least this is what Dimitry told me). This is meant to complement the malloc+annotated pointer spec, as commented by Joe here; #5656 (comment)

@gmlueck
Copy link
Contributor

gmlueck commented Mar 3, 2022

The existing sycl_ext_intel_buffer_location is a compile time property that is passed to clang to generate correct SPIRV (At least this is what Dimitry told me). This is meant to complement the malloc+annotated pointer spec, as commented by Joe here; #5656 (comment)

The existing sycl::ext::intel::property::buffer_location does not follow the structure of a compile-time constant property as specified in sycl_ext_oneapi_properties. In addition, sycl::ext::intel::property::buffer_location is currently passed to sycl::property_list, which undersrtands only runtime properties.

Tagging @GarveyJoe

@GarveyJoe
Copy link
Contributor

sycl::ext::intel::property::buffer_location does in fact define a compile-time-constant property, but it builds on the older SYCL_ONEAPI_accessor_properties which was the precursor to sycl_ext_oneapi_properties. There's a column in table 4.50 labelled "Compile-time Constant" for which the value of this property is true. It can be passed to accessor_property_list, not sycl::property_list, and is preserved at compile time in the type of the accessor.

Sherry, if you want to use this extension in combination with your new USM malloc properties extension then you'll need to update it to follow the approach from sycl_ext_oneapi_properties. The changes will be so significant, and the extension will be so bifurcated for the two different use cases, that it might be easier to create a new extension with a new property with a slightly different name.

@sherry-yuan
Copy link
Contributor Author

sycl::ext::intel::property::buffer_location does in fact define a compile-time-constant property, but it builds on the older SYCL_ONEAPI_accessor_properties which was the precursor to sycl_ext_oneapi_properties. There's a column in table 4.50 labelled "Compile-time Constant" for which the value of this property is true. It can be passed to accessor_property_list, not sycl::property_list, and is preserved at compile time in the type of the accessor.

Sherry, if you want to use this extension in combination with your new USM malloc properties extension then you'll need to update it to follow the approach from sycl_ext_oneapi_properties. The changes will be so significant, and the extension will be so bifurcated for the two different use cases, that it might be easier to create a new extension with a new property with a slightly different name.

Right that make sense, in this case it is probably better to write a separate spec defining the property (which could possibly be directly in #5656 ), I will close this PR for this reason. Feel free to reopen it again if it turns out to be needed.

@sherry-yuan sherry-yuan closed this Mar 7, 2022
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