Skip to content

Commit b79af62

Browse files
committed
Refactor pool_properties struct
1 parent 8248b5e commit b79af62

File tree

7 files changed

+17
-49
lines changed

7 files changed

+17
-49
lines changed

sycl/include/sycl/context.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,6 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {
256256
ext_oneapi_get_default_memory_pool(const device &dev,
257257
sycl::usm::alloc kind) const;
258258

259-
/// Gets default memory pool associated with the context and allocation kind.
260-
///
261-
/// \return a memory pool associated with this context.
262-
sycl::ext::oneapi::experimental::memory_pool
263-
ext_oneapi_get_default_memory_pool(sycl::usm::alloc kind) const;
264-
265259
private:
266260
/// Constructs a SYCL context object from a valid context_impl instance.
267261
context(std::shared_ptr<detail::context_impl> Impl);

sycl/include/sycl/ext/oneapi/experimental/async_alloc/memory_pool.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ class __SYCL_EXPORT memory_pool {
6363

6464
protected:
6565
struct pool_properties {
66-
std::pair<bool, size_t> initial_threshold;
67-
std::pair<bool, size_t> maximum_size;
68-
std::pair<bool, bool> zero_init;
66+
size_t initial_threshold;
67+
size_t maximum_size;
68+
bool zero_init;
6969
};
7070

7171
std::shared_ptr<detail::memory_pool_impl> impl;
@@ -89,17 +89,17 @@ class __SYCL_EXPORT memory_pool {
8989
template <typename Properties> pool_properties stripProps(Properties props) {
9090
pool_properties poolProps{};
9191
if constexpr (decltype(props)::template has_property<initial_threshold>()) {
92-
poolProps.initial_threshold = {
93-
true, props.template get_property<initial_threshold>().value};
92+
poolProps.initial_threshold =
93+
props.template get_property<initial_threshold>().value;
9494
}
9595

9696
if constexpr (decltype(props)::template has_property<maximum_size>()) {
97-
poolProps.maximum_size = {
98-
true, props.template get_property<maximum_size>().value};
97+
poolProps.maximum_size =
98+
props.template get_property<maximum_size>().value;
9999
}
100100

101101
if constexpr (decltype(props)::template has_property<zero_init>()) {
102-
poolProps.zero_init = {true, true};
102+
poolProps.zero_init = true;
103103
}
104104
return poolProps;
105105
}

sycl/source/context.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ const property_list &context::getPropList() const {
135135
sycl::ext::oneapi::experimental::memory_pool
136136
context::ext_oneapi_get_default_memory_pool(const device &dev,
137137
sycl::usm::alloc kind) const {
138-
if (kind == sycl::usm::alloc::host)
139-
throw sycl::exception(
140-
sycl::make_error_code(sycl::errc::invalid),
141-
"Default host memory pool requested but device supplied!");
142138
if (kind == sycl::usm::alloc::unknown)
143139
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
144140
"Unknown allocation kinds are disallowed!");
@@ -153,20 +149,5 @@ context::ext_oneapi_get_default_memory_pool(const device &dev,
153149
impl->get_default_memory_pool(*this, dev, kind));
154150
}
155151

156-
sycl::ext::oneapi::experimental::memory_pool
157-
context::ext_oneapi_get_default_memory_pool(sycl::usm::alloc kind) const {
158-
if (kind == sycl::usm::alloc::device || kind == sycl::usm::alloc::shared)
159-
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
160-
"Device and shared allocation kinds are disallowed "
161-
"without specifying a device!");
162-
if (kind == sycl::usm::alloc::unknown)
163-
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
164-
"Unknown allocation kinds are disallowed!");
165-
166-
throw sycl::exception(
167-
sycl::make_error_code(sycl::errc::feature_not_supported),
168-
"Host allocated pools are unsupported!");
169-
}
170-
171152
} // namespace _V1
172153
} // namespace sycl

sycl/source/detail/graph_memory_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ graph_mem_pool::malloc(size_t Size, usm::alloc AllocType,
3434
// Collect relevant properties from memory pool
3535
if (MemPool) {
3636
auto Props = MemPool->getProps();
37-
if (Props.zero_init.second) {
37+
if (Props.zero_init) {
3838
AllocInfo.ZeroInit = true;
3939
}
4040
}

sycl/source/detail/memory_pool.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,13 @@ __SYCL_EXPORT void memory_pool::increase_threshold_to(size_t newThreshold) {
4444
memory_pool::memory_pool(const sycl::context &ctx, const sycl::device &dev,
4545
sycl::usm::alloc kind,
4646
memory_pool::pool_properties props) {
47-
if (kind == sycl::usm::alloc::host)
48-
throw sycl::exception(
49-
sycl::make_error_code(sycl::errc::invalid),
50-
"Host allocated memory pools selected but device supplied!");
51-
5247
if (kind != sycl::usm::alloc::device)
5348
throw sycl::exception(
5449
sycl::make_error_code(sycl::errc::feature_not_supported),
5550
"Only device allocated memory pools are supported!");
5651

57-
detail::pool_properties poolProps{
58-
{props.initial_threshold.first, props.initial_threshold.second},
59-
{props.maximum_size.first, props.maximum_size.second},
60-
{props.zero_init.first, props.zero_init.second}};
52+
detail::pool_properties poolProps{props.initial_threshold, props.maximum_size,
53+
props.zero_init};
6154
impl = std::make_shared<detail::memory_pool_impl>(ctx, dev, kind, poolProps);
6255
}
6356

sycl/source/detail/memory_pool_impl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ memory_pool_impl::memory_pool_impl(const sycl::context &ctx,
6565
MKind(kind), MProps(props) {
6666

6767
if (kind == sycl::usm::alloc::device)
68-
MPoolHandle = create_memory_pool_device(
69-
ctx, dev, MProps.initial_threshold.second, MProps.maximum_size.second,
70-
MProps.zero_init.second);
68+
MPoolHandle =
69+
create_memory_pool_device(ctx, dev, MProps.initial_threshold,
70+
MProps.maximum_size, MProps.zero_init);
7171
else
7272
throw sycl::exception(
7373
sycl::make_error_code(sycl::errc::feature_not_supported),

sycl/source/detail/memory_pool_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ namespace detail {
2222
// Every property is represented by a pair that represent
2323
// (is_property_assigned, property_value)
2424
struct pool_properties {
25-
std::pair<bool, size_t> initial_threshold;
26-
std::pair<bool, size_t> maximum_size;
27-
std::pair<bool, bool> zero_init;
25+
size_t initial_threshold;
26+
size_t maximum_size;
27+
bool zero_init;
2828
};
2929

3030
class memory_pool_impl {

0 commit comments

Comments
 (0)