Skip to content

Commit 3bd364c

Browse files
committed
Implementation in bsp1d
1 parent 1a48c65 commit 3bd364c

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

include/graphblas/bsp1d/blas3.hpp

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,161 @@ namespace grb {
205205
return internal::checkGlobalErrorStateOrClear( C, ret );
206206
}
207207

208+
template<
209+
Descriptor descr = descriptors::no_operation,
210+
class Monoid,
211+
typename IOType, typename MaskType, typename InputType,
212+
typename RIT_A, typename CIT_A, typename NIT_A,
213+
typename RIT_M, typename CIT_M, typename NIT_M,
214+
typename RIT_B, typename CIT_B, typename NIT_B
215+
>
216+
RC foldl(
217+
Matrix< IOType, BSP1D, RIT_A, CIT_A, NIT_A > &A,
218+
const Matrix< MaskType, BSP1D, RIT_M, CIT_M, NIT_M > &mask,
219+
const Matrix< InputType, BSP1D, RIT_B, CIT_B, NIT_B > &B,
220+
const Monoid &monoid = Monoid(),
221+
const typename std::enable_if<
222+
!grb::is_object< IOType >::value &&
223+
!grb::is_object< InputType >::value &&
224+
!grb::is_object< MaskType >::value &&
225+
grb::is_monoid< Monoid >::value, void
226+
>::type * const = nullptr
227+
) {
228+
229+
#ifdef _DEBUG
230+
std::cout << "In grb::foldl( BSP1D, matrix, mask, matrix, monoid )\n";
231+
#endif
232+
RC rc = SUCCESS;
233+
234+
if( grb::nnz( A ) == 0 || grb::nnz( mask ) == 0 ) {
235+
return rc;
236+
}
237+
238+
// Do local folding
239+
rc = foldl< descr >(
240+
internal::getLocal( A ),
241+
internal::getLocal( mask ),
242+
internal::getLocal( B ),
243+
monoid
244+
);
245+
246+
return rc;
247+
}
248+
249+
template<
250+
Descriptor descr = descriptors::no_operation,
251+
class Monoid,
252+
typename IOType, typename MaskType, typename InputType,
253+
typename RIT_A, typename CIT_A, typename NIT_A,
254+
typename RIT_B, typename CIT_B, typename NIT_B
255+
>
256+
RC foldl(
257+
Matrix< IOType, BSP1D, RIT_A, CIT_A, NIT_A > &A,
258+
const Matrix< InputType, BSP1D, RIT_B, CIT_B, NIT_B > &B,
259+
const Monoid &monoid = Monoid(),
260+
const typename std::enable_if<
261+
!grb::is_object< IOType >::value &&
262+
!grb::is_object< InputType >::value &&
263+
grb::is_monoid< Monoid >::value, void
264+
>::type * const = nullptr
265+
) {
266+
267+
#ifdef _DEBUG
268+
std::cout << "In grb::foldl( BSP1D, matrix, matrix, monoid )\n";
269+
#endif
270+
RC rc = SUCCESS;
271+
272+
if( grb::nnz( A ) == 0 || grb::nnz( B ) == 0 ) {
273+
return rc;
274+
}
275+
276+
// Do local folding
277+
rc = foldl< descr >(
278+
internal::getLocal( A ),
279+
internal::getLocal( B ),
280+
monoid
281+
);
282+
283+
return rc;
284+
}
285+
286+
template<
287+
Descriptor descr = descriptors::no_operation,
288+
class Monoid,
289+
typename IOType, typename MaskType, typename InputType,
290+
typename RIT_A, typename CIT_A, typename NIT_A,
291+
typename RIT_M, typename CIT_M, typename NIT_M,
292+
typename RIT_B, typename CIT_B, typename NIT_B
293+
>
294+
RC foldr(
295+
Matrix< IOType, BSP1D, RIT_A, CIT_A, NIT_A > &A,
296+
const Matrix< MaskType, BSP1D, RIT_M, CIT_M, NIT_M > &mask,
297+
const Matrix< InputType, BSP1D, RIT_B, CIT_B, NIT_B > &B,
298+
const Monoid &monoid = Monoid(),
299+
const typename std::enable_if<
300+
!grb::is_object< IOType >::value &&
301+
!grb::is_object< InputType >::value &&
302+
!grb::is_object< MaskType >::value &&
303+
grb::is_monoid< Monoid >::value, void
304+
>::type * const = nullptr
305+
) {
306+
307+
#ifdef _DEBUG
308+
std::cout << "In grb::foldr( BSP1D, matrix, mask, matrix, monoid )\n";
309+
#endif
310+
RC rc = SUCCESS;
311+
312+
if( grb::nnz( A ) == 0 || grb::nnz( mask ) == 0 ) {
313+
return rc;
314+
}
315+
316+
// Do local folding
317+
rc = foldr< descr >(
318+
internal::getLocal( A ),
319+
internal::getLocal( mask ),
320+
internal::getLocal( B ),
321+
monoid
322+
);
323+
324+
return rc;
325+
}
326+
327+
template<
328+
Descriptor descr = descriptors::no_operation,
329+
class Monoid,
330+
typename IOType, typename MaskType, typename InputType,
331+
typename RIT_A, typename CIT_A, typename NIT_A,
332+
typename RIT_B, typename CIT_B, typename NIT_B
333+
>
334+
RC foldr(
335+
Matrix< IOType, BSP1D, RIT_A, CIT_A, NIT_A > &A,
336+
const Matrix< InputType, BSP1D, RIT_B, CIT_B, NIT_B > &B,
337+
const Monoid &monoid = Monoid(),
338+
const typename std::enable_if<
339+
!grb::is_object< IOType >::value &&
340+
!grb::is_object< InputType >::value &&
341+
grb::is_monoid< Monoid >::value, void
342+
>::type * const = nullptr
343+
) {
344+
#ifdef _DEBUG
345+
std::cout << "In grb::foldr( BSP1D, matrix, matrix, monoid )\n";
346+
#endif
347+
RC rc = SUCCESS;
348+
349+
if( grb::nnz( A ) == 0 || grb::nnz( B ) == 0 ) {
350+
return rc;
351+
}
352+
353+
// Do local folding
354+
rc = foldr< descr >(
355+
internal::getLocal( A ),
356+
internal::getLocal( B ),
357+
monoid
358+
);
359+
360+
return rc;
361+
}
362+
208363
} // namespace grb
209364

210365
#endif

0 commit comments

Comments
 (0)