Skip to content

Commit

Permalink
[NFC][SYCL] Use std::make_unique instead of make_unique_ptr (#12827)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelovikov-intel authored Feb 28, 2024
1 parent aaf7a58 commit 17ded8c
Show file tree
Hide file tree
Showing 28 changed files with 104 additions and 134 deletions.
58 changes: 30 additions & 28 deletions sycl/include/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <sycl/id.hpp> // for id
#include <sycl/property_list.hpp> // for property_list
#include <sycl/range.hpp> // for range, rangeTo...
#include <sycl/stl.hpp> // for make_unique_ptr
#include <sycl/types.hpp> // for is_device_copyable

#include <cstddef> // for size_t, nullptr_t
Expand Down Expand Up @@ -203,7 +202,7 @@ class buffer : public detail::buffer_plain,
const property_list &propList = {},
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<
std::make_unique<
detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>()),
Range(bufferRange) {
buffer_plain::constructorNotification(
Expand All @@ -216,7 +215,7 @@ class buffer : public detail::buffer_plain,
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
std::make_unique<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
allocator)),
Range(bufferRange) {
buffer_plain::constructorNotification(
Expand All @@ -229,7 +228,7 @@ class buffer : public detail::buffer_plain,
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(hostData, bufferRange.size() * sizeof(T), alignof(T),
propList,
make_unique_ptr<
std::make_unique<
detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>()),
Range(bufferRange) {
buffer_plain::constructorNotification(
Expand All @@ -242,7 +241,7 @@ class buffer : public detail::buffer_plain,
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
hostData, bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
std::make_unique<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
allocator)),
Range(bufferRange) {
buffer_plain::constructorNotification(
Expand All @@ -257,7 +256,7 @@ class buffer : public detail::buffer_plain,
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(hostData, bufferRange.size() * sizeof(T), alignof(T),
propList,
make_unique_ptr<
std::make_unique<
detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>()),
Range(bufferRange) {
buffer_plain::constructorNotification(
Expand All @@ -272,7 +271,7 @@ class buffer : public detail::buffer_plain,
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
hostData, bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
std::make_unique<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
allocator)),
Range(bufferRange) {
buffer_plain::constructorNotification(
Expand All @@ -286,7 +285,7 @@ class buffer : public detail::buffer_plain,
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
hostData, bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
std::make_unique<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
allocator),
std::is_const<T>::value),
Range(bufferRange) {
Expand All @@ -302,7 +301,7 @@ class buffer : public detail::buffer_plain,
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
hostData, bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
std::make_unique<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
allocator),
std::is_const<T>::value),
Range(bufferRange) {
Expand All @@ -316,10 +315,11 @@ class buffer : public detail::buffer_plain,
const range<dimensions> &bufferRange,
const property_list &propList = {},
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
hostData, bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
std::is_const<T>::value),
: buffer_plain(hostData, bufferRange.size() * sizeof(T), alignof(T),
propList,
std::make_unique<
detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
std::is_const<T>::value),
Range(bufferRange) {
buffer_plain::constructorNotification(
CodeLoc, (void *)impl.get(), (void *)hostData.get(),
Expand All @@ -331,10 +331,11 @@ class buffer : public detail::buffer_plain,
const range<dimensions> &bufferRange,
const property_list &propList = {},
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
hostData, bufferRange.size() * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
std::is_const<T>::value),
: buffer_plain(hostData, bufferRange.size() * sizeof(T), alignof(T),
propList,
std::make_unique<
detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
std::is_const<T>::value),
Range(bufferRange) {
buffer_plain::constructorNotification(
CodeLoc, (void *)impl.get(), (void *)hostData.get(),
Expand Down Expand Up @@ -364,7 +365,7 @@ class buffer : public detail::buffer_plain,
static_cast<IteratorPointerToNonConstValueType>(ToPtr));
},
std::distance(first, last) * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
std::make_unique<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
allocator),
detail::iterator_to_const_type_t<InputIterator>::value),
Range(range<1>(std::distance(first, last))) {
Expand Down Expand Up @@ -396,7 +397,8 @@ class buffer : public detail::buffer_plain,
static_cast<IteratorPointerToNonConstValueType>(ToPtr));
},
std::distance(first, last) * sizeof(T), alignof(T), propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
std::make_unique<
detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
detail::iterator_to_const_type_t<InputIterator>::value),
Range(range<1>(std::distance(first, last))) {
size_t r[3] = {Range[0], 0, 0};
Expand All @@ -415,7 +417,7 @@ class buffer : public detail::buffer_plain,
: buffer_plain(
container.data(), container.size() * sizeof(T), alignof(T),
propList,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
std::make_unique<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(
allocator)),
Range(range<1>(container.size())) {
size_t r[3] = {Range[0], 0, 0};
Expand Down Expand Up @@ -746,10 +748,10 @@ class buffer : public detail::buffer_plain,
buffer(pi_native_handle MemObject, const context &SyclContext,
bool OwnNativeHandle, event AvailableEvent = {},
const detail::code_location CodeLoc = detail::code_location::current())
: buffer_plain(
MemObject, SyclContext,
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
OwnNativeHandle, std::move(AvailableEvent)),
: buffer_plain(MemObject, SyclContext,
std::make_unique<
detail::SYCLMemObjAllocatorHolder<AllocatorT, T>>(),
OwnNativeHandle, std::move(AvailableEvent)),
Range{0} {

Range[0] = buffer_plain::getSize() / sizeof(T);
Expand Down Expand Up @@ -846,14 +848,14 @@ template <class Container, class AllocatorT>
buffer(Container &, AllocatorT, const property_list & = {})
-> buffer<typename Container::value_type, 1, AllocatorT>;
template <class Container>
buffer(Container &, const property_list & = {})
-> buffer<typename Container::value_type, 1>;
buffer(Container &,
const property_list & = {}) -> buffer<typename Container::value_type, 1>;
template <class T, int dimensions, class AllocatorT>
buffer(const T *, const range<dimensions> &, AllocatorT,
const property_list & = {}) -> buffer<T, dimensions, AllocatorT>;
template <class T, int dimensions>
buffer(const T *, const range<dimensions> &, const property_list & = {})
-> buffer<T, dimensions>;
buffer(const T *, const range<dimensions> &,
const property_list & = {}) -> buffer<T, dimensions>;
#endif // __cpp_deduction_guides

} // namespace _V1
Expand Down
23 changes: 23 additions & 0 deletions sycl/include/sycl/detail/defines_elementary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,26 @@

static_assert(__cplusplus >= 201703L,
"DPCPP does not support C++ version earlier than C++17.");

#if defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)
// SYCL library is designed such a way that STL objects cross DLL boundary,
// which is guaranteed to work properly only when the application uses the same
// C++ runtime that SYCL library uses.
// The appplications using sycl.dll must be linked with dynamic/release C++ MSVC
// runtime, i.e. be compiled with /MD switch. Similarly, the applications using
// sycld.dll must be linked with dynamic/debug C++ runtime and be compiled with
// /MDd switch.
// Compiler automatically adds /MD or /MDd when -fsycl switch is used.
// The options /MD and /MDd that make the code to use dynamic runtime also
// define the _DLL macro.
#if defined(_MSC_VER)
#pragma message( \
"SYCL library is designed to work safely with dynamic C++ runtime." \
"Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, " \
"or -fsycl switch to set C++ runtime automatically.")
#else
#warning "SYCL library is designed to work safely with dynamic C++ runtime."\
"Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, "\
"or -fsycl switch to set C++ runtime automatically."
#endif
#endif // defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)
1 change: 0 additions & 1 deletion sycl/include/sycl/ext/intel/fpga_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <sycl/detail/defines.hpp>
#include <sycl/detail/stl_type_traits.hpp>
#include <sycl/stl.hpp>

namespace sycl {
inline namespace _V1 {
Expand Down
Loading

0 comments on commit 17ded8c

Please sign in to comment.