Skip to content

Commit 6ee0007

Browse files
authored
Fix CUDA warnings in UnitTestCreateOnDevice (#825)
* Fix CUDA warnings in UnitTestCreateOnDevice CDash: https://my.cdash.org/viewBuildError.php?type=1&buildid=1981182 * Add defaulted function decorations
1 parent b70bdfe commit 6ee0007

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

unit_tests/UnitTestCreateOnDevice.C

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,23 @@
1010
#include <KokkosInterface.h>
1111
#include "utils/CreateDeviceExpression.h"
1212

13-
class Deviceable {
14-
protected :
15-
Deviceable *deviceCopy_;
16-
public :
17-
KOKKOS_FORCEINLINE_FUNCTION Deviceable() : deviceCopy_(nullptr) {}
18-
virtual ~Deviceable() {
19-
if (deviceCopy_) delete_device_copy();
20-
deviceCopy_ = nullptr;
21-
}
22-
template <class T> void copy_to_device(const T &t) {
23-
deviceCopy_ = sierra::nalu::create_device_expression(t);
24-
}
25-
void delete_device_copy() {
26-
sierra::nalu::kokkos_free_on_device(deviceCopy_);
27-
}
28-
};
29-
30-
class Shape : public Deviceable {
13+
class Shape
14+
{
3115
public :
32-
KOKKOS_FORCEINLINE_FUNCTION Shape() {}
33-
virtual ~Shape() {}
16+
KOKKOS_FORCEINLINE_FUNCTION Shape() {}
17+
KOKKOS_DEFAULTED_FUNCTION virtual ~Shape() = default;
3418
KOKKOS_FUNCTION
3519
virtual double area() const = 0;
3620
};
3721

3822
class Rectangle : public Shape {
3923
const double length_,width_;
4024
public :
41-
Rectangle(const double l,const double w):Shape(),length_(l),width_(w) {
42-
copy_to_device(*this);
43-
}
44-
KOKKOS_FORCEINLINE_FUNCTION Rectangle(const Rectangle &r):Shape(),length_(r.length_),width_(r.width_) {}
45-
virtual ~Rectangle(){}
25+
Rectangle(const double l,const double w):Shape(),length_(l),width_(w) {}
26+
KOKKOS_FORCEINLINE_FUNCTION Rectangle(const Rectangle& r)
27+
: Shape(), length_(r.length_), width_(r.width_)
28+
{}
29+
KOKKOS_DEFAULTED_FUNCTION virtual ~Rectangle() = default;
4630
KOKKOS_FUNCTION
4731
virtual double area() const final {
4832
return length_ * width_;
@@ -52,11 +36,11 @@ public :
5236
class Circle : public Shape {
5337
const double radius_;
5438
public :
55-
Circle(const double radius):Shape(),radius_(radius) {
56-
copy_to_device(*this);
57-
}
58-
KOKKOS_FORCEINLINE_FUNCTION Circle(const Circle &c):Shape(),radius_(c.radius_) {}
59-
virtual ~Circle(){}
39+
Circle(const double radius):Shape(),radius_(radius) {}
40+
KOKKOS_FORCEINLINE_FUNCTION Circle(const Circle& c)
41+
: Shape(), radius_(c.radius_)
42+
{}
43+
KOKKOS_DEFAULTED_FUNCTION virtual ~Circle() = default;
6044
KOKKOS_FUNCTION
6145
virtual double area() const final {
6246
return 3.14159265 * radius_ * radius_;

0 commit comments

Comments
 (0)