Skip to content

Commit

Permalink
Fixed sum() using wrong iterator type (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffburdick authored Aug 23, 2022
1 parent 54904fd commit 33e5898
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
8 changes: 4 additions & 4 deletions include/matx/transforms/cub.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct BeginOffset {
*
* @return Value at offset
*/
[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ reference operator*() const
[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ stride_type operator*() const
{
return offset_ * size_;
}
Expand All @@ -138,7 +138,7 @@ struct BeginOffset {
return self_type{size_, offset_ + offset};
}

[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ reference operator[](difference_type offset) const
[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ stride_type operator[](difference_type offset) const
{
return *self_type{size_, offset_ + offset};
}
Expand Down Expand Up @@ -187,7 +187,7 @@ struct EndOffset {
*
* @return Value at offset
*/
[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ reference operator*() const
[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ stride_type operator*() const
{
return (offset_ + 1) * size_;
}
Expand All @@ -197,7 +197,7 @@ struct EndOffset {
return self_type{size_, offset_ + offset};
}

[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ reference operator[](difference_type offset) const
[[nodiscard]] __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ stride_type operator[](difference_type offset) const
{
return ( offset + 1) * size_;
}
Expand Down
30 changes: 30 additions & 0 deletions include/matx/transforms/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,36 @@ __MATX_DEVICE__ __MATX_INLINE__ void atomicAll(uint64_t *addr, uint64_t val)
}
}

/**
* Atomic add for int64_t
*
* @param addr
* Source and destination for result
* @param val
* Value to add
*/
__MATX_DEVICE__ __MATX_INLINE__ void atomicAdd(int64_t *addr,
int64_t val)
{
unsigned long long int *addri = reinterpret_cast<unsigned long long int *>(addr);
atomicAdd(addri, (unsigned long long int)val);
}

/**
* Atomic add for uint64_t
*
* @param addr
* Source and destination for result
* @param val
* Value to add
*/
__MATX_DEVICE__ __MATX_INLINE__ void atomicAdd(uint64_t *addr,
uint64_t val)
{
unsigned long long int *addri = reinterpret_cast<unsigned long long int *>(addr);
atomicAdd(addri, (unsigned long long int)val);
}

/**
* Atomic add for complex floats
*
Expand Down
3 changes: 2 additions & 1 deletion test/00_operators/ReductionTests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ TYPED_TEST(ReductionTestsComplexNonHalfTypes, VarianceStdComplex)
MATX_EXIT_HANDLER();
}

TYPED_TEST(ReductionTestsFloatNonComplexNonHalf, Sum)
TYPED_TEST(ReductionTestsNumericNoHalf, Sum)
{
MATX_ENTER_HANDLER();
{
Expand Down Expand Up @@ -273,6 +273,7 @@ TEST(ReductionTests, Any)
TEST(ReductionTests, All)
{
MATX_ENTER_HANDLER();

using TypeParam = int;
{
tensor_t<int, 0> t0;
Expand Down

0 comments on commit 33e5898

Please sign in to comment.