Skip to content

Commit

Permalink
Merge pull request #229 from GraphBLAS/v1.0.2
Browse files Browse the repository at this point in the history
remove GxB_SelectOp
  • Loading branch information
DrTimothyAldenDavis authored Aug 29, 2023
2 parents 102bd15 + 1340799 commit 7887f54
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ jobs:
uses: actions/checkout@v2.0.0
- name: Install dependencies
run: |
brew extract --version=14.0.6 libomp homebrew/cask
brew tap-new libomp/cask
brew extract --version=14.0.6 libomp libomp/cask
brew install libomp@14.0.6
- name: Get GraphBLAS binaries
run: |
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# LAGraph/CMakeLists.txt: cmake script for LAGraph
#-------------------------------------------------------------------------------

# LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
# LAGraph, (c) 2019-2023 by The LAGraph Contributors, All Rights Reserved.
# SPDX-License-Identifier: BSD-2-Clause
#
# For additional details (including references to third party source code and
Expand Down Expand Up @@ -49,10 +49,10 @@ cmake_policy ( SET CMP0048 NEW )
set ( CMAKE_MACOSX_RPATH TRUE )

# version of LAGraph
set ( LAGraph_DATE "Dec 28, 2022" )
set ( LAGraph_DATE "Aug 2, 2023" )
set ( LAGraph_VERSION_MAJOR 1 )
set ( LAGraph_VERSION_MINOR 0 )
set ( LAGraph_VERSION_SUB 1 )
set ( LAGraph_VERSION_SUB 2 )

project ( lagraph
VERSION "${LAGraph_VERSION_MAJOR}.${LAGraph_VERSION_MINOR}.${LAGraph_VERSION_SUB}" )
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.0.2: Aug 2, 2023

* port: removed GxB_SelectOp so LAGraph v1.0.2 can be compiled with
SuiteSparse:GraphBLAS v8.x.

Version 1.0.1: Dec 26, 2022

