Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
# get the version
#-------------------------------------------------------------------------------

cmake_minimum_required ( VERSION 3.20 ) # LAGraph can be built stand-alone
cmake_minimum_required ( VERSION 3.23 )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmake 3.23 is now common. It's also required for the changes in SuiteSparsePolicy.cmake.


# version of LAGraph
set ( LAGraph_DATE "Sept 8, 2025" )
set ( LAGraph_DATE "July 21, 2026" )
set ( LAGraph_VERSION_MAJOR 1 CACHE STRING "" FORCE )
set ( LAGraph_VERSION_MINOR 2 CACHE STRING "" FORCE )
set ( LAGraph_VERSION_SUB 1 CACHE STRING "" FORCE )
set ( LAGraph_VERSION_SUB 2 CACHE STRING "" FORCE )

message ( STATUS "Building LAGraph version: v"
${LAGraph_VERSION_MAJOR}.
Expand Down Expand Up @@ -70,6 +70,17 @@ include ( SuiteSparsePolicy )

enable_language ( C )

# check if stdalign.h exists
include ( CheckIncludeFile )
check_include_file ( stdalign.h HAVE_STDALIGN_H )
if ( HAVE_STDALIGN_H )
set ( LAGraph_HAS_STDALIGN_H 1 )
message ( STATUS "stdalign.h is available" )
else ( )
message ( STATUS "stdalign.h is not available" )
set ( LAGraph_HAS_STDALIGN_H 0 )
endif ( )

# configure LAGraph.h with the LAGraph date and version
configure_file (
"Config/LAGraph.h.in"
Expand Down Expand Up @@ -152,8 +163,7 @@ else ( )
# message ( STATUS "GRAPHBLAS_ROOT: ${GRAPHBLAS_ROOT} $ENV{GRAPHBLAS_ROOT}" )

# No package version is explicitly stated here; an arbitrary GraphBLAS
# library can have any version number. For SuiteSparse:GraphBLAS, LAGraph
# requires v7.1.0 or later, which is checked in LAGraph.h.
# library can have any version number.
message ( STATUS "Looking for GraphBLAS with FindGraphBLAS.cmake" )
find_package ( GraphBLAS MODULE REQUIRED )

Expand Down Expand Up @@ -375,6 +385,25 @@ else ( )
endif ( )
endif ( )

if ( GRAPHBLAS_VERSION )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix for a very strange problem I had in GraphBLAS 10.3.2. In v10.3.1, I had 3 cmake variables, GraphBLAS_VERSION_MAJOR, *_MINOR, and *_SUB. They worked just fine, and were held in the cmake cache.

Then in going to 10.3.2, the _MAJOR and _MINOR variables got "lots". They appear in the cache but are empty when used in cmake. I "fixed" it by renaming them GraphBLAS_VER_MAJOR, etc. It might be that an update to cmake causes the non-cached variables GRAPHBLAS_VERSION_MAJOR etc to clash with the cached GraphBLAS_VERSION_MAJOR variables (note the lower vs upper case).

I fixed the issue in GraphBLAS but then this cmake code in LAGraph could no longer detect the right GraphBLAS version to configure its FindGraphBLAS.cmake script. It does have GRAPHBLAS_VERSION so I've added this cmake script to parse out the 3 major, minor, and update components.

This script now works.

if ( ${GRAPHBLAS_VERSION} MATCHES "([0-9]+).[0-9]+.[0-9]+" )
set ( GraphBLAS_VER_MAJOR ${CMAKE_MATCH_1} )
endif ( )
if ( ${GRAPHBLAS_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+" )
set ( GraphBLAS_VER_MINOR ${CMAKE_MATCH_1} )
endif ( )
if ( ${GRAPHBLAS_VERSION} MATCHES "[0-9]+.[0-9]+.([0-9]+)" )
set ( GraphBLAS_VER_PATCH ${CMAKE_MATCH_1} )
endif ( )
if ( LAGRAPH_DUMP )
message ( STATUS "major: ${GraphBLAS_VER_MAJOR}" )
message ( STATUS "minor: ${GraphBLAS_VER_MINOR}" )
message ( STATUS "patch: ${GraphBLAS_VER_PATCH}" )
endif ( )
endif ( )

message (STATUS "Config with GraphBLAS version ${GraphBLAS_VER_MAJOR}.${GraphBLAS_VER_MINOR}.${GraphBLAS_VER_PATCH}" )

# generate config file to be used in common build tree
set ( SUITESPARSE_IN_BUILD_TREE ON )
configure_package_config_file (
Expand Down
13 changes: 7 additions & 6 deletions Config/LAGraph.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define LAGRAPH_VERSION_MAJOR @LAGraph_VERSION_MAJOR@
#define LAGRAPH_VERSION_MINOR @LAGraph_VERSION_MINOR@
#define LAGRAPH_VERSION_UPDATE @LAGraph_VERSION_SUB@
#define LAGRAPH_HAS_STDALIGN_H @LAGraph_HAS_STDALIGN_H@

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSVC is a pathetic compiler. It claims to be C11 compliant but it does not have stdalign.h. I thus check for it in the cmake script and configure LAGraph accordingly.


//==============================================================================
// include files and helper macros
Expand Down Expand Up @@ -104,8 +105,8 @@

#if ( !LAGRAPH_VANILLA ) && defined ( GxB_SUITESPARSE_GRAPHBLAS )
// use SuiteSparse, and its GxB* extensions
#if GxB_IMPLEMENTATION < GxB_VERSION (9,0,0)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LAGraph no longer works with GraphBLAS 9.0.0 so I took this out.

#error "If using SuiteSparse::GraphBLAS, version 9.0.0 or later is required"
#if GxB_IMPLEMENTATION < GxB_VERSION (10,0,0)
#error "SuiteSparse::GraphBLAS v10.0.0 or later is required"
#endif
#define LAGRAPH_SUITESPARSE 1
#else
Expand Down Expand Up @@ -2410,11 +2411,11 @@ int LAGr_SingleSourceShortestPath
) ;

//------------------------------------------------------------------------------
// LAGr_Betweenness: betweeness centrality metric
// LAGr_Betweenness: betweenness centrality metric
//------------------------------------------------------------------------------

/** LAGr_Betweenness: betweeness centrality metric. This methods computes an
* approximation of the betweeness-centrality metric of all nodes in the graph.
/** LAGr_Betweenness: betweenness centrality metric. This methods computes an
* approximation of the betweenness-centrality metric of all nodes in the graph.
* Only a few given source nodes are used for the approximation. This is an
* Advanced algorithm (G->AT is required).
*
Expand Down Expand Up @@ -2442,7 +2443,7 @@ LAGRAPH_PUBLIC
int LAGr_Betweenness
(
// output:
GrB_Vector *centrality, // centrality(i): betweeness centrality of i
GrB_Vector *centrality, // centrality(i): betweenness centrality of i
// input:
const LAGraph_Graph G, // input graph
const GrB_Index *sources, // source vertices to compute shortest paths
Expand Down
4 changes: 2 additions & 2 deletions Config/LAGraphConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ include ( CMakeFindDependencyMacro )
set ( _dependencies_found ON )

if ( NOT TARGET GraphBLAS::GraphBLAS )
# Look GraphBLAS
# Look for GraphBLAS
list ( PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} )
find_dependency ( GraphBLAS @GraphBLAS_VERSION_MAJOR@.@GraphBLAS_VERSION_MINOR@ )
find_dependency ( GraphBLAS @GraphBLAS_VER_MAJOR@.@GraphBLAS_VER_MINOR@ )
endif ( )

if ( NOT GraphBLAS_FOUND )
Expand Down
20 changes: 10 additions & 10 deletions cmake_modules/FindGraphBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,18 @@ string (

if ( GRAPHBLAS_VERSION )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments below about why I needed to fix this to detect the GraphBLAS version correctly.

if ( ${GRAPHBLAS_VERSION} MATCHES "([0-9]+).[0-9]+.[0-9]+" )
set ( GraphBLAS_VERSION_MAJOR ${CMAKE_MATCH_1} )
set ( GraphBLAS_VER_MAJOR ${CMAKE_MATCH_1} )
endif ( )
if ( ${GRAPHBLAS_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+" )
set ( GraphBLAS_VERSION_MINOR ${CMAKE_MATCH_1} )
set ( GraphBLAS_VER_MINOR ${CMAKE_MATCH_1} )
endif ( )
if ( ${GRAPHBLAS_VERSION} MATCHES "[0-9]+.[0-9]+.([0-9]+)" )
set ( GraphBLAS_VERSION_PATCH ${CMAKE_MATCH_1} )
set ( GraphBLAS_VER_PATCH ${CMAKE_MATCH_1} )
endif ( )
if ( LAGRAPH_DUMP )
message ( STATUS "major: ${GraphBLAS_VERSION_MAJOR}" )
message ( STATUS "minor: ${GraphBLAS_VERSION_MINOR}" )
message ( STATUS "patch: ${GraphBLAS_VERSION_PATCH}" )
message ( STATUS "major: ${GraphBLAS_VER_MAJOR}" )
message ( STATUS "minor: ${GraphBLAS_VER_MINOR}" )
message ( STATUS "patch: ${GraphBLAS_VER_PATCH}" )
endif ( )
endif ( )

Expand All @@ -300,10 +300,10 @@ if ( EXISTS "${GRAPHBLAS_INCLUDE_DIR}" AND NOT GRAPHBLAS_VERSION )
message ( STATUS "minor: ${GRAPHBLAS_MINOR_STR}" )
message ( STATUS "patch: ${GRAPHBLAS_PATCH_STR}" )
endif ( )
string ( REGEX MATCH "[0-9]+" GraphBLAS_VERSION_MAJOR ${GRAPHBLAS_MAJOR_STR} )
string ( REGEX MATCH "[0-9]+" GraphBLAS_VERSION_MINOR ${GRAPHBLAS_MINOR_STR} )
string ( REGEX MATCH "[0-9]+" GraphBLAS_VERSION_PATCH ${GRAPHBLAS_PATCH_STR} )
set (GRAPHBLAS_VERSION "${GraphBLAS_VERSION_MAJOR}.${GraphBLAS_VERSION_MINOR}.${GraphBLAS_VERSION_PATCH}")
string ( REGEX MATCH "[0-9]+" GraphBLAS_VER_MAJOR ${GRAPHBLAS_MAJOR_STR} )
string ( REGEX MATCH "[0-9]+" GraphBLAS_VER_MINOR ${GRAPHBLAS_MINOR_STR} )
string ( REGEX MATCH "[0-9]+" GraphBLAS_VER_PATCH ${GRAPHBLAS_PATCH_STR} )
set (GRAPHBLAS_VERSION "${GraphBLAS_VER_MAJOR}.${GraphBLAS_VER_MINOR}.${GraphBLAS_VER_PATCH}")
endif ( )

set ( GRAPHBLAS_LIBRARIES ${GRAPHBLAS_LIBRARY} )
Expand Down
27 changes: 11 additions & 16 deletions cmake_modules/SuiteSparsePolicy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
# GraphBLAS is false.
#
# SUITESPARSE_CUDA_ARCHITECTURES: a string, such as "all" or
# "35;50;75;80" that lists the CUDA architectures to use

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change to SuiteSparsePolicy.cmake has no effect on LAGraph at all, but I've included it to sync it with my upcoming release of SuiteSparse 7.12.3, which will include LAGraph v1.2.2.

# "75;80" that lists the CUDA architectures to use
# when compiling CUDA kernels with nvcc. The "all"
# option requires cmake 3.23 or later.
# Default: "52;75;80".
# Default: "all".
#
# BLA_VENDOR and BLA_SIZEOF_INTEGER: By default, SuiteSparse searches for
# the BLAS library in a specific order. If you wish to
Expand Down Expand Up @@ -310,24 +310,19 @@ if ( SUITESPARSE_USE_FORTRAN )
set ( SUITESPARSE_HAS_FORTRAN ON )
if ( NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_C_COMPILER_ID}" OR
NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}" )
message ( STATUS " " )
message ( STATUS "Incompatible Fortran/C/C++ compilers detected:" )
message ( STATUS " Fortran: ${CMAKE_Fortran_COMPILER}" )
message ( STATUS " Fortran id: ${CMAKE_Fortran_COMPILER_ID}" )
message ( STATUS " C ${CMAKE_C_COMPILER}" )
message ( STATUS " C id: ${CMAKE_C_COMPILER_ID}" )
message ( STATUS " C++ ${CMAKE_CXX_COMPILER}" )
message ( STATUS " C++ id: ${CMAKE_CXX_COMPILER_ID}" )
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "IntelLLVM" )
message ( STATUS " " )
message ( STATUS "Incompatible Fortran/C/C++ compilers detected:" )
message ( STATUS " Fortran: ${CMAKE_Fortran_COMPILER}" )
message ( STATUS " Fortran id: ${CMAKE_Fortran_COMPILER_ID}" )
message ( STATUS " C ${CMAKE_C_COMPILER}" )
message ( STATUS " C id: ${CMAKE_C_COMPILER_ID}" )
message ( STATUS " C++ ${CMAKE_CXX_COMPILER}" )
message ( STATUS " C++ id: ${CMAKE_CXX_COMPILER_ID}" )
# icx/icpx cannot be used with gfortran: this is a fatal error
message ( FATAL_ERROR "ERROR: Using Fortran with SuiteSparse requires that "
" it has the same compiler ID as the C/C++ compilers."
" Use a compatible Fortran compiler, or set SUITESPARSE_USE_FORTRAN to OFF." )
else ( )
# other cases: just issue a warning and hope it works.
message ( WARNING "Warning: Using Fortran with SuiteSparse requires that "
" it has the same compiler ID as the C/C++ compilers."
" Use a compatible Fortran compiler, or set SUITESPARSE_USE_FORTRAN to OFF." )
endif ( )
endif ( )
message ( STATUS "Fortran: enabled" )
Expand Down Expand Up @@ -401,7 +396,7 @@ endif ( )

if ( SUITESPARSE_HAS_CUDA )
message ( STATUS "CUDA: enabled" )
set ( SUITESPARSE_CUDA_ARCHITECTURES "52;75;80" CACHE STRING "CUDA architectures" )
set ( SUITESPARSE_CUDA_ARCHITECTURES "all" CACHE STRING "CUDA architectures" )
set ( CMAKE_CUDA_ARCHITECTURES ${SUITESPARSE_CUDA_ARCHITECTURES} )
else ( )
message ( STATUS "CUDA: not enabled" )
Expand Down
11 changes: 9 additions & 2 deletions experimental/algorithm/LAGraph_cdlp.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@

#include <LAGraph.h>
#include <LAGraphX.h>
#include <stdalign.h>
#if LAGRAPH_HAS_STDALIGN_H

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments about about the miserable MSVC compiler's claim to C11 compliance while not actualy being C11 compliant by not providing a stdalign.h.

@mmuetzel mmuetzel Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, alignas is C23 (and maybe a GNU extension or POSIX?). For C11, the standard spelling is _Alignas:
https://en.cppreference.com/c/language/_Alignas

According to its documentation, MSVC understands the C11 keyword _Alignas without including any headers (because it is a keyword). So should any C11 conforming compiler.
https://learn.microsoft.com/en-us/cpp/c-language/alignment-c?view=msvc-170

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, alignas is defined as a macro in C11. MSVC should be defining it in <stdalign.h> at least since Visual Studio 2015.

Which version of MSVC is this fix for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. It's from an issue raised here:
DrTimothyAldenDavis/SuiteSparse#1043

The use of stdalign.h is very minor in LAGraph, so I just disabled its use if stdalign.h is not available.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...

I'm not sure with which compiler that user was seeing that problem. They don't seem to have given any hints about that.

Maybe, whichever compiler and which version of it they used, it defaulted to C23. And since in that version of C, align is a language keyword which doesn't require including any header, the implementers decided to remove stdalign.h entirely if that version of the standard is used.

If that is the actual problem, it might be better to check in the test whether using align requires the prior inclusion of any header.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll tag this as a new issue.

#include <stdalign.h>
#define ALIGNAS_64 alignas(64)
#else
// the alignas keyword/macro is not available
#define ALIGNAS_64
#endif
#include "LG_internal.h"

// A Go-style slice / Lisp-style property list
Expand Down Expand Up @@ -141,7 +147,7 @@ void counts_reducer(GrB_Index* e1, GrB_Index* c1, GrB_Index e2, GrB_Index c2) {
#define bucket_shift (64llu - bucket_bits)

typedef struct {
alignas(64) plist buckets[nof_buckets];
ALIGNAS_64 plist buckets[nof_buckets];
} ptable;

void ptable_free(ptable* table) {
Expand Down Expand Up @@ -187,6 +193,7 @@ void ptable_reduce(ptable* table, GrB_Index* entry, GrB_Index* count, plist_redu
}

//****************************************************************************

int LAGraph_cdlp
(
GrB_Vector *CDLP_handle, // output vector
Expand Down
17 changes: 9 additions & 8 deletions include/LAGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
// See also the LAGraph_Version utility method, which returns these values.
// These definitions are derived from LAGraph/CMakeLists.txt.

#define LAGRAPH_DATE "Sept 8, 2025"
#define LAGRAPH_DATE "July 21, 2026"
#define LAGRAPH_VERSION_MAJOR 1
#define LAGRAPH_VERSION_MINOR 2
#define LAGRAPH_VERSION_UPDATE 1
#define LAGRAPH_VERSION_UPDATE 2
#define LAGRAPH_HAS_STDALIGN_H 1

//==============================================================================
// include files and helper macros
Expand Down Expand Up @@ -104,8 +105,8 @@

#if ( !LAGRAPH_VANILLA ) && defined ( GxB_SUITESPARSE_GRAPHBLAS )
// use SuiteSparse, and its GxB* extensions
#if GxB_IMPLEMENTATION < GxB_VERSION (9,0,0)
#error "If using SuiteSparse::GraphBLAS, version 9.0.0 or later is required"
#if GxB_IMPLEMENTATION < GxB_VERSION (10,0,0)
#error "SuiteSparse::GraphBLAS v10.0.0 or later is required"
#endif
#define LAGRAPH_SUITESPARSE 1
#else
Expand Down Expand Up @@ -2410,11 +2411,11 @@ int LAGr_SingleSourceShortestPath
) ;

//------------------------------------------------------------------------------
// LAGr_Betweenness: betweeness centrality metric
// LAGr_Betweenness: betweenness centrality metric
//------------------------------------------------------------------------------

/** LAGr_Betweenness: betweeness centrality metric. This methods computes an
* approximation of the betweeness-centrality metric of all nodes in the graph.
/** LAGr_Betweenness: betweenness centrality metric. This methods computes an
* approximation of the betweenness-centrality metric of all nodes in the graph.
* Only a few given source nodes are used for the approximation. This is an
* Advanced algorithm (G->AT is required).
*
Expand Down Expand Up @@ -2442,7 +2443,7 @@ LAGRAPH_PUBLIC
int LAGr_Betweenness
(
// output:
GrB_Vector *centrality, // centrality(i): betweeness centrality of i
GrB_Vector *centrality, // centrality(i): betweenness centrality of i
// input:
const LAGraph_Graph G, // input graph
const GrB_Index *sources, // source vertices to compute shortest paths
Expand Down
Loading