Skip to content

Commit

Permalink
Did a code review to make sure all public-facing APIs have matrix arg…
Browse files Browse the repository at this point in the history
…uments templated in index arguments. Quite a few were missing, now fixed. Also minor code style fixes included.
  • Loading branch information
anyzelman committed Jun 21, 2023
1 parent b39aa56 commit 60c58cc
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 89 deletions.
11 changes: 6 additions & 5 deletions include/graphblas/base/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,8 @@ namespace grb {
typename RIT, typename CIT, typename NIT
>
RC resize(
Matrix< InputType, backend, RIT, CIT, NIT > &A, const size_t new_nz
Matrix< InputType, backend, RIT, CIT, NIT > &A,
const size_t new_nz
) noexcept {
#ifndef NDEBUG
const bool should_not_call_base_matrix_resize = false;
Expand Down Expand Up @@ -1327,14 +1328,14 @@ namespace grb {
*/
template<
Descriptor descr = descriptors::no_operation,
typename InputType,
typename InputType, typename RIT, typename CIT, typename NIT,
typename fwd_iterator1 = const size_t * __restrict__,
typename fwd_iterator2 = const size_t * __restrict__,
typename fwd_iterator3 = const InputType * __restrict__,
Backend implementation = config::default_backend
>
RC buildMatrixUnique(
Matrix< InputType, implementation > &A,
Matrix< InputType, implementation, RIT, CIT, NIT > &A,
fwd_iterator1 I, const fwd_iterator1 I_end,
fwd_iterator2 J, const fwd_iterator2 J_end,
fwd_iterator3 V, const fwd_iterator3 V_end,
Expand All @@ -1359,14 +1360,14 @@ namespace grb {
*/
template<
Descriptor descr = descriptors::no_operation,
typename InputType,
typename InputType, typename RIT, typename CIT, typename NIT,
typename fwd_iterator1 = const size_t * __restrict__,
typename fwd_iterator2 = const size_t * __restrict__,
typename fwd_iterator3 = const InputType * __restrict__,
Backend implementation = config::default_backend
>
RC buildMatrixUnique(
Matrix< InputType, implementation > &A,
Matrix< InputType, implementation, RIT, CIT, NIT > &A,
fwd_iterator1 I, fwd_iterator2 J, fwd_iterator3 V,
const size_t nz, const IOMode mode
) {
Expand Down
3 changes: 2 additions & 1 deletion include/graphblas/bsp1d/blas2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,13 @@ namespace grb {
typename InputType2 = typename Ring::D2,
typename InputType3 = bool,
typename InputType4 = bool,
typename RIT, typename CIT, typename NIT,
typename Coords
>
RC mxv(
Vector< IOType, BSP1D, Coords > &u,
const Vector< InputType3, BSP1D, Coords > &mask,
const Matrix< InputType2, BSP1D > &A,
const Matrix< InputType2, BSP1D, RIT, CIT, NIT > &A,
const Vector< InputType1, BSP1D, Coords > &v,
const Ring &ring = Ring(),
const Phase &phase = EXECUTE,
Expand Down
77 changes: 47 additions & 30 deletions include/graphblas/hyperdags/blas2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ namespace grb {
template<
Descriptor descr = descriptors::no_operation, class Ring,
typename IOType, typename InputType1, typename InputType2,
typename InputType3, typename Coords
typename InputType3, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC vxm(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType3, hyperdags, Coords > &mask,
const Vector< InputType1, hyperdags, Coords > &v,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Ring &ring = Ring(),
const Phase &phase = EXECUTE,
const typename std::enable_if<
Expand Down Expand Up @@ -87,13 +88,14 @@ namespace grb {
Descriptor descr = descriptors::no_operation,
class AdditiveMonoid, class MultiplicativeOperator,
typename IOType, typename InputType1, typename InputType2,
typename InputType3, typename Coords
typename InputType3, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC vxm(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType3, hyperdags, Coords > &mask,
const Vector< InputType1, hyperdags, Coords > &v,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const AdditiveMonoid &add = AdditiveMonoid(),
const MultiplicativeOperator &mul = MultiplicativeOperator(),
const Phase &phase = EXECUTE,
Expand Down Expand Up @@ -140,12 +142,13 @@ namespace grb {
typename IOType = typename Ring::D4,
typename InputType1 = typename Ring::D1,
typename InputType2 = typename Ring::D2,
typename Coords
typename Coords,
typename RIT, typename CIT, typename NIT
>
RC vxm(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType1, hyperdags, Coords > &v,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Ring &ring = Ring(),
const Phase &phase = EXECUTE,
const typename std::enable_if<
Expand Down Expand Up @@ -186,12 +189,13 @@ namespace grb {
typename InputType1 = typename Ring::D1,
typename InputType2 = typename Ring::D2,
typename InputType3 = bool,
typename Coords
typename Coords,
typename RIT, typename CIT, typename NIT
>
RC mxv(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType3, hyperdags, Coords > &mask,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Vector< InputType1, hyperdags, Coords > &v,
const Ring &ring,
const Phase &phase = EXECUTE,
Expand Down Expand Up @@ -237,12 +241,13 @@ namespace grb {
bool input_may_be_masked = true,
class Ring,
typename IOType, typename InputType1, typename InputType2,
typename InputType3, typename InputType4, typename Coords
typename InputType3, typename InputType4, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC mxv(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType3, hyperdags, Coords > &mask,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Vector< InputType1, hyperdags, Coords > &v,
const Vector< InputType4, hyperdags, Coords > &v_mask,
const Ring &ring,
Expand Down Expand Up @@ -292,12 +297,13 @@ namespace grb {
bool input_may_be_masked = true,
class AdditiveMonoid, class MultiplicativeOperator,
typename IOType, typename InputType1, typename InputType2,
typename InputType3, typename InputType4, typename Coords
typename InputType3, typename InputType4, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC mxv(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType3, hyperdags, Coords > &mask,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Vector< InputType1, hyperdags, Coords > &v,
const Vector< InputType4, hyperdags, Coords > &v_mask,
const AdditiveMonoid &add = AdditiveMonoid(),
Expand Down Expand Up @@ -350,11 +356,12 @@ namespace grb {
typename IOType = typename Ring::D4,
typename InputType1 = typename Ring::D1,
typename InputType2 = typename Ring::D2,
typename Coords
typename Coords,
typename RIT, typename CIT, typename NIT
>
RC mxv(
Vector< IOType, hyperdags, Coords > &u,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Vector< InputType1, hyperdags, Coords > &v,
const Ring &ring,
const Phase &phase = EXECUTE,
Expand Down Expand Up @@ -392,11 +399,12 @@ namespace grb {
template<
Descriptor descr = descriptors::no_operation,
class AdditiveMonoid, class MultiplicativeOperator,
typename IOType, typename InputType1, typename InputType2, typename Coords
typename IOType, typename InputType1, typename InputType2, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC mxv(
Vector< IOType, hyperdags, Coords > &u,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Vector< InputType1, hyperdags, Coords > &v,
const AdditiveMonoid &add = AdditiveMonoid(),
const MultiplicativeOperator &mul = MultiplicativeOperator(),
Expand Down Expand Up @@ -436,11 +444,12 @@ namespace grb {

/** \internal Uses a direct implementation. */
template<
typename Func, typename DataType
typename Func, typename DataType,
typename RIT, typename CIT, typename NIT
>
RC eWiseLambda(
const Func f,
const Matrix< DataType, hyperdags > &A
const Matrix< DataType, hyperdags, RIT, CIT, NIT > &A
) {
const RC ret = eWiseLambda( f, internal::getMatrix(A) );
if( ret != SUCCESS ) { return ret; }
Expand All @@ -461,11 +470,12 @@ namespace grb {

/** \internal This is the end recursion */
template<
typename Func, typename DataType
typename Func, typename DataType,
typename RIT, typename CIT, typename NIT
>
RC hyperdag_ewisematrix(
const Func f,
const Matrix< DataType, grb::hyperdags > &A,
const Matrix< DataType, grb::hyperdags, RIT, CIT, NIT > &A,
std::vector< uintptr_t > &sources,
std::vector< uintptr_t > &destinations
) {
Expand All @@ -486,11 +496,13 @@ namespace grb {
/** \internal This is the base recursion */
template<
typename Func, typename DataType1, typename DataType2,
typename Coords, typename... Args
typename Coords,
typename RIT, typename CIT, typename NIT,
typename... Args
>
RC hyperdag_ewisematrix(
const Func f,
const Matrix< DataType1, grb::hyperdags > &A,
const Matrix< DataType1, grb::hyperdags, RIT, CIT, NIT > &A,
std::vector< uintptr_t > &sources,
std::vector< uintptr_t > &destinations,
const Vector< DataType2, grb::hyperdags, Coords > &x,
Expand All @@ -507,11 +519,13 @@ namespace grb {
template<
typename Func,
typename DataType1, typename DataType2,
typename Coords, typename... Args
typename Coords,
typename RIT, typename CIT, typename NIT,
typename... Args
>
RC eWiseLambda(
const Func f,
const Matrix< DataType1, hyperdags > &A,
const Matrix< DataType1, hyperdags, RIT, CIT, NIT > &A,
const Vector< DataType2, hyperdags, Coords > &x,
Args... args
) {
Expand All @@ -527,14 +541,15 @@ namespace grb {
bool input_may_be_masked = true,
class Ring,
typename IOType, typename InputType1, typename InputType2,
typename InputType3, typename InputType4, typename Coords
typename InputType3, typename InputType4, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC vxm(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType3, hyperdags, Coords > &mask,
const Vector< InputType1, hyperdags, Coords > &v,
const Vector< InputType4, hyperdags, Coords > &v_mask,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const Ring &ring = Ring(),
const Phase &phase = EXECUTE,
const typename std::enable_if<
Expand Down Expand Up @@ -583,14 +598,15 @@ namespace grb {
bool input_may_be_masked = true,
class AdditiveMonoid, class MultiplicativeOperator,
typename IOType, typename InputType1, typename InputType2,
typename InputType3, typename InputType4, typename Coords
typename InputType3, typename InputType4, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC vxm(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType3, hyperdags, Coords > &mask,
const Vector< InputType1, hyperdags, Coords > &v,
const Vector< InputType4, hyperdags, Coords > &v_mask,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, NIT, CIT > &A,
const AdditiveMonoid &add = AdditiveMonoid(),
const MultiplicativeOperator &mul = MultiplicativeOperator(),
const Phase &phase = EXECUTE,
Expand Down Expand Up @@ -639,12 +655,13 @@ namespace grb {
template<
Descriptor descr = descriptors::no_operation,
class AdditiveMonoid, class MultiplicativeOperator,
typename IOType, typename InputType1, typename InputType2, typename Coords
typename IOType, typename InputType1, typename InputType2, typename Coords,
typename RIT, typename CIT, typename NIT
>
RC vxm(
Vector< IOType, hyperdags, Coords > &u,
const Vector< InputType1, hyperdags, Coords > &v,
const Matrix< InputType2, hyperdags > &A,
const Matrix< InputType2, hyperdags, RIT, CIT, NIT > &A,
const AdditiveMonoid &add = AdditiveMonoid(),
const MultiplicativeOperator &mul = MultiplicativeOperator(),
const Phase &phase = EXECUTE,
Expand Down
Loading

0 comments on commit 60c58cc

Please sign in to comment.