Skip to content

Commit

Permalink
hpec24 results
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Jun 26, 2024
1 parent d42df5e commit c9acd62
Show file tree
Hide file tree
Showing 10 changed files with 2,943 additions and 64 deletions.
65 changes: 28 additions & 37 deletions experimental/algorithm/LAGraph_argminmax.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int argminmax
GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
GrB_Type type ;
GRB_TRY (GxB_Matrix_type (&type, A)) ;
//------ --------------------------------------------------------------------
//--------------------------------------------------------------------------
// create outputs x and p, and the iso full vector y
//--------------------------------------------------------------------------

Expand All @@ -60,6 +60,7 @@ int argminmax
// for dim=2: x = min/max (A) where x(i) = min/max (A (i,:))

GRB_TRY (GrB_mxm (*x, NULL, NULL, minmax_first, A, y, desc)) ;

//--------------------------------------------------------------------------
// D = diag (x)
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -88,8 +89,8 @@ int argminmax
}

// drop explicit zeros from G
// GRB_TRY (GxB_Matrix_select (G, NULL, NULL, GxB_NONZERO, G, NULL, NULL)) ;
GRB_TRY (GrB_Matrix_select_BOOL (G, NULL, NULL, GrB_VALUENE_BOOL, G, 0, NULL)) ;
GRB_TRY (GrB_Matrix_select_BOOL (G, NULL, NULL, GrB_VALUENE_BOOL, G, 0,
NULL)) ;

//--------------------------------------------------------------------------
// extract the positions of the entries in G
Expand All @@ -101,15 +102,10 @@ int argminmax
// for dim=2: find the position of the min/max entry in each row:
// p = G*y, so that p(i) = j if x(i) = A(i,j) = min/max (A (i,:)).

// FIXME: 1-based indexing is used in MATLAB, where this function
// derives from (See SuiteSparse/GraphBLAS/GraphBLAS/@GrB/private/
// mexfunctions/gbargminmax.c). In LAGraph, we should use 0-based
// indexing.

// For both cases, use the SECONDI1 operator since built-in indexing is
// 1-based. The ANY monoid would be faster, but this uses MIN so that the
// result for the user is repeatable.
GRB_TRY (GrB_mxm (*p, NULL, NULL, GxB_MIN_SECONDI1_INT64, G, y, desc)) ;
// Use the SECONDI operator since built-in indexing is 0-based. The ANY
// monoid would be faster, but this uses MIN monoid so that the result for
// the user is repeatable.
GRB_TRY (GrB_mxm (*p, NULL, NULL, GxB_MIN_SECONDI_INT64, G, y, desc)) ;

