Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed sum() using wrong iterator type #253

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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