Skip to content

Commit 09e1f7c

Browse files
Merge pull request #377 from GraphBLAS/with_GraphBLAS_v10
Fortran policy; sync with SuiteSparse 7.11.0
2 parents 0cbed2b + 2a2e335 commit 09e1f7c

File tree

2 files changed

+52
-27
lines changed

2 files changed

+52
-27
lines changed

Makefile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#
2020
# To compile with an alternate compiler:
2121
#
22-
# make CC=gcc CXX=g++
22+
# make CC=gcc CXX=g++ FC=gfortran
2323
#
2424
# To compile/install for system-wide usage (typically in /usr/local):
2525
#
@@ -48,28 +48,30 @@
4848

4949
JOBS ?= 8
5050

51+
F = -DSUITESPARSE_USE_FORTRAN=OFF
52+
5153
default: library
5254

5355
library:
54-
( cd build && cmake $(CMAKE_OPTIONS) .. && cmake --build . --config Release -j${JOBS} )
56+
( cd build && cmake $(F) $(CMAKE_OPTIONS) .. && cmake --build . --config Release -j${JOBS} )
5557

5658
# install only in SuiteSparse/lib and SuiteSparse/include
5759
local:
58-
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DSUITESPARSE_LOCAL_INSTALL=1 .. && cmake --build . --config Release -j${JOBS} )
60+
( cd build && cmake $(F) $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DSUITESPARSE_LOCAL_INSTALL=1 .. && cmake --build . --config Release -j${JOBS} )
5961

6062
# install CMAKE_INSTALL_PREFIX
6163
global:
62-
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DSUITESPARSE_LOCAL_INSTALL=0 .. && cmake --build . --config Release -j${JOBS} )
64+
( cd build && cmake $(F) $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DSUITESPARSE_LOCAL_INSTALL=0 .. && cmake --build . --config Release -j${JOBS} )
6365

6466
vanilla:
65-
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DLAGRAPH_VANILLA=1 .. && cmake --build . --config Release -j${JOBS} )
67+
( cd build && cmake $(F) $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DLAGRAPH_VANILLA=1 .. && cmake --build . --config Release -j${JOBS} )
6668

6769
# compile with -g for debugging
6870
debug:
69-
( cd build && cmake $(CMAKE_OPTIONS) -DCMAKE_BUILD_TYPE=Debug .. && cmake --build . --config Release -j${JOBS} )
71+
( cd build && cmake $(F) $(CMAKE_OPTIONS) -DCMAKE_BUILD_TYPE=Debug .. && cmake --build . --config Release -j${JOBS} )
7072

7173
vanilla_debug:
72-
( cd build && cmake $(CMAKE_OPTIONS) -DCMAKE_BUILD_TYPE=Debug -USUITESPARSE_PKGFILEDIR -DLAGRAPH_VANILLA=1 .. && cmake --build . --config Release -j${JOBS} )
74+
( cd build && cmake $(F) $(CMAKE_OPTIONS) -DCMAKE_BUILD_TYPE=Debug -USUITESPARSE_PKGFILEDIR -DLAGRAPH_VANILLA=1 .. && cmake --build . --config Release -j${JOBS} )
7375

7476
all: library
7577

@@ -83,7 +85,7 @@ verbose_test: library
8385
# dlopen and dlinit), and run the tests with valgrind. For best results,
8486
# compile GraphBLAS without OpenMP and with the JIT disabled.
8587
memcheck: distclean
86-
( cd build && cmake $(CMAKE_OPTIONS) -DCMAKE_BUILD_TYPE=Debug -DLAGRAPH_USE_OPENMP=0 .. )
88+
( cd build && cmake $(F) $(CMAKE_OPTIONS) -DCMAKE_BUILD_TYPE=Debug -DLAGRAPH_USE_OPENMP=0 .. )
8789
( cd build && cmake --build . --config Release -j${JOBS} )
8890
( cd build && ctest . -T memcheck )
8991

@@ -96,7 +98,7 @@ remake:
9698

9799
# just run cmake to set things up
98100
setup:
99-
( cd build && cmake $(CMAKE_OPTIONS) .. )
101+
( cd build && cmake $(F) $(CMAKE_OPTIONS) .. )
100102

101103
install:
102104
( cd build && cmake --install . )
@@ -107,7 +109,7 @@ uninstall:
107109

108110
# clean, compile, and run test coverage
109111
cov: distclean
110-
( cd build && cmake -DCOVERAGE=1 .. && cmake --build . --config Release -j${JOBS} && cmake --build . --target test_coverage )
112+
( cd build && cmake $(F) -DCOVERAGE=1 .. && cmake --build . --config Release -j${JOBS} && cmake --build . --target test_coverage )
111113

112114
# remove all files not in the distribution
113115
clean: distclean

