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
|
//------------------------------------------------------------------------------
// GB_AxB_saxpy3_symbolic: symbolic analysis for GB_AxB_saxpy3
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// Symbolic analysis for C=A*B, C<M>=A*B or C<!M>=A*B, via GB_AxB_saxpy3.
// Coarse tasks compute nnz (C (:,j)) for each of their vectors j. Fine tasks
// just scatter the mask M into the hash table. This phase does not depend on
// the semiring, nor does it depend on the type of C, A, or B. It does access
// the values of M, if the mask matrix M is present and not structural.
// If B is hypersparse, C must also be hypersparse.
// Otherwise, C must be sparse.
// If both A and B are bitmap/full for C=A*B or C<!M>=A*B, then saxpy3 is
// not used. C is selected as bitmap instead.
#include "GB_AxB_saxpy3.h"
void GB_AxB_saxpy3_symbolic
(
GrB_Matrix C, // Cp is computed for coarse tasks
const GrB_Matrix M, // mask matrix M
const bool Mask_comp, // M complemented, or not
const bool Mask_struct, // M structural, or not
const bool M_in_place,
const GrB_Matrix A, // A matrix; only the pattern is accessed
const GrB_Matrix B, // B matrix; only the pattern is accessed
GB_saxpy3task_struct *SaxpyTasks, // list of tasks, and workspace
const int ntasks, // total number of tasks
const int nfine, // number of fine tasks
const int nthreads // number of threads
)
{
//--------------------------------------------------------------------------
// check inputs
//--------------------------------------------------------------------------
ASSERT (!GB_ZOMBIES (M)) ;
ASSERT (GB_JUMBLED_OK (M)) ;
ASSERT (!GB_PENDING (M)) ;
ASSERT (!GB_ZOMBIES (A)) ;
ASSERT (GB_JUMBLED_OK (A)) ;
ASSERT (!GB_PENDING (A)) ;
ASSERT (!GB_ZOMBIES (B)) ;
ASSERT (GB_JUMBLED_OK (B)) ;
ASSERT (!GB_PENDING (B)) ;
const bool A_is_sparse = GB_IS_SPARSE (A) ;
const bool A_is_hyper = GB_IS_HYPERSPARSE (A) ;
const bool A_is_bitmap = GB_IS_BITMAP (A) ;
const bool B_is_sparse = GB_IS_SPARSE (B) ;
const bool B_is_hyper = GB_IS_HYPERSPARSE (B) ;
const bool B_is_bitmap = GB_IS_BITMAP (B) ;
//==========================================================================
// phase1: count nnz(C(:,j)) for coarse tasks, scatter M for fine tasks
//==========================================================================
if (M == NULL)
{
//----------------------------------------------------------------------
// C = A*B
//----------------------------------------------------------------------
if (A_is_sparse)
{
if (B_is_sparse)
{
// both A and B are sparse
GB_AxB_saxpy3_sym_ss (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// A is sparse and B is hyper
GB_AxB_saxpy3_sym_sh (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// A is sparse and B is bitmap
GB_AxB_saxpy3_sym_sb (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is sparse and B is full
GB_AxB_saxpy3_sym_sf (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else if (A_is_hyper)
{
if (B_is_sparse)
{
// A is hyper and B is sparse
GB_AxB_saxpy3_sym_hs (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// both A and B are hyper
GB_AxB_saxpy3_sym_hh (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// A is hyper and B is bitmap
GB_AxB_saxpy3_sym_hb (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is hyper and B is full
GB_AxB_saxpy3_sym_hf (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else if (A_is_bitmap)
{
// C=A*B where A is bitmap; B must be sparse/hyper
if (B_is_sparse)
{
// A is bitmap and B is sparse
GB_AxB_saxpy3_sym_bs (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is bitmap and B is hyper
ASSERT (B_is_hyper) ;
GB_AxB_saxpy3_sym_bh (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else
{
// C=A*B where A is full; B must be sparse/hyper
if (B_is_sparse)
{
// A is full and B is sparse
GB_AxB_saxpy3_sym_fs (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is full and B is hyper
ASSERT (B_is_hyper) ;
GB_AxB_saxpy3_sym_fh (C,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
}
else if (!Mask_comp)
{
//----------------------------------------------------------------------
// C<M> = A*B
//----------------------------------------------------------------------
if (A_is_sparse)
{
if (B_is_sparse)
{
// both A and B are sparse
GB_AxB_saxpy3_sym_mss (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// A is sparse and B is hyper
GB_AxB_saxpy3_sym_msh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// A is sparse and B is bitmap
GB_AxB_saxpy3_sym_msb (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is sparse and B is full
GB_AxB_saxpy3_sym_msf (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else if (A_is_hyper)
{
if (B_is_sparse)
{
// A is hyper and B is sparse
GB_AxB_saxpy3_sym_mhs (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// both A and B are hyper
GB_AxB_saxpy3_sym_mhh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// A is hyper and B is bitmap
GB_AxB_saxpy3_sym_mhb (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is hyper and B is full
GB_AxB_saxpy3_sym_mhf (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else if (A_is_bitmap)
{
if (B_is_sparse)
{
// A is bitmap and B is sparse
GB_AxB_saxpy3_sym_mbs (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// A is bitmap and B is hyper
GB_AxB_saxpy3_sym_mbh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// both A and B are bitmap
GB_AxB_saxpy3_sym_mbb (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is bitmap and B is full
GB_AxB_saxpy3_sym_mbf (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else
{
if (B_is_sparse)
{
// A is full and B is sparse
GB_AxB_saxpy3_sym_mfs (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// A is full and B is hyper
GB_AxB_saxpy3_sym_mfh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// A is full and B is bitmap
GB_AxB_saxpy3_sym_mfb (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// both A and B are full
GB_AxB_saxpy3_sym_mff (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
}
else
{
//----------------------------------------------------------------------
// C<!M> = A*B
//----------------------------------------------------------------------
if (A_is_sparse)
{
if (B_is_sparse)
{
// both A and B are sparse
GB_AxB_saxpy3_sym_nss (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// A is sparse and B is hyper
GB_AxB_saxpy3_sym_nsh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// A is sparse and B is bitmap
GB_AxB_saxpy3_sym_nsb (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is sparse and B is full
GB_AxB_saxpy3_sym_nsf (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else if (A_is_hyper)
{
if (B_is_sparse)
{
// A is hyper and B is sparse
GB_AxB_saxpy3_sym_nhs (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_hyper)
{
// both A and B are hyper
GB_AxB_saxpy3_sym_nhh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else if (B_is_bitmap)
{
// A is hyper and B is bitmap
GB_AxB_saxpy3_sym_nhb (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is hyper and B is full
GB_AxB_saxpy3_sym_nhf (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else if (A_is_bitmap)
{
// C<!M>=A*B where A is bitmap; B must be sparse/hyper
if (B_is_sparse)
{
// A is bitmap and B is sparse
GB_AxB_saxpy3_sym_nbs (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is bitmap and B is hyper
ASSERT (B_is_hyper) ;
GB_AxB_saxpy3_sym_nbh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
else
{
// C<!M>=A*B where A is full; B must be sparse/hyper
if (B_is_sparse)
{
// A is full and B is sparse
GB_AxB_saxpy3_sym_nfs (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
else
{
// A is full and B is hyper
ASSERT (B_is_hyper) ;
GB_AxB_saxpy3_sym_nfh (C, M, Mask_struct, M_in_place,
A, B, SaxpyTasks, ntasks, nfine, nthreads) ;
}
}
}
}
|