Skip to content

[SYCL] Pass buffer_location property to buffer #5604

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 33 commits into from
Mar 17, 2022

Conversation

maximdimakov
Copy link
Contributor

@maximdimakov maximdimakov commented Feb 17, 2022

There is the accessor property "buffer_location" that allows to allocate buffer in definite location (spec: https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/sycl_ext_intel_buffer_location.asciidoc)
Current implementation doesn't implement allocating a buffer at the passed location and the buffer will be re-sided when a kernel is enqueued. It leads to problems of various kinds.
The proposed solution implies adding new buffer property in order to store it in a buffer and use it when the buffer is allocated.
If the property is not supported by device it will be ignored.
Signed-off-by: mdimakov [email protected]

Comment on lines 41 to 42
// CHECK-NEXT: 11 | void sycl::detail::SYCLMemObjI::addOrReplaceAccessorProperties(const sycl::property_list &) [pure]
// CHECK-NEXT: 12 | void sycl::detail::SYCLMemObjI::deleteAccessorProperty(const sycl::detail::PropWithDataKind &) [pure]
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this an ABI break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove virtual functions

@maximdimakov
Copy link
Contributor Author

/summary:run

@maximdimakov maximdimakov marked this pull request as ready for review February 21, 2022 07:54
@maximdimakov maximdimakov requested a review from a team as a code owner February 21, 2022 07:54
@maximdimakov
Copy link
Contributor Author

maximdimakov commented Feb 21, 2022

The test fpga_tests/buffer_location.cpp failed because the device the test ran on has no support for the buffer_location feature. There are 2 ways to resolve this problem:

  • Disable this test until CI devices get support for the buffer_location feature
  • Add sycl::aspect for this feature and check it. The difficulty is that spec has no mention for such aspect. It can be added there, but this action may require indefinite amount of time

@bader
Copy link
Contributor

bader commented Feb 21, 2022

  • Add sycl::aspect for this feature and check it. The difficulty is that spec has no mention for such aspect. It can be added there, but this action may require indefinite amount of time

I suggest filing a bug report on the spec and ask for fix ETA.

Please, update the link to the spec and fix punctuation in the description.

@bader
Copy link
Contributor

bader commented Feb 21, 2022

  • Add sycl::aspect for this feature and check it. The difficulty is that spec has no mention for such aspect. It can be added there, but this action may require indefinite amount of time

I suggest filing a bug report on the spec and ask for fix ETA.

Please, update the link to the spec and fix punctuation in the description.

Just confirming that this the issue in the spec and it's going to be fixed by adding a new device aspect might be enough to implement a proper test fix.

