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

ScaLAPACK API singletons #209

Merged
merged 2 commits into from
Jan 11, 2025
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
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ TEST_LDFLAGS = ${LDFLAGS} -L./lib -Wl,-rpath,${abspath ./lib}
TEST_LDFLAGS += -L./testsweeper -Wl,-rpath,${abspath ./testsweeper}
TEST_LDFLAGS += -Wl,-rpath,${abspath ./blaspp/lib}
TEST_LDFLAGS += -Wl,-rpath,${abspath ./lapackpp/lib}
TEST_LIBS = -lslate -lslate_matgen -ltestsweeper ${LIBS}
TEST_LIBS += -lslate -lslate_matgen -ltestsweeper ${LIBS}
ifneq (${SCALAPACK_LIBRARIES},none)
TEST_LIBS += ${SCALAPACK_LIBRARIES}
CXXFLAGS += -DSLATE_HAVE_SCALAPACK
Expand Down
10 changes: 5 additions & 5 deletions include/slate/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ public:
/// @see bool gpu_aware_mpi()
static bool value()
{
return get().gpu_aware_mpi_;
return instance().gpu_aware_mpi_;
}

/// @see void gpu_aware_mpi( bool )
static void value( bool val )
{
get().gpu_aware_mpi_ = val;
instance().gpu_aware_mpi_ = val;
}

private:
/// @return GPU_Aware_MPI singleton.
/// Uses thread-safe Scott Meyers' singleton to query on first call only.
static GPU_Aware_MPI& get()
static GPU_Aware_MPI& instance()
{
static GPU_Aware_MPI singleton;
return singleton;
static GPU_Aware_MPI instance_;
return instance_;
}

/// Constructor checks $SLATE_GPU_AWARE_MPI.
Expand Down
3 changes: 2 additions & 1 deletion scalapack_api/README_scalapack_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ ENVIRONMENT VARIABLES
---------------------

The library libslate_scalapack_api.so uses some environment variables
to make decisions that are not available in a the ScaLAPACK
to make decisions that are not available in the ScaLAPACK
parameters.

* SLATE_SCALAPACK_TARGET HostTask (default), Devices, HostNest, HostBatch (case indifferent)
* SLATE_SCALAPACK_VERBOSE 0,1 (0: no output, 1: print some minor output)
* SLATE_SCALAPACK_PANELTHREADS integer (number of threads to serve the panel, default (maximum omp threads)/2 )
* SLATE_SCALAPACK_IB integer (inner blocking size useful for some routines, default 16)
* SLATE_SCALAPACK_LOOKAHEAD integer (lookahead number of panels, default 1)

