Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Add test for usm buffer location properties #955

Merged
merged 1 commit into from
Apr 3, 2022

Conversation

sherry-yuan
Copy link

@sherry-yuan sherry-yuan commented Mar 28, 2022

Resolves intel/llvm#5750
The test is for PR: intel/llvm#5634

@sherry-yuan sherry-yuan force-pushed the usm_buffer_location branch 2 times, most recently from 877d182 to 7efc703 Compare March 29, 2022 18:26
@sherry-yuan
Copy link
Author

Test failures are in SYCL :: ESIMD/slm_split_barrier.cpp which is not related to the new test.

@sherry-yuan sherry-yuan marked this pull request as ready for review March 30, 2022 14:03
@sherry-yuan sherry-yuan requested a review from a team as a code owner March 30, 2022 14:03
Comment on lines 29 to 36
int *test_src_ptr = malloc_device<int>(
1, dev, ctxt,
property_list{ext::intel::experimental::property::usm::buffer_location(
true_buf_loc)});
int *test_dst_ptr = malloc_device<int>(
1, dev, ctxt,
property_list{ext::intel::experimental::property::usm::buffer_location(
true_buf_loc)});

Choose a reason for hiding this comment

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

These pointers leak. Either of SYCL API calls can throw an exception. Please, wrap them into std::unique_ptr.

Copy link
Author

@sherry-yuan sherry-yuan Mar 30, 2022

Choose a reason for hiding this comment

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

Thanks for reviewing:) I tried this suggestion but it seems like currently both unique_ptr or shareed_ptr are not device copyable (I think its because this poitner is used in the kernel). When I compiled, the following error were thrown:

error: static_assert failed due to requirement 'is_device_copyable<std::unique_ptr<int, std::default_delete<int>>, void>::value || detail::IsDeprecatedDeviceCopyable<std::unique_ptr<int, std::default_delete<int>>, void>::value' "The specified type is not device copyable"
  static_assert(is_device_copyable<FieldT>::value ||

I thin it s fine to leave it at this point, because if there is an error, it is from the lower level runtime, which means the pointer is not successfully allocated. In that case, there wouldn't be any memory leaked.

Copy link
Author

Choose a reason for hiding this comment

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

I improve the check a bit so that if it is only the second one failed, the first allocated memroy will not leak.

Choose a reason for hiding this comment

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

@sherry-yuan you can use std::unique_ptr::get() to copy pointer on device and custom deleters to clean up the memory, see https://en.cppreference.com/w/cpp/memory/unique_ptr

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! the latest commit wraps the device pointer in a new struct with custom deleters.

alexbatashev
alexbatashev previously approved these changes Apr 1, 2022
Copy link

@alexbatashev alexbatashev left a comment

Choose a reason for hiding this comment

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

LGTM

@sherry-yuan sherry-yuan force-pushed the usm_buffer_location branch from bbf6e07 to f0549c0 Compare April 1, 2022 13:51
@sherry-yuan
Copy link
Author

I have applied the suggestion and squashed the commits for a cleaner merge.

@sherry-yuan sherry-yuan requested a review from alexbatashev April 1, 2022 13:57
@vladimirlaz vladimirlaz merged commit e184d60 into intel:intel Apr 3, 2022
myler pushed a commit to myler/llvm-test-suite that referenced this pull request Jun 17, 2022
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Develop e2e test suite for testing usm buffer location
3 participants