cmake_modules/SuiteSparsePolicy.cmake

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,20 @@
7070
# This will require SUITESPARSE_C_TO_FORTRAN to be
7171
# defined explicitly, if the defaults are not appropriate
7272
# for your system.
73-
# Default: OFF
73+
# Default: ON
7474
#
75-
# This setting was ON by default in SuiteSparse 7.10.0 and earlier.
76-
# Note that Fortran is now disabled by default, with the default setting
77-
# of SUITESPARSE_USE_FORTRAN changed from ON to OFF. If the icx compiler
78-
# and the Intel MKL BLAS are available but ifx is not, then loading the
79-
# GNU Fortran compiler causes the cmake FindBLAS to link the Intel MKL
80-
# against libgomp, but at the same time cmake links the application with
81-
# libiomp. Including two OpenMP libraries, libiomp and libgomp, in one
82-
# application can cause serious performance issues. To avoid this issue,
83-
# SUITESPARSE_USE_FORTRAN has been set to OFF. This has little impact on
84-
# SuiteSparse (it disables the AMD Fortran routines, and removes the
85-
# Fortran interface to UMFPACK). If you wish to use those features,
86-
# re-enable the SUITESPARSE_USE_FORTRAN, but be sure to use either gcc
87-
# and gfortran together, or icx and ifx together. Do not mix-and-match
88-
# the compilers.
75+
# *** WARNING: Using the Intel icx compiler, the Intel MKL BLAS, and the
76+
# GNU Fortran compiler together will result in two OpenMP libraries
77+
# linked to the UMFPACK, CHOLMOD, ParU, and SPQR libraries. This will
78+
# cause serious performance issues. This cmake file detects if icx and
79+
# gfortran are in use, and issues a fatal error. Otherwise, if the C,
80+
# C++, and Fortran compilers have a different compiler ID, a warning is
81+
# issued; this is NOT recommended, but it might be OK. In that case,
82+
# ensure that you are linking with just one OpenMP library. If this
83+
# occurs, disable the use of Fortran by setting SUITESPARSE_USE_FORTRAN
84+
# to OFF, use a suite of C/C++/Fortran compilers with the same ID,
85+
# or ensure that all your compiled libraries link against a single
86+
# OpenMP library.
8987
#
9088
# SUITESPARSE_PKGFILEDIR: Directory where CMake Config and pkg-config files
9189
# will be installed. By default, CMake Config files will
@@ -301,13 +299,38 @@ endif ( )
301299
#-------------------------------------------------------------------------------
302300

303301
include ( CheckLanguage )
304-
option ( SUITESPARSE_USE_FORTRAN "ON: use Fortran. OFF (default): do not use Fortran" OFF )
302+
option ( SUITESPARSE_USE_FORTRAN "ON (default): use Fortran. OFF: do not use Fortran" ON )
305303
if ( SUITESPARSE_USE_FORTRAN )
304+
message ( STATUS "Checking if Fortran is available and compatible with C/C++" )
306305
check_language ( Fortran )
307306
if ( CMAKE_Fortran_COMPILER )
307+
# Fortran is available; ensure that it is compatible with C/C++
308+
enable_language ( CXX )
308309
enable_language ( Fortran )
309-
message ( STATUS "Fortran: ${CMAKE_Fortran_COMPILER}" )
310310
set ( SUITESPARSE_HAS_FORTRAN ON )
311+
if ( NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_C_COMPILER_ID}" OR
312+
NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}" )
313+
message ( STATUS " " )
314+
message ( STATUS "Incompatible Fortran/C/C++ compilers detected:" )
315+
message ( STATUS " Fortran: ${CMAKE_Fortran_COMPILER}" )
316+
message ( STATUS " Fortran id: ${CMAKE_Fortran_COMPILER_ID}" )
317+
message ( STATUS " C ${CMAKE_C_COMPILER}" )
318+
message ( STATUS " C id: ${CMAKE_C_COMPILER_ID}" )
319+
message ( STATUS " C++ ${CMAKE_CXX_COMPILER}" )
320+
message ( STATUS " C++ id: ${CMAKE_CXX_COMPILER_ID}" )
321+
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "IntelLLVM" )
322+
# icx/icpx cannot be used with gfortran: this is a fatal error
323+
message ( FATAL_ERROR "ERROR: Using Fortran with SuiteSparse requires that "
324+
" it has the same compiler ID as the C/C++ compilers."
325+
" Use a compatible Fortran compiler, or set SUITESPARSE_USE_FORTRAN to OFF." )
326+
else ( )
327+
# other cases: just issue a warning and hope it works.
328+
message ( WARNING "Warning: Using Fortran with SuiteSparse requires that "
329+
" it has the same compiler ID as the C/C++ compilers."
330+
" Use a compatible Fortran compiler, or set SUITESPARSE_USE_FORTRAN to OFF." )
331+
endif ( )
332+
endif ( )
333+
message ( STATUS "Fortran: enabled" )
311334
else ( )
312335
# Fortran not available:
313336
set ( SUITESPARSE_HAS_FORTRAN OFF )

0 commit comments

Comments
 (0)