From b4bb4aafb3924ff87b4d689951a714efd81b56da Mon Sep 17 00:00:00 2001 From: Alexey Voronov Date: Thu, 12 Sep 2019 17:26:10 +0300 Subject: [PATCH] [SYCL] Delete range class default constructor. The SYCL specification does not provide a default constructor for the range class. Signed-off-by: Alexey Bader Signed-off-by: Alexey Voronov --- sycl/include/CL/sycl/accessor.hpp | 10 ++++++--- sycl/include/CL/sycl/detail/accessor_impl.hpp | 4 +++- sycl/include/CL/sycl/detail/cg.hpp | 21 ++++++++++++------- sycl/include/CL/sycl/detail/common.hpp | 3 ++- sycl/include/CL/sycl/detail/image_impl.hpp | 3 ++- sycl/include/CL/sycl/id.hpp | 3 ++- sycl/include/CL/sycl/range.hpp | 3 ++- 7 files changed, 31 insertions(+), 16 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index 83aa87d8258e..a7fbce290fd7 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -158,7 +158,7 @@ namespace detail { // DefaultValue, truncation just removes extra values. template class T, int OldDim> static T convertToArrayOfN(T OldObj) { - T NewObj; + T NewObj = InitializedVal::template get<0>(); const int CopyDims = NewDim > OldDim ? OldDim : NewDim; for (int I = 0; I < CopyDims; ++I) NewObj[I] = OldObj[I]; @@ -727,7 +727,10 @@ class accessor : public: // Default constructor for objects later initialized with __init member. - accessor() : impl({}) {} + accessor() + : impl({}, detail::InitializedVal::template get<0>(), + detail::InitializedVal::template get<0>()) {} + #else using AccessorBaseHost::getAccessRange; using AccessorBaseHost::getMemoryRange; @@ -1035,7 +1038,8 @@ class accessor::template get<0>()) {} private: PtrType getQualifiedPtr() const { return MData; } diff --git a/sycl/include/CL/sycl/detail/accessor_impl.hpp b/sycl/include/CL/sycl/detail/accessor_impl.hpp index da15dc34839c..102585d614eb 100644 --- a/sycl/include/CL/sycl/detail/accessor_impl.hpp +++ b/sycl/include/CL/sycl/detail/accessor_impl.hpp @@ -45,7 +45,9 @@ template class AccessorImplDevice { template class LocalAccessorBaseDevice { public: - LocalAccessorBaseDevice(sycl::range Size) : AccessRange(Size) {} + LocalAccessorBaseDevice(sycl::range Size) + : AccessRange(Size), + MemRange(InitializedVal::template get<0>()) {} // TODO: Actually we need only one field here, but currently compiler requires // all of them. range AccessRange; diff --git a/sycl/include/CL/sycl/detail/cg.hpp b/sycl/include/CL/sycl/detail/cg.hpp index 7a813f16d316..4a96d7a3d7fa 100644 --- a/sycl/include/CL/sycl/detail/cg.hpp +++ b/sycl/include/CL/sycl/detail/cg.hpp @@ -202,7 +202,7 @@ class HostKernel : public HostKernelBase { runOnHost(const NDRDescT &NDRDesc) { size_t XYZ[3] = {0}; sycl::id ID; - sycl::range Range; + sycl::range Range(InitializedVal::template get<0>()); for (int I = 0; I < Dims; ++I) Range[I] = NDRDesc.GlobalSize[I]; @@ -226,7 +226,7 @@ class HostKernel : public HostKernelBase { typename std::enable_if< std::is_same>::value>::type runOnHost(const NDRDescT &NDRDesc) { - sycl::range Range; + sycl::range Range(InitializedVal::template get<0>()); sycl::id Offset; for (int I = 0; I < Dims; ++I) { Range[I] = NDRDesc.GlobalSize[I]; @@ -253,7 +253,8 @@ class HostKernel : public HostKernelBase { template typename std::enable_if>::value>::type runOnHost(const NDRDescT &NDRDesc) { - sycl::range GroupSize; + sycl::range GroupSize( + InitializedVal::template get<0>()); for (int I = 0; I < Dims; ++I) { if (NDRDesc.LocalSize[I] == 0 || NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0) @@ -261,8 +262,10 @@ class HostKernel : public HostKernelBase { GroupSize[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; } - sycl::range GlobalSize; - sycl::range LocalSize; + sycl::range LocalSize( + InitializedVal::template get<0>()); + sycl::range GlobalSize( + InitializedVal::template get<0>()); sycl::id GlobalOffset; for (int I = 0; I < Dims; ++I) { GlobalOffset[I] = NDRDesc.GlobalOffset[I]; @@ -291,7 +294,7 @@ class HostKernel : public HostKernelBase { template enable_if_t>::value> runOnHost(const NDRDescT &NDRDesc) { - sycl::range NGroups; + sycl::range NGroups(InitializedVal::template get<0>()); for (int I = 0; I < Dims; ++I) { if (NDRDesc.LocalSize[I] == 0 || @@ -299,9 +302,11 @@ class HostKernel : public HostKernelBase { throw sycl::runtime_error("Invalid local size for global size"); NGroups[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; } - sycl::range GlobalSize; - sycl::range LocalSize; + sycl::range LocalSize( + InitializedVal::template get<0>()); + sycl::range GlobalSize( + InitializedVal::template get<0>()); for (int I = 0; I < Dims; ++I) { LocalSize[I] = NDRDesc.LocalSize[I]; GlobalSize[I] = NDRDesc.GlobalSize[I]; diff --git a/sycl/include/CL/sycl/detail/common.hpp b/sycl/include/CL/sycl/detail/common.hpp index f90f6dd6e1eb..36103ea6ddcb 100644 --- a/sycl/include/CL/sycl/detail/common.hpp +++ b/sycl/include/CL/sycl/detail/common.hpp @@ -198,7 +198,8 @@ template struct NDLoop { InitializedVal::template get<0>(); const LoopBoundTy Stride = InitializedVal::template get<1>(); - LoopIndexTy Index; // initialized down the call stack + LoopIndexTy Index = + InitializedVal::template get<0>(); NDLoopIterateImpl{ LowerBound, Stride, UpperBound, f, Index}; diff --git a/sycl/include/CL/sycl/detail/image_impl.hpp b/sycl/include/CL/sycl/detail/image_impl.hpp index 3cb3e0cb3052..3d71d79f2b67 100644 --- a/sycl/include/CL/sycl/detail/image_impl.hpp +++ b/sycl/include/CL/sycl/detail/image_impl.hpp @@ -228,7 +228,8 @@ class image_impl final : public SYCLMemObjT { image_impl(cl_mem MemObject, const context &SyclContext, event AvailableEvent = {}) - : BaseT(MemObject, SyclContext, std::move(AvailableEvent)) { + : BaseT(MemObject, SyclContext, std::move(AvailableEvent)), + MRange(InitializedVal::template get<0>()) { RT::PiMem Mem = pi::cast(BaseT::MInteropMemObject); PI_CALL(RT::piMemGetInfo(Mem, CL_MEM_SIZE, sizeof(size_t), &(BaseT::MSizeInBytes), nullptr)); diff --git a/sycl/include/CL/sycl/id.hpp b/sycl/include/CL/sycl/id.hpp index d28dec60894b..fa9cffc43654 100644 --- a/sycl/include/CL/sycl/id.hpp +++ b/sycl/include/CL/sycl/id.hpp @@ -68,7 +68,8 @@ template class id : public detail::array { : base(item.get_id(0), item.get_id(1), item.get_id(2)) {} explicit operator range() const { - range result; + range result( + detail::InitializedVal::template get<0>()); for (int i = 0; i < dimensions; ++i) { result[i] = this->get(i); } diff --git a/sycl/include/CL/sycl/range.hpp b/sycl/include/CL/sycl/range.hpp index 7739bdb855de..bf00d1b0e05a 100644 --- a/sycl/include/CL/sycl/range.hpp +++ b/sycl/include/CL/sycl/range.hpp @@ -59,7 +59,7 @@ template class range : public detail::array { range(range &&rhs) = default; range &operator=(const range &rhs) = default; range &operator=(range &&rhs) = default; - range() = default; + range() = delete; // OP is: +, -, *, /, %, <<, >>, &, |, ^, &&, ||, <, >, <=, >= #define __SYCL_GEN_OPT(op) \ @@ -133,5 +133,6 @@ template class range : public detail::array { #undef __SYCL_GEN_OPT }; + } // namespace sycl } // namespace cl