|
Amesos2 - Direct Sparse Solver Interfaces
Version of the Day
|
00001 // @HEADER 00002 // 00003 // *********************************************************************** 00004 // 00005 // Amesos2: Templated Direct Sparse Solver Package 00006 // Copyright 2011 Sandia Corporation 00007 // 00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 // the U.S. Government retains certain rights in this software. 00010 // 00011 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00039 // 00040 // *********************************************************************** 00041 // 00042 // @HEADER 00043 00053 #ifndef AMESOS2_SUPERLUMT_FUNCTIONMAP_HPP 00054 #define AMESOS2_SUPERLUMT_FUNCTIONMAP_HPP 00055 00056 #ifdef HAVE_TEUCHOS_COMPLEX 00057 #include <complex> 00058 #endif 00059 00060 #include "Amesos2_FunctionMap.hpp" 00061 #include "Amesos2_MatrixAdapter.hpp" 00062 #include "Amesos2_Superlumt_TypeMap.hpp" 00063 00064 00065 // External definitions of the SuperLU_MT functions 00066 namespace SLUMT { 00067 extern "C" { 00068 00069 typedef int int_t; 00070 00071 #include "slu_mt_util.h" 00072 #include "pxgstrf_synch.h" // preemptive inclusion 00073 00074 namespace S { 00075 #include "pssp_defs.h" // single-precision real definitions 00076 } 00077 00078 namespace D { 00079 #include "pdsp_defs.h" // double-precision real definitions 00080 } 00081 00082 #ifdef HAVE_TEUCHOS_COMPLEX 00083 namespace C { 00084 #include "pcsp_defs.h" // single-precision complex definitions 00085 } 00086 00087 namespace Z { 00088 #include "pzsp_defs.h" // double-precision complex definitions 00089 } 00090 #endif // HAVE_TEUCHOS_COMPLEX 00091 00092 } // end extern "C" 00093 00094 } // end namespace SLUMT 00095 00096 namespace Amesos2 { 00097 00098 template <class Matrix, class Vector> class Superlumt; 00099 00100 /* ==================== Specializations ==================== 00101 * 00102 * \cond SuperLU_MT_function_specializations 00103 */ 00104 00105 /* 00106 * Note that we don't need any generic declarations of the 00107 * SuperLU_MT functions that throw error in case the scalar type is 00108 * not supported. This check is already performed in the factory 00109 * create method. Just go straight for the specializations. 00110 */ 00111 00134 template <> 00135 struct FunctionMap<Superlumt,float> 00136 { 00137 typedef TypeMap<Superlumt,float> type_map; 00138 00142 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00143 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, float* R, float* C, 00144 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork, 00145 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, float* recip_pivot_growth, 00146 float* rcond, float* ferr, float* berr, SLUMT::superlu_memusage_t* mem_usage, 00147 SLUMT::Gstat_t* stat, int* info) 00148 { 00149 options->etree = etree; 00150 options->perm_c = perm_c; 00151 options->perm_r = perm_r; 00152 00153 options->work = work; 00154 options->lwork = lwork; 00155 00156 SLUMT::S::psgssvx(options->nprocs, options, A, perm_c, perm_r, 00157 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr, 00158 berr, mem_usage, info); 00159 } 00160 00164 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L, 00165 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c, 00166 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info) 00167 { 00168 SLUMT::S::sgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info); 00169 } 00170 00188 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00189 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, 00190 SLUMT::Gstat_t* stat, int* info) 00191 { 00192 SLUMT::S::psgstrf(options, A, perm_r, L, U, stat, info); 00193 } 00194 00208 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz, 00209 type_map::type* nzval, int* rowind, int* colptr, 00210 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00211 { 00212 SLUMT::S::sCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr, 00213 stype, dtype, mtype); 00214 } 00215 00227 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n, 00228 type_map::type* x, int ldx, SLUMT::Stype_t stype, 00229 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00230 { 00231 SLUMT::S::sCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype); 00232 } 00233 00240 static void gsequ(SLUMT::SuperMatrix* A, 00241 type_map::magnitude_type* r, 00242 type_map::magnitude_type* c, 00243 type_map::magnitude_type* rowcnd, 00244 type_map::magnitude_type* colcnd, 00245 type_map::magnitude_type* amax, 00246 int* info) 00247 { 00248 SLUMT::S::sgsequ(A, r, c, rowcnd, colcnd, amax, info); 00249 } 00250 00259 static void laqgs(SLUMT::SuperMatrix* A, 00260 type_map::magnitude_type* r, 00261 type_map::magnitude_type* c, 00262 type_map::magnitude_type rowcnd, 00263 type_map::magnitude_type colcnd, 00264 type_map::magnitude_type amax, 00265 SLUMT::equed_t* equed) 00266 { 00267 SLUMT::S::slaqgs(A, r, c, rowcnd, colcnd, amax, equed); 00268 } 00269 }; 00270 00271 00272 template <> 00273 struct FunctionMap<Superlumt,double> 00274 { 00275 typedef TypeMap<Superlumt,double> type_map; 00276 00277 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00278 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, double* R, double* C, 00279 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork, 00280 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, double* recip_pivot_growth, 00281 double* rcond, double* ferr, double* berr, SLUMT::superlu_memusage_t* mem_usage, 00282 SLUMT::Gstat_t* stat, int* info) 00283 { 00284 options->etree = etree; 00285 options->perm_c = perm_c; 00286 options->perm_r = perm_r; 00287 00288 options->work = work; 00289 options->lwork = lwork; 00290 00291 SLUMT::D::pdgssvx(options->nprocs, options, A, perm_c, perm_r, 00292 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr, 00293 berr, mem_usage, info); 00294 } 00295 00296 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L, 00297 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c, 00298 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info) 00299 { 00300 SLUMT::D::dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info); 00301 } 00302 00303 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00304 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, 00305 SLUMT::Gstat_t* stat, int* info) 00306 { 00307 SLUMT::D::pdgstrf(options, A, perm_r, L, U, stat, info); 00308 } 00309 00310 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz, 00311 type_map::type* nzval, int* rowind, int* colptr, 00312 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00313 { 00314 SLUMT::D::dCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr, 00315 stype, dtype, mtype); 00316 } 00317 00318 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n, 00319 type_map::type* x, int ldx, SLUMT::Stype_t stype, 00320 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00321 { 00322 SLUMT::D::dCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype); 00323 } 00324 00325 static void gsequ(SLUMT::SuperMatrix* A, 00326 type_map::magnitude_type* r, 00327 type_map::magnitude_type* c, 00328 type_map::magnitude_type* rowcnd, 00329 type_map::magnitude_type* colcnd, 00330 type_map::magnitude_type* amax, 00331 int* info) 00332 { 00333 SLUMT::D::dgsequ(A, r, c, rowcnd, colcnd, amax, info); 00334 } 00335 00336 static void laqgs(SLUMT::SuperMatrix* A, 00337 type_map::magnitude_type* r, 00338 type_map::magnitude_type* c, 00339 type_map::magnitude_type rowcnd, 00340 type_map::magnitude_type colcnd, 00341 type_map::magnitude_type amax, 00342 SLUMT::equed_t* equed) 00343 { 00344 SLUMT::D::dlaqgs(A, r, c, rowcnd, colcnd, amax, equed); 00345 } 00346 }; 00347 00348 00349 #ifdef HAVE_TEUCHOS_COMPLEX 00350 /* The specializations for Teuchos::as<> for SLUMT::complex and 00351 * SLUMT::doublecomplex are provided in Amesos2_Superlumt_TypeMap.hpp 00352 */ 00353 template <> 00354 struct FunctionMap<Superlumt,SLUMT::C::complex> 00355 { 00356 typedef TypeMap<Superlumt,SLUMT::C::complex> type_map; 00357 00358 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00359 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, float* R, float* C, 00360 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork, 00361 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, float* recip_pivot_growth, 00362 float* rcond, float* ferr, float* berr, SLUMT::superlu_memusage_t* mem_usage, 00363 SLUMT::Gstat_t* stat, int* info) 00364 { 00365 options->etree = etree; 00366 options->perm_c = perm_c; 00367 options->perm_r = perm_r; 00368 00369 options->work = work; 00370 options->lwork = lwork; 00371 00372 SLUMT::C::pcgssvx(options->nprocs, options, A, perm_c, perm_r, 00373 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr, 00374 berr, mem_usage, info); 00375 } 00376 00377 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L, 00378 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c, 00379 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info) 00380 { 00381 SLUMT::C::cgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info); 00382 } 00383 00384 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00385 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, 00386 SLUMT::Gstat_t* stat, int* info) 00387 { 00388 SLUMT::C::pcgstrf(options, A, perm_r, L, U, stat, info); 00389 } 00390 00391 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz, 00392 type_map::type* nzval, int* rowind, int* colptr, 00393 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00394 { 00395 SLUMT::C::cCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr, 00396 stype, dtype, mtype); 00397 } 00398 00399 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n, 00400 type_map::type* x, int ldx, SLUMT::Stype_t stype, 00401 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00402 { 00403 SLUMT::C::cCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype); 00404 } 00405 00406 static void gsequ(SLUMT::SuperMatrix* A, float* r, float* c, 00407 float* rowcnd, float* colcnd, float* amax, int* info) 00408 { 00409 SLUMT::C::cgsequ(A, r, c, rowcnd, colcnd, amax, info); 00410 } 00411 00412 static void laqgs(SLUMT::SuperMatrix* A, float* r, float* c, float rowcnd, 00413 float colcnd, float amax, SLUMT::equed_t* equed) 00414 { 00415 SLUMT::C::claqgs(A, r, c, rowcnd, colcnd, amax, equed); 00416 } 00417 }; 00418 00419 00420 template <> 00421 struct FunctionMap<Superlumt,SLUMT::Z::doublecomplex> 00422 { 00423 typedef TypeMap<Superlumt,SLUMT::Z::doublecomplex> type_map; 00424 00425 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00426 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, double* R, double* C, 00427 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork, 00428 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, double* recip_pivot_growth, 00429 double* rcond, double* ferr, double* berr, SLUMT::superlu_memusage_t* mem_usage, 00430 SLUMT::Gstat_t* stat, int* info) 00431 { 00432 options->etree = etree; 00433 options->perm_c = perm_c; 00434 options->perm_r = perm_r; 00435 00436 options->work = work; 00437 options->lwork = lwork; 00438 00439 SLUMT::Z::pzgssvx(options->nprocs, options, A, perm_c, perm_r, 00440 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr, 00441 berr, mem_usage, info); 00442 } 00443 00444 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L, 00445 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c, 00446 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info) 00447 { 00448 SLUMT::Z::zgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info); 00449 } 00450 00451 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A, 00452 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, 00453 SLUMT::Gstat_t* stat, int* info) 00454 { 00455 SLUMT::Z::pzgstrf(options, A, perm_r, L, U, stat, info); 00456 } 00457 00458 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz, 00459 type_map::type* nzval, int* rowind, int* colptr, 00460 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00461 { 00462 SLUMT::Z::zCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr, 00463 stype, dtype, mtype); 00464 } 00465 00466 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n, 00467 type_map::type* x, int ldx, SLUMT::Stype_t stype, 00468 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype) 00469 { 00470 SLUMT::Z::zCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype); 00471 } 00472 00473 static void gsequ(SLUMT::SuperMatrix* A, double* r, double* c, 00474 double* rowcnd, double* colcnd, double* amax, int* info) 00475 { 00476 SLUMT::Z::zgsequ(A, r, c, rowcnd, colcnd, amax, info); 00477 } 00478 00479 static void laqgs(SLUMT::SuperMatrix* A, double* r, double* c, double rowcnd, 00480 double colcnd, double amax, SLUMT::equed_t* equed) 00481 { 00482 SLUMT::Z::zlaqgs(A, r, c, rowcnd, colcnd, amax, equed); 00483 } 00484 }; 00485 #endif // HAVE_TEUCHOS_COMPLEX 00486 00487 /* \endcond SuperLU_MT_function_specializations */ 00488 00489 } // end namespace Amesos2 00490 00491 00492 #endif // AMESOS2_SUPERLUMT_FUNCTIONMAP_HPP
1.7.6.1