当前位置: 首页 > article >正文

Linux下编译安装SuperLU

SuperLU用于求解大规模稀疏线性方程组,本文记录在远程Linux服务器下编译安装SuperLU的流程。

一、配置VS Code

2.1 安装VS Code Extensions

在本地打开VS Code, 安装以下扩展插件,

Task Explorer

Output Colorizer

Git Extension Pack

Remote Developement

Remote X11

C/C++ Extension Pack

C++ TestMate

Modern Fortran

FORTRAN InstelliSense

Fortran Breakpoint Support

Extension Pack for Intel Software Developer Tools

2.2 Remote SSH

通过"Remote Development"扩展插件登录远程Linux服务器,并安装以下插件

C/C++ Extension Pack

C++ TestMate

Modern Fortran

FORTRAN InstelliSense

Fortran Breakpoint Support

Extension Pack for Intel Software Developer Tools

二、安装与配置oneAPI

1.1 配置包管理器

wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null

echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list

sudo apt update

1.2 安装

sudo apt -y install cmake pkg-config build-essential

1.3 安装oneAPI

sudo apt install intel-basekit
sudo apt install intel-hpckit

1.4 配置CMake Kits

打开VS Code, 执行"CMake: Edit User-Local CMake Kits",编辑“~/.local/share/CMakeTools/cmake-tools-kits.json”文件,

[
  {
    "name": "GCC 11.4.0 x86_64-linux-gnu",
    "compilers": {
      "C": "/usr/bin/gcc",
      "CXX": "/usr/bin/g++"
    },
    "isTrusted": true
  },
  {
    "name": "Intel(R) oneAPI DPC++/C++ Compiler 2024.2.1",
    "compilers": {
      "C": "/opt/intel/oneapi/compiler/2024.2/bin/icx",
      "CXX": "/opt/intel/oneapi/compiler/2024.2/bin/icpx"
    },
    "isTrusted": true
  }
]

1.5 oneAPI环境变量配置

编辑"~/.bashrc"文件,添加以下内容,

source /opt/intel/oneapi/setvars.sh --force

然后重启远程服务器,在本地重新通过"VS Code"连接远程Linux服务器。

三、编译安装SuperLU

3.1 下载SuperLU

git https://github.com/xiaoyeli/superlu.git
cd ./superlu
git checkout v7.0.0

3.2 编译安装SuperLU

可以使用CMake Kits或者CMake Presets来构建SuperLU,

方法1: 使用CMake Kits

选择"Intel(R) oneAPI DPC++/C++ Compiler 2024.2.1", 使用在VS Code中使用CMake Tools完成构建,同时做如下配置修改,

CMAKE_C_FLAGS-fPIC
CMAKE_BUILD_TYPE

Release

BUILD_SHARED_LIBSON
BUILD_TESTINGOFF
enable_testsOFF
CMAKE_INSTALL_PREFIX/data/3rdparty/install/intel-opt-dto
方法2: 使用CMake Presets

在superlu目录下,编辑CMakeUserPresets.json文件,

{
    "version": 4,
    "configurePresets": [
        {
            "name": "linux_default",
            "hidden": true,
            "displayName": "Default Linux Config",
            "description": "Default build using Unix Makefiles generator",
            "generator": "Unix Makefiles",
            "binaryDir": "${sourceDir}/out/build/${presetName}",
            "cacheVariables": {
                "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
                "CMAKE_BUILD_TYPE": "Debug"
            }
        },
        {
            "name": "linux_gcc",
            "inherits": "linux_default",
            "displayName": "GCC 11.4.0 x86_64-linux-gnu",
            "description": "Using compilers: C = /usr/bin/gcc, CXX = /usr/bin/g++",
            "cacheVariables": {
                "CMAKE_C_COMPILER": "/usr/bin/gcc",
                "CMAKE_CXX_COMPILER": "/usr/bin/g++",
                "CMAKE_MAKE_PROGRAM": "/usr/bin/make"
            }
        },
        {
            "name": "linux_intel",
            "inherits": "linux_default",
            "displayName": "Intel(R) oneAPI DPC++/C++ Compiler 2024.0.2",
            "description": "Using compilers: C = /opt/intel/oneapi/compiler/latest/bin/icx, CXX = /opt/intel/oneapi/compiler/latest/bin/icpx",
            "cacheVariables": {
                "CMAKE_C_COMPILER": "/opt/intel/oneapi/compiler/latest/bin/icx",
                "CMAKE_CXX_COMPILER": "/opt/intel/oneapi/compiler/latest/bin/icpx"
            }
        }
    ],
    "buildPresets": [
        {
            "name": "linux_gcc",
            "description": "",
            "displayName": "",
            "configurePreset": "linux_gcc"
        },
        {
            "name": "linux_intel",
            "description": "",
            "displayName": "",
            "configurePreset": "linux_intel"
        }
    ]
}

然后在VS Code CMake Tools中,修改CMake Cache,

CMAKE_C_FLAGS-fPIC
CMAKE_BUILD_TYPE

Release

BUILD_SHARED_LIBSON
BUILD_TESTINGOFF
enable_testsOFF
CMAKE_INSTALL_PREFIX/data/3rdparty/install/intel-opt-dto

3.3 检查SuperLU连接引用

