Skip to content

[SYCL] USM Buffer Location Properties #5634

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 6 commits into from
Mar 9, 2022
Merged

Conversation

sherry-yuan
Copy link
Contributor

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

Lower level runtime's usm allocation API now supports pass in of buffer location property [1] defined in OpenCL spec [2]

For this feature to be accessible to users, sycl runtime now passes in usm::buffer_location property defined in sycl spec [3] into the opencl runtime calls, the property is only passed if the extension name occurs in the platform extension string. If the lower level runtime does not support such property, then the property will yield no effect.

This is a temporary solution to allow user to specify which memory location the device usm allocation should be in. The full solution will require retuning an annotated_ptr that carries compile time properties for further optimization. The full solution spec is in [4]

[1] https://github.com/intel/fpga-runtime-for-opencl/pull/46/files
[2] https://github.com/KhronosGroup/OpenCL-Docs/blob/master/extensions/cl_intel_mem_alloc_buffer_location.asciidoc
[3] #5665
[4] #5656

@sherry-yuan sherry-yuan force-pushed the usm_buffer_loc branch 2 times, most recently from d674afb to 991fdd6 Compare February 24, 2022 15:31
@sherry-yuan
Copy link
Contributor Author

sherry-yuan commented Feb 24, 2022

SYCL / Linux / HIP AMDGPU LLVM Test Suite fails not due to this change, because it falled for a no-functional change in https://github.com/intel/llvm/pull/5656/files# as well

@sherry-yuan sherry-yuan marked this pull request as ready for review February 24, 2022 18:29
@sherry-yuan sherry-yuan requested a review from a team as a code owner February 24, 2022 18:29
@sherry-yuan sherry-yuan changed the title [WIP] USM Buffer Location Properties USM Buffer Location Properties Feb 24, 2022
@steffenlarsen
Copy link
Contributor

Note that this does not directly adhere to the cl_intel_mem_alloc_buffer_location proposal as this implementation uses SYCL 2020 properties instead of the properties introduced in the sycl_ext_oneapi_properties proposal (in development).

@gmlueck - Should we add a variant of this for SYCL 2020 property lists to prevent it from being blocked by the development of the compile-time property lists?

@sherry-yuan
Copy link
Contributor Author

sherry-yuan commented Feb 24, 2022

Note that this does not directly adhere to the cl_intel_mem_alloc_buffer_location proposal as this implementation uses SYCL 2020 properties instead of the properties introduced in the sycl_ext_oneapi_properties proposal (in development).

@steffenlarsen Yes this is more of a stopgap solution for passing properties into the runtime. so that memories can be allocated in the right place. Spec for full solution that uses sycl_ext_oneapi_properties is here; #5656

Once the new property is ready, this change will introduce an override malloc function that uses the new property.

sherry-yuan added a commit to sherry-yuan/llvm that referenced this pull request Feb 24, 2022
…device

-----------------------------------------------------------------------------------

This serves as a temporary solution to supporting usm buffer location, and it is the easiest to implement.
Align with changes in intel#5634

A more complex workaround is to define a new malloc API that accept sycl::ext::oneapi::experimental::properties as its property argument of malloc.

The full solution is to define a malloc api that takes sycl::ext::oneapi::experimental::properties as property argument and returns annotated_ptr
@sherry-yuan

This comment was marked as duplicate.

@sherry-yuan sherry-yuan changed the title USM Buffer Location Properties [SYCL] USM Buffer Location Properties Mar 2, 2022
bader pushed a commit that referenced this pull request Mar 3, 2022
This serves as a temporary solution to supporting usm buffer location, and it is the easiest to implement.
Align with changes in #5634

A more complex workaround is to define a new malloc API that accept sycl::ext::oneapi::experimental::properties as its property argument of malloc.

The full solution is to define a malloc api that takes sycl::ext::oneapi::experimental::properties as property argument and returns annotated_ptr
gmlueck
gmlueck previously approved these changes Mar 3, 2022
Copy link
Contributor

@gmlueck gmlueck left a comment

Choose a reason for hiding this comment

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

LGTM, but someone else should review.

@cperkinsintel
Copy link
Contributor

Once the new property is ready, this change will introduce an override malloc function that uses the new property.

The new properties were merged at the beginning of this week. For both spec conformance and to reduce churn, should we not use them instead?
@steffenlarsen

@sherry-yuan
Copy link
Contributor Author

sherry-yuan commented Mar 4, 2022

The new properties were merged at the beginning of this week. For both spec conformance and to reduce churn, should we not use them instead?

@cperkinsintel Having the new property list alone is not sufficient, we will also need annotated pointer to be ready. See the full solution spec for details: #5656

I don't think the full solution will be ready by Mar 27 given the bandwidth, so this is a workaround that uses existing API and only introduce a simple property in this spec: #5665

We went with this solution because it falls more closely with the expected timeline, bandwidth.

@sherry-yuan
Copy link
Contributor Author

There was no error that was caused by this change, it seems like some test need to be updated because the name space of property was being confused with the new property list.

@steffenlarsen
Copy link
Contributor

As @sherry-yuan pointed out there is another extension for using the new properties for doing this exactly, but it requires a new return type. We could make this an experimental feature and change the return type, which would mean we would break experimental ABI when the new return type is introduced. By using sycl::property_list instead we can deprecate this temporary API and allow users some time to transition to the "final" API.

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.

Some minor comments, otherwise LGTM. Failures do not seem related.

Copy link
Contributor

@cperkinsintel cperkinsintel left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM! Is it possible to write a test for this?

@sherry-yuan
Copy link
Contributor Author

sherry-yuan commented Mar 7, 2022

LGTM! Is it possible to write a test for this?

Thanks! I am not completely sure, it will have to be an e2e test and make sure that the icd loaded runtime has the correct version that contains accept buffer location property. Currently, an e2e test is developed internally and passes (and afaik it seems like intel ocl runtime is the only one that support this property for now). I will look more into how e2e test can be developed in sycl runtime and put that up in a separate PR.

I created an issue to track it here: #5750

@sherry-yuan
Copy link
Contributor Author

@intel/llvm-gatekeepers This PR is ready to merge.

The desired commit message body is the same as PR description & title.

Thanks,
Sherry

@sherry-yuan
Copy link
Contributor Author

sherry-yuan commented Mar 8, 2022

@intel/llvm-gatekeepers Note on precommit test failures: some of the tests (4) does not use explicit namespace reference which caused some confusion with the new property, the test are fixed in this PR: intel/llvm-test-suite#904

@sherry-yuan
Copy link
Contributor Author

@intel/llvm-gatekeepers the tests are fixed, but I currently don't have permissions to re-run the workflows. The tests should pass.

@bader bader merged commit 12c988a into intel:sycl Mar 9, 2022
@sherry-yuan
Copy link
Contributor Author

Thank you all for helping to get this in 😊!

sherry-yuan added a commit to sherry-yuan/llvm-test-suite that referenced this pull request Apr 1, 2022
vladimirlaz pushed a commit to intel/llvm-test-suite that referenced this pull request Apr 3, 2022
pvchupin pushed a commit that referenced this pull request Jun 7, 2022
This ports commit 12c988a from
malloc_device to malloc_shared for use with the FPGA Runtime for OpenCL.

See malloc_device implementation in #5634

See extension specification in #5665
steffenlarsen pushed a commit that referenced this pull request Jun 8, 2022
…h malloc_shared (#6269)

Use the same call to USMDeviceAlloc with an empty property list in all
cases, to allow for straight-forward extension with future properties.

Query buffer location extension only if buffer location property is passed.

This amends #5634

See also #6220
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
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.

6 participants