Skip to content

Commit

Permalink
demo
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Sep 6, 2022
1 parent 9992f75 commit 0002ffd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 192 deletions.
23 changes: 6 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# cmake 3.13 is required; cmake 3.17 or later required for CUDA
cmake_minimum_required ( VERSION 3.13 )

message ( STATUS "GrapphBLAS source: " ${CMAKE_SOURCE_DIR} )
message ( STATUS "GrapphBLAS build: " ${CMAKE_BINARY_DIR} )
message ( STATUS "GraphBLAS source: " ${CMAKE_SOURCE_DIR} )
message ( STATUS "GraphBLAS build: " ${CMAKE_BINARY_DIR} )
message ( STATUS "CMake version: " ${CMAKE_VERSION} )

# version of SuiteSparse:GraphBLAS
Expand All @@ -27,21 +27,10 @@ set ( GraphBLAS_VERSION_SUB 0 )
message ( STATUS "Building SuiteSparse:GraphBLAS version: v" ${GraphBLAS_VERSION_MAJOR}.${GraphBLAS_VERSION_MINOR}.${GraphBLAS_VERSION_SUB} " date: " ${GraphBLAS_DATE} )

# GraphBLAS C API Specification version, at graphblas.org
if ( GraphBLAS_VERSION_MAJOR GREATER_EQUAL 6 )
# SuiteSparse:GraphBLAS v6.0.0 and later fully implement the v2 spec
set ( GraphBLAS_API_DATE "Nov 15, 2021" )
set ( GraphBLAS_API_VERSION_MAJOR 2 )
set ( GraphBLAS_API_VERSION_MINOR 0 )
set ( GraphBLAS_API_VERSION_SUB 0 )
else ( )
# SuiteSparse:GraphBLAS v5.2.0 has much of the v2 spec but not all.
# It is backward compatible with all v5.x which have little of the new
# features of the v2 C API Specification.
set ( GraphBLAS_API_DATE "Sept 25, 2019" )
set ( GraphBLAS_API_VERSION_MAJOR 1 )
set ( GraphBLAS_API_VERSION_MINOR 3 )
set ( GraphBLAS_API_VERSION_SUB 0 )
endif ( )
set ( GraphBLAS_API_DATE "Nov 15, 2021" )
set ( GraphBLAS_API_VERSION_MAJOR 2 )
set ( GraphBLAS_API_VERSION_MINOR 0 )
set ( GraphBLAS_API_VERSION_SUB 0 )

message ( STATUS "GraphBLAS C API: v" "${GraphBLAS_API_VERSION_MAJOR}.${GraphBLAS_API_VERSION_MINOR}, date: ${GraphBLAS_API_DATE}" )

Expand Down
2 changes: 1 addition & 1 deletion Demo/Output/wildtype_demo.out
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ a wildtype scalar: [this is A(3,7)]
Printing the matrix with GxB_Matrix_fprint:

10x10 GraphBLAS wildtype matrix, hypersparse by row
input B, 1 entry, memory: 36.5 KB
input B, 1 entry, memory: 36.9 KB
pending tuples: 2 max pending: 256 zombies: 0

(7,2) [user-defined value]
Expand Down
172 changes: 0 additions & 172 deletions Demo/Program/wathen_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,178 +64,6 @@ int main (int argc, char **argv)

FREE_ALL ;

#if 0

//--------------------------------------------------------------------------
// benchmark Wathen matrices (for ACM TOMS submission)
//--------------------------------------------------------------------------

GrB_Descriptor Desc_Gustavson = NULL, Desc_Hash = NULL ;
GrB_Descriptor_new (&Desc_Gustavson) ;
GrB_Descriptor_new (&Desc_Hash) ;
GxB_Desc_set (Desc_Gustavson, GxB_AxB_METHOD, GxB_AxB_GUSTAVSON) ;
GxB_Desc_set (Desc_Hash , GxB_AxB_METHOD, GxB_AxB_HASH ) ;

