Skip to content

[SYCL] Fix mem-leak/potential SegFault in LIT test, add 2 required bu… #2591

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 7 commits into from
Feb 17, 2021
21 changes: 21 additions & 0 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ class buffer {
allocator));
}

buffer(const shared_ptr_class<T[]> &hostData,
const range<dimensions> &bufferRange, AllocatorT allocator,
const property_list &propList = {})
: Range(bufferRange) {
impl = std::make_shared<detail::buffer_impl>(
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
allocator));
}

buffer(const shared_ptr_class<T> &hostData,
const range<dimensions> &bufferRange,
const property_list &propList = {})
Expand All @@ -139,6 +150,16 @@ class buffer {
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
}

buffer(const shared_ptr_class<T[]> &hostData,
const range<dimensions> &bufferRange,
const property_list &propList = {})
: Range(bufferRange) {
impl = std::make_shared<detail::buffer_impl>(
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
}

template <class InputIterator, int N = dimensions,
typename = EnableIfOneDimension<N>,
typename = EnableIfItInputIterator<InputIterator>>
Expand Down