* bug fix: LAGraph_MMWrite incorrectly created a Matrix Market
Expand Down
23 changes: 9 additions & 14 deletions experimental/algorithm/LAGraph_msf.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,17 @@ static GrB_Index *weight = NULL, *parent = NULL, *partner = NULL;
// for each element A(i, j), it is selected if
// 1. weight[i] == A(i, j) -- where weight[i] stores i's minimum edge weight
// 2. parent[j] == partner[i] -- j belongs to the specified connected component
bool f1 (
GrB_Index i, GrB_Index j,
const void *x, const void *thunk)
void f1 (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
{
uint64_t *aij = (uint64_t*) x;
return (weight[i] == *aij) && (parent[j] == partner[i]);
(*z) = (weight[i] == *aij) && (parent[j] == partner[i]);
}

// edge removal:
// A(i, j) is removed when parent[i] == parent[j]
bool f2 (
GrB_Index i, GrB_Index j,
const void *x, const void *thunk)
void f2 (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
{
uint64_t *aij = (uint64_t*) x;
return (parent[i] != parent[j]);
(*z) = (parent[i] != parent[j]);
}

//****************************************************************************
Expand Down Expand Up @@ -134,7 +129,7 @@ int LAGraph_msf
GrB_Semiring combMin = NULL;
GrB_UnaryOp fst = NULL, snd = NULL;

GxB_SelectOp s1 = NULL, s2 = NULL;
GrB_IndexUnaryOp s1 = NULL, s2 = NULL;
if (result == NULL || A == NULL) return (GrB_NULL_POINTER) ;

GrB_Index ncols ;
Expand Down Expand Up @@ -190,8 +185,8 @@ int LAGraph_msf
GRB_TRY (GrB_UnaryOp_new (&snd, get_snd, GrB_UINT64, GrB_UINT64));

// GrB_SelectOp
GxB_SelectOp_new (&s1, f1, GrB_UINT64, GrB_NULL);
GxB_SelectOp_new (&s2, f2, GrB_UINT64, GrB_NULL);
GrB_IndexUnaryOp_new (&s1, (void *) f1, GrB_BOOL, GrB_UINT64, GrB_UINT64);
GrB_IndexUnaryOp_new (&s2, (void *) f2, GrB_BOOL, GrB_UINT64, GrB_UINT64);

// the main computation
GrB_Index nvals, diff, ntuples = 0, num;
Expand Down Expand Up @@ -242,7 +237,7 @@ int LAGraph_msf
GRB_TRY (GrB_assign (t, 0, 0, inf, GrB_ALL, 0, 0));
GRB_TRY (GrB_apply (t, mask, 0, snd, edge, 0));
GRB_TRY (GrB_Vector_extractTuples (I, partner, &n, t));
GRB_TRY (GxB_select (T, 0, 0, s1, S, GrB_NULL, 0));
GRB_TRY (GrB_select (T, 0, 0, s1, S, 0, 0));
GRB_TRY (GrB_Vector_clear (t));

// 5. the generated matrix may still have redundant edges
Expand All @@ -268,7 +263,7 @@ int LAGraph_msf

// remove the edges in the same connected component
GRB_TRY (GrB_Vector_extractTuples (I, parent, &n, f));
GRB_TRY (GxB_select (S, 0, 0, s2, S, GrB_NULL, 0));
GRB_TRY (GrB_select (S, 0, 0, s2, S, 0, 0));
GrB_Matrix_nvals (&nvals, S);
if (nvals == 0) break;
}
Expand Down
29 changes: 15 additions & 14 deletions experimental/algorithm/LAGraph_scc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ GrB_Index *I = NULL, *V = NULL, *F = NULL, *B = NULL, *M = NULL;
// hold. The converse is not true unless F[u]==B[u]. However, we can safely remove
// an edge (u, v) if either F[u]!=F[v] or B[u]!=B[v] holds, which can accelerate
// the SCC computation in the future rounds.
bool edge_removal (GrB_Index i, GrB_Index j, const void *x, const void *thunk) ;
bool edge_removal (GrB_Index i, GrB_Index j, const void *x, const void *thunk)

void edge_removal (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk) ;
void edge_removal (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
{
return !M[i] && !M[j] && F[i] == F[j] && B[i] == B[j];
(*z) = (!M[i] && !M[j] && F[i] == F[j] && B[i] == B[j]) ;
}

//****************************************************************************
// trim_one: remove the edges connected to trivial SCCs
// - A vertex is a trivial SCC if it has no incoming or outgoing edges.
// - M[i] = i | if vertex i is a trivial SCC
// M[i] = n | otherwise
bool trim_one (GrB_Index i, GrB_Index j, const void *x, const void *thunk) ;
bool trim_one (GrB_Index i, GrB_Index j, const void *x, const void *thunk)

void trim_one (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk) ;
void trim_one (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
{
return M[i] == M[j];
(*z) = (M[i] == M[j]) ;
}

//****************************************************************************
Expand Down Expand Up @@ -123,7 +125,7 @@ int LAGraph_scc
GrB_Vector ind;
GrB_Vector inf;
GrB_Vector f, b, mask;
GxB_SelectOp sel1, sel2;
GrB_IndexUnaryOp sel1 = NULL, sel2 = NULL ;
GrB_Monoid Add;

if (result == NULL || A == NULL) return (GrB_NULL_POINTER) ;
Expand Down Expand Up @@ -169,9 +171,8 @@ int LAGraph_scc
GRB_TRY (GrB_Vector_new (&f, GrB_UINT64, n));
GRB_TRY (GrB_Vector_new (&b, GrB_UINT64, n));
GRB_TRY (GrB_Vector_new (&mask, GrB_UINT64, n));
// GxB_SelectOp
GRB_TRY (GxB_SelectOp_new (&sel1, trim_one, GrB_BOOL, GrB_NULL));
GRB_TRY (GxB_SelectOp_new (&sel2, edge_removal, GrB_BOOL, GrB_NULL));
GRB_TRY (GrB_IndexUnaryOp_new (&sel1, (void *) trim_one, GrB_BOOL, GrB_UINT64, GrB_UINT64));
GRB_TRY (GrB_IndexUnaryOp_new (&sel2, (void *) edge_removal, GrB_BOOL, GrB_UINT64, GrB_UINT64));

// remove trivial SCCs
GRB_TRY (GrB_reduce (f, 0, GrB_PLUS_UINT64, GrB_PLUS_UINT64, FW, 0));
Expand All @@ -186,8 +187,8 @@ int LAGraph_scc
if (nvals < n)
{
GRB_TRY (GrB_Vector_extractTuples (I, M, &n, scc));
GRB_TRY (GxB_select (FW, 0, 0, sel1, FW, GrB_NULL, 0));
GRB_TRY (GxB_select (BW, 0, 0, sel1, BW, GrB_NULL, 0));
GRB_TRY (GrB_select (FW, 0, 0, sel1, FW, 0, 0));
GRB_TRY (GrB_select (BW, 0, 0, sel1, BW, 0, 0));
}

GRB_TRY (GrB_Matrix_nvals (&nvals, FW));
Expand All @@ -209,8 +210,8 @@ int LAGraph_scc
GRB_TRY (GrB_Vector_extractTuples (I, B, &n, b));
GRB_TRY (GrB_Vector_extractTuples (I, M, &n, mask));

GRB_TRY (GxB_select (FW, 0, 0, sel2, FW, GrB_NULL, 0));
GRB_TRY (GxB_select (BW, 0, 0, sel2, BW, GrB_NULL, 0));
GRB_TRY (GrB_select (FW, 0, 0, sel2, FW, 0, 0));
GRB_TRY (GrB_select (BW, 0, 0, sel2, BW, 0, 0));

GRB_TRY (GrB_Matrix_nvals (&nvals, FW));
}
Expand Down
4 changes: 2 additions & 2 deletions include/LAGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
// See also the LAGraph_Version utility method, which returns these values.
// These definitions are derived from LAGraph/CMakeLists.txt.

#define LAGRAPH_DATE "Dec 28, 2022"
#define LAGRAPH_DATE "Aug 2, 2023"
#define LAGRAPH_VERSION_MAJOR 1
#define LAGRAPH_VERSION_MINOR 0
#define LAGRAPH_VERSION_UPDATE 1
#define LAGRAPH_VERSION_UPDATE 2

//==============================================================================
// include files and helper macros
Expand Down
4 changes: 2 additions & 2 deletions src/benchmark/LAGraph_demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,8 @@ static inline int demo_init (bool burble)
char msg [LAGRAPH_MSG_LEN] ;
msg [0] = '\0' ;

#ifdef __linux__
// Use mallopt to speedup malloc and free on Linux. Otherwise, it can take
#ifdef __GLIBC__
// Use mallopt to speedup malloc and free on Linux (glibc). Otherwise, it can take
// several seconds to free a large block of memory. For this to be
// effective, demo_init must be called before calling malloc/free, and
// before calling LAGraph_Init.
Expand Down
6 changes: 0 additions & 6 deletions src/test/test_Type.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,8 @@ void test_TypeName (void)
name [0] = '\0' ;
OK (GrB_Type_new (&type, sizeof (myint))) ;
int result = LAGraph_NameOfType (name, type, msg) ;
#if LAGRAPH_SUITESPARSE
printf ("\nSuiteSparse knows the type name: [%s]\n", name) ;
TEST_CHECK (result == GrB_SUCCESS) ;
OK (strcmp (name, "myint")) ;
#else
TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
printf ("\nmsg: %s\n", msg) ;
#endif

TEST_CHECK (LAGraph_NameOfType (NULL, NULL, msg) == GrB_NULL_POINTER) ;
printf ("\nmsg: %s\n", msg) ;
Expand Down
9 changes: 0 additions & 9 deletions src/utility/LAGraph_NameOfType.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ int LAGraph_NameOfType
// determine the name of the type
//--------------------------------------------------------------------------

#if LAGRAPH_SUITESPARSE

// always succeeds, even for user-defined types, unless the
// type is an invalid object
return (GxB_Type_name (name, type)) ;

#else

if (type == GrB_BOOL ) strcpy (name, "bool") ;
else if (type == GrB_INT8 ) strcpy (name, "int8_t") ;
else if (type == GrB_INT16 ) strcpy (name, "int16_t") ;
Expand All @@ -71,5 +63,4 @@ int LAGraph_NameOfType
}
return (GrB_SUCCESS) ;

#endif
}

0 comments on commit 7887f54

Please sign in to comment.