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 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142
|
/* ************************************************************************
* Copyright (C) 2018-2024 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 cop-
* ies 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 IM-
* PLIED, 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 CONNE-
* CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* ************************************************************************ */
#pragma once
#include "testing_common.hpp"
#include "type_dispatch.hpp"
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#ifdef WIN32
#include <stdlib.h>
#define setenv(A, B, C) _putenv_s(A, B)
#else
#include <sys/param.h>
#include <unistd.h>
#endif
#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#else
#error no filesystem found
#endif
template <typename T>
static constexpr auto precision_letter = "*";
template <>
ROCBLAS_CLANG_STATIC constexpr auto precision_letter<rocblas_half> = "h";
template <>
ROCBLAS_CLANG_STATIC constexpr auto precision_letter<float> = "s";
template <>
ROCBLAS_CLANG_STATIC constexpr auto precision_letter<double> = "d";
template <>
ROCBLAS_CLANG_STATIC constexpr auto precision_letter<rocblas_float_complex> = "c";
template <>
ROCBLAS_CLANG_STATIC constexpr auto precision_letter<rocblas_double_complex> = "z";
#ifdef WIN32
int diff_files(std::string path1, std::string path2)
{
std::replace(path1.begin(), path1.end(), '/', '\\');
std::replace(path2.begin(), path2.end(), '/', '\\');
std::ifstream actual(path1);
std::ifstream expected(path2);
std::string test((std::istreambuf_iterator<char>(actual)), std::istreambuf_iterator<char>());
std::string gold((std::istreambuf_iterator<char>(expected)), std::istreambuf_iterator<char>());
actual.close();
expected.close();
int cmp = test != gold;
return cmp;
}
#endif
// replaces X in string with s, d, c, z or h depending on typename T
template <typename T>
std::string replaceX(rocblas_client_api api, std::string input_string)
{
std::replace(input_string.begin(), input_string.end(), 'X', precision_letter<T>[0]);
if(api & c_API_64)
{
input_string += "_64";
}
return input_string;
}
template <typename T>
void testing_logging(const Arguments& arg)
{
rocblas_pointer_mode test_pointer_mode
= arg.pointer_mode_host ? rocblas_pointer_mode_host : rocblas_pointer_mode_device;
// set environment variable ROCBLAS_LAYER to turn on logging. Note that setenv
// only has scope for this executable, so it is not necessary to save and restore
// this environment variable
//
// ROCBLAS_LAYER is a bit mask:
// ROCBLAS_LAYER = 1 turns on log_trace
// ROCBLAS_LAYER = 2 turns on log_bench
// ROCBLAS_LAYER = 4 turns on log_profile
int setenv_status;
setenv_status = setenv("ROCBLAS_LAYER", "3", true);
#ifdef GOOGLE_TEST
ASSERT_EQ(setenv_status, 0);
#endif
// open files
static std::string tmp_dir = rocblas_tempname();
const fs::path trace_fspath1
= tmp_dir + std::string("trace_") + std::string(precision_letter<T>) + std::string(".csv");
const fs::path trace_fspath2 = tmp_dir + std::string("trace_")
+ std::string(precision_letter<T>) + std::string("_gold.csv");
const fs::path bench_fspath1
= tmp_dir + std::string("bench_") + std::string(precision_letter<T>) + std::string(".txt");
const fs::path bench_fspath2 = tmp_dir + std::string("bench_")
+ std::string(precision_letter<T>) + std::string("_gold.txt");
std::string trace_path1 = trace_fspath1.generic_string();
std::string trace_path2 = trace_fspath2.generic_string();
std::string bench_path1 = bench_fspath1.generic_string();
std::string bench_path2 = bench_fspath2.generic_string();
// set environment variable to give pathname of for log_trace file
setenv_status = setenv("ROCBLAS_LOG_TRACE_PATH", trace_path1.c_str(), true);
#ifdef GOOGLE_TEST
ASSERT_EQ(setenv_status, 0);
#endif
// set environment variable to give pathname of for log_bench file
setenv_status = setenv("ROCBLAS_LOG_BENCH_PATH", bench_path1.c_str(), true);
#ifdef GOOGLE_TEST
ASSERT_EQ(setenv_status, 0);
#endif
//
// call rocBLAS functions with log_trace and log_bench to output log_trace and log_bench files
//
int64_t m = 3;
int64_t n = 2;
int64_t k = 1;
int64_t kl = 1;
int64_t ku = 1;
int64_t incx = 1;
int64_t incy = 1;
int64_t lda = 4;
rocblas_stride stride_a = 40;
int64_t ldb = 5;
rocblas_stride stride_b = 50;
int64_t ldc = 6;
rocblas_stride stride_c = 60;
int64_t ldd = 7;
rocblas_stride stride_d = 70;
int64_t batch_count = 1;
T h_alpha = 1.5;
T h_beta = 0.5;
T* alpha = &h_alpha;
T* beta = &h_beta;
// for gemm_ex
float alpha_float = 1.5;
float beta_float = 0.5;
DEVICE_MEMCHECK(device_vector<T>, d_alpha, (1));
DEVICE_MEMCHECK(device_vector<T>, d_beta, (1));
bool device_mode = test_pointer_mode == rocblas_pointer_mode_device;
if(device_mode)
{
CHECK_HIP_ERROR(hipMemcpy(d_alpha, alpha, sizeof(T), hipMemcpyHostToDevice));
CHECK_HIP_ERROR(hipMemcpy(d_beta, beta, sizeof(T), hipMemcpyHostToDevice));
alpha = d_alpha;
beta = d_beta;
}
rocblas_operation transA = rocblas_operation_none;
rocblas_operation transB = rocblas_operation_transpose;
rocblas_fill uplo = rocblas_fill_upper;
rocblas_diagonal diag = rocblas_diagonal_unit;
rocblas_side side = rocblas_side_left;
// use m as larger
int64_t size_x = m * incx;
int64_t size_y = m * incy;
// strides set above max requirements
int64_t size_a = stride_a * batch_count;
int64_t size_b = stride_b * batch_count;
int64_t size_c = stride_c * batch_count;
int64_t size_d = stride_d * batch_count;
// allocate memory on device
DEVICE_MEMCHECK(device_vector<T>, dx, (size_x));
DEVICE_MEMCHECK(device_vector<T>, dy, (size_y));
DEVICE_MEMCHECK(device_vector<T>, da, (size_a));
DEVICE_MEMCHECK(device_vector<T>, db, (size_b));
DEVICE_MEMCHECK(device_vector<T>, dc, (size_c));
DEVICE_MEMCHECK(device_vector<T>, dd, (size_d));
// enclose in {} so rocblas_local_handle destructor called as it goes out of scope
{
int64_t h_i64_result;
rocblas_int h_i32_result;
DEVICE_MEMCHECK(device_vector<int64_t>, d_i64_result, (1));
DEVICE_MEMCHECK(device_vector<rocblas_int>, d_i32_result, (1));
DEVICE_MEMCHECK(device_vector<T>, d_result, (1));
T h_result;
T* result = &h_result;
int64_t* i64_result = &h_i64_result;
rocblas_int* i32_result = &h_i32_result;
if(device_mode)
{
result = d_result;
i64_result = d_i64_result;
i32_result = d_i32_result;
}
rocblas_pointer_mode mode;
// Auxiliary functions
rocblas_local_handle handle;
rocblas_set_pointer_mode(handle, test_pointer_mode);
rocblas_get_pointer_mode(handle, &mode);
// *************************************************** BLAS1 ***************************************************
if(arg.api == C_64)
{
rocblas_iamax_64<T>(handle, n, dx, incx, i64_result);
rocblas_iamin_64<T>(handle, n, dx, incx, i64_result);
}
else
{
rocblas_iamax<T>(handle, n, dx, incx, i32_result);
rocblas_iamin<T>(handle, n, dx, incx, i32_result);
}
auto rocblas_asum_fn = rocblas_asum<T>;
auto rocblas_asum_fn_64 = rocblas_asum_64<T>;
DAPI_CHECK(rocblas_asum_fn, (handle, n, dx, incx, result));
auto rocblas_axpy_fn = rocblas_axpy<T>;
auto rocblas_axpy_fn_64 = rocblas_axpy_64<T>;
DAPI_CHECK(rocblas_axpy_fn, (handle, n, alpha, dx, incx, dy, incy));
auto rocblas_axpy_ex_fn = rocblas_axpy_ex;
auto rocblas_axpy_ex_fn_64 = rocblas_axpy_ex_64;
// fixed datatype dispatch
rocblas_datatype dt = rocblas_type2datatype<T>();
DAPI_CHECK(rocblas_axpy_ex_fn, (handle, n, alpha, dt, dx, dt, incx, dy, dt, incy, dt));
auto rocblas_copy_fn = rocblas_copy<T>;
auto rocblas_copy_fn_64 = rocblas_copy_64<T>;
DAPI_CHECK(rocblas_copy_fn, (handle, n, dx, incx, dy, incy));
auto rocblas_dot_fn = rocblas_dot<T>;
auto rocblas_dot_fn_64 = rocblas_dot_64<T>;
DAPI_CHECK(rocblas_dot_fn, (handle, n, dx, incx, dy, incy, result));
auto rocblas_nrm2_fn = rocblas_nrm2<T>;
auto rocblas_nrm2_fn_64 = rocblas_nrm2_64<T>;
DAPI_CHECK(rocblas_nrm2_fn, (handle, n, dx, incx, result));
auto rocblas_scal_fn = rocblas_scal<T>;
auto rocblas_scal_fn_64 = rocblas_scal_64<T>;
DAPI_CHECK(rocblas_scal_fn, (handle, n, alpha, dx, incx));
auto rocblas_swap_fn = rocblas_swap<T>;
auto rocblas_swap_fn_64 = rocblas_swap_64<T>;
DAPI_CHECK(rocblas_swap_fn, (handle, n, dx, incx, dy, incy));
// *************************************************** BLAS2 ***************************************************
auto rocblas_gbmv_fn = rocblas_gbmv<T>;
auto rocblas_gbmv_fn_64 = rocblas_gbmv_64<T>;
DAPI_CHECK(rocblas_gbmv_fn,
(handle, transA, m, n, kl, ku, alpha, da, lda, dx, incx, beta, dy, incy));
auto rocblas_gemv_fn = rocblas_gemv<T>;
auto rocblas_gemv_fn_64 = rocblas_gemv_64<T>;
DAPI_CHECK(rocblas_gemv_fn,
(handle, transA, m, n, alpha, da, lda, dx, incx, beta, dy, incy));
auto rocblas_ger_fn = rocblas_ger<T, false>;
auto rocblas_ger_fn_64 = rocblas_ger_64<T, false>;
DAPI_CHECK(rocblas_ger_fn, (handle, m, n, alpha, dx, incx, dy, incy, da, lda));
auto rocblas_sbmv_fn = rocblas_sbmv<T>;
auto rocblas_sbmv_fn_64 = rocblas_sbmv_64<T>;
DAPI_CHECK(rocblas_sbmv_fn, (handle, uplo, n, k, alpha, da, lda, dx, incx, beta, dy, incy));
auto rocblas_spmv_fn = rocblas_spmv<T>;
auto rocblas_spmv_fn_64 = rocblas_spmv_64<T>;
DAPI_CHECK(rocblas_spmv_fn, (handle, uplo, n, alpha, da, dx, incx, beta, dy, incy));
auto rocblas_spr_fn = rocblas_spr<T>;
auto rocblas_spr_fn_64 = rocblas_spr_64<T>;
DAPI_CHECK(rocblas_spr_fn, (handle, uplo, n, alpha, dx, incx, da));
auto rocblas_spr2_fn = rocblas_spr2<T>;
auto rocblas_spr2_fn_64 = rocblas_spr2_64<T>;
DAPI_CHECK(rocblas_spr2_fn, (handle, uplo, n, alpha, dx, incx, dy, incy, da));
auto rocblas_symv_fn = rocblas_symv<T>;
auto rocblas_symv_fn_64 = rocblas_symv_64<T>;
DAPI_CHECK(rocblas_symv_fn, (handle, uplo, n, alpha, da, lda, dx, incx, beta, dy, incy));
auto rocblas_syr_fn = rocblas_syr<T>;
auto rocblas_syr_fn_64 = rocblas_syr_64<T>;
DAPI_CHECK(rocblas_syr_fn, (handle, uplo, n, alpha, dx, incx, da, lda));
auto rocblas_syr2_fn = rocblas_syr2<T>;
auto rocblas_syr2_fn_64 = rocblas_syr2_64<T>;
DAPI_CHECK(rocblas_syr2_fn, (handle, uplo, n, alpha, dx, incx, dy, incy, da, lda));
auto rocblas_tbmv_fn = rocblas_tbmv<T>;
auto rocblas_tbmv_fn_64 = rocblas_tbmv_64<T>;
DAPI_CHECK(rocblas_tbmv_fn, (handle, uplo, transA, diag, n, k, da, lda, dx, incx));
auto rocblas_tpmv_fn = rocblas_tpmv<T>;
auto rocblas_tpmv_fn_64 = rocblas_tpmv_64<T>;
DAPI_CHECK(rocblas_tpmv_fn, (handle, uplo, transA, diag, n, da, dx, incx));
auto rocblas_trmv_fn = rocblas_trmv<T>;
auto rocblas_trmv_fn_64 = rocblas_trmv_64<T>;
DAPI_CHECK(rocblas_trmv_fn, (handle, uplo, transA, diag, n, da, lda, dx, incx));
auto rocblas_tbsv_fn = rocblas_tbsv<T>;
auto rocblas_tbsv_fn_64 = rocblas_tbsv_64<T>;
DAPI_CHECK(rocblas_tbsv_fn, (handle, uplo, transA, diag, n, k, da, lda, dx, incx));
auto rocblas_tpsv_fn = rocblas_tpsv<T>;
auto rocblas_tpsv_fn_64 = rocblas_tpsv_64<T>;
DAPI_CHECK(rocblas_tpsv_fn, (handle, uplo, transA, diag, n, da, dx, incx));
auto rocblas_trsv_fn = rocblas_trsv<T>;
auto rocblas_trsv_fn_64 = rocblas_trsv_64<T>;
DAPI_CHECK(rocblas_trsv_fn, (handle, uplo, transA, diag, n, da, lda, dx, incx));
#if BUILD_WITH_TENSILE
// *************************************************** BLAS3 ***************************************************
auto rocblas_trsm_fn = rocblas_trsm<T>;
auto rocblas_trsm_fn_64 = rocblas_trsm_64<T>;
DAPI_CHECK(rocblas_trsm_fn,
(handle, side, uplo, transA, diag, m, n, alpha, da, lda, db, ldb));
// ILP64 additions later
CHECK_ROCBLAS_ERROR(
rocblas_geam<T>(handle, transA, transB, m, n, alpha, da, lda, beta, db, ldb, dc, ldc));
CHECK_ROCBLAS_ERROR(rocblas_gemm<T>(
handle, transA, transB, m, n, k, alpha, da, lda, db, ldb, beta, dc, ldc));
CHECK_ROCBLAS_ERROR(
rocblas_symm<T>(handle, side, uplo, m, n, alpha, da, lda, db, ldb, beta, dc, ldc));
CHECK_ROCBLAS_ERROR(
rocblas_syrk<T>(handle, uplo, transA, n, k, alpha, da, lda, beta, dc, ldc));
CHECK_ROCBLAS_ERROR(
rocblas_syr2k<T>(handle, uplo, transA, n, k, alpha, da, lda, db, ldb, beta, dc, ldc));
CHECK_ROCBLAS_ERROR(
rocblas_syrkx<T>(handle, uplo, transA, n, k, alpha, da, lda, db, ldb, beta, dc, ldc));
CHECK_ROCBLAS_ERROR(rocblas_trmm<T>(
handle, side, uplo, transA, diag, m, n, alpha, da, lda, db, ldb, dc, ldc));
CHECK_ROCBLAS_ERROR(rocblas_gemm_strided_batched<T>(handle,
transA,
transB,
m,
n,
k,
alpha,
da,
lda,
stride_a,
db,
ldb,
stride_b,
beta,
dc,
ldc,
stride_c,
batch_count));
// exclude trtri as it is an internal function
// rocblas_trtri<T>(handle, uplo, diag, n, da, lda, db, ldb);
// trmm
// tritri
// BLAS_EX
{
void* alpha_gemm_ex = nullptr;
void* beta_gemm_ex = nullptr;
rocblas_half alpha_half(alpha_float);
rocblas_half beta_half(beta_float);
double alpha_double(alpha_float);
double beta_double(beta_float);
rocblas_gemm_algo algo = rocblas_gemm_algo_standard;
int32_t solution_index = 0;
uint32_t flags = 0;
rocblas_datatype a_type;
rocblas_datatype b_type;
rocblas_datatype c_type;
rocblas_datatype d_type;
rocblas_datatype compute_type;
DEVICE_MEMCHECK(device_vector<rocblas_half>, d_alpha_half, (1));
DEVICE_MEMCHECK(device_vector<rocblas_half>, d_beta_half, (1));
DEVICE_MEMCHECK(device_vector<float>, d_alpha_float, (1));
DEVICE_MEMCHECK(device_vector<float>, d_beta_float, (1));
DEVICE_MEMCHECK(device_vector<double>, d_alpha_double, (1));
DEVICE_MEMCHECK(device_vector<double>, d_beta_double, (1));
if(std::is_same_v<T, rocblas_half>)
{
a_type = rocblas_datatype_f16_r;
b_type = rocblas_datatype_f16_r;
c_type = rocblas_datatype_f16_r;
d_type = rocblas_datatype_f16_r;
compute_type = rocblas_datatype_f16_r;
alpha_gemm_ex = &alpha_half;
beta_gemm_ex = &beta_half;
if(device_mode)
{
CHECK_HIP_ERROR(hipMemcpy(
d_alpha_half, alpha_gemm_ex, sizeof(rocblas_half), hipMemcpyHostToDevice));
CHECK_HIP_ERROR(hipMemcpy(
d_beta_half, beta_gemm_ex, sizeof(rocblas_half), hipMemcpyHostToDevice));
alpha_gemm_ex = d_alpha_half;
beta_gemm_ex = d_beta_half;
}
}
else if(std::is_same_v<T, float>)
{
a_type = rocblas_datatype_f32_r;
b_type = rocblas_datatype_f32_r;
c_type = rocblas_datatype_f32_r;
d_type = rocblas_datatype_f32_r;
compute_type = rocblas_datatype_f32_r;
alpha_gemm_ex = &alpha_float;
beta_gemm_ex = &beta_float;
if(device_mode)
{
CHECK_HIP_ERROR(hipMemcpy(
d_alpha_float, alpha_gemm_ex, sizeof(float), hipMemcpyHostToDevice));
CHECK_HIP_ERROR(hipMemcpy(
d_beta_float, beta_gemm_ex, sizeof(float), hipMemcpyHostToDevice));
alpha_gemm_ex = d_alpha_float;
beta_gemm_ex = d_beta_float;
}
}
else if(std::is_same_v<T, double>)
{
a_type = rocblas_datatype_f64_r;
b_type = rocblas_datatype_f64_r;
c_type = rocblas_datatype_f64_r;
d_type = rocblas_datatype_f64_r;
compute_type = rocblas_datatype_f64_r;
alpha_gemm_ex = &alpha_double;
beta_gemm_ex = &beta_double;
if(device_mode)
{
CHECK_HIP_ERROR(hipMemcpy(
d_alpha_double, alpha_gemm_ex, sizeof(double), hipMemcpyHostToDevice));
CHECK_HIP_ERROR(hipMemcpy(
d_beta_double, beta_gemm_ex, sizeof(double), hipMemcpyHostToDevice));
alpha_gemm_ex = d_alpha_double;
beta_gemm_ex = d_beta_double;
}
}
CHECK_ROCBLAS_ERROR(rocblas_gemm_ex(handle,
transA,
transB,
m,
n,
k,
alpha_gemm_ex,
da,
a_type,
lda,
db,
b_type,
ldb,
beta_gemm_ex,
dc,
c_type,
ldc,
dd,
d_type,
ldd,
compute_type,
algo,
solution_index,
flags));
CHECK_ROCBLAS_ERROR(rocblas_gemm_strided_batched_ex(handle,
transA,
transB,
m,
n,
k,
alpha_gemm_ex,
da,
a_type,
lda,
stride_a,
db,
b_type,
ldb,
stride_b,
beta_gemm_ex,
dc,
c_type,
ldc,
stride_c,
dd,
d_type,
ldd,
stride_d,
batch_count,
compute_type,
algo,
solution_index,
flags));
}
#endif // BUILD_WITH_TENSILE
}
setenv_status = setenv("ROCBLAS_LAYER", "0", true);
#ifdef GOOGLE_TEST
ASSERT_EQ(setenv_status, 0);
#endif
//
// write "golden file"
//
std::ofstream trace_ofs;
std::ofstream bench_ofs;
trace_ofs.exceptions(std::ifstream::badbit | std::ifstream::failbit);
trace_ofs.exceptions(std::ofstream::badbit | std::ofstream::failbit);
trace_ofs.open(trace_path2);
bench_ofs.open(bench_path2);
#ifdef GOOGLE_TEST
ASSERT_FALSE(trace_ofs.fail());
ASSERT_FALSE(trace_ofs.bad());
ASSERT_FALSE(bench_ofs.fail());
ASSERT_FALSE(bench_ofs.bad());
#endif
rocblas_internal_ostream trace_ofs2;
rocblas_internal_ostream bench_ofs2;
std::string bench(arg.api == C_64 ? "./rocblas-bench --api 1" : "./rocblas-bench");
// Auxiliary function
int pmode = (int)test_pointer_mode;
trace_ofs2 << "rocblas_create_handle,atomics_allowed\n";
trace_ofs2 << "rocblas_set_pointer_mode," << pmode << ",atomics_allowed\n";
trace_ofs2 << "rocblas_get_pointer_mode," << pmode << ",atomics_allowed\n";
// *************************************************** BLAS1 ***************************************************
//
// AMAX
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_iXamax") << "," << n << "," << (void*)dx << ","
<< incx << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f iamax -r " << rocblas_precision_string<T> << " -n " << n
<< " --incx " << incx << "\n";
//
// AMIN
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_iXamin") << "," << n << "," << (void*)dx << ","
<< incx << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f iamin -r " << rocblas_precision_string<T> << " -n " << n
<< " --incx " << incx << "\n";
//
// ASUM
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xasum") << "," << n << "," << (void*)dx << ","
<< incx << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f asum -r " << rocblas_precision_string<T> << " -n " << n
<< " --incx " << incx << "\n";
//
// AXPY
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xaxpy") << "," << n << "," << h_alpha << ","
<< (void*)dx << "," << incx << "," << (void*)dy << "," << incy
<< ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f axpy -r " << rocblas_precision_string<T> << " -n " << n
<< " --alpha " << h_alpha << " --incx " << incx << " --incy " << incy << "\n";
//
// AXPY_EX
//
std::string dt_str(rocblas_datatype_string(rocblas_type2datatype<T>()));
if(test_pointer_mode == rocblas_pointer_mode_host)
{
trace_ofs2 << replaceX<T>(arg.api, "rocblas_axpy_ex") << "," << n << "," << h_alpha << ","
<< dt_str << "," << (void*)dx << "," << dt_str << "," << incx << "," << (void*)dy
<< "," << dt_str << "," << incy << "," << dt_str << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f axpy_ex"
<< " -n " << n << " --alpha " << h_alpha << " --a_type " << dt_str
<< " --b_type " << dt_str << " --incx " << incx << " --c_type " << dt_str
<< " --incy " << incy << " --compute_type " << dt_str << "\n";
}
else
{
trace_ofs2 << replaceX<T>(arg.api, "rocblas_axpy_ex") << "," << n << "," << dt_str << ","
<< (void*)dx << "," << dt_str << "," << incx << "," << (void*)dy << "," << dt_str
<< "," << incy << "," << dt_str << ",atomics_allowed\n";
// no bench output TODO
}
//
// COPY
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xcopy") << "," << n << "," << (void*)dx << ","
<< incx << "," << (void*)dy << "," << incy << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f copy -r " << rocblas_precision_string<T> << " -n " << n
<< " --incx " << incx << " --incy " << incy << "\n";
//
// DOT
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xdot") << "," << n << "," << (void*)dx << ","
<< incx << "," << (void*)dy << "," << incy << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f dot -r " << rocblas_precision_string<T> << " -n " << n
<< " --incx " << incx << " --incy " << incy << "\n";
//
// NRM2
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xnrm2") << "," << n << "," << (void*)dx << ","
<< incx << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f nrm2 -r " << rocblas_precision_string<T> << " -n " << n
<< " --incx " << incx << "\n";
//
// SCAL
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xscal") << "," << n << "," << h_alpha << ","
<< (void*)dx << "," << incx << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f scal --a_type "
<< rocblas_precision_string<T> << " --b_type "
<< rocblas_precision_string<T> << " -n " << n << " --alpha " << h_alpha << " --incx "
<< incx << "\n";
//
// SWAP
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xswap") << "," << n << "," << (void*)dx << ","
<< incx << "," << (void*)dy << "," << incy << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f swap -r " << rocblas_precision_string<T> << " -n " << n
<< " --incx " << incx << " --incy " << incy << "\n";
// *************************************************** BLAS2 ***************************************************
auto transA_letter = rocblas2char_operation(transA);
auto transB_letter = rocblas2char_operation(transB);
auto side_letter = rocblas2char_side(side);
auto uplo_letter = rocblas2char_fill(uplo);
auto diag_letter = rocblas2char_diagonal(diag);
//
// GBMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xgbmv") << "," << transA << "," << m << "," << n
<< "," << kl << "," << ku << "," << h_alpha << "," << (void*)da << "," << lda << ","
<< (void*)dx << "," << incx << "," << h_beta << "," << (void*)dy << "," << incy
<< ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f gbmv -r " << rocblas_precision_string<T> << " --transposeA "
<< transA_letter << " -m " << m << " -n " << n << " --kl " << kl << " --ku " << ku
<< " --alpha " << h_alpha << " --lda " << lda << " --incx " << incx << " --beta "
<< h_beta << " --incy " << incy << "\n";
//
// GEMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xgemv") << "," << transA << "," << m << "," << n
<< "," << h_alpha << "," << (void*)da << "," << lda << "," << (void*)dx << ","
<< incx << "," << h_beta << "," << (void*)dy << "," << incy << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f gemv -r " << rocblas_precision_string<T> << " --transposeA "
<< transA_letter << " -m " << m << " -n " << n << " --alpha " << h_alpha << " --lda "
<< lda << " --incx " << incx << " --beta " << h_beta << " --incy " << incy << "\n";
//
// GER
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xger") << "," << m << "," << n << "," << h_alpha
<< "," << (void*)dx << "," << incx << "," << (void*)dy << "," << incy << ","
<< (void*)da << "," << lda << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f ger -r " << rocblas_precision_string<T> << " -m " << m
<< " -n " << n << " --alpha " << h_alpha << " --incx " << incx << " --incy " << incy
<< " --lda " << lda << "\n";
//
// SBMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xsbmv") << "," << uplo << "," << n << "," << k
<< "," << h_alpha << "," << (void*)da << "," << lda << "," << (void*)dx << ","
<< incx << "," << h_beta << "," << (void*)dy << "," << incy << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f sbmv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " -n " << n << " -k " << k << " --alpha " << h_alpha << " --lda "
<< lda << " --incx " << incx << " --beta " << h_beta << " --incy " << incy << "\n";
//
// SPMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xspmv") << "," << uplo << "," << n << "," << h_alpha
<< "," << (void*)da << "," << (void*)dx << "," << incx << "," << h_beta << ","
<< (void*)dy << "," << incy << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f spmv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " -n " << n << " --alpha " << h_alpha << " --incx " << incx
<< " --beta " << h_beta << " --incy " << incy << "\n";
//
// SPR
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xspr") << "," << uplo << "," << n << "," << h_alpha
<< "," << (void*)dx << "," << incx << "," << (void*)da << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f spr -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " -n " << n << " --alpha " << h_alpha << " --incx " << incx
<< "\n";
//
// SPR2
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xspr2") << "," << uplo << "," << n << "," << h_alpha
<< "," << (void*)dx << "," << incx << "," << (void*)dy << "," << incy << ","
<< (void*)da << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f spr2 -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " -n " << n << " --alpha " << h_alpha << " --incx " << incx
<< " --incy " << incy << "\n";
//
// SYMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xsymv") << "," << uplo << "," << n << "," << h_alpha
<< "," << (void*)da << "," << lda << "," << (void*)dx << "," << incx << "," << h_beta
<< "," << (void*)dy << "," << incy << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f symv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " -n " << n << " --alpha " << h_alpha << " --lda " << lda
<< " --incx " << incx << " --beta " << h_beta << " --incy " << incy << "\n";
//
// SYR
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xsyr") << "," << uplo << "," << n << "," << h_alpha
<< "," << (void*)dx << "," << incx << "," << (void*)da << "," << lda
<< ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f syr -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " -n " << n << " --alpha " << h_alpha << " --incx " << incx
<< " --lda " << lda << "\n";
//
// SYR2
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xsyr2") << "," << uplo << "," << n << "," << h_alpha
<< "," << (void*)dx << "," << incx << "," << (void*)dy << "," << incy << ","
<< (void*)da << "," << lda << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f syr2 -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " -n " << n << " --alpha " << h_alpha << " --lda " << lda
<< " --incx " << incx << " --incy " << incy << "\n";
//
// TBMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xtbmv") << "," << uplo << "," << transA << ","
<< diag << "," << n << "," << k << "," << (void*)da << "," << lda << "," << (void*)dx
<< "," << incx << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f tbmv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " --diag " << diag_letter
<< " -n " << n << " -k " << k << " --lda " << lda << " --incx " << incx << "\n";
//
// TPMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xtpmv") << "," << uplo << "," << transA << ","
<< diag << "," << n << "," << (void*)da << "," << (void*)dx << "," << incx
<< ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f tpmv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " --diag " << diag_letter
<< " -n " << n << " --incx " << incx << "\n";
//
// TRMV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xtrmv") << "," << uplo << "," << transA << ","
<< diag << "," << n << "," << (void*)da << "," << lda << "," << (void*)dx << ","
<< incx << ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f trmv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " --diag " << diag_letter
<< " -n " << n << " --lda " << lda << " --incx " << incx << "\n";
//
// TBSV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xtbsv") << "," << uplo << "," << transA << ","
<< diag << "," << n << "," << k << "," << (void*)da << "," << lda << "," << (void*)dx
<< "," << incx << ",atomics_allowed\n";
if(test_pointer_mode == rocblas_pointer_mode_host)
bench_ofs2 << bench.c_str() << " -f tbsv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " --diag " << diag_letter
<< " -n " << n << " -k " << k << " --lda " << lda << " --incx " << incx << "\n";
//
// TPSV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xtpsv") << "," << uplo << "," << transA << ","
<< diag << "," << n << "," << (void*)da << "," << (void*)dx << "," << incx
<< ",atomics_allowed\n";
if(test_pointer_mode == rocblas_pointer_mode_host)
bench_ofs2 << bench.c_str() << " -f tpsv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " --diag " << diag_letter
<< " -n " << n << " --incx " << incx << "\n";
//
// TRSV
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xtrsv") << "," << uplo << "," << transA << ","
<< diag << "," << n << "," << (void*)da << "," << lda << "," << (void*)dx << ","
<< incx << ",atomics_allowed\n";
if(test_pointer_mode == rocblas_pointer_mode_host)
bench_ofs2 << bench.c_str() << " -f trsv -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " --diag " << diag_letter
<< " -n " << n << " --lda " << lda << " --incx " << incx << "\n";
#if BUILD_WITH_TENSILE
{
// *************************************************** BLAS3 ***************************************************
//
// TRSM
//
trace_ofs2 << replaceX<T>(arg.api, "rocblas_Xtrsm") << "," << side << "," << uplo << ","
<< transA << "," << diag << "," << m << "," << n << "," << h_alpha << ","
<< (void*)da << "," << lda << "," << (void*)db << "," << ldb
<< ",atomics_allowed\n";
bench_ofs2 << bench.c_str() << " -f trsm -r " << rocblas_precision_string<T> << " --side "
<< side_letter << " --uplo " << uplo_letter << " --transposeA " << transA_letter
<< " --diag " << diag_letter << " -m " << m << " -n " << n << " --alpha "
<< h_alpha << " --lda " << lda << " --ldb " << ldb << "\n";
// replaceX<T>(C -> replaceX<T>(arg.api when ILP64 implemented for BLAS3
//
// GEAM
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xgeam") << "," << transA << "," << transB << "," << m
<< "," << n << "," << h_alpha << "," << (void*)da << "," << lda << "," << h_beta
<< "," << (void*)db << "," << ldb << "," << (void*)dc << "," << ldc
<< ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f geam -r "
<< rocblas_precision_string<T> << " --transposeA " << transA_letter
<< " --transposeB " << transB_letter << " -m " << m << " -n " << n << " --alpha "
<< h_alpha << " --lda " << lda << " --beta " << h_beta << " --ldb " << ldb
<< " --ldc " << ldc << "\n";
//
// GEMM
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xgemm") << "," << transA << "," << transB << "," << m
<< "," << n << "," << k << "," << h_alpha << "," << (void*)da << "," << lda
<< "," << (void*)db << "," << ldb << "," << h_beta << "," << (void*)dc << ","
<< ldc << ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f gemm -r "
<< rocblas_precision_string<T> << " --transposeA " << transA_letter
<< " --transposeB " << transB_letter << " -m " << m << " -n " << n << " -k " << k
<< " --alpha " << h_alpha << " --lda " << lda << " --ldb " << ldb << " --beta "
<< h_beta << " --ldc " << ldc << "\n";
//
// SYMM
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xsymm") << "," << side << "," << uplo << "," << m
<< "," << n << "," << h_alpha << "," << (void*)da << "," << lda << ","
<< (void*)db << "," << ldb << "," << h_beta << "," << (void*)dc << "," << ldc
<< ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f symm -r " << rocblas_precision_string<T> << " --side "
<< side_letter << " --uplo " << uplo_letter << " -m " << m << " -n " << n
<< " --alpha " << h_alpha << " --lda " << lda << " --ldb " << ldb << " --beta "
<< h_beta << " --ldc " << ldc << "\n";
//
// SYRK
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xsyrk") << "," << uplo << "," << transA << "," << n
<< "," << k << "," << h_alpha << "," << (void*)da << "," << lda << "," << h_beta
<< "," << (void*)dc << "," << ldc << ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f syrk -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " -n " << n << " -k " << k
<< " --alpha " << h_alpha << " --lda " << lda << " --beta " << h_beta
<< " --ldc " << ldc << "\n";
//
// SYR2K
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xsyr2k") << "," << uplo << "," << transA << "," << n
<< "," << k << "," << h_alpha << "," << (void*)da << "," << lda << ","
<< (void*)db << "," << ldb << "," << h_beta << "," << (void*)dc << "," << ldc
<< ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f syr2k -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " -n " << n << " -k " << k
<< " --alpha " << h_alpha << " --lda " << lda << " --ldb " << ldb << " --beta "
<< h_beta << " --ldc " << ldc << "\n";
//
// SYRKX
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xsyrkx") << "," << uplo << "," << transA << "," << n
<< "," << k << "," << h_alpha << "," << (void*)da << "," << lda << ","
<< (void*)db << "," << ldb << "," << h_beta << "," << (void*)dc << "," << ldc
<< ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f syrkx -r " << rocblas_precision_string<T> << " --uplo "
<< uplo_letter << " --transposeA " << transA_letter << " -n " << n << " -k " << k
<< " --alpha " << h_alpha << " --lda " << lda << " --ldb " << ldb << " --beta "
<< h_beta << " --ldc " << ldc << "\n";
//
// TRMM
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xtrmm") << "," << side << "," << uplo << "," << transA
<< "," << diag << "," << m << "," << n << "," << h_alpha << "," << (void*)da
<< "," << lda << "," << (void*)db << "," << ldb << "," << (void*)dc << "," << ldc
<< ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f trmm -r " << rocblas_precision_string<T> << " --side "
<< side_letter << " --uplo " << uplo_letter << " --transposeA " << transA_letter
<< " --diag " << diag_letter << " -m " << m << " -n " << n << " --alpha "
<< h_alpha << " --lda " << lda << " --ldb " << ldb << " --ldc " << ldc << "\n";
//
// GEMM_STRIDED_BATCHED
//
trace_ofs2 << replaceX<T>(C, "rocblas_Xgemm_strided_batched") << "," << transA << ","
<< transB << "," << m << "," << n << "," << k << "," << h_alpha << ","
<< (void*)da << "," << lda << "," << stride_a << "," << (void*)db << "," << ldb
<< "," << stride_b << "," << h_beta << "," << (void*)dc << "," << ldc << ","
<< stride_c << "," << batch_count << ",atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f gemm_strided_batched -r "
<< rocblas_precision_string<T> << " --transposeA " << transA_letter
<< " --transposeB " << transB_letter << " -m " << m << " -n " << n << " -k " << k
<< " --alpha " << h_alpha << " --lda " << lda << " --stride_a " << stride_a
<< " --ldb " << ldb << " --stride_b " << stride_b << " --beta " << h_beta
<< " --ldc " << ldc << " --stride_c " << stride_c << " --batch_count "
<< batch_count << "\n";
rocblas_datatype a_type, b_type, c_type, d_type, compute_type;
if(std::is_same_v<T, rocblas_half>)
{
a_type = rocblas_datatype_f16_r;
b_type = rocblas_datatype_f16_r;
c_type = rocblas_datatype_f16_r;
d_type = rocblas_datatype_f16_r;
compute_type = rocblas_datatype_f16_r;
}
else if(std::is_same_v<T, float>)
{
a_type = rocblas_datatype_f32_r;
b_type = rocblas_datatype_f32_r;
c_type = rocblas_datatype_f32_r;
d_type = rocblas_datatype_f32_r;
compute_type = rocblas_datatype_f32_r;
}
if(std::is_same_v<T, double>)
{
a_type = rocblas_datatype_f64_r;
b_type = rocblas_datatype_f64_r;
c_type = rocblas_datatype_f64_r;
d_type = rocblas_datatype_f64_r;
compute_type = rocblas_datatype_f64_r;
}
rocblas_gemm_algo algo = rocblas_gemm_algo_standard;
int32_t solution_index = 0;
uint32_t flags = 0;
//
//GEMM_EX
//
trace_ofs2 << replaceX<T>(C, "rocblas_gemm_ex") << "," << transA << "," << transB << ","
<< m << "," << n << "," << k << "," << alpha_float << "," << (void*)da << ","
<< rocblas_datatype_string(a_type) << "," << lda << "," << (void*)db << ","
<< rocblas_datatype_string(b_type) << "," << ldb << "," << beta_float << ","
<< (void*)dc << "," << rocblas_datatype_string(c_type) << "," << ldc << ","
<< (void*)dd << "," << rocblas_datatype_string(d_type) << "," << ldd << ","
<< rocblas_datatype_string(compute_type) << "," << algo << "," << solution_index
<< ",none,atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f gemm_ex"
<< " --transposeA " << transA_letter << " --transposeB " << transB_letter
<< " -m " << m << " -n " << n << " -k " << k << " --alpha " << alpha_float
<< " --a_type " << rocblas_datatype_string(a_type) << " --lda " << lda
<< " --b_type " << rocblas_datatype_string(b_type) << " --ldb " << ldb
<< " --beta " << beta_float << " --c_type " << rocblas_datatype_string(c_type)
<< " --ldc " << ldc << " --d_type " << rocblas_datatype_string(d_type)
<< " --ldd " << ldd << " --compute_type "
<< rocblas_datatype_string(compute_type) << " --algo " << algo
<< " --solution_index " << solution_index << " --flags " << flags << "\n";
//
//GEMM_STRIDED_BATCHED_EX
//
trace_ofs2 << replaceX<T>(C, "rocblas_gemm_strided_batched_ex") << "," << transA << ","
<< transB << "," << m << "," << n << "," << k << "," << alpha_float << ","
<< (void*)da << "," << rocblas_datatype_string(a_type) << "," << lda << ","
<< stride_a << "," << (void*)db << "," << rocblas_datatype_string(b_type) << ","
<< ldb << "," << stride_b << "," << beta_float << "," << (void*)dc << ","
<< rocblas_datatype_string(c_type) << "," << ldc << "," << stride_c << ","
<< (void*)dd << "," << rocblas_datatype_string(d_type) << "," << ldd << ","
<< stride_d << "," << batch_count << "," << rocblas_datatype_string(compute_type)
<< "," << algo << "," << solution_index << ",none,atomics_allowed\n";
bench_ofs2 << "./rocblas-bench -f gemm_strided_batched_ex"
<< " --transposeA " << transA_letter << " --transposeB " << transB_letter
<< " -m " << m << " -n " << n << " -k " << k << " --alpha " << alpha_float
<< " --a_type " << rocblas_datatype_string(a_type) << " --lda " << lda
<< " --stride_a " << stride_a << " --b_type " << rocblas_datatype_string(b_type)
<< " --ldb " << ldb << " --stride_b " << stride_b << " --beta " << beta_float
<< " --c_type " << rocblas_datatype_string(c_type) << " --ldc " << ldc
<< " --stride_c " << stride_c << " --d_type " << rocblas_datatype_string(d_type)
<< " --ldd " << ldd << " --stride_d " << stride_d << " --batch_count "
<< batch_count << " --compute_type " << rocblas_datatype_string(compute_type)
<< " --algo " << algo << " --solution_index " << solution_index << " --flags "
<< flags << "\n";
}
#endif // BUILD_WITH_TENSILE
// exclude trtri as it is an internal function
// trace_ofs2 << "\n" << replaceX<T>("rocblas_Xtrtri") << "," << uplo << "," << diag << "," <<
// n
// << "," << (void*)da << "," << lda << "," << (void*)db << "," << ldb;
// Auxiliary function
trace_ofs2 << "rocblas_destroy_handle,atomics_allowed\n";
// Flush the streams
trace_ofs2.flush();
bench_ofs2.flush();
// Transfer the formatted output to the files
trace_ofs << trace_ofs2;
bench_ofs << bench_ofs2;
// Flush the streams
trace_ofs.flush();
bench_ofs.flush();
// Close the files
trace_ofs.close();
bench_ofs.close();
//
// check if rocBLAS output files same as "golden files"
//
#ifdef WIN32
// need all file descriptors closed to allow file removal on windows before process exits
rocblas_internal_ostream::clear_workers();
int trace_cmp = diff_files(trace_path1, trace_path2);
//int trace_cmp = system(("fc.exe \"" + trace_path1 + "\" \"" + trace_path2 + "\" | findstr *****").c_str());
#else
int trace_cmp = system(("/usr/bin/diff " + trace_path1 + " " + trace_path2).c_str());
#endif
#ifdef GOOGLE_TEST
ASSERT_EQ(trace_cmp, 0);
#endif
if(!trace_cmp)
{
fs::remove(trace_fspath1);
fs::remove(trace_fspath2);
}
#ifdef WIN32
int bench_cmp = diff_files(bench_path1, bench_path2);
//int bench_cmp = system(("fc.exe \"" + bench_path1 + "\" \"" + bench_path2 + "\" | findstr *****").c_str());
#else
int bench_cmp = system(("/usr/bin/diff " + bench_path1 + " " + bench_path2).c_str());
#endif
#ifdef GOOGLE_TEST
ASSERT_EQ(bench_cmp, 0);
#endif
if(!bench_cmp)
{
fs::remove(bench_fspath1);
fs::remove(bench_fspath2);
}
}
|