//--------------------------------------------------------------------------
// free workspace
Expand All @@ -136,15 +132,14 @@ int LAGraph_argminmax
)
{

// //--------------------------------------------------------------------------
// // check inputs
// //--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// check inputs
//--------------------------------------------------------------------------

// FIXME: need LAGraph error checks here

// LAGraph_usage (nargin == 3 && nargout == 2, USAGE) ;
// GrB_Matrix A = LAGraph_get_shallow (pargin [0]) ;
// bool is_min = (bool) (mxGetScalar (pargin [1]) == 0) ;
// int dim = (int) mxGetScalar (pargin [2]) ;
// CHECK_ERROR (dim < 0 || dim > 2, "invalid dim") ;
(*x) = NULL ;
(*p) = NULL ;

//--------------------------------------------------------------------------
// select the semirings
Expand Down Expand Up @@ -175,17 +170,17 @@ int LAGraph_argminmax
minmax_first = GrB_MIN_FIRST_SEMIRING_INT16 ;
any_equal = GxB_ANY_EQ_INT16 ;
}
else if (type == GrB_INT32)
else if (type == GrB_INT32)
{
minmax_first = GrB_MIN_FIRST_SEMIRING_INT32 ;
any_equal = GxB_ANY_EQ_INT32 ;
}
else if (type == GrB_INT64)
else if (type == GrB_INT64)
{
minmax_first = GrB_MIN_FIRST_SEMIRING_INT64 ;
any_equal = GxB_ANY_EQ_INT64 ;
}
else if (type == GrB_UINT8)
else if (type == GrB_UINT8)
{
minmax_first = GrB_MIN_FIRST_SEMIRING_UINT8 ;
any_equal = GxB_ANY_EQ_UINT8 ;
Expand Down Expand Up @@ -243,17 +238,17 @@ int LAGraph_argminmax
minmax_first = GrB_MAX_FIRST_SEMIRING_INT16 ;
any_equal = GxB_ANY_EQ_INT16 ;
}
else if (type == GrB_INT32)
else if (type == GrB_INT32)
{
minmax_first = GrB_MAX_FIRST_SEMIRING_INT32 ;
any_equal = GxB_ANY_EQ_INT32 ;
}
else if (type == GrB_INT64)
else if (type == GrB_INT64)
{
minmax_first = GrB_MAX_FIRST_SEMIRING_INT64 ;
any_equal = GxB_ANY_EQ_INT64 ;
}
else if (type == GrB_UINT8)
else if (type == GrB_UINT8)
{
minmax_first = GrB_MAX_FIRST_SEMIRING_UINT8 ;
any_equal = GxB_ANY_EQ_UINT8 ;
Expand Down Expand Up @@ -294,8 +289,6 @@ int LAGraph_argminmax
// compute the argmin/max
//--------------------------------------------------------------------------

// GrB_Matrix x = NULL, p = NULL ; //PUT BACK

if (dim == 0)
{

Expand All @@ -305,11 +298,9 @@ int LAGraph_argminmax

// [x1,p1] = argmin/max of each column of A
GrB_Matrix x1, p1 ;
argminmax (&x1, &p1, A, 1, minmax_first, any_equal,msg) ;
// GxB_print(x1,3);
argminmax (&x1, &p1, A, 1, minmax_first, any_equal, msg) ;
// [x,p] = argmin/max of each entry in x
argminmax (x, p, x1, 1, minmax_first, any_equal,msg) ;
// GxB_print(x,3);
argminmax (x, p, x1, 1, minmax_first, any_equal, msg) ;
// get the row and column index of the overall argmin/max of A
int64_t I [2] = { 0, 0 } ;
GrB_Index nvals0, nvals1 ;
Expand All @@ -324,7 +315,7 @@ int LAGraph_argminmax
GRB_TRY (GrB_Matrix_extractElement_INT64 (&(I [1]), p1, I [0] - 1, 0)) ;
}

// free workspace and create p = [row, col]
// free workspace and create p = [row, col]
GRB_TRY (GrB_Matrix_free (&x1)) ;
GRB_TRY (GrB_Matrix_free (&p1)) ;
GRB_TRY (GrB_Matrix_free (p)) ;
Expand All @@ -343,7 +334,7 @@ int LAGraph_argminmax
// argmin/max of each column of A
//----------------------------------------------------------------------

argminmax (x, p, A, 1, minmax_first, any_equal,msg) ;
argminmax (x, p, A, 1, minmax_first, any_equal, msg) ;
}
else
{
Expand All @@ -353,14 +344,14 @@ int LAGraph_argminmax
// argmin/max of each row of A
//----------------------------------------------------------------------

argminmax (x, p, A, 2, minmax_first, any_equal,msg);

argminmax (x, p, A, 2, minmax_first, any_equal, msg) ;
}

//--------------------------------------------------------------------------
// return result
//--------------------------------------------------------------------------

GRB_TRY (GrB_Matrix_free (&A)) ;
return(GrB_SUCCESS);
return (GrB_SUCCESS) ;
}

2 changes: 1 addition & 1 deletion experimental/utility/LAGraph_Random.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int LAGraph_Random_Init (char *msg)
GRB_TRY (GrB_UnaryOp_new (&LG_rand_next_op, LG_rand_next_f2,
GrB_UINT64, GrB_UINT64)) ;
GRB_TRY (GrB_IndexUnaryOp_new (&LG_rand_init_op, LG_rand_init_func,
GrB_UINT64, GrB_UINT64, GrB_UINT64) ;
GrB_UINT64, GrB_UINT64, GrB_UINT64)) ;
}
#endif
}
Expand Down
26 changes: 0 additions & 26 deletions src/algorithm/LG_BreadthFirstSearch_SSGrB.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ int LG_BreadthFirstSearch_SSGrB