检查编译生成的libsuperlu.so是否正常链接到了oneAPI MKL,

ldd /data/3rdparty/install/intel-opt-dto/lib/libsuperlu.so
        linux-vdso.so.1 (0x00007ffc24be1000)
        libmkl_intel_lp64.so.2 => /opt/intel/oneapi/mkl/2024.2/lib/libmkl_intel_lp64.so.2 (0x00007dd914c00000)
        libmkl_intel_thread.so.2 => /opt/intel/oneapi/mkl/2024.2/lib/libmkl_intel_thread.so.2 (0x00007dd912800000)
        libmkl_core.so.2 => /opt/intel/oneapi/mkl/2024.2/lib/libmkl_core.so.2 (0x00007dd90e800000)
        libiomp5.so => /opt/intel/oneapi/compiler/2024.2/lib/libiomp5.so (0x00007dd90e200000)
        libimf.so => /opt/intel/oneapi/compiler/2024.2/lib/libimf.so (0x00007dd90dc00000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007dd915b88000)
        libsvml.so => /opt/intel/oneapi/compiler/2024.2/lib/libsvml.so (0x00007dd90c400000)
        libirng.so => /opt/intel/oneapi/compiler/2024.2/lib/libirng.so (0x00007dd914b07000)
        libintlc.so.5 => /opt/intel/oneapi/compiler/2024.2/lib/libintlc.so.5 (0x00007dd915b25000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007dd90c000000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007dd915b20000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007dd915b1b000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007dd915b16000)
        /lib64/ld-linux-x86-64.so.2 (0x00007dd915d2e000)

可以看到,SuperLU实际上是链接到了LP64接口的MKL。若想SuperLU链接到ILP64接口的MKL,需要做如下CMake配置,

BLA_SIZEOF_INTEGER8
BLA_VENDORIntel10_64ilp

四、FAQs

Q. 在主程序中同时引用oneMKL、SuperLU,运行时调用oneMKL API报错。

A. 这个可能是由于libmkl_intel_lp64.so/libmkl_intel_ilp64.so混合调用所致。可考虑将CMake Cache “MKL_INTERFACE”设置为"lp64",这样会在主程序中使用"LP64"接口的MKL。

网络资料

Intel® oneAPI Toolkits Installation Guidesicon-default.png?t=N7T8https://www.intel.com/content/www/us/en/developer/articles/guide/installation-guide-for-oneapi-toolkits.html

Get Started with the Intel® oneAPI Base Toolkit for Linux*icon-default.png?t=N7T8https://www.intel.com/content/www/us/en/docs/oneapi-base-toolkit/get-started-guide-linux/2024-0/overview.html

Get Started with the Intel® HPC Toolkit for Linux*icon-default.png?t=N7T8https://www.intel.com/content/www/us/en/docs/oneapi-hpc-toolkit/get-started-guide-linux/2024-0/overview.html

Using Visual Studio Code with Intel® oneAPI Toolkits User Guideicon-default.png?t=N7T8https://www.intel.com/content/www/us/en/docs/oneapi/user-guide-vs-code/2024-2/overview.html

How to use CMake with Intel® oneAPI Toolkiticon-default.png?t=N7T8https://www.intel.com/content/www/us/en/developer/articles/technical/how-to-use-cmake-with-intel-oneapi-toolkits.html?wapkw=cmake

SuperLU: Home Page (nersc.gov)icon-default.png?t=N7T8https://portal.nersc.gov/project/sparse/superlu/#superluUsing the ILP64 Interface vs. LP64 Interfaceicon-default.png?t=N7T8https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-windows/2023-0/using-the-ilp64-interface-vs-lp64-interface.html


http://www.kler.cn/a/283859.html

相关文章:

  • Django基础用法+Demo演示
  • [CKS] K8S NetworkPolicy Set Up
  • 45.第二阶段x86游戏实战2-hook监控实时抓取游戏lua
  • 软件测试面试2024最新热点问题
  • Rust 建造者模式
  • Python如何用正则表达式匹配并处理文件名
  • 应对Java虚拟机(JVM)负载突然增大的全面指南
  • Sentinel-1 Level 1数据处理的详细算法定义(七)
  • ARM/Linux嵌入式面经(三二):百度
  • 【区块链 + 司法存证】智慧审判留痕系统 | FISCO BCOS应用案例
  • 掀起社交娱乐新浪潮!AI如何应用到短视频APP?
  • Windows 局域网文件共享
  • js 如何获取文件名
  • 哈希(C语言)
  • 华为设备ENSP-AAA认证配置
  • Python | Leetcode Python题解之第386题字典序排数
  • FPGA 学习之路:挑战与策略
  • 磁盘I/O性能优化示例
  • Go 语言中的接口详解
  • Django 使用Apscheduler执行定时任务
  • vue nginx部署 配置 解决href = ‘/login路由‘ 跳转404问题
  • 代码随想录刷题day17丨654.最大二叉树,617.合并二叉树,700.二叉搜索树中的搜索,98.验证二叉搜索树
  • Java线程生命周期详解_(1)
  • 在 Maven 的 POM 文件中配置 npm 镜像源
  • SpringMVC处理流程介绍
  • 【HuggingFace Transformers】BertSelfOutput 和 BertOutput源码解析