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

Implement gesdd #899

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions clients/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ if(BUILD_CLIENTS_BENCHMARKS OR BUILD_CLIENTS_TESTS)
common/lapack/testing_getrs.cpp
common/lapack/testing_gesv.cpp
common/lapack/testing_gesvd.cpp
common/lapack/testing_gesdd.cpp
common/lapack/testing_gesvdj.cpp
common/lapack/testing_gesvdx.cpp
common/lapack/testing_trtri.cpp
Expand Down
32 changes: 32 additions & 0 deletions clients/common/lapack/testing_gesdd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* **************************************************************************
* Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* *************************************************************************/

#include "testing_gesdd.hpp"

#define TESTING_GESDD(...) template void testing_gesdd<__VA_ARGS__>(Arguments&);

INSTANTIATE(TESTING_GESDD, FOREACH_MATRIX_DATA_LAYOUT, FOREACH_SCALAR_TYPE, APPLY_STAMP)
914 changes: 914 additions & 0 deletions clients/common/lapack/testing_gesdd.hpp

Large diffs are not rendered by default.

249 changes: 249 additions & 0 deletions clients/common/misc/rocsolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4170,6 +4170,255 @@ inline rocblas_status rocsolver_gesvd(bool STRIDED,
}
/********************************************************/

/******************** GESDD ********************/
// normal and strided_batched
inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
float* A,
rocblas_int lda,
rocblas_stride stA,
float abstol,
float* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
float* S,
rocblas_stride stS,
float* U,
rocblas_int ldu,
rocblas_stride stU,
float* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return STRIDED ? rocsolver_sgesdd_strided_batched(handle, leftv, rightv, m, n, A, lda, stA,
// abstol, residual, max_sweeps, n_sweeps,
S, stS, U, ldu, stU, V, ldv, stV, info, bc)
: rocsolver_sgesdd(handle, leftv, rightv, m, n, A, lda,
// abstol, residual,
// max_sweeps, n_sweeps,
S, U, ldu, V, ldv, info);
}

inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
double* A,
rocblas_int lda,
rocblas_stride stA,
double abstol,
double* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
double* S,
rocblas_stride stS,
double* U,
rocblas_int ldu,
rocblas_stride stU,
double* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return STRIDED ? rocsolver_dgesdd_strided_batched(handle, leftv, rightv, m, n, A, lda, stA,
// abstol, residual, max_sweeps, n_sweeps,
S,
stS, U, ldu, stU, V, ldv, stV, info, bc)
: rocsolver_dgesdd(handle, leftv, rightv, m, n, A, lda, // abstol, residual,
/* max_sweeps, n_sweeps, */
S, U, ldu, V, ldv, info);
}

inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
rocblas_float_complex* A,
rocblas_int lda,
rocblas_stride stA,
float abstol,
float* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
float* S,
rocblas_stride stS,
rocblas_float_complex* U,
rocblas_int ldu,
rocblas_stride stU,
rocblas_float_complex* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return STRIDED ? rocsolver_cgesdd_strided_batched(handle, leftv, rightv, m, n, A, lda, stA,
/* abstol, residual, max_sweeps, n_sweeps,*/ S,
stS, U, ldu, stU, V, ldv, stV, info, bc)
: rocsolver_cgesdd(handle, leftv, rightv, m, n, A, lda, /*abstol, residual,
max_sweeps, n_sweeps,*/ S, U, ldu, V, ldv, info);
}

inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
rocblas_double_complex* A,
rocblas_int lda,
rocblas_stride stA,
double abstol,
double* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
double* S,
rocblas_stride stS,
rocblas_double_complex* U,
rocblas_int ldu,
rocblas_stride stU,
rocblas_double_complex* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return STRIDED ? rocsolver_zgesdd_strided_batched(handle, leftv, rightv, m, n, A, lda, stA,
/* abstol, residual, max_sweeps, n_sweeps,*/ S,
stS, U, ldu, stU, V, ldv, stV, info, bc)
: rocsolver_zgesdd(handle, leftv, rightv, m, n, A, lda, /* abstol, residual,
max_sweeps, n_sweeps,*/ S, U, ldu, V, ldv, info);
}

