Skip to content

Commit 3f92d20

Browse files
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_utils.h - move the definition of __usm_or_buffer_accessor into __result_and_scratch_storage
1 parent afa995f commit 3f92d20

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_utils.h

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -437,46 +437,6 @@ using __repacked_tuple_t = typename __repacked_tuple<T>::type;
437437
template <typename _ContainerOrIterable>
438438
using __value_t = typename __internal::__memobj_traits<_ContainerOrIterable>::value_type;
439439

440-
template <typename _Accessor>
441-
struct __usm_or_buffer_accessor
442-
{
443-
private:
444-
using _T = std::decay_t<typename _Accessor::value_type>;
445-
_Accessor __acc;
446-
_T* __ptr = nullptr;
447-
bool __usm = false;
448-
size_t __offset = 0;
449-
450-
public:
451-
// Buffer accessor
452-
__usm_or_buffer_accessor(sycl::handler& __cgh, sycl::buffer<_T, 1>* __sycl_buf,
453-
const sycl::property_list& __prop_list)
454-
: __acc(*__sycl_buf, __cgh, __prop_list)
455-
{
456-
}
457-
__usm_or_buffer_accessor(sycl::handler& __cgh, sycl::buffer<_T, 1>* __sycl_buf, size_t __acc_offset,
458-
const sycl::property_list& __prop_list)
459-
: __acc(*__sycl_buf, __cgh, __prop_list), __offset(__acc_offset)
460-
{
461-
}
462-
463-
// USM pointer
464-
__usm_or_buffer_accessor(sycl::handler&, _T* __usm_buf, const sycl::property_list&)
465-
: __ptr(__usm_buf), __usm(true)
466-
{
467-
}
468-
__usm_or_buffer_accessor(sycl::handler&, _T* __usm_buf, size_t __ptr_offset, const sycl::property_list&)
469-
: __ptr(__usm_buf), __usm(true), __offset(__ptr_offset)
470-
{
471-
}
472-
473-
auto
474-
__get_pointer() const // should be cached within a kernel
475-
{
476-
return __usm ? __ptr + __offset : &__acc[__offset];
477-
}
478-
};
479-
480440
// This base class is provided to allow same-typed shared pointer return values from kernels in
481441
// a `__future` for keeping alive temporary data, while allowing run-time branches to lead to
482442
// differently typed temporary storage for kernels. Virtual destructor is required to call
@@ -492,6 +452,46 @@ using __result_and_scratch_storage_base_ptr_t = std::unique_ptr<__result_and_scr
492452
template <typename _TResult, std::size_t _NResults = 1, typename _TScratchData = _TResult>
493453
struct __result_and_scratch_storage : __result_and_scratch_storage_base
494454
{
455+
template <typename _Accessor>
456+
struct __usm_or_buffer_accessor
457+
{
458+
private:
459+
using _T = std::decay_t<typename _Accessor::value_type>;
460+
_Accessor __acc;
461+
_T* __ptr = nullptr;
462+
bool __usm = false;
463+
size_t __offset = 0;
464+
465+
public:
466+
// Buffer accessor
467+
__usm_or_buffer_accessor(sycl::handler& __cgh, sycl::buffer<_T, 1>* __sycl_buf,
468+
const sycl::property_list& __prop_list)
469+
: __acc(*__sycl_buf, __cgh, __prop_list)
470+
{
471+
}
472+
__usm_or_buffer_accessor(sycl::handler& __cgh, sycl::buffer<_T, 1>* __sycl_buf, size_t __acc_offset,
473+
const sycl::property_list& __prop_list)
474+
: __acc(*__sycl_buf, __cgh, __prop_list), __offset(__acc_offset)
475+
{
476+
}
477+
478+
// USM pointer
479+
__usm_or_buffer_accessor(sycl::handler&, _T* __usm_buf, const sycl::property_list&)
480+
: __ptr(__usm_buf), __usm(true)
481+
{
482+
}
483+
__usm_or_buffer_accessor(sycl::handler&, _T* __usm_buf, size_t __ptr_offset, const sycl::property_list&)
484+
: __ptr(__usm_buf), __usm(true), __offset(__ptr_offset)
485+
{
486+
}
487+
488+
auto
489+
__get_pointer() const // should be cached within a kernel
490+
{
491+
return __usm ? __ptr + __offset : &__acc[__offset];
492+
}
493+
};
494+
495495
private:
496496

497497
// struct __result_and_scratch_storage_impl - internal implementation of result and scratch storage

0 commit comments

Comments
 (0)