Skip to content

Commit

Permalink
Implementation in nonblocking (delegating)
Browse files Browse the repository at this point in the history
  • Loading branch information
byjtew committed Jun 28, 2023
1 parent c12b31c commit 86682f3
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 1 deletion.
121 changes: 121 additions & 0 deletions include/graphblas/nonblocking/blas3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,127 @@ namespace grb {
);
}

template<
Descriptor descr = descriptors::no_operation,
class Operator,
typename IOType, typename MaskType, typename InputType,
typename RIT_A, typename CIT_A, typename NIT_A,
typename RIT_M, typename CIT_M, typename NIT_M
>
RC foldl(
Matrix< IOType, nonblocking, RIT_A, CIT_A, NIT_A > &A,
const Matrix< MaskType, nonblocking, RIT_M, CIT_M, NIT_M > &mask,
const InputType &x,
const Operator &op = Operator(),
const typename std::enable_if<
!grb::is_object< IOType >::value &&
!grb::is_object< InputType >::value &&
!grb::is_object< MaskType >::value &&
grb::is_operator< Operator >::value, void
>::type * const = nullptr
) {

#ifdef _DEBUG
std::cout << "In grb::foldl( nonblocking, matrix, mask, scalar, op )\n";
#endif
RC rc = SUCCESS;

if( grb::nnz( A ) == 0 ) {
return rc;
}

// Do local folding
rc = foldl< descr >( internal::getRefMatrix( A ), internal::getRefMatrix( mask ), x, op );

return rc;
}

template<
Descriptor descr = descriptors::no_operation,
class Operator,
typename IOType, typename MaskType, typename InputType,
typename RIT, typename CIT, typename NIT
>
RC foldl(
Matrix< IOType, nonblocking, RIT, CIT, NIT > &A,
const InputType &x,
const Operator &op = Operator(),
const typename std::enable_if<
!grb::is_object< IOType >::value &&
!grb::is_object< InputType >::value &&
!grb::is_object< MaskType >::value &&
grb::is_operator< Operator >::value, void
>::type * const = nullptr
) {

#ifdef _DEBUG
std::cout << "In grb::foldl( nonblocking, matrix, scalar, op )\n";
#endif
// nonblocking execution is not supported
// first, execute any computation that is not completed
internal::le.execution();

// second, delegate to the reference backend
return foldl< descr, Operator >( internal::getRefMatrix( A ), x, op );
}

template<
Descriptor descr = descriptors::no_operation,
class Operator,
typename IOType, typename MaskType, typename InputType,
typename RIT_A, typename CIT_A, typename NIT_A,
typename RIT_M, typename CIT_M, typename NIT_M
>
RC foldr(
Matrix< IOType, nonblocking, RIT_A, CIT_A, NIT_A > &A,
const Matrix< MaskType, nonblocking, RIT_M, CIT_M, NIT_M > &mask,
const InputType &x,
const Operator &op = Operator(),
const typename std::enable_if<
!grb::is_object< IOType >::value &&
!grb::is_object< InputType >::value &&
!grb::is_object< MaskType >::value &&
grb::is_operator< Operator >::value, void
>::type * const = nullptr
) {

#ifdef _DEBUG
std::cout << "In grb::foldr( nonblocking, matrix, scalar, mask, op )\n";
#endif
// nonblocking execution is not supported
// first, execute any computation that is not completed
internal::le.execution();

// second, delegate to the reference backend
return foldr< descr, Operator >( internal::getRefMatrix( A ), internal::getRefMatrix( mask ), x, op );
}

template<
Descriptor descr = descriptors::no_operation,
class Operator,
typename IOType, typename InputType,
typename RIT, typename CIT, typename NIT
>
RC foldr(
Matrix< IOType, nonblocking, RIT, CIT, NIT > &A,
const InputType &x,
const Operator &op = Operator(),
const typename std::enable_if<
!grb::is_object< IOType >::value &&
!grb::is_object< InputType >::value &&
grb::is_operator< Operator >::value, void
>::type * const = nullptr
) {
#ifdef _DEBUG
std::cout << "In grb::foldr( nonblocking, matrix, scalar, op )\n";
#endif
// nonblocking execution is not supported
// first, execute any computation that is not completed
internal::le.execution();

// second, delegate to the reference backend
return foldr< descr, Operator >( internal::getRefMatrix( A ), x, op );
}
} // namespace grb

#undef NO_CAST_ASSERT
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ add_grb_executables( eWiseMul eWiseMul.cpp
)

add_grb_executables( fold_matrix_scalar_to_matrix fold_matrix_scalar_to_matrix.cpp
BACKENDS reference reference_omp hyperdags bsp1d hybrid
BACKENDS reference reference_omp bsp1d hybrid hyperdags nonblocking
)

add_grb_executables( muladd muladd.cpp
Expand Down

0 comments on commit 86682f3

Please sign in to comment.