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
|
//------------------------------------------------------------------------------
// GB_AxB__any_pair_iso.c: matrix multiply for a single semiring
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// If this file is in the Generated1/ or Generated2/ folder, do not edit it
// (it is auto-generated from Generator/*).
#include "GB_dev.h"
#if 1
#include "GB.h"
#include "GB_control.h"
#include "GB_sort.h"
#include "GB_atomics.h"
#include "GB_AxB_saxpy.h"
#if 0
#include "GB_AxB__include2.h"
#else
#include "GB_AxB__include1.h"
#endif
#include "GB_unused.h"
#include "GB_bitmap_assign_methods.h"
#include "GB_ek_slice_search.c"
// This C=A*B semiring is defined by the following types and operators:
// A'*B (dot2): GB (_Adot2B__any_pair_iso)
// A'*B (dot3): GB (_Adot3B__any_pair_iso)
// C+=A'*B (dot4): GB (_Adot4B__(none))
// A*B (saxpy bitmap): GB (_AsaxbitB__any_pair_iso)
// A*B (saxpy3): GB (_Asaxpy3B__any_pair_iso)
// no mask: GB (_Asaxpy3B_noM__any_pair_iso)
// mask M: GB (_Asaxpy3B_M__any_pair_iso)
// mask !M: GB (_Asaxpy3B_notM__any_pair_iso)
// A*B (saxpy4): GB (_Asaxpy4B__(none))
// A*B (saxpy5): GB (_Asaxpy5B__(none))
// C type: iso
// A type: any type
// A pattern? 1
// B type: any type
// B pattern? 1
// Multiply:
// Add: ;
// 'any' monoid? 1
// atomic? 1
// OpenMP atomic? 1
// identity:
// terminal? 1
// terminal condition: break ;
// MultAdd:
#define GB_ATYPE \
any type
#define GB_BTYPE \
any type
#define GB_CTYPE \
iso
#define GB_ASIZE \
0
#define GB_BSIZE \
0
#define GB_CSIZE \
0
// # of bits in the type of C, for AVX2 and AVX512F
#define GB_CNBITS \
0
// true for int64, uint64, float, double, float complex, and double complex
#define GB_CTYPE_IGNORE_OVERFLOW \
1
// aik = Ax [pA]
#define GB_GETA(aik,Ax,pA,A_iso) \
;
// true if values of A are not used
#define GB_A_IS_PATTERN \
1 \
// bkj = Bx [pB]
#define GB_GETB(bkj,Bx,pB,B_iso) \
;
// true if values of B are not used
#define GB_B_IS_PATTERN \
1 \
// Gx [pG] = Ax [pA]
#define GB_LOADA(Gx,pG,Ax,pA,A_iso) \
;
// Gx [pG] = Bx [pB]
#define GB_LOADB(Gx,pG,Bx,pB,B_iso) \
;
#define GB_CX(p) \
// multiply operator
#define GB_MULT(z, x, y, i, k, j) \
// cast from a real scalar (or 2, if C is complex) to the type of C
#define GB_CTYPE_CAST(x,y) \
// cast from a real scalar (or 2, if A is complex) to the type of A
#define GB_ATYPE_CAST(x,y) \
// multiply-add
#define GB_MULTADD(z, x, y, i, k, j) \
// monoid identity value
#define GB_IDENTITY \
// 1 if the identity value can be assigned via memset, with all bytes the same
#define GB_HAS_IDENTITY_BYTE \
0
// identity byte, for memset
#define GB_IDENTITY_BYTE \
(none)
// true if the monoid has a terminal value
#define GB_MONOID_IS_TERMINAL \
1
// break if cij reaches the terminal value (dot product only)
#define GB_DOT_TERMINAL(cij) \
break ;
// simd pragma for dot-product loop vectorization
#define GB_PRAGMA_SIMD_DOT(cij) \
;
// simd pragma for other loop vectorization
#define GB_PRAGMA_SIMD_VECTORIZE GB_PRAGMA_SIMD
// 1 for the PLUS_PAIR_(real) semirings, not for the complex case
#define GB_IS_PLUS_PAIR_REAL_SEMIRING \
0
// 1 if the semiring is accelerated with AVX2 or AVX512f
#define GB_SEMIRING_HAS_AVX_IMPLEMENTATION \
0
// declare the cij scalar (initialize cij to zero for PLUS_PAIR)
#define GB_CIJ_DECLARE(cij) \
// Cx [pC] = cij
#define GB_PUTC(cij,p) \
// Cx [p] = t
#define GB_CIJ_WRITE(p,t) \
// C(i,j) += t
#define GB_CIJ_UPDATE(p,t) \
;
// x + y
#define GB_ADD_FUNCTION(x,y) \
// bit pattern for bool, 8-bit, 16-bit, and 32-bit integers
#define GB_CTYPE_BITS \
0
// 1 if monoid update can skipped entirely (the ANY monoid)
#define GB_IS_ANY_MONOID \
1
// 1 if monoid update is EQ
#define GB_IS_EQ_MONOID \
0
// 1 if monoid update can be done atomically, 0 otherwise
#define GB_HAS_ATOMIC \
1
// 1 if monoid update can be done with an OpenMP atomic update, 0 otherwise
#if GB_COMPILER_MSC
/* MS Visual Studio only has OpenMP 2.0, with fewer atomics */
#define GB_HAS_OMP_ATOMIC \
0
#else
#define GB_HAS_OMP_ATOMIC \
1
#endif
// 1 for the ANY_PAIR_ISO semiring
#define GB_IS_ANY_PAIR_SEMIRING \
1
// 1 if PAIR is the multiply operator
#define GB_IS_PAIR_MULTIPLIER \
1
// 1 if monoid is PLUS_FC32
#define GB_IS_PLUS_FC32_MONOID \
0
// 1 if monoid is PLUS_FC64
#define GB_IS_PLUS_FC64_MONOID \
0
// 1 if monoid is ANY_FC32
#define GB_IS_ANY_FC32_MONOID \
0
// 1 if monoid is ANY_FC64
#define GB_IS_ANY_FC64_MONOID \
0
// 1 if monoid is MIN for signed or unsigned integers
#define GB_IS_IMIN_MONOID \
0
// 1 if monoid is MAX for signed or unsigned integers
#define GB_IS_IMAX_MONOID \
0
// 1 if monoid is MIN for float or double
#define GB_IS_FMIN_MONOID \
0
// 1 if monoid is MAX for float or double
#define GB_IS_FMAX_MONOID \
0
// 1 for the FIRSTI or FIRSTI1 multiply operator
#define GB_IS_FIRSTI_MULTIPLIER \
0
// 1 for the FIRSTJ or FIRSTJ1 multiply operator
#define GB_IS_FIRSTJ_MULTIPLIER \
0
// 1 for the SECONDJ or SECONDJ1 multiply operator
#define GB_IS_SECONDJ_MULTIPLIER \
0
// 1 for the FIRSTI1, FIRSTJ1, SECONDI1, or SECONDJ1 multiply operators
#define GB_OFFSET \
0
// atomic compare-exchange
#define GB_ATOMIC_COMPARE_EXCHANGE(target, expected, desired) \
;
// Hx [i] = t
#define GB_HX_WRITE(i,t) \
;
// Cx [p] = Hx [i]
#define GB_CIJ_GATHER(p,i) \
;
// Cx [p] += Hx [i]
#define GB_CIJ_GATHER_UPDATE(p,i) \
;
// Hx [i] += t
#define GB_HX_UPDATE(i,t) \
;
// memcpy (&(Cx [p]), &(Hx [i]), len)
#define GB_CIJ_MEMCPY(p,i,len) \
;
// disable this semiring and use the generic case if these conditions hold
#define GB_DISABLE \
0
//------------------------------------------------------------------------------
// GB_Adot2B: C=A'*B, C<M>=A'*B, or C<!M>=A'*B: dot product method, C is bitmap
//------------------------------------------------------------------------------
// if A_not_transposed is true, then C=A*B is computed where A is bitmap or full
GrB_Info GB (_Adot2B__any_pair_iso)
(
GrB_Matrix C,
const GrB_Matrix M, const bool Mask_comp, const bool Mask_struct,
const bool A_not_transposed,
const GrB_Matrix A, int64_t *restrict A_slice,
const GrB_Matrix B, int64_t *restrict B_slice,
int nthreads, int naslice, int nbslice
)
{
#if 0
return (GrB_NO_VALUE) ;
#else
#include "GB_AxB_dot2_meta.c"
return (GrB_SUCCESS) ;
#endif
}
//------------------------------------------------------------------------------
// GB_Adot3B: C<M>=A'*B: masked dot product, C is sparse or hyper
//------------------------------------------------------------------------------
GrB_Info GB (_Adot3B__any_pair_iso)
(
GrB_Matrix C,
const GrB_Matrix M, const bool Mask_struct,
const GrB_Matrix A,
const GrB_Matrix B,
const GB_task_struct *restrict TaskList,
const int ntasks,
const int nthreads
)
{
#if 0
return (GrB_NO_VALUE) ;
#else
#include "GB_AxB_dot3_meta.c"
return (GrB_SUCCESS) ;
#endif
}
//------------------------------------------------------------------------------
// GB_Adot4B: C+=A'*B: dense dot product (not used for ANY_PAIR_ISO)
//------------------------------------------------------------------------------
#if 0
GrB_Info GB (_Adot4B__(none))
(
GrB_Matrix C,
const GrB_Matrix A, int64_t *restrict A_slice, int naslice,
const GrB_Matrix B, int64_t *restrict B_slice, int nbslice,
const int nthreads,
GB_Context Context
)
{
#if 0
return (GrB_NO_VALUE) ;
#else
#include "GB_AxB_dot4_meta.c"
return (GrB_SUCCESS) ;
#endif
}
#endif
//------------------------------------------------------------------------------
// GB_AsaxbitB: C=A*B, C<M>=A*B, C<!M>=A*B: saxpy method, C is bitmap/full
//------------------------------------------------------------------------------
#include "GB_AxB_saxpy3_template.h"
GrB_Info GB (_AsaxbitB__any_pair_iso)
(
GrB_Matrix C, // bitmap or full
const GrB_Matrix M, const bool Mask_comp, const bool Mask_struct,
const GrB_Matrix A,
const GrB_Matrix B,
GB_Context Context
)
{
#if 0
return (GrB_NO_VALUE) ;
#else
#include "GB_bitmap_AxB_saxpy_template.c"
return (GrB_SUCCESS) ;
#endif
}
//------------------------------------------------------------------------------
// GB_Asaxpy4B: C += A*B when C is full
//------------------------------------------------------------------------------
#if 0
GrB_Info GB (_Asaxpy4B__(none))
(
GrB_Matrix C,
const GrB_Matrix A,
const GrB_Matrix B,
const int ntasks,
const int nthreads,
const int nfine_tasks_per_vector,
const bool use_coarse_tasks,
const bool use_atomics,
const int64_t *A_slice,
GB_Context Context
)
{
#if 0
return (GrB_NO_VALUE) ;
#else
#include "GB_AxB_saxpy4_template.c"
return (GrB_SUCCESS) ;
#endif
}
#endif
//------------------------------------------------------------------------------
// GB_Asaxpy5B: C += A*B when C is full, A is bitmap/full, B is sparse/hyper
//------------------------------------------------------------------------------
#if 0
#if 0
#elif ( !GB_A_IS_PATTERN )
//----------------------------------------------------------------------
// saxpy5 method with vectors of length 8 for double, 16 for single
//----------------------------------------------------------------------
// AVX512F: vector registers are 512 bits, or 64 bytes, which can hold
// 16 floats or 8 doubles.
#define GB_V16_512 (16 * GB_CNBITS <= 512)
#define GB_V8_512 ( 8 * GB_CNBITS <= 512)
#define GB_V4_512 ( 4 * GB_CNBITS <= 512)
#define GB_V16 GB_V16_512
#define GB_V8 GB_V8_512
#define GB_V4 GB_V4_512
#if GB_SEMIRING_HAS_AVX_IMPLEMENTATION && GB_COMPILER_SUPPORTS_AVX512F \
&& GB_V4_512
GB_TARGET_AVX512F static inline void GB_AxB_saxpy5_unrolled_avx512f
(
GrB_Matrix C,
const GrB_Matrix A,
const GrB_Matrix B,
const int ntasks,
const int nthreads,
const int64_t *B_slice,
GB_Context Context
)
{
#include "GB_AxB_saxpy5_unrolled.c"
}
#endif
//----------------------------------------------------------------------
// saxpy5 method with vectors of length 4 for double, 8 for single
//----------------------------------------------------------------------
// AVX2: vector registers are 256 bits, or 32 bytes, which can hold
// 8 floats or 4 doubles.
#define GB_V16_256 (16 * GB_CNBITS <= 256)
#define GB_V8_256 ( 8 * GB_CNBITS <= 256)
#define GB_V4_256 ( 4 * GB_CNBITS <= 256)
#undef GB_V16
#undef GB_V8
#undef GB_V4
#define GB_V16 GB_V16_256
#define GB_V8 GB_V8_256
#define GB_V4 GB_V4_256
#if GB_SEMIRING_HAS_AVX_IMPLEMENTATION && GB_COMPILER_SUPPORTS_AVX2 \
&& GB_V4_256
GB_TARGET_AVX2 static inline void GB_AxB_saxpy5_unrolled_avx2
(
GrB_Matrix C,
const GrB_Matrix A,
const GrB_Matrix B,
const int ntasks,
const int nthreads,
const int64_t *B_slice,
GB_Context Context
)
{
#include "GB_AxB_saxpy5_unrolled.c"
}
#endif
//----------------------------------------------------------------------
// saxpy5 method unrolled, with no vectors
//----------------------------------------------------------------------
#undef GB_V16
#undef GB_V8
#undef GB_V4
#define GB_V16 0
#define GB_V8 0
#define GB_V4 0
static inline void GB_AxB_saxpy5_unrolled_vanilla
(
GrB_Matrix C,
const GrB_Matrix A,
const GrB_Matrix B,
const int ntasks,
const int nthreads,
const int64_t *B_slice,
GB_Context Context
)
{
#include "GB_AxB_saxpy5_unrolled.c"
}
#endif
GrB_Info GB (_Asaxpy5B__(none))
(
GrB_Matrix C,
const GrB_Matrix A,
const GrB_Matrix B,
const int ntasks,
const int nthreads,
const int64_t *B_slice,
GB_Context Context
)
{
#if 0
return (GrB_NO_VALUE) ;
#else
#include "GB_AxB_saxpy5_meta.c"
return (GrB_SUCCESS) ;
#endif
}
#endif
//------------------------------------------------------------------------------
// GB_Asaxpy3B: C=A*B, C<M>=A*B, C<!M>=A*B: saxpy method (Gustavson + Hash)
//------------------------------------------------------------------------------
GrB_Info GB (_Asaxpy3B__any_pair_iso)
(
GrB_Matrix C, // C<any M>=A*B, C sparse or hypersparse
const GrB_Matrix M, const bool Mask_comp, const bool Mask_struct,
const bool M_in_place,
const GrB_Matrix A,
const GrB_Matrix B,
GB_saxpy3task_struct *restrict SaxpyTasks,
const int ntasks, const int nfine, const int nthreads, const int do_sort,
GB_Context Context
)
{
#if 0
return (GrB_NO_VALUE) ;
#else
ASSERT (GB_IS_SPARSE (C) || GB_IS_HYPERSPARSE (C)) ;
if (M == NULL)
{
// C = A*B, no mask
return (GB (_Asaxpy3B_noM__any_pair_iso) (C, A, B,
SaxpyTasks, ntasks, nfine, nthreads, do_sort, Context)) ;
}
else if (!Mask_comp)
{
// C<M> = A*B
return (GB (_Asaxpy3B_M__any_pair_iso) (C,
M, Mask_struct, M_in_place, A, B,
SaxpyTasks, ntasks, nfine, nthreads, do_sort, Context)) ;
}
else
{
// C<!M> = A*B
return (GB (_Asaxpy3B_notM__any_pair_iso) (C,
M, Mask_struct, M_in_place, A, B,
SaxpyTasks, ntasks, nfine, nthreads, do_sort, Context)) ;
}
#endif
}
//------------------------------------------------------------------------------
// GB_Asaxpy3B_M: C<M>=A*B: saxpy method (Gustavson + Hash)
//------------------------------------------------------------------------------
#if 1
GrB_Info GB (_Asaxpy3B_M__any_pair_iso)
(
GrB_Matrix C, // C<M>=A*B, C sparse or hypersparse
const GrB_Matrix M, const bool Mask_struct,
const bool M_in_place,
const GrB_Matrix A,
const GrB_Matrix B,
GB_saxpy3task_struct *restrict SaxpyTasks,
const int ntasks, const int nfine, const int nthreads,
const int do_sort,
GB_Context Context
)
{
if (GB_IS_SPARSE (A) && GB_IS_SPARSE (B))
{
// both A and B are sparse
#define GB_META16
#define GB_NO_MASK 0
#define GB_MASK_COMP 0
#define GB_A_IS_SPARSE 1
#define GB_A_IS_HYPER 0
#define GB_A_IS_BITMAP 0
#define GB_A_IS_FULL 0
#define GB_B_IS_SPARSE 1
#define GB_B_IS_HYPER 0
#define GB_B_IS_BITMAP 0
#define GB_B_IS_FULL 0
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
else
{
// general case
#undef GB_META16
#define GB_NO_MASK 0
#define GB_MASK_COMP 0
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
return (GrB_SUCCESS) ;
}
#endif
//------------------------------------------------------------------------------
//GB_Asaxpy3B_noM: C=A*B: saxpy method (Gustavson + Hash)
//------------------------------------------------------------------------------
#if 1
GrB_Info GB (_Asaxpy3B_noM__any_pair_iso)
(
GrB_Matrix C, // C=A*B, C sparse or hypersparse
const GrB_Matrix A,
const GrB_Matrix B,
GB_saxpy3task_struct *restrict SaxpyTasks,
const int ntasks, const int nfine, const int nthreads,
const int do_sort,
GB_Context Context
)
{
if (GB_IS_SPARSE (A) && GB_IS_SPARSE (B))
{
// both A and B are sparse
#define GB_META16
#define GB_NO_MASK 1
#define GB_MASK_COMP 0
#define GB_A_IS_SPARSE 1
#define GB_A_IS_HYPER 0
#define GB_A_IS_BITMAP 0
#define GB_A_IS_FULL 0
#define GB_B_IS_SPARSE 1
#define GB_B_IS_HYPER 0
#define GB_B_IS_BITMAP 0
#define GB_B_IS_FULL 0
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
else
{
// general case
#undef GB_META16
#define GB_NO_MASK 1
#define GB_MASK_COMP 0
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
return (GrB_SUCCESS) ;
}
#endif
//------------------------------------------------------------------------------
//GB_Asaxpy3B_notM: C<!M>=A*B: saxpy method (Gustavson + Hash)
//------------------------------------------------------------------------------
#if 1
GrB_Info GB (_Asaxpy3B_notM__any_pair_iso)
(
GrB_Matrix C, // C<!M>=A*B, C sparse or hypersparse
const GrB_Matrix M, const bool Mask_struct,
const bool M_in_place,
const GrB_Matrix A,
const GrB_Matrix B,
GB_saxpy3task_struct *restrict SaxpyTasks,
const int ntasks, const int nfine, const int nthreads,
const int do_sort,
GB_Context Context
)
{
if (GB_IS_SPARSE (A) && GB_IS_SPARSE (B))
{
// both A and B are sparse
#define GB_META16
#define GB_NO_MASK 0
#define GB_MASK_COMP 1
#define GB_A_IS_SPARSE 1
#define GB_A_IS_HYPER 0
#define GB_A_IS_BITMAP 0
#define GB_A_IS_FULL 0
#define GB_B_IS_SPARSE 1
#define GB_B_IS_HYPER 0
#define GB_B_IS_BITMAP 0
#define GB_B_IS_FULL 0
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
else
{
// general case
#undef GB_META16
#define GB_NO_MASK 0
#define GB_MASK_COMP 1
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
return (GrB_SUCCESS) ;
}
#endif
#endif
|