File: GB_reduce_to_scalar_cuda_branch.cpp

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (40 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (2)
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

// Decide branch direction for GPU use for the dot-product MxM
#include "GB_cuda.h"

bool GB_reduce_to_scalar_cuda_branch 
(
    const GrB_Monoid reduce,        // monoid to do the reduction
    const GrB_Matrix A,             // input matrix
    GB_Context Context
)
{

    // work to do
    double work = GB_nnz (A) ;

    int ngpus_to_use = GB_ngpus_to_use (work) ;
    GBURBLE (" work:%g gpus:%d ", work, ngpus_to_use) ;

    GB_Opcode opcode = reduce->op->opcode ;

    if (ngpus_to_use > 0
        // do it on the CPU if the monoid operator is user-defined:
        // FIXME: handle user-defined operators
        && (opcode != GB_USER_binop_code)
        // the ANY monoid takes O(1) time; do it on the CPU:
        && (opcode != GB_ANY_binop_code)
        // FIXME: handle user-defined types:
        && (A->type->code != GB_UDT_code)
        // A iso takes O(log(nvals(A))) time; do it on the CPU:
        && !A->iso
    )
    {
        return true;
    }
    else
    { 
        return false;
    }
}