.wait();
std::shared_ptr<sycl::detail::buffer_impl> BufImpl =
sycl::detail::getSyclObjImpl(Buf);
EXPECT_EQ(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why buffer impl is used here instead of PassedLocation?
If the property shouldn't be there in call to piMemBufferCreate then it should be checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no kernel in the command group above, so piMemBufferCreate will not be called. This check verifies that new buffer_location is passed to the buffer properties. Check that this value is passed correctly is placed above
https://github.com/intel/llvm/pull/5604/files/4d548846221b21799da61a62f7755bc33b59f829#diff-8e8ed34037520ee5405a46f25d39b96ff066f684a71560371fd3258ac46be9f8R146

.wait();

EXPECT_EQ(
BufImpl->has_property<sycl::property::buffer::detail::buffer_location>(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

@maximdimakov
Copy link
Contributor Author

@bader I have opened PR with adding the aspect #5660. It was decided to ignore this property if it is not supported on device. So, fpga_tests/buffer_location.cpp works as before.

Comment on lines 218 to 227
auto Plugin = getPlugin();
for (auto &Device : MDevices) {
const RT::PiDevice PiDevice = getSyclObjImpl(Device)->getHandleRef();
if (Plugin.call_nocheck<detail::PiApiKind::piDeviceGetInfo>(
PiDevice, (pi_device_info)PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION,
sizeof(pi_device_info), &device_info, &return_size) != PI_SUCCESS) {
SupportBufferLocationByDevices = NotSupported;
break;
}
}
Copy link
Contributor

@sherry-yuan sherry-yuan Mar 2, 2022

Choose a reason for hiding this comment

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

I think this specific way of calling get device info will always return false since the lower level runtime currently does not support passing PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION into the get device info API. Is there no other way of determining whether the target is an FPGA that does not rely on lower level runtime?

If we do this, then the OpenCL Spec has to be changed.

P.S refer to the opencl spec for what can be done with the property
https://github.com/KhronosGroup/OpenCL-Docs/blob/main/extensions/cl_intel_mem_alloc_buffer_location.asciidoc

Copy link
Contributor

Choose a reason for hiding this comment

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

Although technically the opencl spec is written in a way that enforces all vendor's runtime to accept this property, so technically it should be fine to directly pass it into other runtime (although they may do nothing with the property).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there no other way of determining whether the target is an FPGA that does not rely on lower level runtime?
We can determine if the device is FPGA or not in runtime. I tried to do this in ccf73a6
Do you think it would be better to just check if a device is FPGA or not?

Copy link
Contributor

@sherry-yuan sherry-yuan Mar 2, 2022

Choose a reason for hiding this comment

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

Yes I do think it is better to check if a device is FPGA directly, because even if it error out on FPGA device, it will prompt the other vendor to support passing in of buffer location feature in their runtime API. (Technically all vendor should support this property anyways)

sherry-yuan added a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this pull request Mar 2, 2022
------------------------------------------------------

Currently sycl runtime is trying to distinguish whether buffer location is supported on the target device using lower level runtime getDeviceInfo call to determine it. However current runtime get device info does not yet support accepting the buffer location property yet, this change addes it.

The referenced sycl runtime PR: intel/llvm#5604
sherry-yuan added a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this pull request Mar 2, 2022
------------------------------------------------------

Currently sycl runtime is trying to distinguish whether buffer location is supported on the target device using lower level runtime getDeviceInfo call to determine it. However current runtime get device info does not yet support accepting the buffer location property yet, this change addes it.

The referenced sycl runtime PR: intel/llvm#5604
@maximdimakov
Copy link
Contributor Author

/summary:run

Comment on lines 50 to 51
PropWithDataKindSize = 5
AccPropBufferLocation = 5,
PropWithDataKindSize = 6,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason why new enum is not added at the end?

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to ignore, I found the reason: there is a comparison somewhere where all other enum of the same type cannot exceed this last enum.

if (PropKind >= PropWithDataKind::PropWithDataKindSize)

Copy link
Contributor

@sherry-yuan sherry-yuan Mar 2, 2022

Choose a reason for hiding this comment

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

Is this an ABI breaking change given that PropWithDataKindSize changed from 5 -> 6? If there are existing object file that assumes PropWithDataKindSize is 5?

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 not an ABI breaking change, because it is not a property and it is used only in property_list_base.hpp

@maximdimakov
Copy link
Contributor Author

@s-kanaev could you, please, review?

sherry-yuan
sherry-yuan previously approved these changes Mar 7, 2022
Copy link
Contributor

@sherry-yuan sherry-yuan left a comment

Choose a reason for hiding this comment

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

LGTM, The latest change passes internal test and has the expected behavior.
Wait for others' approval though.

bader pushed a commit that referenced this pull request Mar 10, 2022
Update spec accordingly to the changes from #5604. buffer_location property will be ignored if the device it passed to doesn't support it.
Signed-off-by: mdimakov <[email protected]>
@maximdimakov maximdimakov requested a review from s-kanaev March 11, 2022 09:01
Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

LGTM overall

@@ -177,6 +182,7 @@ class context_impl {
std::map<std::pair<DeviceLibExt, RT::PiDevice>, RT::PiProgram>
MCachedLibPrograms;
mutable KernelProgramCache MKernelProgramCache;
mutable PropertySupport SupportBufferLocationByDevices;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mutable PropertySupport SupportBufferLocationByDevices;
mutable PropertySupport MSupportBufferLocationByDevices;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@maximdimakov maximdimakov requested a review from s-kanaev March 15, 2022 16:03
@@ -33,4 +33,5 @@ add_subdirectory(program_manager)
add_subdirectory(assert)
add_subdirectory(Extensions)
add_subdirectory(windows)
add_subdirectory(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

That's an interesting change in this late commit...

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 tried to resolve merge conflict. This line has already added to CMakeLists.txt

Copy link
Contributor

@s-kanaev s-kanaev 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
Copy link
Contributor

bader commented Mar 16, 2022

/summary:run

@bader bader merged commit 9808525 into intel:sycl Mar 17, 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.

4 participants