1 //------------------------------------------------------------------------------
2 // GB_red:  hard-coded functions for reductions
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7 
8 //------------------------------------------------------------------------------
9 
10 // If this file is in the Generated/ folder, do not edit it (auto-generated).
11 
12 #include "GB.h"
13 #ifndef GBCOMPACT
14 #include "GB_atomics.h"
15 #include "GB_control.h"
16 #include "GB_red__include.h"
17 
18 // The reduction is defined by the following types and operators:
19 
20 // Assemble tuples:    GB (_red_build__times_fp64)
21 // Reduce to scalar:   GB (_red_scalar__times_fp64)
22 
23 // A type:   double
24 // C type:   double
25 
26 // Reduce:   s *= aij
27 // Identity: 1
28 // Terminal: ;
29 
30 #define GB_ATYPE \
31     double
32 
33 #define GB_CTYPE \
34     double
35 
36 // monoid identity value
37 
38     #define GB_IDENTITY \
39         1
40 
41 // declare a scalar and set it equal to the monoid identity value
42 
43     #define GB_SCALAR_IDENTITY(s)                   \
44         double s = GB_IDENTITY
45 
46 // Array to array
47 
48     // W [k] = (ztype) S [i], with typecast
49     #define GB_CAST_ARRAY_TO_ARRAY(W,k,S,i)         \
50         W [k] = S [i]
51 
52     // W [k] += (ztype) S [i], with typecast
53     #define GB_ADD_CAST_ARRAY_TO_ARRAY(W,k,S,i)     \
54         W [k] *= S [i]
55 
56     // W [k] = S [i], no typecast
57     #define GB_COPY_ARRAY_TO_ARRAY(W,k,S,i)         \
58         W [k] = S [i]
59 
60     // W [k] += S [i], no typecast
61     #define GB_ADD_ARRAY_TO_ARRAY(W,k,S,i)          \
62         W [k] *= S [i]
63 
64 // Array to scalar
65 
66     // s = (ztype) Ax [p], with typecast
67     #define GB_CAST_ARRAY_TO_SCALAR(s,Ax,p)         \
68         s = Ax [p]
69 
70     // s = W [k], no typecast
71     #define GB_COPY_ARRAY_TO_SCALAR(s,W,k)          \
72         s = W [k]
73 
74     // s += (ztype) Ax [p], with typecast
75     #define GB_ADD_CAST_ARRAY_TO_SCALAR(s,Ax,p)     \
76         s *= Ax [p]
77 
78     // s += S [i], no typecast
79     #define GB_ADD_ARRAY_TO_SCALAR(s,S,i)           \
80         s *= S [i]
81 
82 // Scalar to array
83 
84     // W [k] = s, no typecast
85     #define GB_COPY_SCALAR_TO_ARRAY(W,k,s)          \
86         W [k] = s
87 
88     // W [k] += s, no typecast
89     #define GB_ADD_SCALAR_TO_ARRAY(W,k,s)           \
90         W [k] *= s
91 
92 // break the loop if terminal condition reached
93 
94     #define GB_HAS_TERMINAL                         \
95         0
96 
97     #define GB_IS_TERMINAL(s)                       \
98         (none)
99 
100     #define GB_TERMINAL_VALUE                       \
101         (none)
102 
103     #define GB_BREAK_IF_TERMINAL(s)                 \
104         ;
105 
106 // panel size for built-in operators
107 
108     #define GB_PANEL                                \
109         32
110 
111 // special case for the ANY monoid
112 
113     #define GB_IS_ANY_MONOID                        \
114         0
115 
116 // disable this operator and use the generic case if these conditions hold
117 #define GB_DISABLE \
118     (GxB_NO_TIMES || GxB_NO_FP64 || GxB_NO_TIMES_FP64)
119 
120 //------------------------------------------------------------------------------
121 // reduce to a scalar, for monoids only
122 //------------------------------------------------------------------------------
123 
124 
125 
GB(_red_scalar__times_fp64)126 GrB_Info GB (_red_scalar__times_fp64)
127 (
128     double *result,
129     const GrB_Matrix A,
130     GB_void *restrict W_space,
131     bool *restrict F,
132     int ntasks,
133     int nthreads
134 )
135 {
136     #if GB_DISABLE
137     return (GrB_NO_VALUE) ;
138     #else
139     double s = (*result) ;
140     double *restrict W = (double *) W_space ;
141     if (A->nzombies > 0 || GB_IS_BITMAP (A))
142     {
143         #include "GB_reduce_to_scalar_template.c"
144     }
145     else
146     {
147         #include "GB_reduce_panel.c"
148     }
149     (*result) = s ;
150     return (GrB_SUCCESS) ;
151     #endif
152 }
153 
154 
155 
156 //------------------------------------------------------------------------------
157 // build matrix
158 //------------------------------------------------------------------------------
159 
GB(_red_build__times_fp64)160 GrB_Info GB (_red_build__times_fp64)
161 (
162     double *restrict Tx,
163     int64_t  *restrict Ti,
164     const double *restrict S,
165     int64_t nvals,
166     int64_t ndupl,
167     const int64_t *restrict I_work,
168     const int64_t *restrict K_work,
169     const int64_t *restrict tstart_slice,
170     const int64_t *restrict tnz_slice,
171     int nthreads
172 )
173 {
174     #if GB_DISABLE
175     return (GrB_NO_VALUE) ;
176     #else
177     #include "GB_reduce_build_template.c"
178     return (GrB_SUCCESS) ;
179     #endif
180 }
181 
182 #endif
183 
184