Skip to content

Commit

Permalink
Fix CUDA warnings in UnitTestCreateOnDevice (#825)
Browse files Browse the repository at this point in the history
* Fix CUDA warnings in UnitTestCreateOnDevice

CDash: https://my.cdash.org/viewBuildError.php?type=1&buildid=1981182

* Add defaulted function decorations
  • Loading branch information
sayerhs authored Mar 15, 2021
1 parent b70bdfe commit 6ee0007
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions unit_tests/UnitTestCreateOnDevice.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,23 @@
#include <KokkosInterface.h>
#include "utils/CreateDeviceExpression.h"

class Deviceable {
protected :
Deviceable *deviceCopy_;
public :
KOKKOS_FORCEINLINE_FUNCTION Deviceable() : deviceCopy_(nullptr) {}
virtual ~Deviceable() {
if (deviceCopy_) delete_device_copy();
deviceCopy_ = nullptr;
}
template <class T> void copy_to_device(const T &t) {
deviceCopy_ = sierra::nalu::create_device_expression(t);
}
void delete_device_copy() {
sierra::nalu::kokkos_free_on_device(deviceCopy_);
}
};

class Shape : public Deviceable {
class Shape
{
public :
KOKKOS_FORCEINLINE_FUNCTION Shape() {}
virtual ~Shape() {}
KOKKOS_FORCEINLINE_FUNCTION Shape() {}
KOKKOS_DEFAULTED_FUNCTION virtual ~Shape() = default;
KOKKOS_FUNCTION
virtual double area() const = 0;
};

class Rectangle : public Shape {
const double length_,width_;
public :
Rectangle(const double l,const double w):Shape(),length_(l),width_(w) {
copy_to_device(*this);
}
KOKKOS_FORCEINLINE_FUNCTION Rectangle(const Rectangle &r):Shape(),length_(r.length_),width_(r.width_) {}
virtual ~Rectangle(){}
Rectangle(const double l,const double w):Shape(),length_(l),width_(w) {}
KOKKOS_FORCEINLINE_FUNCTION Rectangle(const Rectangle& r)
: Shape(), length_(r.length_), width_(r.width_)
{}
KOKKOS_DEFAULTED_FUNCTION virtual ~Rectangle() = default;
KOKKOS_FUNCTION
virtual double area() const final {
return length_ * width_;
Expand All @@ -52,11 +36,11 @@ public :
class Circle : public Shape {
const double radius_;
public :
Circle(const double radius):Shape(),radius_(radius) {
copy_to_device(*this);
}
KOKKOS_FORCEINLINE_FUNCTION Circle(const Circle &c):Shape(),radius_(c.radius_) {}
virtual ~Circle(){}
Circle(const double radius):Shape(),radius_(radius) {}
KOKKOS_FORCEINLINE_FUNCTION Circle(const Circle& c)
: Shape(), radius_(c.radius_)
{}
KOKKOS_DEFAULTED_FUNCTION virtual ~Circle() = default;
KOKKOS_FUNCTION
virtual double area() const final {
return 3.14159265 * radius_ * radius_;
Expand Down

0 comments on commit 6ee0007

Please sign in to comment.