Skip to content

Instantly share code, notes, and snippets.

@scivision
Last active August 29, 2023 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scivision/b81948e7cc3e220103653f6f0016ca8c to your computer and use it in GitHub Desktop.
Save scivision/b81948e7cc3e220103653f6f0016ca8c to your computer and use it in GitHub Desktop.
CMake Intel oneMKL example with LAPACK
cmake_minimum_required(VERSION 3.19)
project(intel_mkl LANGUAGES C Fortran)
message(STATUS "ENV{MKLROOT}: $ENV{MKLROOT}")
# variables set before find_package(MKL)
# https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-linux/2023-2/cmake-config-for-onemkl.html
# default: lp64
# set(MKL_INTERFACE "lp64")
# set(MKL_INTERFACE "ilp64")
# set(ENABLE_BLAS95 true)
# set(ENABLE_LAPACK95 true)
# MKL_THREADING default: "intel_thread" which is Intel OpenMP
# set(MKL_THREADING "tbb_thread")
# default: dynamic
# set(MKL_LINK "static")
find_package(MKL CONFIG REQUIRED)
enable_testing()
add_executable(mkl_version mkl_version.c)
target_link_libraries(mkl_version PRIVATE MKL::MKL)
add_test(NAME mkl_version COMMAND mkl_version)
add_executable(snrm_f snrm.f90)
target_link_libraries(snrm_f PRIVATE MKL::MKL)
add_test(NAME snrm_f COMMAND snrm_f)
file(GENERATE OUTPUT .gitignore CONTENT "*")
// https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-linux/2023-2/cmake-config-for-onemkl.html
#include <stdio.h>
#include "mkl.h"
int main(void)
{
MKLVersion mkl_version;
mkl_get_version(&mkl_version);
printf("oneMKL %d.%d\n", mkl_version.MajorVersion, mkl_version.UpdateVersion);
return 0;
}
program check_snrm
use, intrinsic :: iso_fortran_env, only : real32
implicit none
real(real32), external :: snrm2
print *, snrm2(1, [0._real32], 1)
end program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment