Skip to content

Commit

Permalink
Make matxHalf trivially copyable (#513)
Browse files Browse the repository at this point in the history
Set copy ctor and copy assignment methods to default.
Also use default ctors for both matxHalf and matxHalfComplex.
Thus, the MatX half types no longer initialize to zero.
  • Loading branch information
tbensonatl authored Nov 3, 2023
1 parent f467cd7 commit ae802e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
22 changes: 7 additions & 15 deletions include/matx/core/half.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,17 @@ template <typename T> struct alignas(sizeof(T)) matxHalf {
using value_type = T; ///< Type of half

/**
* @brief Initialize to zero
* @brief Default constructor
*
*/
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalf() : x(0.0f) {}
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalf() = default;

/**
* @brief Copy constructor
* @brief Default copy constructor
*
* @param x_ Parameter to copy
*/
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalf(const matxHalf<T> &x_) noexcept
: x(x_.x)
{
}
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalf(const matxHalf<T> &x_) noexcept = default;

/**
* @brief Copy constructor from arbitrary type
Expand All @@ -79,7 +76,7 @@ template <typename T> struct alignas(sizeof(T)) matxHalf {
}

/**
* @brief Default desctructor
* @brief Default destructor
*
*/
__MATX_INLINE__ ~matxHalf() = default;
Expand Down Expand Up @@ -115,16 +112,11 @@ template <typename T> struct alignas(sizeof(T)) matxHalf {
}

/**
* @brief Copy assignment operator
* @brief Default copy assignment operator
*
* @param rhs Value to copy
*/
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalf<T> &
operator=(const matxHalf<T> &rhs)
{
x = rhs.x;
return *this;
}
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalf<T> &operator=(const matxHalf<T> &rhs) = default;

/**
* @brief Copy assignment operator
Expand Down
4 changes: 2 additions & 2 deletions include/matx/core/half_complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ template <typename T> struct alignas(sizeof(T) * 2) matxHalfComplex {
using value_type = T; ///< Type trait to get type

/**
* @brief Constructor a half complex object with defaults of zero
* @brief Default constructor
*
*/
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalfComplex() : x(0.0f), y(0.0f) {}
__MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalfComplex() = default;

/**
* @brief Copy constructor from a complex float
Expand Down

0 comments on commit ae802e6

Please sign in to comment.