Example on a properly configured SLATE install on a machine with GPUs.

Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_gecon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ void slate_pgecon(const char* normstr, int n, scalar_t* a, int ia, int ja, int*
Norm norm{};
from_string( std::string( 1, normstr[0] ), &norm );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t ib = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t ib = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// todo: extract the real info from getrf
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_gels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ void slate_pgels(const char* transstr, int m, int n, int nrhs, scalar_t* a, int
Op trans{};
from_string( std::string( 1, transstr[0] ), &trans );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t inner_blocking = slate_scalapack_set_ib();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t inner_blocking = IBConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// A is m-by-n, BX is max(m, n)-by-nrhs.
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_gemm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ void slate_pgemm(const char* transastr, const char* transbstr, int m, int n, int
from_string( std::string( 1, transastr[0] ), &transA );
from_string( std::string( 1, transbstr[0] ), &transB );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// sizes of A and B
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_gesv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ extern "C" void pzgesv_(int* n, int* nrhs, std::complex<double>* a, int* ia, int
template< typename scalar_t >
void slate_pgesv(int n, int nrhs, scalar_t* a, int ia, int ja, int* desca, int* ipiv, scalar_t* b, int ib, int jb, int* descb, int* info)
{
static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t inner_blocking = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t inner_blocking = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_gesv_mixed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ void slate_pgesv_mixed(int n, int nrhs, scalar_t* a, int ia, int ja, int* desca,
{
using real_t = blas::real_type<scalar_t>;

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t inner_blocking = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t inner_blocking = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_gesvd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ void slate_pgesvd(const char* jobustr, const char* jobvtstr, int m, int n, scala
from_string( std::string( 1, jobustr[0] ), &jobu );
from_string( std::string( 1, jobvtstr[0] ), &jobvt );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t ib = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t ib = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// todo: extract the real info from gesvd
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_getrf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ extern "C" void pzgetrf_(int* m, int* n, std::complex<double>* a, int* ia, int*
template< typename scalar_t >
void slate_pgetrf(int m, int n, scalar_t* a, int ia, int ja, int* desca, int* ipiv, int* info)
{
static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t ib = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t ib = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_getri.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ extern "C" void pzgetri_(int* n, std::complex<double>* a, int* ia, int* ja, int*
template< typename scalar_t >
void slate_pgetri(int n, scalar_t* a, int ia, int ja, int* desca, int* ipiv, scalar_t* work, int lwork, int* iwork, int liwork, int* info)
{
static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t ib = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t ib = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

slate::Options const opts = {
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_getrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ extern "C" void pzgetrs_(const char* trans, int* n, int* nrhs, std::complex<doub
template< typename scalar_t >
void slate_pgetrs(const char* transstr, int n, int nrhs, scalar_t* a, int ia, int ja, int* desca, int* ipiv, scalar_t* b, int ib, int jb, int* descb, int* info)
{
static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

slate::Options const opts = {
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_heev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ void slate_pheev(const char* jobzstr, const char* uplostr, int n, scalar_t* a, i
from_string( std::string( 1, uplostr[0] ), &uplo );
from_string( std::string( 1, jobzstr[0] ), &jobz );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t ib = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t ib = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// todo: extract the real info from heev
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_heevd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ void slate_pheevd(const char* jobzstr, const char* uplostr, int n, scalar_t* a,
from_string( std::string( 1, uplostr[0] ), &uplo );
from_string( std::string( 1, jobzstr[0] ), &jobz );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t ib = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t ib = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// todo: extract the real info from heevd
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_hemm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ void slate_phemm(const char* sidestr, const char* uplostr, int m, int n, scalar_
from_string( std::string( 1, sidestr[0] ), &side );
from_string( std::string( 1, uplostr[0] ), &uplo );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

int64_t An = (side == blas::Side::Left ? m : n);
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_her2k.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ void slate_pher2k(const char* uplostr, const char* transstr, int n, int k, scala
from_string( std::string( 1, uplostr[0] ), &uplo );
from_string( std::string( 1, transstr[0] ), &trans );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// setup so op(A) and op(B) are n-by-k
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_herk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ void slate_pherk(const char* uplostr, const char* transstr, int n, int k, blas::
from_string( std::string( 1, uplostr[0] ), &uplo );
from_string( std::string( 1, transstr[0] ), &transA );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// setup so op(A) is n-by-k
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_lange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ blas::real_type<scalar_t> slate_plange(const char* normstr, int m, int n, scalar
Norm norm{};
from_string( std::string( 1, normstr[0] ), &norm );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_lanhe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ blas::real_type<scalar_t> slate_planhe(const char* normstr, const char* uplostr,
from_string( std::string( 1, uplostr[0] ), &uplo );
from_string( std::string( 1, normstr[0] ), &norm );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_lansy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ blas::real_type<scalar_t> slate_plansy(const char* normstr, const char* uplostr,
from_string( std::string( 1, uplostr[0] ), &uplo );
from_string( std::string( 1, normstr[0] ), &norm );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_lantr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ blas::real_type<scalar_t> slate_plantr(const char* normstr, const char* uplostr,
from_string( std::string( 1, uplostr[0] ), &uplo );
from_string( std::string( 1, diagstr[0] ), &diag );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
10 changes: 5 additions & 5 deletions scalapack_api/scalapack_pocon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ void slate_ppocon(const char* uplostr, int n, scalar_t* a, int ia, int ja, int*
Uplo uplo{};
from_string( std::string( 1, uplostr[0] ), &uplo );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
static int64_t panel_threads = slate_scalapack_set_panelthreads();
static int64_t ib = slate_scalapack_set_ib();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
int64_t panel_threads = PanelThreadsConfig::value();
int64_t ib = IBConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// todo: extract the real info from getrf
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_posv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void slate_pposv(const char* uplostr, int n, int nrhs, scalar_t* a, int ia, int
Uplo uplo{};
from_string( std::string( 1, uplostr[0] ), &uplo );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_potrf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void slate_ppotrf(const char* uplostr, int n, scalar_t* a, int ia, int ja, int*
Uplo uplo{};
from_string( std::string( 1, uplostr[0] ), &uplo );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_potri.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void slate_ppotri(const char* uplostr, int n, scalar_t* a, int ia, int ja, int*
Uplo uplo{};
from_string( std::string( 1, uplostr[0] ), &uplo );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// Matrix sizes
Expand Down
6 changes: 3 additions & 3 deletions scalapack_api/scalapack_potrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void slate_ppotrs(const char* uplostr, int n, int nrhs, scalar_t* a, int ia, int
Uplo uplo{};
from_string( std::string( 1, uplostr[0] ), &uplo );

static slate::Target target = slate_scalapack_set_target();
static int verbose = slate_scalapack_set_verbose();
static int64_t lookahead = slate_scalapack_set_lookahead();
slate::Target target = TargetConfig::value();
int verbose = VerboseConfig::value();
int64_t lookahead = LookaheadConfig::value();
slate::GridOrder grid_order = slate_scalapack_blacs_grid_order();

// create SLATE matrices from the ScaLAPACK layouts
Expand Down
Loading