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 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
|
/*! \file */
/* ************************************************************************
* Copyright (C) 2020-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.
*
* ************************************************************************ */
#pragma once
#ifndef ROCSPARSE_HOST_HPP
#define ROCSPARSE_HOST_HPP
#include "rocsparse_test.hpp"
#include <hip/hip_runtime_api.h>
#include <limits>
#ifdef _OPENMP
#include <omp.h>
#endif
template <typename T, typename I, typename J>
struct rocsparse_host
{
static void csrddmm(rocsparse_operation trans_A,
rocsparse_operation trans_B,
rocsparse_order order_A,
rocsparse_order order_B,
J M,
J N,
J K,
I nnz,
const T* alpha,
const T* A,
J lda,
const T* B,
J ldb,
const T* beta,
const I* csr_row_ptr_C,
const J* csr_col_ind_C,
T* csr_val_C,
rocsparse_index_base base_C);
static void cscddmm(rocsparse_operation trans_A,
rocsparse_operation trans_B,
rocsparse_order order_A,
rocsparse_order order_B,
J M,
J N,
J K,
I nnz,
const T* alpha,
const T* A,
J lda,
const T* B,
J ldb,
const T* beta,
const I* csr_row_ptr_C,
const J* csr_col_ind_C,
T* csr_val_C,
rocsparse_index_base base_C);
static void cooddmm(rocsparse_operation trans_A,
rocsparse_operation trans_B,
rocsparse_order order_A,
rocsparse_order order_B,
J M,
J N,
J K,
I nnz,
const T* alpha,
const T* A,
J lda,
const T* B,
J ldb,
const T* beta,
const I* coo_row_ind_C,
const I* coo_col_ind_C,
T* coo_val_C,
rocsparse_index_base base_C);
static void cooaosddmm(rocsparse_operation trans_A,
rocsparse_operation trans_B,
rocsparse_order order_A,
rocsparse_order order_B,
J M,
J N,
J K,
I nnz,
const T* alpha,
const T* A,
J lda,
const T* B,
J ldb,
const T* beta,
const I* coo_row_ind_C,
const I* coo_col_ind_C,
T* coo_val_C,
rocsparse_index_base base_C);
static void ellddmm(rocsparse_operation trans_A,
rocsparse_operation trans_B,
rocsparse_order order_A,
rocsparse_order order_B,
J M,
J N,
J K,
I nnz,
const T* alpha,
const T* A,
J lda,
const T* B,
J ldb,
const T* beta,
const J ell_width,
const I* ell_ind_C,
T* ell_val_C,
rocsparse_index_base base_C);
};
// BSR indexing macros
#define BSR_IND(j, bi, bj, dir) \
((dir == rocsparse_direction_row) ? BSR_IND_R(j, bi, bj) : BSR_IND_C(j, bi, bj))
#define BSR_IND_R(j, bi, bj) (bsr_dim * bsr_dim * (j) + (bi)*bsr_dim + (bj))
#define BSR_IND_C(j, bi, bj) (bsr_dim * bsr_dim * (j) + (bi) + (bj)*bsr_dim)
/*
* ===========================================================================
* level 1 SPARSE
* ===========================================================================
*/
template <typename I, typename T>
void host_axpby(I size,
I nnz,
T alpha,
const T* x_val,
const I* x_ind,
T beta,
T* y,
rocsparse_index_base base);
template <typename I, typename T>
void host_doti(
I nnz, const T* x_val, const I* x_ind, const T* y, T* result, rocsparse_index_base base);
template <typename I, typename T>
void host_dotci(
I nnz, const T* x_val, const I* x_ind, const T* y, T* result, rocsparse_index_base base);
template <typename I, typename T>
void host_gthr(I nnz, const T* y, T* x_val, const I* x_ind, rocsparse_index_base base);
template <typename T>
void host_gthrz(
rocsparse_int nnz, T* y, T* x_val, const rocsparse_int* x_ind, rocsparse_index_base base);
template <typename I, typename T>
void host_roti(
I nnz, T* x_val, const I* x_ind, T* y, const T* c, const T* s, rocsparse_index_base base);
template <typename I, typename T>
void host_sctr(I nnz, const T* x_val, const I* x_ind, T* y, rocsparse_index_base base);
/*
* ===========================================================================
* level 2 SPARSE
* ===========================================================================
*/
template <typename T, typename I, typename J>
void host_bsrmv(rocsparse_direction dir,
rocsparse_operation trans,
J mb,
J nb,
I nnzb,
T alpha,
const I* bsr_row_ptr,
const J* bsr_col_ind,
const T* bsr_val,
J bsr_dim,
const T* x,
T beta,
T* y,
rocsparse_index_base base);
template <typename T>
void host_bsrxmv(rocsparse_direction dir,
rocsparse_operation trans,
rocsparse_int size_of_mask,
rocsparse_int mb,
rocsparse_int nb,
rocsparse_int nnzb,
T alpha,
const rocsparse_int* bsr_mask_ptr,
const rocsparse_int* bsr_row_ptr,
const rocsparse_int* bsr_end_ptr,
const rocsparse_int* bsr_col_ind,
const T* bsr_val,
rocsparse_int bsr_dim,
const T* x,
T beta,
T* y,
rocsparse_index_base base);
template <typename T>
void host_bsrsv(rocsparse_operation trans,
rocsparse_direction dir,
rocsparse_int mb,
rocsparse_int nnzb,
T alpha,
const rocsparse_int* bsr_row_ptr,
const rocsparse_int* bsr_col_ind,
const T* bsr_val,
rocsparse_int bsr_dim,
const T* x,
T* y,
rocsparse_diag_type diag_type,
rocsparse_fill_mode fill_mode,
rocsparse_index_base base,
rocsparse_int* struct_pivot,
rocsparse_int* numeric_pivot);
template <typename I, typename T>
void host_coomv(rocsparse_operation trans,
I M,
I N,
I nnz,
T alpha,
const I* coo_row_ind,
const I* coo_col_ind,
const T* coo_val,
const T* x,
T beta,
T* y,
rocsparse_index_base base);
template <typename I, typename T>
void host_coomv_aos(rocsparse_operation trans,
I M,
I N,
I nnz,
T alpha,
const I* coo_ind,
const T* coo_val,
const T* x,
T beta,
T* y,
rocsparse_index_base base);
template <typename I, typename J, typename T>
void host_csrmv(rocsparse_operation trans,
J M,
J N,
I nnz,
T alpha,
const I* csr_row_ptr,
const J* csr_col_ind,
const T* csr_val,
const T* x,
T beta,
T* y,
rocsparse_index_base base,
rocsparse_matrix_type matrix_type,
rocsparse_spmv_alg algo,
bool force_conj);
template <typename I, typename J, typename T>
void host_cscmv(rocsparse_operation trans,
J M,
J N,
I nnz,
T alpha,
const I* __restrict csc_col_ptr,
const J* __restrict csc_row_ind,
const T* __restrict csc_val,
const T* __restrict x,
T beta,
T* __restrict y,
rocsparse_index_base base,
rocsparse_matrix_type matrix_type,
rocsparse_spmv_alg algo);
template <typename I, typename J, typename T>
void host_csrsv(rocsparse_operation trans,
J M,
I nnz,
T alpha,
const I* csr_row_ptr,
const J* csr_col_ind,
const T* csr_val,
const T* x,
T* y,
rocsparse_diag_type diag_type,
rocsparse_fill_mode fill_mode,
rocsparse_index_base base,
J* struct_pivot,
J* numeric_pivot);
template <typename I, typename T>
void host_coosv(rocsparse_operation trans,
I M,
I nnz,
T alpha,
const std::vector<I>& coo_row_ind,
const std::vector<I>& coo_col_ind,
const std::vector<T>& coo_val,
const std::vector<T>& x,
std::vector<T>& y,
rocsparse_diag_type diag_type,
rocsparse_fill_mode fill_mode,
rocsparse_index_base base,
I* struct_pivot,
I* numeric_pivot);
template <typename I, typename T>
void host_ellmv(rocsparse_operation trans,
I M,
I N,
T alpha,
const I* ell_col_ind,
const T* ell_val,
I ell_width,
const T* x,
T beta,
T* y,
rocsparse_index_base base);
template <typename T>
void host_hybmv(rocsparse_operation trans,
rocsparse_int M,
rocsparse_int N,
T alpha,
rocsparse_int ell_nnz,
const rocsparse_int* ell_col_ind,
const T* ell_val,
rocsparse_int ell_width,
rocsparse_int coo_nnz,
const rocsparse_int* coo_row_ind,
const rocsparse_int* coo_col_ind,
const T* coo_val,
const T* x,
T beta,
T* y,
rocsparse_index_base base);
template <typename T>
void host_gebsrmv(rocsparse_direction dir,
rocsparse_operation trans,
rocsparse_int mb,
rocsparse_int nb,
rocsparse_int nnzb,
T alpha,
const rocsparse_int* bsr_row_ptr,
const rocsparse_int* bsr_col_ind,
const T* bsr_val,
rocsparse_int row_block_dim,
rocsparse_int col_block_dim,
const T* x,
T beta,
T* y,
rocsparse_index_base base);
template <typename I, typename T>
void host_gemvi(I M,
I N,
T alpha,
const T* A,
I lda,
I nnz,
const T* x_val,
const I* x_ind,
T beta,
T* y,
rocsparse_index_base base);
/*
* ===========================================================================
* level 3 SPARSE
* ===========================================================================
*/
template <typename T>
void host_bsrmm(rocsparse_handle handle,
rocsparse_direction dir,
rocsparse_operation trans_A,
rocsparse_operation trans_B,
rocsparse_int mb,
rocsparse_int n,
rocsparse_int kb,
rocsparse_int nnzb,
const T* alpha,
const rocsparse_mat_descr descr,
const T* bsr_val,
const rocsparse_int* bsr_row_ptr,
const rocsparse_int* bsr_col_ind,
rocsparse_int block_dim,
const T* B,
rocsparse_int ldb,
const T* beta,
T* C,
rocsparse_int ldc);
template <typename T>
void host_gebsrmm(rocsparse_handle handle,
rocsparse_direction dir,
rocsparse_operation trans_A,
rocsparse_operation trans_B,
rocsparse_int mb,
rocsparse_int n,
rocsparse_int kb,
rocsparse_int nnzb,
const T* alpha,
const rocsparse_mat_descr descr,
const T* bsr_val,
const rocsparse_int* bsr_row_ptr,
const rocsparse_int* bsr_col_ind,
rocsparse_int row_block_dim,
rocsparse_int col_block_dim,
const T* B,
rocsparse_int ldb,
const T* beta,
T* C,
rocsparse_int ldc);
template <typename T, typename I = rocsparse_int, typename J = rocsparse_int>
void host_csrmm(J M,
J N,
J K,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* csr_row_ptr_A,
const J* csr_col_ind_A,
const T* csr_val_A,
const T* B,
J ldb,
T beta,
T* C,
J ldc,
rocsparse_order order,
rocsparse_index_base base,
bool force_conj_A);
template <typename T, typename I = rocsparse_int, typename J = rocsparse_int>
void host_csrmm_batched(J M,
J N,
J K,
J batch_count_A,
I offsets_batch_stride_A,
I columns_values_batch_stride_A,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* csr_row_ptr_A,
const J* csr_col_ind_A,
const T* csr_val_A,
const T* B,
J ldb,
J batch_count_B,
I batch_stride_B,
T beta,
T* C,
J ldc,
J batch_count_C,
I batch_stride_C,
rocsparse_order order,
rocsparse_index_base base,
bool force_conj_A);
template <typename T, typename I>
void host_coomm(I M,
I N,
I K,
I nnz,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* coo_row_ind_A,
const I* coo_col_ind_A,
const T* coo_val_A,
const T* B,
I ldb,
T beta,
T* C,
I ldc,
rocsparse_order order,
rocsparse_index_base base);
template <typename T, typename I>
void host_coomm_batched(I M,
I N,
I K,
I nnz,
I batch_count_A,
I batch_stride_A,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* coo_row_ind_A,
const I* coo_col_ind_A,
const T* coo_val_A,
const T* B,
I ldb,
I batch_count_B,
I batch_stride_B,
T beta,
T* C,
I ldc,
I batch_count_C,
I batch_stride_C,
rocsparse_order order,
rocsparse_index_base base);
template <typename T, typename I = rocsparse_int, typename J = rocsparse_int>
void host_cscmm(J M,
J N,
J K,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* __restrict csc_col_ptr_A,
const J* __restrict csc_row_ind_A,
const T* __restrict csc_val_A,
const T* __restrict B,
J ldb,
T beta,
T* __restrict C,
J ldc,
rocsparse_order order,
rocsparse_index_base base);
template <typename T, typename I = rocsparse_int, typename J = rocsparse_int>
void host_cscmm_batched(J M,
J N,
J K,
J batch_count_A,
I offsets_batch_stride_A,
I rows_values_batch_stride_A,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* csc_col_ptr_A,
const J* csc_row_ind_A,
const T* csc_val_A,
const T* B,
J ldb,
J batch_count_B,
I batch_stride_B,
T beta,
T* C,
J ldc,
J batch_count_C,
I batch_stride_C,
rocsparse_order order,
rocsparse_index_base base);
template <typename I, typename J, typename T>
void host_csrsm(J M,
J nrhs,
I nnz,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* csr_row_ptr,
const J* csr_col_ind,
const T* csr_val,
T* B,
J ldb,
rocsparse_diag_type diag_type,
rocsparse_fill_mode fill_mode,
rocsparse_index_base base,
J* struct_pivot,
J* numeric_pivot);
template <typename I, typename T>
void host_coosm(I M,
I nrhs,
I nnz,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const I* coo_row_ind,
const I* coo_col_ind,
const T* coo_val,
T* B,
I ldb,
rocsparse_diag_type diag_type,
rocsparse_fill_mode fill_mode,
rocsparse_index_base base,
I* struct_pivot,
I* numeric_pivot);
template <typename T>
void host_bsrsm(rocsparse_int mb,
rocsparse_int nrhs,
rocsparse_int nnzb,
rocsparse_direction dir,
rocsparse_operation transA,
rocsparse_operation transX,
T alpha,
const rocsparse_int* __restrict bsr_row_ptr,
const rocsparse_int* __restrict bsr_col_ind,
const T* __restrict bsr_val,
rocsparse_int bsr_dim,
const T* B,
rocsparse_int ldb,
T* X,
rocsparse_int ldx,
rocsparse_diag_type diag_type,
rocsparse_fill_mode fill_mode,
rocsparse_index_base base,
rocsparse_int* struct_pivot,
rocsparse_int* numeric_pivot);
template <typename T>
void host_gemmi(rocsparse_int M,
rocsparse_int N,
rocsparse_operation transA,
rocsparse_operation transB,
T alpha,
const T* A,
rocsparse_int lda,
const rocsparse_int* csr_row_ptr,
const rocsparse_int* csr_col_ind,
const T* csr_val,
T beta,
T* C,
rocsparse_int ldc,
rocsparse_index_base base);
/*
* ===========================================================================
* extra SPARSE
* ===========================================================================
*/
template <typename T>
void host_csrgeam_nnz(rocsparse_int M,
rocsparse_int N,
T alpha,
const std::vector<rocsparse_int>& csr_row_ptr_A,
const std::vector<rocsparse_int>& csr_col_ind_A,
T beta,
const std::vector<rocsparse_int>& csr_row_ptr_B,
const std::vector<rocsparse_int>& csr_col_ind_B,
std::vector<rocsparse_int>& csr_row_ptr_C,
rocsparse_int* nnz_C,
rocsparse_index_base base_A,
rocsparse_index_base base_B,
rocsparse_index_base base_C);
template <typename T>
void host_csrgeam(rocsparse_int M,
rocsparse_int N,
T alpha,
const std::vector<rocsparse_int>& csr_row_ptr_A,
const std::vector<rocsparse_int>& csr_col_ind_A,
const std::vector<T>& csr_val_A,
T beta,
const std::vector<rocsparse_int>& csr_row_ptr_B,
const std::vector<rocsparse_int>& csr_col_ind_B,
const std::vector<T>& csr_val_B,
const std::vector<rocsparse_int>& csr_row_ptr_C,
std::vector<rocsparse_int>& csr_col_ind_C,
std::vector<T>& csr_val_C,
rocsparse_index_base base_A,
rocsparse_index_base base_B,
rocsparse_index_base base_C);
template <typename T, typename I = rocsparse_int, typename J = rocsparse_int>
void host_csrgemm_nnz(J M,
J N,
J K,
const T* alpha,
const I* csr_row_ptr_A,
const J* csr_col_ind_A,
const I* csr_row_ptr_B,
const J* csr_col_ind_B,
const T* beta,
const I* csr_row_ptr_D,
const J* csr_col_ind_D,
I* csr_row_ptr_C,
I* nnz_C,
rocsparse_index_base base_A,
rocsparse_index_base base_B,
rocsparse_index_base base_C,
rocsparse_index_base base_D);
template <typename T, typename I = rocsparse_int, typename J = rocsparse_int>
void host_csrgemm(J M,
J N,
J L,
const T* alpha,
const I* csr_row_ptr_A,
const J* csr_col_ind_A,
const T* csr_val_A,
const I* csr_row_ptr_B,
const J* csr_col_ind_B,
const T* csr_val_B,
const T* beta,
const I* csr_row_ptr_D,
const J* csr_col_ind_D,
const T* csr_val_D,
const I* csr_row_ptr_C,
J* csr_col_ind_C,
T* csr_val_C,
rocsparse_index_base base_A,
rocsparse_index_base base_B,
rocsparse_index_base base_C,
rocsparse_index_base base_D);
/*
* ===========================================================================
* precond SPARSE
* ===========================================================================
*/
template <typename T>
void host_bsric0(rocsparse_direction direction,
rocsparse_int Mb,
rocsparse_int block_dim,
const std::vector<rocsparse_int>& bsr_row_ptr,
const std::vector<rocsparse_int>& bsr_col_ind,
std::vector<T>& bsr_val,
rocsparse_index_base base,
rocsparse_int* struct_pivot,
rocsparse_int* numeric_pivot);
template <typename T, typename U>
void host_bsrilu0(rocsparse_direction dir,
rocsparse_int mb,
const std::vector<rocsparse_int>& bsr_row_ptr,
const std::vector<rocsparse_int>& bsr_col_ind,
std::vector<T>& bsr_val,
rocsparse_int bsr_dim,
rocsparse_index_base base,
rocsparse_int* struct_pivot,
rocsparse_int* numeric_pivot,
bool boost,
U boost_tol,
T boost_val);
template <typename T>
void host_csric0(rocsparse_int M,
const std::vector<rocsparse_int>& csr_row_ptr,
const std::vector<rocsparse_int>& csr_col_ind,
std::vector<T>& csr_val,
rocsparse_index_base base,
rocsparse_int* struct_pivot,
rocsparse_int* numeric_pivot);
template <typename T, typename U>
void host_csrilu0(rocsparse_int M,
const std::vector<rocsparse_int>& csr_row_ptr,
const std::vector<rocsparse_int>& csr_col_ind,
std::vector<T>& csr_val,
rocsparse_index_base base,
rocsparse_int* struct_pivot,
rocsparse_int* numeric_pivot,
bool boost,
U boost_tol,
T boost_val);
template <typename T>
void host_gtsv_no_pivot(rocsparse_int m,
rocsparse_int n,
const std::vector<T>& dl,
const std::vector<T>& d,
const std::vector<T>& du,
std::vector<T>& B,
rocsparse_int ldb);
template <typename T>
void host_gtsv_no_pivot_strided_batch(rocsparse_int m,
const std::vector<T>& dl,
const std::vector<T>& d,
const std::vector<T>& du,
std::vector<T>& x,
rocsparse_int batch_count,
rocsparse_int batch_stride);
template <typename T>
void host_gtsv_interleaved_batch(rocsparse_gtsv_interleaved_alg algo,
rocsparse_int m,
const T* dl,
const T* d,
const T* du,
T* x,
rocsparse_int batch_count,
rocsparse_int batch_stride);
template <typename T>
void host_gpsv_interleaved_batch(rocsparse_gpsv_interleaved_alg algo,
rocsparse_int m,
T* ds,
T* dl,
T* d,
T* du,
T* dw,
T* x,
rocsparse_int batch_count,
rocsparse_int batch_stride);
/*
* ===========================================================================
* conversion SPARSE
* ===========================================================================
*/
template <typename T>
rocsparse_status host_nnz(rocsparse_direction dirA,
rocsparse_int m,
rocsparse_int n,
const T* A,
rocsparse_int lda,
rocsparse_int* nnz_per_row_columns,
rocsparse_int* nnz_total_dev_host_ptr);
template <typename T>
void host_prune_dense2csr(rocsparse_int m,
rocsparse_int n,
const std::vector<T>& A,
rocsparse_int lda,
rocsparse_index_base base,
T threshold,
rocsparse_int& nnz,
std::vector<T>& csr_val,
std::vector<rocsparse_int>& csr_row_ptr,
std::vector<rocsparse_int>& csr_col_ind);
template <typename T>
void host_prune_dense2csr_by_percentage(rocsparse_int m,
rocsparse_int n,
const std::vector<T>& A,
rocsparse_int lda,
rocsparse_index_base base,
T percentage,
rocsparse_int& nnz,
std::vector<T>& csr_val,
std::vector<rocsparse_int>& csr_row_ptr,
std::vector<rocsparse_int>& csr_col_ind);
template <rocsparse_direction DIRA, typename T, typename I, typename J>
void host_dense2csx(J m,
J n,
rocsparse_index_base base,
const T* A,
I ld,
rocsparse_order order,
const I* nnz_per_row_columns,
T* csx_val,
I* csx_row_col_ptr,
J* csx_col_row_ind);
template <rocsparse_direction DIRA, typename T, typename I, typename J>
void host_csx2dense(J m,
J n,
rocsparse_index_base base,
rocsparse_order order,
const T* csx_val,
const I* csx_row_col_ptr,
const J* csx_col_row_ind,
T* A,
I ld);
template <typename I, typename T>
void host_dense_to_coo(I m,
I n,
rocsparse_index_base base,
const std::vector<T>& A,
I ld,
rocsparse_order order,
const std::vector<I>& nnz_per_row,
std::vector<T>& coo_val,
std::vector<I>& coo_row_ind,
std::vector<I>& coo_col_ind);
template <typename I, typename T>
void host_coo_to_dense(I m,
I n,
I nnz,
rocsparse_index_base base,
const std::vector<T>& coo_val,
const std::vector<I>& coo_row_ind,
const std::vector<I>& coo_col_ind,
std::vector<T>& A,
I ld,
rocsparse_order order);
template <typename I, typename J>
void host_csr_to_coo(J M,
I nnz,
const std::vector<I>& csr_row_ptr,
std::vector<J>& coo_row_ind,
rocsparse_index_base base);
template <typename I, typename J>
void host_csr_to_coo_aos(J M,
I nnz,
const std::vector<I>& csr_row_ptr,
const std::vector<J>& csr_col_ind,
std::vector<I>& coo_ind,
rocsparse_index_base base);
template <typename I, typename J, typename T>
void host_csr_to_csc(J M,
J N,
I nnz,
const I* csr_row_ptr,
const J* csr_col_ind,
const T* csr_val,
std::vector<J>& csc_row_ind,
std::vector<I>& csc_col_ptr,
std::vector<T>& csc_val,
rocsparse_action action,
rocsparse_index_base base);
template <typename T>
void host_gebsr_to_gebsc(rocsparse_int Mb,
rocsparse_int Nb,
rocsparse_int nnzb,
const std::vector<rocsparse_int>& bsr_row_ptr,
const std::vector<rocsparse_int>& bsr_col_ind,
const std::vector<T>& bsr_val,
rocsparse_int row_block_dim,
rocsparse_int col_block_dim,
std::vector<rocsparse_int>& bsc_row_ind,
std::vector<rocsparse_int>& bsc_col_ptr,
std::vector<T>& bsc_val,
rocsparse_action action,
rocsparse_index_base base);
template <typename T>
void host_gebsr_to_csr(rocsparse_direction direction,
rocsparse_int mb,
rocsparse_int nb,
rocsparse_int nnzb,
const std::vector<T>& bsr_val,
const std::vector<rocsparse_int>& bsr_row_ptr,
const std::vector<rocsparse_int>& bsr_col_ind,
rocsparse_int row_block_dim,
rocsparse_int col_block_dim,
rocsparse_index_base bsr_base,
std::vector<T>& csr_val,
std::vector<rocsparse_int>& csr_row_ptr,
std::vector<rocsparse_int>& csr_col_ind,
rocsparse_index_base csr_base);
template <typename T>
void host_csr_to_gebsr(rocsparse_direction direction,
rocsparse_int m,
rocsparse_int n,
rocsparse_int nnz,
const std::vector<T>& csr_val,
const std::vector<rocsparse_int>& csr_row_ptr,
const std::vector<rocsparse_int>& csr_col_ind,
rocsparse_int row_block_dim,
rocsparse_int col_block_dim,
rocsparse_index_base csr_base,
std::vector<T>& bsr_val,
std::vector<rocsparse_int>& bsr_row_ptr,
std::vector<rocsparse_int>& bsr_col_ind,
rocsparse_index_base bsr_base);
template <typename T>
void host_bsrpad_value(rocsparse_int m,
rocsparse_int mb,
rocsparse_int nnzb,
rocsparse_int block_dim,
T value,
T* __restrict bsr_val,
const rocsparse_int* __restrict bsr_row_ptr,
const rocsparse_int* __restrict bsr_col_ind,
rocsparse_index_base bsr_base);
template <typename T>
void host_gebsr_to_gebsr(rocsparse_direction direction,
rocsparse_int mb,
rocsparse_int nb,
rocsparse_int nnzb,
const std::vector<T>& bsr_val_A,
const std::vector<rocsparse_int>& bsr_row_ptr_A,
const std::vector<rocsparse_int>& bsr_col_ind_A,
rocsparse_int row_block_dim_A,
rocsparse_int col_block_dim_A,
rocsparse_index_base base_A,
std::vector<T>& bsr_val_C,
std::vector<rocsparse_int>& bsr_row_ptr_C,
std::vector<rocsparse_int>& bsr_col_ind_C,
rocsparse_int row_block_dim_C,
rocsparse_int col_block_dim_C,
rocsparse_index_base base_C);
template <typename T>
void host_bsr_to_bsc(rocsparse_int mb,
rocsparse_int nb,
rocsparse_int nnzb,
rocsparse_int bsr_dim,
const rocsparse_int* bsr_row_ptr,
const rocsparse_int* bsr_col_ind,
const T* bsr_val,
std::vector<rocsparse_int>& bsc_row_ind,
std::vector<rocsparse_int>& bsc_col_ptr,
std::vector<T>& bsc_val,
rocsparse_index_base bsr_base,
rocsparse_index_base bsc_base);
template <typename I, typename J, typename T>
void host_csr_to_ell(J M,
const std::vector<I>& csr_row_ptr,
const std::vector<J>& csr_col_ind,
const std::vector<T>& csr_val,
std::vector<J>& ell_col_ind,
std::vector<T>& ell_val,
J& ell_width,
rocsparse_index_base csr_base,
rocsparse_index_base ell_base);
template <typename T>
void host_csr_to_hyb(rocsparse_int M,
rocsparse_int nnz,
const std::vector<rocsparse_int>& csr_row_ptr,
const std::vector<rocsparse_int>& csr_col_ind,
const std::vector<T>& csr_val,
std::vector<rocsparse_int>& ell_col_ind,
std::vector<T>& ell_val,
rocsparse_int& ell_width,
rocsparse_int& ell_nnz,
std::vector<rocsparse_int>& coo_row_ind,
std::vector<rocsparse_int>& coo_col_ind,
std::vector<T>& coo_val,
rocsparse_int& coo_nnz,
rocsparse_hyb_partition part,
rocsparse_index_base base);
template <typename T>
void host_csr_to_csr_compress(rocsparse_int M,
rocsparse_int N,
rocsparse_int nnz,
const std::vector<rocsparse_int>& csr_row_ptr_A,
const std::vector<rocsparse_int>& csr_col_ind_A,
const std::vector<T>& csr_val_A,
std::vector<rocsparse_int>& csr_row_ptr_C,
std::vector<rocsparse_int>& csr_col_ind_C,
std::vector<T>& csr_val_C,
rocsparse_index_base base,
T tol);
template <typename T>
void host_prune_csr_to_csr(rocsparse_int M,
rocsparse_int N,
rocsparse_int nnz_A,
const std::vector<rocsparse_int>& csr_row_ptr_A,
const std::vector<rocsparse_int>& csr_col_ind_A,
const std::vector<T>& csr_val_A,
rocsparse_int& nnz_C,
std::vector<rocsparse_int>& csr_row_ptr_C,
std::vector<rocsparse_int>& csr_col_ind_C,
std::vector<T>& csr_val_C,
rocsparse_index_base csr_base_A,
rocsparse_index_base csr_base_C,
T threshold);
template <typename T>
void host_prune_csr_to_csr_by_percentage(rocsparse_int M,
rocsparse_int N,
rocsparse_int nnz_A,
const std::vector<rocsparse_int>& csr_row_ptr_A,
const std::vector<rocsparse_int>& csr_col_ind_A,
const std::vector<T>& csr_val_A,
rocsparse_int& nnz_C,
std::vector<rocsparse_int>& csr_row_ptr_C,
std::vector<rocsparse_int>& csr_col_ind_C,
std::vector<T>& csr_val_C,
rocsparse_index_base csr_base_A,
rocsparse_index_base csr_base_C,
T percentage);
template <typename I, typename J>
void host_coo_to_csr(
J M, I nnz, const J* coo_row_ind, std::vector<I>& csr_row_ptr, rocsparse_index_base base);
template <typename T>
void host_ell_to_csr(rocsparse_int M,
rocsparse_int N,
const std::vector<rocsparse_int>& ell_col_ind,
const std::vector<T>& ell_val,
rocsparse_int ell_width,
std::vector<rocsparse_int>& csr_row_ptr,
std::vector<rocsparse_int>& csr_col_ind,
std::vector<T>& csr_val,
rocsparse_int& csr_nnz,
rocsparse_index_base ell_base,
rocsparse_index_base csr_base);
template <typename T>
void host_coosort_by_column(rocsparse_int M,
rocsparse_int nnz,
std::vector<rocsparse_int>& coo_row_ind,
std::vector<rocsparse_int>& coo_col_ind,
std::vector<T>& coo_val);
#endif // ROCSPARSE_HOST_HPP
|