// batched
inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
float* const A[],
rocblas_int lda,
rocblas_stride stA,
float abstol,
float* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
float* S,
rocblas_stride stS,
float* U,
rocblas_int ldu,
rocblas_stride stU,
float* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return rocsolver_sgesdd_batched(handle, leftv, rightv, m, n, A, lda, /* abstol, residual,
max_sweeps, n_sweeps,*/ S, stS, U, ldu, stU, V, ldv, stV, info,
bc);
}

inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
double* const A[],
rocblas_int lda,
rocblas_stride stA,
double abstol,
double* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
double* S,
rocblas_stride stS,
double* U,
rocblas_int ldu,
rocblas_stride stU,
double* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return rocsolver_dgesdd_batched(handle, leftv, rightv, m, n, A, lda, /*abstol, residual,
max_sweeps, n_sweeps,*/ S, stS, U, ldu, stU, V, ldv, stV, info,
bc);
}

inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
rocblas_float_complex* const A[],
rocblas_int lda,
rocblas_stride stA,
float abstol,
float* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
float* S,
rocblas_stride stS,
rocblas_float_complex* U,
rocblas_int ldu,
rocblas_stride stU,
rocblas_float_complex* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return rocsolver_cgesdd_batched(handle, leftv, rightv, m, n, A, lda, /* abstol, residual,
max_sweeps, n_sweeps,*/ S, stS, U, ldu, stU, V, ldv, stV, info,
bc);
}

inline rocblas_status rocsolver_gesdd(bool STRIDED,
rocblas_handle handle,
rocblas_svect leftv,
rocblas_svect rightv,
rocblas_int m,
rocblas_int n,
rocblas_double_complex* const A[],
rocblas_int lda,
rocblas_stride stA,
double abstol,
double* residual,
rocblas_int max_sweeps,
rocblas_int* n_sweeps,
double* S,
rocblas_stride stS,
rocblas_double_complex* U,
rocblas_int ldu,
rocblas_stride stU,
rocblas_double_complex* V,
rocblas_int ldv,
rocblas_stride stV,
rocblas_int* info,
rocblas_int bc)
{
return rocsolver_zgesdd_batched(handle, leftv, rightv, m, n, A, lda, /* abstol, residual,
max_sweeps, n_sweeps,*/ S, stS, U, ldu, stU, V, ldv, stV, info,
bc);
}
/********************************************************/


/******************** GESVDJ ********************/
// normal and strided_batched
inline rocblas_status rocsolver_gesvdj(bool STRIDED,
Expand Down
5 changes: 5 additions & 0 deletions clients/common/misc/rocsolver_dispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#include "common/lapack/testing_gerq2_gerqf.hpp"
#include "common/lapack/testing_gesv.hpp"
#include "common/lapack/testing_gesvd.hpp"
#include "common/lapack/testing_gesdd.hpp"
#include "common/lapack/testing_gesvdj.hpp"
#include "common/lapack/testing_gesvdx.hpp"
#include "common/lapack/testing_getf2_getrf.hpp"
Expand Down Expand Up @@ -250,6 +251,10 @@ class rocsolver_dispatcher
{"gesvd", testing_gesvd<false, false, T>},
{"gesvd_batched", testing_gesvd<true, true, T>},
{"gesvd_strided_batched", testing_gesvd<false, true, T>},
// gesdd
{"gesdd", testing_gesdd<false, false, T>},
{"gesdd_batched", testing_gesdd<true, true, T>},
{"gesdd_strided_batched", testing_gesdd<false, true, T>},
// gesvdj
{"gesvdj", testing_gesvdj<false, false, T>},
{"gesvdj_batched", testing_gesvdj<true, true, T>},
Expand Down
1 change: 1 addition & 0 deletions clients/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ set(roclapack_test_source
lapack/sygsx_hegsx_gtest.cpp
# singular value decomposition
lapack/gesvd_gtest.cpp
lapack/gesdd_gtest.cpp
lapack/gesvdj_gtest.cpp
lapack/gesvdx_gtest.cpp
# symmetric eigensolvers
Expand Down
Loading