Skip to content

Commit e11a340

Browse files
Merge pull request #294 from GraphBLAS/with_GraphBLAS_v10
random number generators moved to src/utility
2 parents 411e6ed + 8fbb0c1 commit e11a340

14 files changed

+173
-65
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
config:
1616
# if there are multiple items in this list, only use should
1717
# deployit=true for just one of them.
18-
# - {grb_version: 9.4.5, deployit: false}
18+
- {grb_version: 9.0.0, deployit: false}
1919
- {grb_version: 10.0.3, deployit: true}
2020
steps:
2121
- name: Checkout
@@ -57,7 +57,7 @@ jobs:
5757
strategy:
5858
matrix:
5959
config:
60-
# - {grb_version: 9.4.5}
60+
- {grb_version: 9.0.0}
6161
- {grb_version: 10.0.3}
6262
steps:
6363
- name: Checkout

TODO.txt

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
LAGraph TODO:
22

3+
For May 14, 2025, meeting:
4+
5+
Propose releasing a stable v1.2 branch
6+
full test coverage except RegularPathQuery
7+
Requires SS:GraphBLAS v9.0.0 or later, but additional features of v10.0.0 used
8+
by some methods (with an #ifdef)
9+
Add LAGraph_Random* methods to src/utililty, but no other methods added to
10+
src/algorithm or src/utility (do those later)
11+
312
Aug 21, 2024:
413

514
(1) LAGraph 1.1.4 release, with latest GraphBLAS compiled in CI, not

config/LAGraph.h.in

+54-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898

9999
#if ( !LAGRAPH_VANILLA ) && defined ( GxB_SUITESPARSE_GRAPHBLAS )
100100
// use SuiteSparse, and its GxB* extensions
101-
#if GxB_IMPLEMENTATION < GxB_VERSION (10,0,3)
102-
#error "If using SuiteSparse::GraphBLAS, version 10.0.3 or later is required"
101+
#if GxB_IMPLEMENTATION < GxB_VERSION (9,0,0)
102+
#error "If using SuiteSparse::GraphBLAS, version 9.0.0 or later is required"
103103
#endif
104104
#define LAGRAPH_SUITESPARSE 1
105105
#else
@@ -2021,6 +2021,58 @@ int LAGraph_Vector_IsEqualOp
20212021
char *msg
20222022
) ;
20232023

2024+
//------------------------------------------------------------------------------
2025+
// Random number generator
2026+
//------------------------------------------------------------------------------
2027+
2028+
// FIXME: rename these methods?
2029+
2030+
/** LAGraph_Random_Seed creates a random vector. On input, its values are
2031+
* ignored but its structure is used. On output, all entries that were in
2032+
* the original structure are assigned random values, depending on the scalar
2033+
* seed value. Each entry is considered its own pseudo-random number stream,
2034+
* with the overall seed value being revised for each entry in the vector,
2035+
* depending on their index in the vector.
2036+
*
2037+
* @param[out,out] State vector to initialize with random numbers.
2038+
* @param[in] seed scalar seed value.
2039+
* @param[in,out] msg any error messages.
2040+
*
2041+
* @retval GrB_SUCCESS if successful.
2042+
* @retval GrB_NULL_POINTER if State is NULL.
2043+
* @returns any GraphBLAS errors that may have been encountered.
2044+
*/
2045+
2046+
LAGRAPH_PUBLIC
2047+
int LAGraph_Random_Seed // construct a random State vector
2048+
(
2049+
// input/output:
2050+
GrB_Vector State, // vector of random number States, normally GrB_UINT64
2051+
// input:
2052+
uint64_t seed, // scalar input seed
2053+
char *msg
2054+
) ;
2055+
2056+
/** LAGraph_Random_Next takes as input a vector previously initialized by
2057+
* LAGraph_Random_Seed, and modifies all of them so that they take on their
2058+
* next value in its pseudo-random number stream.
2059+
*
2060+
* @param[out,out] State vector with random numbers to be advanced.
2061+
* @param[in,out] msg any error messages.
2062+
*
2063+
* @retval GrB_SUCCESS if successful.
2064+
* @retval GrB_NULL_POINTER if State is NULL.
2065+
* @returns any GraphBLAS errors that may have been encountered.
2066+
*/
2067+
2068+
LAGRAPH_PUBLIC
2069+
int LAGraph_Random_Next // advance to next random vector
2070+
(
2071+
// input/output:
2072+
GrB_Vector State, // vector of random number States, normally GrB_UINT64
2073+
char *msg
2074+
) ;
2075+
20242076
//==============================================================================
20252077
// LAGraph Basic algorithms
20262078
//==============================================================================

