1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
|
/*! \file */
/* ************************************************************************
* Copyright (C) 2021-2022 Advanced Micro Devices, Inc. All rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* ************************************************************************ */
#include "rocsparse_arguments_config.hpp"
rocsparse_arguments_config::rocsparse_arguments_config()
{
//
// Arguments must be a C-compatible struct so cppcheck complains about non-initialized member variables.
// Then we need to initialize.
{
this->M = static_cast<rocsparse_int>(0);
this->N = static_cast<rocsparse_int>(0);
this->K = static_cast<rocsparse_int>(0);
this->nnz = static_cast<rocsparse_int>(0);
this->block_dim = static_cast<rocsparse_int>(0);
this->row_block_dimA = static_cast<rocsparse_int>(0);
this->col_block_dimA = static_cast<rocsparse_int>(0);
this->row_block_dimB = static_cast<rocsparse_int>(0);
this->col_block_dimB = static_cast<rocsparse_int>(0);
this->dimx = static_cast<rocsparse_int>(0);
this->dimy = static_cast<rocsparse_int>(0);
this->dimz = static_cast<rocsparse_int>(0);
this->ll = static_cast<rocsparse_int>(0);
this->l = static_cast<rocsparse_int>(0);
this->u = static_cast<rocsparse_int>(0);
this->uu = static_cast<rocsparse_int>(0);
this->index_type_I = static_cast<rocsparse_indextype>(0);
this->index_type_J = static_cast<rocsparse_indextype>(0);
this->compute_type = static_cast<rocsparse_datatype>(0);
this->alpha = static_cast<double>(0);
this->alphai = static_cast<double>(0);
this->beta = static_cast<double>(0);
this->betai = static_cast<double>(0);
this->threshold = static_cast<double>(0);
this->percentage = static_cast<double>(0);
this->transA = static_cast<rocsparse_operation>(0);
this->transB = static_cast<rocsparse_operation>(0);
this->baseA = static_cast<rocsparse_index_base>(0);
this->baseB = static_cast<rocsparse_index_base>(0);
this->baseC = static_cast<rocsparse_index_base>(0);
this->baseD = static_cast<rocsparse_index_base>(0);
this->action = static_cast<rocsparse_action>(0);
this->part = static_cast<rocsparse_hyb_partition>(0);
this->matrix_type = static_cast<rocsparse_matrix_type>(0);
this->diag = static_cast<rocsparse_diag_type>(0);
this->uplo = static_cast<rocsparse_fill_mode>(0);
this->storage = static_cast<rocsparse_storage_mode>(0);
this->apol = static_cast<rocsparse_analysis_policy>(0);
this->spol = static_cast<rocsparse_solve_policy>(0);
this->direction = static_cast<rocsparse_direction>(0);
this->order = static_cast<rocsparse_order>(0);
this->format = static_cast<rocsparse_format>(0);
this->sddmm_alg = rocsparse_sddmm_alg_default;
this->spmv_alg = rocsparse_spmv_alg_default;
this->spsv_alg = rocsparse_spsv_alg_default;
this->spsm_alg = rocsparse_spsm_alg_default;
this->spmm_alg = rocsparse_spmm_alg_default;
this->spgemm_alg = rocsparse_spgemm_alg_default;
this->sparse_to_dense_alg = rocsparse_sparse_to_dense_alg_default;
this->dense_to_sparse_alg = rocsparse_dense_to_sparse_alg_default;
this->gtsv_interleaved_alg = static_cast<rocsparse_gtsv_interleaved_alg>(0);
this->gpsv_interleaved_alg = static_cast<rocsparse_gpsv_interleaved_alg>(0);
this->matrix = static_cast<rocsparse_matrix_init>(0);
this->matrix_init_kind = static_cast<rocsparse_matrix_init_kind>(0);
this->unit_check = static_cast<rocsparse_int>(0);
this->timing = static_cast<rocsparse_int>(1);
this->iters = static_cast<rocsparse_int>(0);
this->denseld = static_cast<rocsparse_int>(0);
this->batch_count = static_cast<rocsparse_int>(0);
this->batch_count_A = static_cast<rocsparse_int>(0);
this->batch_count_B = static_cast<rocsparse_int>(0);
this->batch_count_C = static_cast<rocsparse_int>(0);
this->batch_stride = static_cast<rocsparse_int>(0);
this->algo = static_cast<uint32_t>(0);
this->numericboost = static_cast<int>(0);
this->boosttol = static_cast<double>(0);
this->boostval = static_cast<double>(0);
this->boostvali = static_cast<double>(0);
this->tolm = static_cast<double>(0);
this->filename[0] = '\0';
this->function[0] = '\0';
this->name[0] = '\0';
this->category[0] = '\0';
}
this->precision = 's';
this->indextype = 's';
}
void rocsparse_arguments_config::set_description(options_description& desc)
{
desc.add_options()("help,h", "produces this help message")
// clang-format off
("sizem,m",
value<rocsparse_int>(&this->M)->default_value(128),
"Specific matrix size testing: sizem is only applicable to SPARSE-2 "
"& SPARSE-3: the number of rows.")
("sizen,n",
value<rocsparse_int>(&this->N)->default_value(128),
"Specific matrix/vector size testing: SPARSE-1: the length of the "
"dense vector. SPARSE-2 & SPARSE-3: the number of columns")
("sizek,k",
value<rocsparse_int>(&this->K)->default_value(128),
"Specific matrix/vector size testing: SPARSE-3: the number of columns")
("sizennz,z",
value<rocsparse_int>(&this->nnz)->default_value(32),
"Specific vector size testing, LEVEL-1: the number of non-zero elements "
"of the sparse vector.")
("blockdim",
value<rocsparse_int>(&this->block_dim)->default_value(2),
"BSR block dimension (default: 2)")
("row-blockdimA",
value<rocsparse_int>(&this->row_block_dimA)->default_value(2),
"General BSR row block dimension (default: 2)")
("col-blockdimA",
value<rocsparse_int>(&this->col_block_dimA)->default_value(2),
"General BSR col block dimension (default: 2)")
("row-blockdimB",
value<rocsparse_int>(&this->row_block_dimB)->default_value(2),
"General BSR row block dimension (default: 2)")
("col-blockdimB",
value<rocsparse_int>(&this->col_block_dimB)->default_value(2),
"General BSR col block dimension (default: 2)")
("mtx",
value<std::string>(&this->b_matrixmarket)->default_value(""), "read from matrix "
"market (.mtx) format. This will override parameters -m, -n, and -z.")
("rocalution",
value<std::string>(&this->b_rocalution)->default_value(""),
"read from rocalution matrix binary file. This will override parameter --mtx")
("rocsparseio",
value<std::string>(&this->b_rocsparseio)->default_value(""),
"read from rocsparseio matrix binary file. This will override parameter --rocalution")
("file",
value<std::string>(&this->b_file)->default_value(""),
"read from file with file extension detection. This will override parameters --rocsparseio,rocalution,mtx")
("dimx",
value<rocsparse_int>(&this->dimx)->default_value(0), "assemble "
"laplacian matrix with dimensions <dimx dimy dimz>. dimz is optional. This "
"will override parameters -m, -n, -z and --mtx.")
("dimy",
value<rocsparse_int>(&this->dimy)->default_value(0), "assemble "
"laplacian matrix with dimensions <dimx dimy dimz>. dimz is optional. This "
"will override parameters -m, -n, -z and --mtx.")
("dimz",
value<rocsparse_int>(&this->dimz)->default_value(0), "assemble "
"laplacian matrix with dimensions <dimx dimy dimz>. dimz is optional. This "
"will override parameters -m, -n, -z and --mtx.")
("diag_ll",
value<rocsparse_int>(&this->ll)->default_value(0), "assemble "
"pentadiagonal matrix with stencil <ll l u, uu>.")
("diag_l",
value<rocsparse_int>(&this->l)->default_value(0), "assemble "
"tridiagonal matrix with stencil <l u> or pentadiagonal matrix with stencil <ll l u, uu>.")
("diag_u",
value<rocsparse_int>(&this->u)->default_value(0), "assemble "
"tridiagonal matrix with stencil <l u> or pentadiagonal matrix with stencil <ll l u, uu>.")
("diag_uu",
value<rocsparse_int>(&this->uu)->default_value(0), "assemble "
"pentadiagonal matrix with stencil <ll l u, uu>.")
("alpha",
value<double>(&this->alpha)->default_value(1.0), "specifies the scalar alpha")
("beta",
value<double>(&this->beta)->default_value(0.0), "specifies the scalar beta")
("threshold",
value<double>(&this->threshold)->default_value(1.0), "specifies the scalar threshold")
("percentage",
value<double>(&this->percentage)->default_value(0.0), "specifies the scalar percentage")
("transposeA",
value<char>(&this->b_transA)->default_value('N'),
"N = no transpose, T = transpose, C = conjugate transpose")
("transposeB",
value<char>(&this->b_transB)->default_value('N'),
"N = no transpose, T = transpose, C = conjugate transpose, (default = N)")
("indexbaseA",
value<int>(&this->b_baseA)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")
("indexbaseB",
value<int>(&this->b_baseB)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")
("indexbaseC",
value<int>(&this->b_baseC)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")
("indexbaseD",
value<int>(&this->b_baseD)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")
("action",
value<int>(&this->b_action)->default_value(0),
"0 = rocsparse_action_numeric, 1 = rocsparse_action_symbolic, (default: 0)")
("hybpart",
value<int>(&this->b_part)->default_value(0),
"0 = rocsparse_hyb_partition_auto, 1 = rocsparse_hyb_partition_user,\n"
"2 = rocsparse_hyb_partition_max, (default: 0)")
("matrix_type",
value<int>(&this->b_matrix_type)->default_value(0),
"0 = rocsparse_matrix_type_general, 1 = rocsparse_matrix_type_symmetric,\n"
"2 = rocsparse_matrix_type_hermitian, 3 = rocsparse_matrix_type_triangular, (default: 0)")
("diag",
value<char>(&this->b_diag)->default_value('N'),
"N = non-unit diagonal, U = unit diagonal, (default = N)")
("uplo",
value<char>(&this->b_uplo)->default_value('L'),
"L = lower fill, U = upper fill, (default = L)")
("storage",
value<int>(&this->b_storage)->default_value(0),
"0 = rocsparse_storage_mode_sorted, 1 = rocsparse_storage_mode_unsorted, (default = 0)")
("apolicy",
value<char>(&this->b_apol)->default_value('R'),
"R = reuse meta data, F = force re-build, (default = R)")
("function,f",
value<std::string>(&this->function_name)->default_value("axpyi"),
"SPARSE function to test. Options:\n"
" Level1: axpyi, doti, dotci, gthr, gthrz, roti, sctr\n"
" Level2: bsrmv, bsrxmv, bsrsv, coomv, coomv_aos, csrmv, csrmv_managed, csrsv, coosv, ellmv, hybmv, gebsrmv, gemvi\n"
" Level3: bsrmm, bsrsm, gebsrmm, csrmm, csrmm_batched, coomm, coomm_batched, cscmm, cscmm_batched, csrsm, coosm, gemmi, sddmm\n"
" Extra: csrgeam, csrgemm, csrgemm_reuse\n"
" Preconditioner: bsric0, bsrilu0, csric0, csrilu0, gtsv, gtsv_no_pivot, gtsv_no_pivot_strided_batch, gtsv_interleaved_batch, gpsv_interleaved_batch\n"
" Conversion: csr2coo, csr2csc, gebsr2gebsc, csr2ell, csr2hyb, csr2bsr, csr2gebsr\n"
" coo2csr, ell2csr, hyb2csr, dense2csr, dense2coo, prune_dense2csr, prune_dense2csr_by_percentage, dense2csc\n"
" csr2dense, csc2dense, coo2dense, bsr2csr, gebsr2csr, gebsr2gebsr, csr2csr_compress, prune_csr2csr, prune_csr2csr_by_percentage\n"
" sparse_to_dense_coo, sparse_to_dense_csr, sparse_to_dense_csc, dense_to_sparse_coo, dense_to_sparse_csr, dense_to_sparse_csc\n"
" Sorting: cscsort, csrsort, coosort\n"
" Misc: identity, nnz\n"
" Util: check_matrix_csr, check_matrix_csc, check_matrix_coo, check_matrix_gebsr, check_matrix_gebsc, check_matrix_ell, check_matrix_hyb")
("indextype",
value<char>(&this->indextype)->default_value('s'),
"Specify index types to be int32_t (s), int64_t (d) or mixed (m). Options: s,d,m")
("precision,r",
value<char>(&this->precision)->default_value('s'), "Options: s,d,c,z")
("verify,v",
value<rocsparse_int>(&this->unit_check)->default_value(0),
"Validate GPU results with CPU? 0 = No, 1 = Yes (default: No)")
("iters,i",
value<int>(&this->iters)->default_value(10),
"Iterations to run inside timing loop")
("device,d",
value<rocsparse_int>(&this->device_id)->default_value(0),
"Set default device to be used for subsequent program runs")
("direction",
value<rocsparse_int>(&this->b_dir)->default_value(rocsparse_direction_row),
"Indicates whether a dense matrix should be parsed by rows or by columns, assuming column-major storage: row = 0, column = 1 (default: 0)")
("order",
value<rocsparse_int>(&this->b_order)->default_value(rocsparse_order_column),
"Indicates whether a dense matrix is laid out in column-major storage: 1, or row-major storage 0 (default: 1)")
("format",
value<rocsparse_int>(&this->b_format)->default_value(rocsparse_format_coo),
"Indicates wther a sparse matrix is laid out in coo format: 0, coo_aos format: 1, csr format: 2, csc format: 3 or ell format: 4 (default:0)")
("denseld",
value<rocsparse_int>(&this->denseld)->default_value(128),
"Indicates the leading dimension of a dense matrix >= M, assuming a column-oriented storage.")
("batch_count",
value<rocsparse_int>(&this->batch_count)->default_value(128),
"Indicates the batch count for batched routines.")
("batch_count_A",
value<rocsparse_int>(&this->batch_count_A)->default_value(128),
"Indicates the batch count for the sparse A matrix in spmm batched routines.")
("batch_count_B",
value<rocsparse_int>(&this->batch_count_B)->default_value(128),
"Indicates the batch count for the dense B matrix in spmm batched routines.")
("batch_count_C",
value<rocsparse_int>(&this->batch_count_C)->default_value(128),
"Indicates the batch count for the dense C matrix in spmm batched routines.")
("batch_stride",
value<rocsparse_int>(&this->batch_stride)->default_value(128),
"Indicates the batch stride for batched routines.")
#ifdef ROCSPARSE_WITH_MEMSTAT
("memstat-report",
value<std::string>(&this->b_memory_report_filename)->default_value("rocsparse_bench_memstat.json"),
"output filename for memory report.")
#endif
("spmv_alg",
value<rocsparse_int>(&this->b_spmv_alg)->default_value(rocsparse_spmv_alg_default),
"Indicates what algorithm to use when running SpMV. Possibly choices are default: 0, COO: 1, CSR adaptive: 2, CSR stream: 3, ELL: 4, COO atomic: 5 (default:0)")
("spmm_alg",
value<rocsparse_int>(&this->b_spmm_alg)->default_value(rocsparse_spmm_alg_default),
"Indicates what algorithm to use when running SpMM. Possibly choices are default: 0, CSR: 1, COO segmented: 2, COO atomic: 3, CSR row split: 4, CSR merge: 5, COO segmented atomic: 6, BELL: 7 (default:0)")
("gtsv_interleaved_alg",
value<rocsparse_int>(&this->b_gtsv_interleaved_alg)->default_value(rocsparse_gtsv_interleaved_alg_default),
"Indicates what algorithm to use when running rocsparse_gtsv_interleaved_batch. Possibly choices are thomas: 1, lu: 2, qr: 3 (default:3)");
}
int rocsparse_arguments_config::parse(int&argc,char**&argv, options_description&desc)
{
variables_map vm;
store(parse_command_line(argc, argv, desc, sizeof(rocsparse_arguments_config)), vm);
notify(vm);
if(vm.count("help"))
{
std::cout << desc << std::endl;
return -2;
}
if(this->b_dir != rocsparse_direction_row && this->b_dir != rocsparse_direction_column)
{
std::cerr << "Invalid value for --direction" << std::endl;
return -1;
}
if(this->b_order != rocsparse_order_row && this->b_order != rocsparse_order_column)
{
std::cerr << "Invalid value for --order" << std::endl;
return -1;
}
if(this->b_format != rocsparse_format_csr && this->b_format != rocsparse_format_coo
&& this->b_format != rocsparse_format_coo_aos && this->b_format != rocsparse_format_ell
&& this->b_format != rocsparse_format_csc)
{
std::cerr << "Invalid value for --format" << std::endl;
return -1;
}
if(this->b_spmv_alg != rocsparse_spmv_alg_default
&& this->b_spmv_alg != rocsparse_spmv_alg_coo
&& this->b_spmv_alg != rocsparse_spmv_alg_csr_adaptive
&& this->b_spmv_alg != rocsparse_spmv_alg_csr_stream
&& this->b_spmv_alg != rocsparse_spmv_alg_ell
&& this->b_spmv_alg != rocsparse_spmv_alg_coo_atomic)
{
std::cerr << "Invalid value for --spmv_alg" << std::endl;
return -1;
}
if(this->b_spmm_alg != rocsparse_spmm_alg_default
&& this->b_spmm_alg != rocsparse_spmm_alg_csr
&& this->b_spmm_alg != rocsparse_spmm_alg_coo_segmented
&& this->b_spmm_alg != rocsparse_spmm_alg_coo_atomic
&& this->b_spmm_alg != rocsparse_spmm_alg_csr_row_split
&& this->b_spmm_alg != rocsparse_spmm_alg_csr_merge
&& this->b_spmm_alg != rocsparse_spmm_alg_coo_segmented_atomic
&& this->b_spmm_alg != rocsparse_spmm_alg_bell)
{
std::cerr << "Invalid value for --spmm_alg" << std::endl;
return -1;
}
if(this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_default
&& this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_thomas
&& this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_lu
&& this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_qr)
{
std::cerr << "Invalid value for --gtsv_interleaved_alg" << std::endl;
return -1;
}
if(this->b_transA == 'N')
{
this->transA = rocsparse_operation_none;
}
else if(this->b_transA == 'T')
{
this->transA = rocsparse_operation_transpose;
}
else if(this->b_transA == 'C')
{
this->transA = rocsparse_operation_conjugate_transpose;
}
if(this->b_transB == 'N')
{
this->transB = rocsparse_operation_none;
}
else if(this->b_transB == 'T')
{
this->transB = rocsparse_operation_transpose;
}
else if(this->b_transB == 'C')
{
this->transB = rocsparse_operation_conjugate_transpose;
}
sprintf(this->function,"%s",this->function_name.c_str());
this->baseA = (this->b_baseA == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->baseB = (this->b_baseB == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->baseC = (this->b_baseC == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->baseD = (this->b_baseD == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->action = (this->b_action == 0) ? rocsparse_action_numeric : rocsparse_action_symbolic;
this->part = (this->b_part == 0) ? rocsparse_hyb_partition_auto
: (this->b_part == 1) ? rocsparse_hyb_partition_user
: rocsparse_hyb_partition_max;
this->matrix_type = (this->b_matrix_type == 0) ? rocsparse_matrix_type_general
: (this->b_matrix_type == 1) ? rocsparse_matrix_type_symmetric
: (this->b_matrix_type == 2) ? rocsparse_matrix_type_hermitian
: rocsparse_matrix_type_triangular;
this->diag = (this->b_diag == 'N') ? rocsparse_diag_type_non_unit : rocsparse_diag_type_unit;
this->uplo = (this->b_uplo == 'L') ? rocsparse_fill_mode_lower : rocsparse_fill_mode_upper;
this->storage = (this->b_storage == 0) ? rocsparse_storage_mode_sorted : rocsparse_storage_mode_unsorted;
this->apol = (this->b_apol == 'R') ? rocsparse_analysis_policy_reuse : rocsparse_analysis_policy_force;
this->spol = rocsparse_solve_policy_auto;
this->direction
= (this->b_dir == rocsparse_direction_row) ? rocsparse_direction_row : rocsparse_direction_column;
this->order = (this->b_order == rocsparse_order_row) ? rocsparse_order_row : rocsparse_order_column;
this->format = (rocsparse_format)this->b_format;
this->spmv_alg = (rocsparse_spmv_alg)this->b_spmv_alg;
this->spmm_alg = (rocsparse_spmm_alg)this->b_spmm_alg;
this->gtsv_interleaved_alg = (rocsparse_gtsv_interleaved_alg)this->b_gtsv_interleaved_alg;
#ifdef ROCSPARSE_WITH_MEMSTAT
rocsparse_status status = rocsparse_memstat_report(this->b_memory_report_filename.c_str());
if (status != rocsparse_status_success)
{
std::cerr << "rocsparse_memstat_report failed " << std::endl;
return -1;
}
#endif
// rocALUTION parameter overrides filename parameter
if(this->b_file != "")
{
strcpy(this->filename, this->b_file.c_str());
}
else if(this->b_rocsparseio != "")
{
strcpy(this->filename, this->b_rocsparseio.c_str());
this->matrix = rocsparse_matrix_file_rocsparseio;
}
else if(this->b_rocalution != "")
{
strcpy(this->filename, this->b_rocalution.c_str());
this->matrix = rocsparse_matrix_file_rocalution;
}
else if(this->dimx != 0 && this->dimy != 0 && this->dimz != 0)
{
this->matrix = rocsparse_matrix_laplace_3d;
}
else if(this->dimx != 0 && this->dimy != 0)
{
this->matrix = rocsparse_matrix_laplace_2d;
}
else if(this->b_matrixmarket != "")
{
strcpy(this->filename, this->b_matrixmarket.c_str());
this->matrix = rocsparse_matrix_file_mtx;
}
else if(this->ll == 0 && this->l != 0 && this->u != 0 && this->uu == 0)
{
this->matrix = rocsparse_matrix_tridiagonal;
}
else if(this->ll != 0 && this->l != 0 && this->u != 0 && this->uu != 0)
{
this->matrix = rocsparse_matrix_pentadiagonal;
}
else
{
this->matrix = rocsparse_matrix_random;
}
this->matrix_init_kind = rocsparse_matrix_init_kind_default;
/* ============================================================================================
*/
if(this->M < 0 || this->N < 0)
{
std::cerr << "Invalid dimension" << std::endl;
return -1;
}
if(this->block_dim < 1)
{
std::cerr << "Invalid value for --blockdim" << std::endl;
return -1;
}
if(this->row_block_dimA < 1)
{
std::cerr << "Invalid value for --row-blockdimA" << std::endl;
return -1;
}
if(this->col_block_dimA < 1)
{
std::cerr << "Invalid value for --col-blockdimA" << std::endl;
return -1;
}
if(this->row_block_dimB < 1)
{
std::cerr << "Invalid value for --row-blockdimB" << std::endl;
return -1;
}
if(this->col_block_dimB < 1)
{
std::cerr << "Invalid value for --col-blockdimB" << std::endl;
return -1;
}
switch(this->indextype)
{
case 's':
{
this->index_type_I = rocsparse_indextype_i32;
this->index_type_J = rocsparse_indextype_i32;
break;
}
case 'd':
{
this->index_type_I = rocsparse_indextype_i64;
this->index_type_J = rocsparse_indextype_i64;
break;
}
case 'm':
{
this->index_type_I = rocsparse_indextype_i64;
this->index_type_J = rocsparse_indextype_i32;
break;
}
default:
{
std::cerr << "Invalid value for --indextype" << std::endl;
return -1;
}
}
switch(this->precision)
{
case 's':
{
this->compute_type = rocsparse_datatype_f32_r;
break;
}
case 'd':
{
this->compute_type = rocsparse_datatype_f64_r;
break;
}
case 'c':
{
this->compute_type = rocsparse_datatype_f32_c;
break;
}
case 'z':
{
this->compute_type = rocsparse_datatype_f64_c;
break;
}
default:
{
std::cerr << "Invalid value for --precision" << std::endl;
return -1;
}
}
return 0;
}
int rocsparse_arguments_config::parse_no_default(int&argc,char**&argv, options_description&desc)
{
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
notify(vm);
if(vm.count("help"))
{
std::cout << desc << std::endl;
return -2;
}
if(this->b_dir != rocsparse_direction_row && this->b_dir != rocsparse_direction_column)
{
std::cerr << "Invalid value for --direction" << std::endl;
return -1;
}
if(this->b_order != rocsparse_order_row && this->b_order != rocsparse_order_column)
{
std::cerr << "Invalid value for --order" << std::endl;
return -1;
}
if(this->b_format != rocsparse_format_csr && this->b_format != rocsparse_format_coo
&& this->b_format != rocsparse_format_coo_aos && this->b_format != rocsparse_format_ell
&& this->b_format != rocsparse_format_csc)
{
std::cerr << "Invalid value for --format" << std::endl;
return -1;
}
if(this->b_spmv_alg != rocsparse_spmv_alg_default
&& this->b_spmv_alg != rocsparse_spmv_alg_coo
&& this->b_spmv_alg != rocsparse_spmv_alg_csr_adaptive
&& this->b_spmv_alg != rocsparse_spmv_alg_csr_stream
&& this->b_spmv_alg != rocsparse_spmv_alg_ell
&& this->b_spmv_alg != rocsparse_spmv_alg_coo_atomic)
{
std::cerr << "Invalid value for --spmv_alg" << std::endl;
return -1;
}
if(this->b_spmm_alg != rocsparse_spmm_alg_default
&& this->b_spmm_alg != rocsparse_spmm_alg_csr
&& this->b_spmm_alg != rocsparse_spmm_alg_coo_segmented
&& this->b_spmm_alg != rocsparse_spmm_alg_coo_atomic
&& this->b_spmm_alg != rocsparse_spmm_alg_csr_row_split
&& this->b_spmm_alg != rocsparse_spmm_alg_csr_merge
&& this->b_spmm_alg != rocsparse_spmm_alg_coo_segmented_atomic
&& this->b_spmm_alg != rocsparse_spmm_alg_bell)
{
std::cerr << "Invalid value for --spmm_alg" << std::endl;
return -1;
}
if(this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_default
&& this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_thomas
&& this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_lu
&& this->b_gtsv_interleaved_alg != rocsparse_gtsv_interleaved_alg_qr)
{
std::cerr << "Invalid value for --gtsv_interleaved_alg" << std::endl;
return -1;
}
if(b_transA == 'N')
{
this->transA = rocsparse_operation_none;
}
else if(b_transA == 'T')
{
this->transA = rocsparse_operation_transpose;
}
else if(b_transA == 'C')
{
this->transA = rocsparse_operation_conjugate_transpose;
}
if(b_transB == 'N')
{
this->transB = rocsparse_operation_none;
}
else if(b_transB == 'T')
{
this->transB = rocsparse_operation_transpose;
}
else if(b_transB == 'C')
{
this->transB = rocsparse_operation_conjugate_transpose;
}
sprintf(this->function,"%s",this->function_name.c_str());
this->baseA = (b_baseA == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->baseB = (b_baseB == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->baseC = (b_baseC == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->baseD = (b_baseD == 0) ? rocsparse_index_base_zero : rocsparse_index_base_one;
this->action = (b_action == 0) ? rocsparse_action_numeric : rocsparse_action_symbolic;
this->part = (b_part == 0) ? rocsparse_hyb_partition_auto
: (b_part == 1) ? rocsparse_hyb_partition_user
: rocsparse_hyb_partition_max;
this->diag = (b_diag == 'N') ? rocsparse_diag_type_non_unit : rocsparse_diag_type_unit;
this->uplo = (b_uplo == 'L') ? rocsparse_fill_mode_lower : rocsparse_fill_mode_upper;
this->storage= (b_storage == 0) ? rocsparse_storage_mode_sorted : rocsparse_storage_mode_unsorted;
this->apol = (b_apol == 'R') ? rocsparse_analysis_policy_reuse : rocsparse_analysis_policy_force;
this->spol = rocsparse_solve_policy_auto;
this->direction
= (b_dir == rocsparse_direction_row) ? rocsparse_direction_row : rocsparse_direction_column;
this->order = (b_order == rocsparse_order_row) ? rocsparse_order_row : rocsparse_order_column;
this->format = (rocsparse_format)b_format;
this->spmv_alg = (rocsparse_spmv_alg)this->b_spmv_alg;
this->spmm_alg = (rocsparse_spmm_alg)this->b_spmm_alg;
this->gtsv_interleaved_alg = (rocsparse_gtsv_interleaved_alg)this->b_gtsv_interleaved_alg;
// rocALUTION parameter overrides filename parameter
if(b_file != "")
{
strcpy(this->filename, b_file.c_str());
const char * p = b_file.c_str();
const char * q = nullptr;
while(*p!='\0') { if (*p=='.') q = p; ++p;}
if (q!=nullptr)
{
std::cerr << "extension is not detected in filename '"<< b_file <<"' " << std::endl;
return -1;
}
if (!strcmp(q,".mtx"))
{
this->matrix = rocsparse_matrix_file_mtx;
}
else if (!strcmp(q,".bin"))
{
this->matrix = rocsparse_matrix_file_rocsparseio;
}
else if (!strcmp(q,".csr"))
{
this->matrix = rocsparse_matrix_file_rocalution;
}
}
else if(b_rocsparseio != "")
{
strcpy(this->filename, b_rocsparseio.c_str());
this->matrix = rocsparse_matrix_file_rocsparseio;
}
else if(b_rocalution != "")
{
strcpy(this->filename, b_rocalution.c_str());
this->matrix = rocsparse_matrix_file_rocalution;
}
else if(this->dimx != 0 && this->dimy != 0 && this->dimz != 0)
{
this->matrix = rocsparse_matrix_laplace_3d;
}
else if(this->dimx != 0 && this->dimy != 0)
{
this->matrix = rocsparse_matrix_laplace_2d;
}
else if(b_matrixmarket != "")
{
strcpy(this->filename, b_matrixmarket.c_str());
this->matrix = rocsparse_matrix_file_mtx;
}
else
{
this->matrix = rocsparse_matrix_random;
}
this->matrix_init_kind = rocsparse_matrix_init_kind_default;
/* ============================================================================================
*/
if(this->M < 0 || this->N < 0)
{
std::cerr << "Invalid dimension" << std::endl;
return -1;
}
if(this->block_dim < 1)
{
std::cerr << "Invalid value for --blockdim" << std::endl;
return -1;
}
if(this->row_block_dimA < 1)
{
std::cerr << "Invalid value for --row-blockdimA" << std::endl;
return -1;
}
if(this->col_block_dimA < 1)
{
std::cerr << "Invalid value for --col-blockdimA" << std::endl;
return -1;
}
if(this->row_block_dimB < 1)
{
std::cerr << "Invalid value for --row-blockdimB" << std::endl;
return -1;
}
if(this->col_block_dimB < 1)
{
std::cerr << "Invalid value for --col-blockdimB" << std::endl;
return -1;
}
switch(this->indextype)
{
case 's':
{
this->index_type_I = rocsparse_indextype_i32;
this->index_type_J = rocsparse_indextype_i32;
break;
}
case 'd':
{
this->index_type_I = rocsparse_indextype_i64;
this->index_type_J = rocsparse_indextype_i64;
break;
}
case 'm':
{
this->index_type_I = rocsparse_indextype_i64;
this->index_type_J = rocsparse_indextype_i32;
break;
}
default:
{
std::cerr << "Invalid value for --indextype" << std::endl;
return -1;
}
}
switch(this->precision)
{
case 's':
{
this->compute_type = rocsparse_datatype_f32_r;
break;
}
case 'd':
{
this->compute_type = rocsparse_datatype_f64_r;
break;
}
case 'c':
{
this->compute_type = rocsparse_datatype_f32_c;
break;
}
case 'z':
{
this->compute_type = rocsparse_datatype_f64_c;
break;
}
default:
{
std::cerr << "Invalid value for --precision" << std::endl;
return -1;
}
}
return 0;
}
|