GRB_TRY (GrB_Matrix_nvals (&nvals, A)) ;

#if 0
// HACK for HPEC'24: push/pull disabled to compare with vanilla
GrB_Matrix AT = NULL ;
GrB_Vector Degree = G->out_degree ;
if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
Expand All @@ -114,7 +112,6 @@ int LG_BreadthFirstSearch_SSGrB
// direction-optimization requires G->AT (if G is directed) and
// G->out_degree (for both undirected and directed cases)
bool push_pull = (Degree != NULL && AT != NULL) ;
#endif

// determine the semiring type
GrB_Type int_type = (n > INT32_MAX) ? GrB_INT64 : GrB_INT32 ;
Expand Down Expand Up @@ -160,43 +157,31 @@ int LG_BreadthFirstSearch_SSGrB
GRB_TRY (GrB_Vector_new (&w, GrB_INT64, n)) ;

GrB_Index nq = 1 ; // number of nodes in the current level
#if 0
// HACK for HPEC'24: push/pull disabled to compare with vanilla
double alpha = 8.0 ;
double beta1 = 8.0 ;
double beta2 = 512.0 ;
int64_t n_over_beta1 = (int64_t) (((double) n) / beta1) ;
int64_t n_over_beta2 = (int64_t) (((double) n) / beta2) ;
#endif

//--------------------------------------------------------------------------
// BFS traversal and label the nodes
//--------------------------------------------------------------------------

#if 0
// HACK for HPEC'24: push/pull disabled to compare with vanilla
bool do_push = true ; // start with push
GrB_Index last_nq = 0 ;
int64_t edges_unexplored = nvals ;
bool any_pull = false ; // true if any pull phase has been done
#endif

// {!mask} is the set of unvisited nodes
GrB_Vector mask = (compute_parent) ? pi : v ;

#if 0
for (int64_t nvisited = 1, k = 1 ; nvisited < n ; nvisited += nq, k++)
#endif
for (int64_t k = 1 ; ; k++) // HACK for HPEC'24: no push/pull
{

//----------------------------------------------------------------------
// select push vs pull
//----------------------------------------------------------------------

#if 0
// HACK for HPEC'24: push/pull disabled to compare with vanilla

if (push_pull)
{
if (do_push)
Expand Down Expand Up @@ -253,41 +238,30 @@ int LG_BreadthFirstSearch_SSGrB
}
any_pull = any_pull || (!do_push) ;
}
#endif

//----------------------------------------------------------------------
// q = kth level of the BFS
//----------------------------------------------------------------------

// mask is pi if computing parent, v if computing just level
#if 0
// HACK for HPEC'24: do push-only to compare with vanilla
if (do_push)
#endif
{
// push (saxpy-based vxm): q'{!mask} = q'*A
// HACK for HPEC'24: shall I remove this format hint?
GRB_TRY (LG_SET_FORMAT_HINT (q, LG_SPARSE)) ;
GRB_TRY (GrB_vxm (q, mask, NULL, semiring, q, A, GrB_DESC_RSC)) ;
}
#if 0
// HACK for HPEC'24: push/pull disabled to compare with vanilla

else
{
// pull (dot-product-based mxv): q{!mask} = AT*q
GRB_TRY (LG_SET_FORMAT_HINT (q, LG_BITMAP)) ;
GRB_TRY (GrB_mxv (q, mask, NULL, semiring, AT, q, GrB_DESC_RSC)) ;
}
#endif

//----------------------------------------------------------------------
// done if q is empty
//----------------------------------------------------------------------

#if 0
last_nq = nq ;
#endif
GRB_TRY (GrB_Vector_nvals (&nq, q)) ;
if (nq == 0)
{
Expand Down
Loading

0 comments on commit c9acd62

Please sign in to comment.