data/random_weighted_general2.mtx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%%MatrixMarket matrix coordinate integer symmetric
2-
%%GraphBLAS type uint32_t
2+
%%GraphBLAS type uint64_t
33
300 300 746
44
185 90 4294420090
55
227 66 4288698439

experimental/test/test_MaximalMatching.c

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void test_MaximalMatching (void)
9696
{
9797
const char *aname = tests [k].name ;
9898
if (strlen (aname) == 0) break ;
99+
printf ("\n======================= %s:\n", aname) ;
99100
TEST_CASE (aname) ;
100101

101102
// old code using files
@@ -109,6 +110,7 @@ void test_MaximalMatching (void)
109110

110111
TEST_CHECK (A != NULL) ;
111112
TEST_MSG ("Building of adjacency matrix failed") ;
113+
GxB_print (A, 1) ;
112114

113115
OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
114116

include/LAGraph.h

+54-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898

9999
#if ( !LAGRAPH_VANILLA ) && defined ( GxB_SUITESPARSE_GRAPHBLAS )
100100
// use SuiteSparse, and its GxB* extensions
101-
#if GxB_IMPLEMENTATION < GxB_VERSION (10,0,3)
102-
#error "If using SuiteSparse::GraphBLAS, version 10.0.3 or later is required"
101+
#if GxB_IMPLEMENTATION < GxB_VERSION (9,0,0)
102+
#error "If using SuiteSparse::GraphBLAS, version 9.0.0 or later is required"
103103
#endif
104104
#define LAGRAPH_SUITESPARSE 1
105105
#else
@@ -2021,6 +2021,58 @@ int LAGraph_Vector_IsEqualOp
20212021
char *msg
20222022
) ;
20232023

2024+
//------------------------------------------------------------------------------
2025+
// Random number generator
2026+
//------------------------------------------------------------------------------
2027+
2028+
// FIXME: rename these methods?
2029+
2030+
/** LAGraph_Random_Seed creates a random vector. On input, its values are
2031+
* ignored but its structure is used. On output, all entries that were in
2032+
* the original structure are assigned random values, depending on the scalar
2033+
* seed value. Each entry is considered its own pseudo-random number stream,
2034+
* with the overall seed value being revised for each entry in the vector,
2035+
* depending on their index in the vector.
2036+
*
2037+
* @param[out,out] State vector to initialize with random numbers.
2038+
* @param[in] seed scalar seed value.
2039+
* @param[in,out] msg any error messages.
2040+
*
2041+
* @retval GrB_SUCCESS if successful.
2042+
* @retval GrB_NULL_POINTER if State is NULL.
2043+
* @returns any GraphBLAS errors that may have been encountered.
2044+
*/
2045+
2046+
LAGRAPH_PUBLIC
2047+
int LAGraph_Random_Seed // construct a random State vector
2048+
(
2049+
// input/output:
2050+
GrB_Vector State, // vector of random number States, normally GrB_UINT64
2051+
// input:
2052+
uint64_t seed, // scalar input seed
2053+
char *msg
2054+
) ;
2055+
2056+
/** LAGraph_Random_Next takes as input a vector previously initialized by
2057+
* LAGraph_Random_Seed, and modifies all of them so that they take on their
2058+
* next value in its pseudo-random number stream.
2059+
*
2060+
* @param[out,out] State vector with random numbers to be advanced.
2061+
* @param[in,out] msg any error messages.
2062+
*
2063+
* @retval GrB_SUCCESS if successful.
2064+
* @retval GrB_NULL_POINTER if State is NULL.
2065+
* @returns any GraphBLAS errors that may have been encountered.
2066+
*/
2067+
2068+
LAGRAPH_PUBLIC
2069+
int LAGraph_Random_Next // advance to next random vector
2070+
(
2071+
// input/output:
2072+
GrB_Vector State, // vector of random number States, normally GrB_UINT64
2073+
char *msg
2074+
) ;
2075+
20242076
//==============================================================================
20252077
// LAGraph Basic algorithms
20262078
//==============================================================================

