Skip to content

Commit 0487023

Browse files
author
Jared Frazier
committed
fix for mkl_spblas.mod and doxygen doc is now Fortran specific
1 parent a0796df commit 0487023

File tree

6 files changed

+48
-9
lines changed

6 files changed

+48
-9
lines changed

CMakeLists.txt

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON)
44
option(BUILD_TESTING "Build tests" OFF)
55

66
option(ENABLE_SPBLAS "Build with SPBLAS" ON)
7+
option(ENABLE_FIND_INTEL_MKL "Find intel MKL config" OFF)
78

89
option(ENABLE_FFTPACK "Build with fftpack" OFF)
910
option(ENABLE_PFUNIT "Build with pFUnit" OFF)
1011
option(ENABLE_TEST_DRIVE "Build with test-drive" OFF)
1112

12-
1313
project(
1414
HelloSPBLAS
1515
VERSION 0.1.0
@@ -19,7 +19,12 @@ project(
1919

2020
# Set paths to Intel oneAPI MKL
2121
if(${ENABLE_SPBLAS})
22-
#find_package(MKL CONFIG)
22+
if (${ENABLE_FIND_INTEL_MKL})
23+
find_package(MKL CONFIG)
24+
get_target_property(MKLINCLUDE MKL::MKL INTERFACE_INCLUDE_DIRECTORIES)
25+
endif()
26+
27+
# manually set MKL vars
2328
if (NOT MKL_FOUND)
2429
message(STATUS "Did not find MKL, trying to use env vars/user input")
2530
set(MKLROOT $ENV{MKLROOT} CACHE PATH "Installation directory of Intel MKL")
@@ -31,6 +36,33 @@ if(${ENABLE_SPBLAS})
3136
else()
3237
message(STATUS "Found MKL")
3338
endif()
39+
40+
if(NOT EXISTS "${MKLINCLUDE}/mkl_spblas.mod")
41+
set(NO_MKL_SPBLAS_MOD "
42+
=======================================================================
43+
${MKLINCLUDE} does not contain mkl_spblas.mod
44+
If you installed Intel MKL to a directory
45+
that requires root permissions,
46+
(e.g., /opt/intel/oneapi/mkl/latest/)
47+
```
48+
# alternatively... you could update secure path in sudo visudo
49+
sudo -i
50+
echo 'source /opt/intel/oneapi/setvars.sh > /dev/null' >> ~/.bashrc
51+
source ~/.bashrc
52+
your_mkl_include=/opt/intel/oneapi/mkl/latest/include
53+
ifx -c your_mkl_include/mkl_spblas.f90
54+
```
55+
otherwise if you installed to a directory
56+
that does not require root permissions, it
57+
should be sufficient to call
58+
```
59+
cd /your/mkl/include # replace with your local path
60+
ifx -c mkl_spblas.f90
61+
```
62+
=======================================================================
63+
")
64+
message(FATAL_ERROR "${NO_MKL_SPBLAS_MOD}")
65+
endif()
3466
endif()
3567

3668
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Can easily use `pFUnit` or `test-drive` for unit testing.
88

99
Make sure you have the [Intel oneAPI HPC Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit-download.html?packages=hpc-toolkit&hpc-toolkit-os=linux&hpc-toolkit-lin=apt) or [Intel Fortran Essentials](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit-download.html?packages=fortran-essentials&fortran-essentials-os=linux&fortran-essentials-lin=apt).
1010

11+
Make sure also that in your `${MKLROOT}/include` directory there is a file
12+
called `mkl_spblas.mod`. The most up to date version of Intel MKL does not
13+
ship with `mkl_spblas.mod` by default, so you have to compile it separately
14+
via `ifx -c /path/to/mkl_spblas.f90`.
15+
1116
Then, you can configure, build, and run tests for the project.
1217

1318
```shell

cmake/helper.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# modified from fftpack
77

88
function(link_spblas targ)
9-
#
109
if (MKL_FOUND)
1110
# https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-macos/2023-0/cmake-config-for-onemkl.html
1211
target_compile_options(
@@ -19,7 +18,7 @@ function(link_spblas targ)
1918
# Add include directories
2019
target_include_directories(
2120
${targ}
22-
PUBLIC ${MKLINCLUDE}/intel64/ilp64/
21+
PUBLIC ${MKLINCLUDE}
2322
)
2423

2524
# Specify the MKL libraries for linking

config/intel_ubuntu_spblas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# where buildodcs is any nonempty string to trigger doc build
44
builddocs=$1
55
[[ -d build-spblas ]] && rm -rf build-spblas
6-
cmake -S . -B build-spblas -DCMAKE_Fortran_COMPILER=ifx -DBUILD_TESTING=ON
6+
cmake -S . -B build-spblas\
7+
-DCMAKE_Fortran_COMPILER=ifx\
8+
-DBUILD_TESTING=ON\
9+
-DENABLE_SPBLAS=ON\
10+
-DENABLE_FIND_INTEL_MKL=ON
711
cmake --build build-spblas
812
./build-spblas/test/test_spblas
913
[[ -n $builddocs ]] && cmake --build build-spblas --target doxygen_docs

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ if(NOT EXISTS ${Fortran_MODULE_DIRECTORY})
1313
file(MAKE_DIRECTORY "${Fortran_MODULE_DIRECTORY}")
1414
endif()
1515

16+
# Add my library
1617
add_library(${PROJECT_NAME} ${HelloSPBLAS_SOURCES})
1718
set_target_properties(
1819
${PROJECT_NAME}
@@ -37,6 +38,8 @@ if(${ENABLE_SPBLAS})
3738
link_spblas(${PROJECT_NAME})
3839
endif()
3940

41+
42+
4043
# installation/configuration steps (modified from fotran-lang/stdlib)
4144
install(
4245
TARGETS ${PROJECT_NAME}

src/mo_square.f90

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
!> @file mo_square.f90
22
!! @brief Defines a module of simple mathematical operations.
3-
!! @todo remove the ifdef include statement since this throws off doxygen
4-
!#ifdef INTEL_SPBLAS
5-
!INCLUDE "mkl_spblas.f90"
6-
!#endif
73
MODULE mo_square
84

95
#ifdef FFTPACK

0 commit comments

Comments
 (0)