for (nx = 100 ; nx <= 2200 ; nx += 100)
{
printf ("\n ------------------- nx %ld\n", nx) ;
GxB_set (GxB_NTHREADS, 40) ;

// create the wathen matrix
t = omp_get_wtime ( ) ;
OK (wathen (&A, nx, nx, false, 0, NULL)) ;
t = omp_get_wtime ( ) - t ;
GrB_Index nvals1, nvals2, n ;
OK (GrB_Matrix_nrows (&n, A)) ;
OK (GrB_Matrix_nvals (&nvals1, A)) ;
double t2_sequential, t4_sequential, t8_sequential ;

printf ("\n=================================\n"
"nx %5ld n %10.3fM nvals %10.3fM create: %10.3f sec\n",
nx, (double) n / 1e6, (double) nvals1 / 1e6, t) ;

double T2 [3][7], T4 [3][7], T8 [3][7] ;
double T2best [7], T4best [7], T8best [7] ;

for (int algo = 0 ; algo <= 2 ; algo++)
// for (int algo = 0 ; algo <= 1 ; algo++)
{
GrB_Descriptor desc = NULL ;
if (algo == 1) desc = Desc_Gustavson ;
if (algo == 2) desc = Desc_Hash ;

int Nthreads [7] = {1, 2, 4, 8, 16, 20, 40} ;
for (int k = 0 ; k < 7 ; k++)
{
// set the # of threads to use
int nth = Nthreads [k] ;
GxB_set (GxB_NTHREADS, nth) ;

GrB_Matrix C = NULL ;
OK (GrB_Matrix_new (&C, GrB_FP64, n, n)) ;
char *algo_name = (algo == 0) ? "Auto" :
((algo == 1) ? "Gustavson" : "Hash") ;
printf ("\nalgo: %s nthreads: %d\n", algo_name, nth) ;
// if (nth == 2 || nth == 40)
GxB_set (GxB_BURBLE, true) ;

// square it: C = A*A
double t2 = omp_get_wtime ( ) ;
OK (GrB_mxm (C, NULL, NULL, GrB_PLUS_TIMES_SEMIRING_FP64,
A, A, desc)) ;
t2 = omp_get_wtime ( ) - t2 ;
GxB_set (GxB_BURBLE, false) ;
OK (GrB_Matrix_nvals (&nvals2, C)) ;
GxB_set (GxB_BURBLE, true) ;
printf ("C=A^2 threads: %2d mxm: %10.3f nvals %10.3fM ",
nth, t2, ((double) nvals2) / 1e6) ;
if (nth == 1) t2_sequential = t2 ;
printf ("speedup: %g\n", t2_sequential/t2) ;
T2 [algo][k] = t2 ;

// square it again: C = C*C to get A^4
// if (nx <= 4000)
{
double t4 = omp_get_wtime ( ) ;
OK (GrB_mxm (C, NULL, NULL, GrB_PLUS_TIMES_SEMIRING_FP64,
C, C, desc)) ;
t4 = omp_get_wtime ( ) - t4 ;
GxB_set (GxB_BURBLE, false) ;
OK (GrB_Matrix_nvals (&nvals2, C)) ;
GxB_set (GxB_BURBLE, true) ;
printf ("C=A^4 threads: %2d mxm: %10.3f nvals %10.3fM ",
nth, t4, ((double) nvals2) / 1e6) ;
if (nth == 1) t4_sequential = t4 ;
printf ("speedup: %g\n", t4_sequential/t4) ;
T4 [algo][k] = t4 ;
}

// square it again: C = C*C to get A^8
// if (nx <= 1000)
{
double t8 = omp_get_wtime ( ) ;
OK (GrB_mxm (C, NULL, NULL, GrB_PLUS_TIMES_SEMIRING_FP64,
C, C, desc)) ;
t8 = omp_get_wtime ( ) - t8 ;
GxB_set (GxB_BURBLE, false) ;
OK (GrB_Matrix_nvals (&nvals2, C)) ;
GxB_set (GxB_BURBLE, true) ;
printf ("C=A^8 threads: %2d mxm: %10.3f nvals %10.3fM ",
nth, t8, ((double) nvals2) / 1e6) ;
if (nth == 1) t8_sequential = t8 ;
printf ("speedup: %g\n", t8_sequential/t8) ;
T8 [algo][k] = t8 ;
}

GxB_set (GxB_BURBLE, false) ;
GrB_Matrix_free (&C) ;
}
}
GrB_Matrix_free (&A) ;

printf ("\nSummary:\n") ;
for (int algo = 0 ; algo <= 2 ; algo++)
{
char *algo_name = (algo == 0) ? "Auto" : ((algo == 1) ? "Gus " : "Hash") ;
printf ("algo %s : ", algo_name) ;
printf ("| T2: ") ;
for (int k = 0 ; k < 7 ; k++)
{
printf ("%10.2f ", T2 [algo][k]) ;
}
printf ("| T4: ") ;
for (int k = 0 ; k < 7 ; k++)
{
printf ("%10.2f ", T4 [algo][k]) ;
}
printf ("| T8: ") ;
for (int k = 0 ; k < 7 ; k++)
{
printf ("%10.2f ", T8 [algo][k]) ;
}
printf ("\n") ;
}

for (int k = 0 ; k < 7 ; k++)
{
T2best [k] = fmin (fmin (T2 [0][k], T2 [1][k]), T2 [2][k]) ;
T4best [k] = fmin (fmin (T4 [0][k], T4 [1][k]), T4 [2][k]) ;
T8best [k] = fmin (fmin (T8 [0][k], T8 [1][k]), T8 [2][k]) ;
}

printf ("\nRelative:\n") ;
for (int algo = 0 ; algo <= 2 ; algo++)
{
char *algo_name = (algo == 0) ? "Auto" : ((algo == 1) ? "Gus " : "Hash") ;
printf ("algo %s : ", algo_name) ;
printf ("| T2: ") ;
for (int k = 0 ; k < 7 ; k++)
{
if (T2 [algo][k] == T2best [k]) printf (" 1 ") ;
else printf ("%10.2f ", T2 [algo][k] / T2best [k]) ;
}
printf ("| T4: ") ;
for (int k = 0 ; k < 7 ; k++)
{
if (T4 [algo][k] == T4best [k]) printf (" 1 ") ;
else printf ("%10.2f ", T4 [algo][k] / T4best [k]) ;
}
printf ("| T8: ") ;
for (int k = 0 ; k < 7 ; k++)
{
if (T8 [algo][k] == T8best [k]) printf (" 1 ") ;
else printf ("%10.2f ", T8 [algo][k] / T8best [k]) ;
}
printf ("\n") ;
}


}

GrB_free (&Desc_Gustavson) ;
GrB_free (&Desc_Hash) ;
#endif

OK (GrB_finalize ( )) ;
}

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ debug:
all:
( cd build ; cmake $(CMAKE_OPTIONS) -DDEMO=1 .. ; $(MAKE) --jobs=$(JOBS) )

# just run the demos
run: all
# run the demos
demo: all
( cd Demo ; ./demo )

# just do 'make' in build; do not rerun the cmake script
Expand Down

0 comments on commit 0002ffd

Please sign in to comment.