参考: https://blog.csdn.net/qq_44263574/article/details/123582481
官网下载: https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html?packages=oneapi-toolkit&oneapi-toolkit-os=linux&oneapi-lin=offline
填写邮件和国家,下面可以看到下载和安装链接,依次执行即可:
安装后查看:
$ ls /opt/intel/oneapi/
2025.0 compiler dnnl ipp mkl pti tcm
advisor dal dpcpp-ct ippcp modulefiles-setup.sh setvars.sh umf
ccl debugger dpl licensing mpi support.txt vtune
common dev-utilities installer logs oneapi-base-toolkit tbb
一个cmake和makefile的例子, 我需要mkl, openmp:
makefile:
CC = g++ONEAPI_PATH=/opt/intel/oneapiCXXFLAGS = -std=c++14 -I${ONEAPI_PATH}/mkl/latest/include
LDFLAGS = -L${ONEAPI_PATH}/mkl/latest/lib/intel64 -L${ONEAPI_PATH}/compiler/latest/libLDLIBS = -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5 -lpthread -lm -ldl
# 在运行时查找动态库的路径
RPATH_FLAGS = -Wl,-rpath,${ONEAPI_PATH}/mkl/latest/lib/intel64 -Wl,-rpath,${ONEAPI_PATH}/compiler/latest/lib# 项目名和源文件
TARGET = test_single
SRC = test_single.cppall: $(TARGET)$(TARGET): $(SRC)$(CC) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(RPATH_FLAGS)clean:rm -f $(TARGET)
cmakelists:
cmake_minimum_required(VERSION 3.10)
project(MyMKLProject)# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)# Intel MKL options
set(MKL_ROOT "/opt/intel/oneapi/mkl/latest")# 包含 MKL 头文件目录
include_directories(${MKL_ROOT}/include)# 链接
link_directories(${MKL_ROOT}/lib/intel64)
link_directories(/opt/intel/oneapi/compiler/latest/lib)# 添加执行文件
add_executable(test_single test_single.cpp)# 链接到 MKL 库
target_link_libraries(test_singlemkl_intel_lp64 # LP64 modelmkl_sequential # Single-threadedmkl_core # Core MKL routinesiomp5 # Intel OpenMP library (if using MKL with OpenMP)pthreadmdl
)