Skip to content

Commit 3a7e3d6

Browse files
Vika-Fmergify[bot]
authored andcommitted
Fix *_input classes destructors visibility (#3591)
Fixes the ABI breakage introduced by CPU SPMD algorithms in the PRs #3507, #3585 Make the binding type of the destructors (~compute_input(), ~partial_compute_input(), ~train_input(), etc.) stably "WEAK" and not dependent on the compiler's logic by adding their non-default implementations. Also fixes `set_responses` method in KNN. (cherry picked from commit 0a5f4cb)
1 parent 5e49ac9 commit 3a7e3d6

18 files changed

Lines changed: 579 additions & 4 deletions

File tree

.github/.abignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,19 @@ drop = yes
9292
[suppress_function]
9393
symbol_name_regexp = _Z+N6oneapi3dal[[:digit:]].*7preview[[:digit:]].*
9494
drop = yes
95+
96+
; deselect oneapi::dal newly added symbols
97+
[suppress_type]
98+
symbol_name_regexp = _Z[ZT]?[ISV]?N6oneapi3dal[[:digit:]].*
99+
change_kind = added-type
100+
drop = yes
101+
102+
[suppress_variable]
103+
symbol_name_regexp = _Z[ZT]?[ISV]?N6oneapi3dal[[:digit:]].*
104+
change_kind = added-variable
105+
drop = yes
106+
107+
[suppress_function]
108+
symbol_name_regexp = _Z[ZT]?[ISV]?N6oneapi3dal[[:digit:]].*
109+
change_kind = added-function
110+
drop = yes

cpp/oneapi/dal/algo/basic_statistics/compute_types.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,33 @@ template <typename Task>
7373
compute_input<Task>::compute_input(const table& data, const table& weights)
7474
: impl_(new compute_input_impl<Task>(data, weights)) {}
7575

76+
template <typename Task>
77+
compute_input<Task>::~compute_input() {}
78+
79+
template <typename Task>
80+
compute_input<Task>::compute_input(const compute_input& other) : impl_(other.impl_) {}
81+
82+
template <typename Task>
83+
compute_input<Task>::compute_input(compute_input&& other) noexcept
84+
: impl_(std::move(other.impl_)) {}
85+
86+
template <typename Task>
87+
compute_input<Task>& compute_input<Task>::operator=(const compute_input& other) {
88+
if (this != &other) {
89+
compute_input<Task> tmp(other);
90+
swap(*this, tmp);
91+
}
92+
return *this;
93+
}
94+
95+
template <typename Task>
96+
compute_input<Task>& compute_input<Task>::operator=(compute_input&& other) noexcept {
97+
if (this != &other) {
98+
swap(*this, other);
99+
}
100+
return *this;
101+
}
102+
76103
template <typename Task>
77104
const table& compute_input<Task>::get_data() const {
78105
return impl_->data;
@@ -93,6 +120,11 @@ void compute_input<Task>::set_weights_impl(const table& value) {
93120
impl_->weights = value;
94121
}
95122

123+
template <typename Task>
124+
void compute_input<Task>::swap(compute_input<Task>& a, compute_input<Task>& b) noexcept {
125+
std::swap(a.impl_, b.impl_);
126+
}
127+
96128
using msg = dal::detail::error_messages;
97129

98130
template <typename Task>
@@ -353,6 +385,46 @@ template <typename Task>
353385
const table& partial_compute_result<Task>::get_partial_sum_squares_centered() const {
354386
return impl_->partial_sum_squares_centered;
355387
}
388+
389+
template <typename Task>
390+
partial_compute_input<Task>::~partial_compute_input() {}
391+
392+
template <typename Task>
393+
partial_compute_input<Task>::partial_compute_input(const partial_compute_input& other)
394+
: compute_input<Task>(other),
395+
prev_(other.prev_) {}
396+
397+
template <typename Task>
398+
partial_compute_input<Task>::partial_compute_input(partial_compute_input&& other) noexcept
399+
: compute_input<Task>(std::move(other)),
400+
prev_(std::move(other.prev_)) {}
401+
402+
template <typename Task>
403+
partial_compute_input<Task>& partial_compute_input<Task>::operator=(
404+
const partial_compute_input& other) {
405+
if (this != &other) {
406+
partial_compute_input<Task> tmp(other);
407+
swap(*this, tmp);
408+
}
409+
return *this;
410+
}
411+
412+
template <typename Task>
413+
partial_compute_input<Task>& partial_compute_input<Task>::operator=(
414+
partial_compute_input&& other) noexcept {
415+
if (this != &other) {
416+
swap(*this, other);
417+
}
418+
return *this;
419+
}
420+
421+
template <typename Task>
422+
void partial_compute_input<Task>::swap(partial_compute_input<Task>& a,
423+
partial_compute_input<Task>& b) noexcept {
424+
compute_input<Task>::swap(a, b);
425+
std::swap(a.prev_, b.prev_);
426+
}
427+
356428
template class ONEDAL_EXPORT compute_input<task::compute>;
357429
template class ONEDAL_EXPORT compute_result<task::compute>;
358430
template class ONEDAL_EXPORT partial_compute_result<task::compute>;

cpp/oneapi/dal/algo/basic_statistics/compute_types.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ class compute_input : public base {
5454
compute_input(const table& data);
5555
compute_input(const table& data, const table& weights);
5656

57+
// Do not remove the destructor.
58+
// It is needed to properly handle the visibility of the class in the shared library
59+
// while compiling with -fvisibility=hidden
60+
~compute_input() override;
61+
62+
// Rule of five methods defined here due to the definition of the destructor.
63+
compute_input(const compute_input&);
64+
compute_input(compute_input&&) noexcept;
65+
compute_input& operator=(const compute_input&);
66+
compute_input& operator=(compute_input&&) noexcept;
67+
5768
/// An $n \\times p$ table with the training data, where each row stores one
5869
/// feature vector.
5970
/// @remark default = table{}
@@ -74,6 +85,7 @@ class compute_input : public base {
7485
protected:
7586
void set_data_impl(const table& data);
7687
void set_weights_impl(const table& weights);
88+
static void swap(compute_input<Task>& a, compute_input<Task>& b) noexcept;
7789

7890
private:
7991
dal::detail::pimpl<detail::compute_input_impl<Task>> impl_;
@@ -307,6 +319,17 @@ class partial_compute_input : protected compute_input<Task> {
307319
const table& data,
308320
const table& weights);
309321

322+
// Do not remove the destructor.
323+
// It is needed to properly handle the visibility of the class in the shared library
324+
// while compiling with -fvisibility=hidden
325+
~partial_compute_input() override;
326+
327+
// Rule of five methods defined here due to the definition of the destructor.
328+
partial_compute_input(const partial_compute_input&);
329+
partial_compute_input(partial_compute_input&&) noexcept;
330+
partial_compute_input& operator=(const partial_compute_input&);
331+
partial_compute_input& operator=(partial_compute_input&&) noexcept;
332+
310333
const table& get_data() const {
311334
return compute_input<Task>::get_data();
312335
}
@@ -334,6 +357,9 @@ class partial_compute_input : protected compute_input<Task> {
334357
return *this;
335358
}
336359

360+
protected:
361+
static void swap(partial_compute_input<Task>& a, partial_compute_input<Task>& b) noexcept;
362+
337363
private:
338364
partial_compute_result<Task> prev_;
339365
};

cpp/oneapi/dal/algo/covariance/compute_types.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,33 @@ compute_input<Task>::compute_input() : impl_(new compute_input_impl<Task>{}) {}
140140
template <typename Task>
141141
compute_input<Task>::compute_input(const table& data) : impl_(new compute_input_impl<Task>(data)) {}
142142

143+
template <typename Task>
144+
compute_input<Task>::~compute_input() {}
145+
146+
template <typename Task>
147+
compute_input<Task>::compute_input(const compute_input& other) : impl_(other.impl_) {}
148+
149+
template <typename Task>
150+
compute_input<Task>::compute_input(compute_input&& other) noexcept
151+
: impl_(std::move(other.impl_)) {}
152+
153+
template <typename Task>
154+
compute_input<Task>& compute_input<Task>::operator=(const compute_input& other) {
155+
if (this != &other) {
156+
compute_input<Task> tmp(other);
157+
swap(*this, tmp);
158+
}
159+
return *this;
160+
}
161+
162+
template <typename Task>
163+
compute_input<Task>& compute_input<Task>::operator=(compute_input&& other) noexcept {
164+
if (this != &other) {
165+
swap(*this, other);
166+
}
167+
return *this;
168+
}
169+
143170
template <typename Task>
144171
const table& compute_input<Task>::get_data() const {
145172
return impl_->data;
@@ -150,6 +177,11 @@ void compute_input<Task>::set_data_impl(const table& value) {
150177
impl_->data = value;
151178
}
152179

180+
template <typename Task>
181+
void compute_input<Task>::swap(compute_input<Task>& a, compute_input<Task>& b) noexcept {
182+
std::swap(a.impl_, b.impl_);
183+
}
184+
153185
template <typename Task>
154186
compute_result<Task>::compute_result() : impl_(new compute_result_impl<Task>{}) {}
155187

@@ -265,6 +297,45 @@ void partial_compute_result<Task>::set_partial_sum_impl(const table& value) {
265297
impl_->sums = value;
266298
}
267299

300+
template <typename Task>
301+
partial_compute_input<Task>::~partial_compute_input() {}
302+
303+
template <typename Task>
304+
partial_compute_input<Task>::partial_compute_input(const partial_compute_input& other)
305+
: compute_input<Task>(other),
306+
prev_(other.prev_) {}
307+
308+
template <typename Task>
309+
partial_compute_input<Task>::partial_compute_input(partial_compute_input&& other) noexcept
310+
: compute_input<Task>(std::move(other)),
311+
prev_(std::move(other.prev_)) {}
312+
313+
template <typename Task>
314+
partial_compute_input<Task>& partial_compute_input<Task>::operator=(
315+
const partial_compute_input& other) {
316+
if (this != &other) {
317+
partial_compute_input<Task> tmp(other);
318+
swap(*this, tmp);
319+
}
320+
return *this;
321+
}
322+
323+
template <typename Task>
324+
partial_compute_input<Task>& partial_compute_input<Task>::operator=(
325+
partial_compute_input&& other) noexcept {
326+
if (this != &other) {
327+
swap(*this, other);
328+
}
329+
return *this;
330+
}
331+
332+
template <typename Task>
333+
void partial_compute_input<Task>::swap(partial_compute_input<Task>& a,
334+
partial_compute_input<Task>& b) noexcept {
335+
compute_input<Task>::swap(a, b);
336+
std::swap(a.prev_, b.prev_);
337+
}
338+
268339
template class ONEDAL_EXPORT compute_input<task::compute>;
269340
template class ONEDAL_EXPORT compute_result<task::compute>;
270341
template class ONEDAL_EXPORT partial_compute_result<task::compute>;

cpp/oneapi/dal/algo/covariance/compute_types.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ class compute_input : public base {
118118
/// property value
119119
compute_input(const table& data);
120120

121+
// Do not remove the destructor.
122+
// It is needed to properly handle the visibility of the class in the shared library
123+
// while compiling with -fvisibility=hidden
124+
~compute_input() override;
125+
126+
// Rule of five methods defined here due to the definition of the destructor.
127+
compute_input(const compute_input&);
128+
compute_input(compute_input&&) noexcept;
129+
compute_input& operator=(const compute_input&);
130+
compute_input& operator=(compute_input&&) noexcept;
131+
121132
/// An $n \\times p$ table with the training data, where each row stores one
122133
/// feature vector.
123134
/// @remark default = table{}
@@ -130,6 +141,7 @@ class compute_input : public base {
130141

131142
protected:
132143
void set_data_impl(const table& value);
144+
static void swap(compute_input<Task>& a, compute_input<Task>& b) noexcept;
133145

134146
private:
135147
dal::detail::pimpl<detail::compute_input_impl<Task>> impl_;
@@ -249,6 +261,18 @@ class partial_compute_input : protected compute_input<Task> {
249261

250262
partial_compute_input(const partial_compute_result<Task>& prev, const table& data);
251263

264+
// Do not remove the destructor.
265+
// It is needed to properly handle the visibility of the class in the shared library
266+
// while compiling with -fvisibility=hidden
267+
~partial_compute_input() override;
268+
269+
// Rule of five methods defined here due to the definition of the destructor.
270+
partial_compute_input(const partial_compute_input&);
271+
partial_compute_input(partial_compute_input&&) noexcept;
272+
partial_compute_input& operator=(const partial_compute_input&);
273+
partial_compute_input& operator=(partial_compute_input&&) noexcept;
274+
275+
/// A $n \\times p$ table with the portion of the training data, where each row stores one feature vector.
252276
const table& get_data() const {
253277
return compute_input<Task>::get_data();
254278
}
@@ -258,6 +282,7 @@ class partial_compute_input : protected compute_input<Task> {
258282
return *this;
259283
}
260284

285+
/// Partial result from the previous step of the online covariance computation.
261286
const partial_compute_result<Task>& get_prev() const {
262287
return prev_;
263288
}
@@ -267,6 +292,9 @@ class partial_compute_input : protected compute_input<Task> {
267292
return *this;
268293
}
269294

295+
protected:
296+
static void swap(partial_compute_input<Task>& a, partial_compute_input<Task>& b) noexcept;
297+
270298
private:
271299
partial_compute_result<Task> prev_;
272300
};

cpp/oneapi/dal/algo/dbscan/compute_types.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,33 @@ template <typename Task>
5151
compute_input<Task>::compute_input(const table& data, const table& weights)
5252
: impl_(new compute_input_impl<Task>(data, weights)) {}
5353

54+
template <typename Task>
55+
compute_input<Task>::~compute_input() {}
56+
57+
template <typename Task>
58+
compute_input<Task>::compute_input(const compute_input& other) : impl_(other.impl_) {}
59+
60+
template <typename Task>
61+
compute_input<Task>::compute_input(compute_input&& other) noexcept
62+
: impl_(std::move(other.impl_)) {}
63+
64+
template <typename Task>
65+
compute_input<Task>& compute_input<Task>::operator=(const compute_input& other) {
66+
if (this != &other) {
67+
compute_input<Task> tmp(other);
68+
swap(*this, tmp);
69+
}
70+
return *this;
71+
}
72+
73+
template <typename Task>
74+
compute_input<Task>& compute_input<Task>::operator=(compute_input&& other) noexcept {
75+
if (this != &other) {
76+
swap(*this, other);
77+
}
78+
return *this;
79+
}
80+
5481
template <typename Task>
5582
const table& compute_input<Task>::get_data() const {
5683
return impl_->data;
@@ -71,6 +98,11 @@ void compute_input<Task>::set_weights_impl(const table& value) {
7198
impl_->weights = value;
7299
}
73100

101+
template <typename Task>
102+
void compute_input<Task>::swap(compute_input<Task>& a, compute_input<Task>& b) noexcept {
103+
std::swap(a.impl_, b.impl_);
104+
}
105+
74106
template <typename Task>
75107
compute_result<Task>::compute_result() : impl_(new compute_result_impl<Task>{}) {}
76108

cpp/oneapi/dal/algo/dbscan/compute_types.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ class compute_input : public base {
4949
/// :literal:`weights`
5050
compute_input(const table& data = {}, const table& weights = {});
5151

52+
// Do not remove the destructor.
53+
// It is needed to properly handle the visibility of the class in the shared library
54+
// while compiling with -fvisibility=hidden
55+
~compute_input() override;
56+
57+
// Rule of five methods defined here due to the definition of the destructor.
58+
compute_input(const compute_input&);
59+
compute_input(compute_input&&) noexcept;
60+
compute_input& operator=(const compute_input&);
61+
compute_input& operator=(compute_input&&) noexcept;
62+
5263
/// An $n \\times p$ table with the data to be clustered, where each row
5364
/// stores one feature vector.
5465
const table& get_data() const;
@@ -70,6 +81,7 @@ class compute_input : public base {
7081
protected:
7182
void set_data_impl(const table& data);
7283
void set_weights_impl(const table& weights);
84+
static void swap(compute_input<Task>& a, compute_input<Task>& b) noexcept;
7385

7486
private:
7587
dal::detail::pimpl<detail::compute_input_impl<Task>> impl_;

0 commit comments

Comments
 (0)