include/LAGraphX.h

+2-20
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ extern "C"
5757
//------------------------------------------------------------------------------
5858

5959
LAGRAPHX_PUBLIC
60-
int LAGraph_Random_Init
60+
int LAGraph_Random_Init // FIXME: remove this
6161
(
6262
char *msg
6363
) ;
6464
LAGRAPHX_PUBLIC
65-
int LAGraph_Random_Finalize
65+
int LAGraph_Random_Finalize // FIXME: remove this
6666
(
6767
char *msg
6868
) ;
@@ -72,24 +72,6 @@ int LAGraph_Random_Finalize
7272
LAGRAPHX_PUBLIC extern bool random_hack ;
7373
#endif
7474

75-
LAGRAPHX_PUBLIC
76-
int LAGraph_Random_Seed // construct a random seed vector
77-
(
78-
// input/output
79-
GrB_Vector Seed, // vector of random number seeds, normally GrB_UINT64
80-
// input
81-
uint64_t seed, // scalar input seed
82-
char *msg
83-
) ;
84-
85-
LAGRAPHX_PUBLIC
86-
int LAGraph_Random_Next // advance to next random vector
87-
(
88-
// input/output
89-
GrB_Vector Seed,
90-
char *msg
91-
) ;
92-
9375
LAGRAPHX_PUBLIC
9476
GrB_Info LAGraph_Random_Matrix // random matrix of any built-in type
9577
(

src/benchmark/LAGraph_demo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ static int readproblem // returns 0 if successful, -1 if failure
910910
// typecast, if requested
911911
//--------------------------------------------------------------------------
912912

913-
GRB_TRY (GxB_Matrix_type (&atype, A)) ; // FIXME: use GrB_get
913+
GRB_TRY (GxB_Matrix_type (&atype, A)) ;
914914

915915
if (structural)
916916
{

src/test/test_ConnectedComponents.c

+5
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ void test_cc_matrices (void)
154154
TEST_CHECK (ncomponents == ncomp) ;
155155
OK (LG_check_cc (C2, G, msg)) ;
156156
OK (GrB_free (&C2)) ;
157+
#else
158+
printf ("\n------ CC_FastSV7: requires SS:GrB v10.0.0 or later\n") ;
159+
int result7 = LG_CC_FastSV7 (&C2, G, msg) ;
160+
TEST_CHECK (result7 == GrB_NOT_IMPLEMENTED) ;
161+
TEST_CHECK (C2 == NULL) ;
157162
#endif
158163

159164
#endif
File renamed without changes.

src/utility/LAGr_Init.c

+2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ int LAGr_Init
218218
// create global objects
219219
//--------------------------------------------------------------------------
220220

221+
LG_Random_Init (msg) ;
222+
221223
// LAGraph_plus_first_T: using the GrB_PLUS_MONOID_T monoid and the
222224
// GrB_FIRST_T multiplicative operator. These semirings compute C=A*B
223225
// where only the structure of B is accessed. In MATLAB, this can be

src/utility/LAGraph_Finalize.c

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ int LAGraph_Finalize (char *msg)
3030
// free global objects
3131
//--------------------------------------------------------------------------
3232

33+
LG_TRY (LG_Random_Finalize (msg)) ;
34+
3335
GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_int8 )) ;
3436
GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_int16 )) ;
3537
GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_int32 )) ;
@@ -82,3 +84,4 @@ int LAGraph_Finalize (char *msg)
8284
GRB_TRY (GrB_finalize ( )) ;
8385
return (GrB_SUCCESS) ;
8486
}
87+

0 commit comments

Comments
 (0)