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

Add unittest for linalg::axpy #942

Merged
merged 4 commits into from
Oct 27, 2022
Merged

Conversation

benfred
Copy link
Member

@benfred benfred commented Oct 21, 2022

Closes #873
Closes #944

@benfred benfred requested review from a team as code owners October 21, 2022 21:47
@benfred benfred added non-breaking Non-breaking change improvement Improvement / enhancement to an existing function labels Oct 21, 2022
Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this test, @benfred! Not sure if you are finished but I figured it wouldn't hurt to do a quick first-pass review before I take off for the weekend.

cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
int blocks = raft::ceildiv<int>(params.len, threads);
naiveAxpy<T><<<blocks, threads, 0, stream>>>(params.len, params.scalar, x.data(), refy.data());

axpy(handle, params.len, &params.scalar, x.data(), 1.0, y.data(), 1.0, stream);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to test the new mdspan APIs (which will test the raw pointer functions as well since they just wrap them. Eventually the raw pointer APIs are going to go away and we'll just be using mdspan across the public APIs (and start using it in the detail APIs as well).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also test this with different strides.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to use the new mdspan api's - but hit some problems trying to get this going with different strides =( #944

cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
cpp/test/linalg/axpy.cu Outdated Show resolved Hide resolved
@cjnolet
Copy link
Member

cjnolet commented Oct 24, 2022

Do you want to go ahead and make the changes for #944 in this PR? I think the amount of changes is still reasonably small to correct the API and get the test supporting the different strides.

} else if (params.incx > 1) {
axpy(handle,
make_host_scalar_view<const T>(&params.alpha),
make_strided_device_vector_view<const T>(x.data(), params.len, params.incx),
Copy link
Member

@cjnolet cjnolet Oct 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also test w/ column-major mdspan inputs directly? I think (e.g. raft::make_device_vector_view<const T, std::uint32_t, raft::col_major>(...))? We should be able to capture the layout directly and then use the strides when a strided (and contiguous) layout is provided.

OutType y,
const int incx,
const int incy)
OutType y)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look great! Just a follow-up from our offline discussion yesterday. What do you think about just having the host scalar side accept the const typename InType::value_type directly for now until we have the infrastructure to automatically convert to the host scalar view? We could also merge this and do it in a follow-on PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a Github issue to do this in a follow-on. I think we could scrape through and do it more generally as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds great - I think we should handle auto converting to host_scalar_view in a couple other spots than just the axpy code, so seems out of scope for this PR

@cjnolet
Copy link
Member

cjnolet commented Oct 27, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit ced7bce into rapidsai:branch-22.12 Oct 27, 2022
@benfred benfred deleted the axpy_test branch October 27, 2022 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake cpp improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
2 participants