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

Fix grid dimensions for transpose. #182

Merged
merged 2 commits into from
May 26, 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
5 changes: 3 additions & 2 deletions include/matx_tensor_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,9 @@ inline
static_cast<int>(in.TotalSize() / (in.Size(RANK - 1) * in.Size(RANK - 2)));

dim3 block(TILE_DIM, TILE_DIM);
dim3 grid(batch_dims, static_cast<int>((in.Size(RANK - 1) + TILE_DIM - 1) / TILE_DIM),
static_cast<int>((in.Size(RANK - 2) + TILE_DIM - 1) / TILE_DIM));
dim3 grid(static_cast<int>((in.Size(RANK - 1) + TILE_DIM - 1) / TILE_DIM),
static_cast<int>((in.Size(RANK - 2) + TILE_DIM - 1) / TILE_DIM),
batch_dims);
transpose_kernel_oop<<<grid, block, shm, stream>>>(out, in);
}
#endif
Expand Down
33 changes: 31 additions & 2 deletions test/00_operators/OperatorTests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,35 @@ TYPED_TEST(OperatorTestsNumeric, NonSquareTranspose)
MATX_EXIT_HANDLER();
}

TYPED_TEST(OperatorTestsNumeric, Transpose3D)
{
MATX_ENTER_HANDLER();

index_t num_rows = 5998;
index_t num_cols = 64;

tensor_t<TypeParam, 3> t3 ({1, num_rows, num_cols});
tensor_t<TypeParam, 3> t3t({1, num_cols, num_rows});

for (index_t i = 0; i < num_rows; i++) {
for (index_t j = 0; j < num_cols; j++) {
t3(0, i, j) = static_cast<detail::value_promote_t<TypeParam>>(i * num_cols + j);
}
}

transpose(t3t, t3, 0);
cudaError_t error = cudaStreamSynchronize(0);
ASSERT_EQ(error, cudaSuccess);

for (index_t i = 0; i < num_rows; i++) {
for (index_t j = 0; j < num_cols; j++) {
EXPECT_EQ(t3(0, i, j), t3t(0, j, i));
}
}

MATX_EXIT_HANDLER();
}

TYPED_TEST(OperatorTestsNumeric, CloneAndAdd)
{
MATX_ENTER_HANDLER();
Expand Down Expand Up @@ -854,8 +883,8 @@ TYPED_TEST(OperatorTestsNumeric, CloneAndAdd)
}
}

auto smx =
steeredMx.Clone<4>({matxKeepDim, numPulses, numPairs, matxKeepDim});
auto smx =
steeredMx.Clone<4>({matxKeepDim, numPulses, numPairs, matxKeepDim});
auto vah = velAccelHypoth.Clone<4>(
{numBeams, matxKeepDim, matxKeepDim, matxKeepDim});

Expand Down
25 changes: 0 additions & 25 deletions test/00_tensor/ViewTests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -535,28 +535,3 @@ TYPED_TEST(ViewTestsComplex, RealComplexView)
}
MATX_EXIT_HANDLER();
}


TYPED_TEST(ViewTestsNumericNonComplex, Permute)
{
MATX_ENTER_HANDLER();

auto t3n = make_tensor<TypeParam>({1, 20, 10});
auto t3t = make_tensor<TypeParam>({1, 10, 20});

for (index_t i = 0; i < t3n.TotalSize(); i++) {
t3n(0, i / t3n.Size(2), i % t3n.Size(2)) = (TypeParam)i;
}

transpose(t3t, t3n, 0);
cudaStreamSynchronize(0);

for (int i = 0; i < t3n.Size(1); i++) {
for (int j = 0; j < t3n.Size(2); j++) {
ASSERT_EQ(t3n(0,i,j), t3t(0,j,i));
}
}


MATX_EXIT_HANDLER();
}