Skip to content

Commit 8f93a84

Browse files
include/oneapi/dpl/internal/sycl_submitter_base_impl.h - implements struct __sycl_submitter_base
1 parent 3041cd4 commit 8f93a84

File tree

2 files changed

+79
-15
lines changed

2 files changed

+79
-15
lines changed

include/oneapi/dpl/internal/scan_by_segment_impl.h

+8-15
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
#include "../pstl/hetero/dpcpp/sycl_traits.h" //SYCL traits specialization for some oneDPL types.
5050

51+
#include "sycl_submitter_base_impl.h" // Base sycl submitter class
52+
5153
namespace oneapi
5254
{
5355
namespace dpl
@@ -113,31 +115,22 @@ struct __sycl_scan_by_segment_submitter_factory
113115
};
114116

115117
template <bool __is_inclusive, typename _ExecutionPolicy>
116-
struct __sycl_scan_by_segment_submitter
118+
struct __sycl_scan_by_segment_submitter : protected __sycl_submitter_base<_ExecutionPolicy>
117119
{
118-
// We should instantiate this submitter only for cleared _ExecutionPolicy type
119-
static_assert(std::is_same_v<_ExecutionPolicy, std::decay_t<_ExecutionPolicy>>);
120-
121120
friend __sycl_scan_by_segment_submitter_factory;
122121

123-
protected:
122+
template <typename... _Name>
123+
using _SegScanWgPhase = __seg_scan_wg_kernel<__is_inclusive, _Name...>;
124124

125-
_ExecutionPolicy __exec;
125+
template <typename... _Name>
126+
using _SegScanPrefixPhase = __seg_scan_prefix_kernel<__is_inclusive, _Name...>;
126127

127128
template <typename _ExecutionPolicyCtor>
128129
__sycl_scan_by_segment_submitter(_ExecutionPolicyCtor&& __exec)
130+
: __sycl_submitter_base<_ExecutionPolicy>(std::forward<_ExecutionPolicyCtor>(__exec))
129131
{
130-
__exec = std::forward<_ExecutionPolicyCtor>(__exec);
131132
}
132133

133-
public:
134-
135-
template <typename... _Name>
136-
using _SegScanWgPhase = __seg_scan_wg_kernel<__is_inclusive, _Name...>;
137-
138-
template <typename... _Name>
139-
using _SegScanPrefixPhase = __seg_scan_prefix_kernel<__is_inclusive, _Name...>;
140-
141134
template <typename _BackendTag, typename _Range1, typename _Range2, typename _Range3, typename _BinaryPredicate,
142135
typename _BinaryOperator, typename _T>
143136
void
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* Copyright (c) 2023 Intel Corporation
2+
*
3+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
*  
5+
* Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
6+
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*     * Redistributions of source code must retain the above copyright
10+
*       notice, this list of conditions and the following disclaimer.
11+
*     * Redistributions in binary form must reproduce the above copyright
12+
*       notice, this list of conditions and the following disclaimer in the
13+
*       documentation and/or other materials provided with the distribution.
14+
*     * Neither the name of the NVIDIA CORPORATION nor the
15+
*       names of its contributors may be used to endorse or promote products
16+
*       derived from this software without specific prior written permission.
17+
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
21+
* ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
22+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef _ONEDPL_SYCL_SUBMITTER_BASE_IMPL_H
31+
#define _ONEDPL_SYCL_SUBMITTER_BASE_IMPL_H
32+
33+
#if _ONEDPL_BACKEND_SYCL
34+
35+
#include <type_traits> // std::is_same_v, std::decay_t
36+
#include <utility> // std::forward
37+
38+
namespace oneapi
39+
{
40+
namespace dpl
41+
{
42+
namespace internal
43+
{
44+
45+
////////////////////////////////////////////////////////////////////////////////
46+
// struct __sycl_submitter_base - base class for all sycl submitters
47+
template <typename _ExecutionPolicy>
48+
struct __sycl_submitter_base
49+
{
50+
protected:
51+
52+
// We should instantiate this submitter only for cleared _ExecutionPolicy type
53+
static_assert(std::is_same_v<_ExecutionPolicy, std::decay_t<_ExecutionPolicy>>);
54+
55+
// Execution policy for using inside submitter implementation
56+
_ExecutionPolicy __exec;
57+
58+
template <typename _ExecutionPolicyCtor>
59+
__sycl_submitter_base(_ExecutionPolicyCtor&& __exec)
60+
: __exec(std::forward<_ExecutionPolicyCtor>(__exec))
61+
{
62+
}
63+
};
64+
65+
} // namespace internal
66+
} // namespace dpl
67+
} // namespace oneapi
68+
69+
#endif // _ONEDPL_BACKEND_SYCL
70+
71+
#endif // _ONEDPL_SYCL_SUBMITTER_BASE_IMPL_H

0 commit comments

Comments
 (0)