Intel oneAPI でのお仕事環境の構築


Related Index Debian

始めに

いつの頃からか定かではないのだが, Intel コンパイラなどの開発環境が Intel oneAPI として公開されていて, apt でインストールできる様になっている. …まあ, 例によって設定スクリプトに未だ bashism が残っていたりするのがアレだけれど, HPC 環境で Intel Compiler を使うことも多いので, テストに使う分には非常に助かるわけで.

導入と設定

この節は趣味の領域(飛ばして OK) ビルドしたモノは /usr/local/intel 以下にインストールする予定なので 最低限

  • PATH=/usr/local/intel/bin:${PATH}
  • LD_LIBRARY_PATH=/usr/local/intel/lib:${LD_LIBRARY_APTH}

だけは設定しておくと良い.

導入

apt で導入します.

最近は deb822 形式で apt のソースを書いているので 以下のファイルを /etc/apt/sources.list.d/oneapi.sources として 作成します.

Types: deb
URIs:https://apt.repos.intel.com/oneapi
Suites: all
Components: main
Arch: amd64
Signed-by: /usr/local/share/keyrings/intel.asc

続いて, 鍵を上記ファイルに置いておきます.

sudo wget https://repositories.intel.com/graphics/intel-graphics.key \
  -O /usr/local/share/keyrings/intel.asc

インストールするパッケージは色々と選べるわけですが, 多過ぎて良くわからない. とりあえずは以下の通り:

% sudo apt-get update
% sudo apt-get install cmake pkg-config build-essential
% sudo apt-get install intel-hpckit intel-hpckit-runtime

何も考えずインストールしているので, かなり大きめです. コーヒーでも呑みながら待ちましょう. …ちなみに, WSL2 でも使えるらしいですね(プロファイラ回りの kernel module がどうなるのか知らんけど…).

なお, このパッケージは削除時に /usr/local/share/pkgconfig を削除します. …雑なパッケージですねぇ.

設定

安直に環境設定するなら

% source /opt/intel/oneapi/setvars.sh

で良いです. しかしながら, 目的は計算もさることがならテストですから環境を切り替えたいと思うのが人情と言うものです.

setvars.sh を眺めてみます.

  • 453行目で component_array=$(command ls "${script_root}"/*/*/env/vars.sh 2>/dev/null | awk 'NF') として, 読み込む設定ファイルをリストアップしてます.
  • これを uniq なんかを使って整理して, source してます.

というわけで, 実際にコンポーネントをリストアップしてみると….

% command ls /opt/intel/opneapi/*/*/env/vars.sh | awk 'NF' | grep latest | sort -u
/opt/intel/oneapi/advisor/latest/env/vars.sh
/opt/intel/oneapi/ccl/latest/env/vars.sh
/opt/intel/oneapi/clck/latest/env/vars.sh
/opt/intel/oneapi/compiler/latest/env/vars.sh
/opt/intel/oneapi/dal/latest/env/vars.sh
/opt/intel/oneapi/debugger/latest/env/vars.sh
/opt/intel/oneapi/dev-utilities/latest/env/vars.sh
/opt/intel/oneapi/dnnl/latest/env/vars.sh
/opt/intel/oneapi/dpcpp-ct/latest/env/vars.sh
/opt/intel/oneapi/dpl/latest/env/vars.sh
/opt/intel/oneapi/inspector/latest/env/vars.sh
/opt/intel/oneapi/intelpython/latest/env/vars.sh
/opt/intel/oneapi/ipp/latest/env/vars.sh
/opt/intel/oneapi/ippcp/latest/env/vars.sh
/opt/intel/oneapi/itac/latest/env/vars.sh
/opt/intel/oneapi/mkl/latest/env/vars.sh
/opt/intel/oneapi/mpi/latest/env/vars.sh
/opt/intel/oneapi/tbb/latest/env/vars.sh
/opt/intel/oneapi/vpl/latest/env/vars.sh
/opt/intel/oneapi/vtune/latest/env/vars.sh

…いや, まあ, こんなに使わんのだが (Data Sicnese やら Deep Learning やらで Python 関連が入るんだなぁ…). というわけで, 整理して切り替え可能にした zsh 関数はこんな感じかな? intel コンパイラでビルドした諸々は /usr/local/intel 以下に置くことにしている

変数設定

#! /bin/zsh
## common
_ONEAPI_ROOT=/opt/intel/oneapi
_SETVARS_VARS_PATH=${_ONEAPI_ROOT}/vtune/latest/env/vars.sh
_INTEL_LICENSE_FILE=/opt/intel/licenses:${HOME}/intel/licenses
## Advisor
_ADVISOR_2021_DIR=${_ONEAPI_ROOT}/advisor/2021.4.0
_PYTHONPATH=${_ADVISOR_2021_DIR}/pythonapi
_APM=${_ADVISOR_2021_DIR}/perfmodels
#
_PATH=${_ADVISOR_2021_DIR}/bin64
_PKG_CONFIG_PATH=${_ADVISOR_2021_DIR}/include/pkgconfig/lib64
# CCL
_CCL_ROOT=${_ONEAPI_ROOT}/ccl/2021.4.0
_CCL_CONFIGURATION=cpu_gpu_dpcpp
_LD_LIBRARY_PATH=${_CCL_ROOT}/lib/cpu_gpu_dpcpp
_LIBRARY_PATH=${_CCL_ROOT}/lib/cpu_gpu_dpcpp
_CPATH=${_CCL_ROOT}/include/cpu_gpu_dpcpp
_PKG_CONFIG_PATH=${_CCL_ROOT}/lib/pkgconfig:
# CLCK
_CLCK_ROOT=${_ONEAPI_ROOT}/clck/2021.4.0
_INTEL_LICENSE_FILE=${_INTEL_LICENSE_FILE}:${_CLCK_ROOT}/licensing
_PATH=${_CLCK_ROOT}/bin/intel64:${_PATH}
_LIBRARY_PATH=${_CLCK_ROOT}/lib/intel64:${_LIBRARY_PATH}
_CPLUS_INCLUDE_PATH=${_CLCK_ROOT}/include
_MANPATH=${_CLCK_ROOT}/man
# COMPILER
_CMPLR_ROOT=${_ONEAPI_ROOT}/compiler/2021.4.0
_OCL_ICD_FILENAMES=libintelocl_emu.so:libalteracl.so:${_CMPLR_ROOT}/linux/lib/x64/libintelocl.so
_ACL_BOARD_VENDOR_PATH=/opt/Intel/OpenCLFPGA/oneAPI/Boards
_FPGA_VARS_DIR=${_CMPLR_ROOT}/linux/lib/oclfpga
_FPGA_VARS_ARGS=
_INTELFPGAOCLSDKROOT=${_FPGA_VARS_DIR}
_PATH=${_CMPLR_ROOT}/linux/bin:${_PATH}
_PATH=${_CMPLR_ROOT}/linux/bin/intel64:${_PATH}
_PATH=${_FPGA_VARS_DIR}/bin:${_PATH}
_PATh=${_FPGA_VARS_DIR}/llvm/aocl-bin:${_PATH}
_LD_LIBRARY_PATH=${_CMPLR_ROOT}/linux/compiler/lib/intel64_lin:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_FPGA_VARS_DIR}/linux64/lib:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_FPGA_VARS_DIR}/host/linux64/lib:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_CMPLR_ROOT}/linux/lib/emu:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_CMPLR_ROOT}/linux/lib/x64:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_CMPLR_ROOT}/linux/lib:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_CMPLR_ROOT}/linux/lib:${_LIBRARY_PATH}
_LIBRARY_PATH=${_CMPLR_ROOT}/linux/compiler/lib/intel64_lin:${_LIBRARY_PATH}
_CPATH=${_CMPLR_ROOT}/linux/include:${_CPATH}
_PKG_CONFIG_PATH=${_CMPLR_ROOT}/lib/pkgconfig:${_PKG_CONFIG_PATH}
_MANPATH=${_CMPLR_ROOT}/documentation/en/man/common:${_MANPATH}
## DAL
_DALROOT=${_ONEAPI_ROOT}/dal/2021.4.0
_DAALROOT=${_DALROOT}
_LD_LIBRARY_PATH=${_DALROOT}/lib/intel64:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_DALROOT}/lib/intel64:${_LIBRARY_PATH}
_CPATH=${_DALROOT}/include:${_CPATH}
_PKG_CONFIG_PATH=${_DALROOT}/lib/pkgconfig:${_PKG_CONFIG_PATH}
_CLASSPATH=${_DALROOT}/lib/onedal.jar
_CMAKE_PREFIX_PATH=${_DALROOT}
## debugger
_INTEL_PYTHONHOME=${_ONEAPI_ROOT}/debugger/10.2.4/dep
_INFOPATH=${_ONEAPI_ROOT}/debugger/10.2.4/gdb/intel64/lib
_GDB_INFO=${_ONEAPI_ROOT}/debugger/10.2.4/documentation/info/
_PATH=${_ONEAPI_ROOT}/debugger/10.2.4/gdb/intel64/bin:${_PATH}
_LD_LIBRARY_PATH=${_INTEL_PYTHONHOME}/lib:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_ONEAPI_ROOT}/debugger/10.2.4/libipt/intel64/lib:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_INFOPATH}:${_LD_LIBRARY_PATH}
_MANPATH=${_ONEAPI_ROOT}/debugger/10.2.4/documentation/man:${_MANPATH}
## utilities
_PATH=${_ONEAPI_ROOT}/dev-utilities/2021.4.0/bin:${_PATH}
_CPATH=${_ONEAPI_ROOT}/dev-utilities/2021.4.0/include:${_CPATH}
## DNNL
_DNNLROOT=${_ONEAPI_ROOT}/dnnl/2021.4.0/cpu_dpcpp_gpu_dpcpp
_LD_LIBRARY_PATH=${_DNNLROOT}/lib:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_DNNLROOT}/lib:${_LIBRARY_PATH}
_CPATH=${_DNNLROOT}/lib:${_CPATH}
## DPCT
_DPCT_BUNDLE_ROOT=${_ONEAPI_ROOT}/dpcpp-ct/2021.4.0
_PATH=${_DPCT_BUNDLE_ROOT}/bin:${_PATH}
_CPATH=${_DPCT_BUNDLE_ROOT}/include:${_CPATH}
## DPL
_DPL_ROOT=${_ONEAPI_ROOT}/dpl/2021.5.0
_CPATH=${_DPL_ROOT}/linux/include:${_CPATH}
_PKG_CONFIG_PATH=${_DPL_ROOT}/lib/pkgconfig:${_PKG_CONFIG_PATH}
## INSPECTOR
_INSPECTOR_2021_DIR=${_ONEAPI_ROOT}/inspector/2021.4.0
_PATH=${_INSPECTOR_2021_DIR}/bin64:${_PATH}
_PKG_CONFIG_PATH=${_INSPECTOR_2021_DIR}/include/pkgconfig/lib64:${_PKG_CONFIG_PATH}
## CONDA
_CONDA_PREFIX=${_ONEAPI_ROOT}/intelpython/latest
_CONDA_EXE=${_CONDA_PREFIX}/bin/conda
_CONDA_PYTHON_EXE=${_CONDA_PREFIX}/bin/python
_CONDA_DEFAULT_ENV=intelpython-python3.7
_CONDA_PROMPT_MODIFIER=(intelpython-python3.7)
_PATH=${_CONDA_PREFIX}/condabin:${_PATH}
_PATH=${_CONDA_PREFIX}/bin:${_PATH}
## IPP
_IPPROOT=${_ONEAPI_ROOT}/ipp/2021.4.0
_IPP_TARGET_ARCH=intel64
_IPPCRYPTOROOT=${_ONEAPI_ROOT}/ippcp/2021.4.0
_IPPCP_TARGET_ARCH=intel64
_LD_LIBRARY_PATH=${_IPPROOT}/lib/intel64:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_IPPCRYPTOROOT}/lib/intel64:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_IPPROOT}/lib/intel64:${_LIBRARY_PATH}
_LIBRARY_PATH=${_IPPCRYPTOROOT}/lib/intel64:${_LIBRARY_PATH}
_CPATH=${_IPPROOT}/include:${_CPATH}
_CPATH=${_IPPCRYPTOROOT}/include:${_CPATH}
_PKG_CONFIG_PATH=${_IPPCRYPTOROOT}/lib/pkgconfig:${_PKG_CONFIG_PATH}
# VT
_VT_ROOT=${_ONEAPI_ROOT}/itac/2021.4.0
_VT_MPI=impi4
_VT_LIB_DIR=${_VT_ROOT}/lib
_VT_SLIB_DIR=${_VT_ROOT}/slib
_VT_ADD_LIBS="-ldwarf -lelf -lvtunwind -lm -lpthread"
_PATH=${_VT_ROOT}/bin:${_PATH}
_LD_LIBRARY_PATH=${_VT_ROOT}/slib:${_LD_LIBRARY_PATH}
_MANPATH=${_VT_ROOT}/man:${_MANPATH}
# MKL
_MKLROOT=${_ONEAPI_ROOT}/mkl/2021.4.0
_PATH=${_MKLROOT}/bin/intel64:${_PATH}
_LD_LIBRARY_PATH=${_MKLROOT}/lib/intel64:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_MKLROOT}/lib/intel64:${_LIBRARY_PATH}
_CPATH=${_MKLROOT}/include:${_CPATH}
_NLSPATH=${_MKLROOT}/lib/intel64/locale/%l_%t/%N:
_PKG_CONFIG_PATH=${_MKLROOT}/lib/pkgconfig:${_PKG_CONFIG_PATH}
# MPI
_I_MPI_ROOT=${_ONEAPI_ROOT}/mpi/2021.4.0
_FI_PROVIDER_PATH=${_I_MPI_ROOT}/libfabric/lib/prov:/usr/lib64/libfabric
_PATH=${_I_MPI_ROOT}/bin:${_PATH}
_PATH=${_I_MPI_ROOT}/libfabric/bin:${_PATH}
_LD_LIBRARY_PATH=${_I_MPI_ROOT}/lib:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_I_MPI_ROOT}/lib/release:${_LD_LIBRARY_PATH}
_LD_LIBRARY_PATH=${_I_MPI_ROOT}/libfabric/lib:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_I_MPI_ROOT}/lib:${_LIBRARY_PATH}
_LIBRARY_PATH=${_I_MPI_ROOT}/lib/release:${_LIBRARY_PATH}
_LIBRARY_PATH=${_I_MPI_ROOT}/libfabric/lib:${_LIBRARY_PATH}
_CPATH=${_I_MPI_ROOT}/include:${_CPATH}
_PKG_CONFIG_PATH=${_I_MPI_ROOT}/lib/pkgconfig:${_CPATH}
_MANPATH=${_I_MPI_ROOT}/man:${_MANPATH}
_CLASSPATH=${_I_MPI_ROOT}/lib/mpi.jar:${_CLASSPATH}
# TBB
_TBBROOT=${_ONEAPI_ROOT}/tbb/2021.4.0/
_LD_LIBRARY_PATH=${_TBBROOT}/lib/intel64/gcc4.8:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_TBBROOT}/lib/intel64/gcc4.8:${_LIBRARY_PATH}
_CPATH=${_TBBROOT}/include:${_CPATH}
_PKG_CONFIG_PATH=${_TBBROOT}/lib/pkgconfig:${_PKG_CONFIG_PATH}
_CMAKE_PREFIX_PATH=${_TBBROOT}:${_CMAKE_PREFIX_PATH}
# VPL
_PATH=${_ONEAPI_ROOT}/vpl/2021.6.0/bin:${_PATH}
_LD_LIBRARY_PATH=${_ONEAPI_ROOT}/vpl/2021.6.0/lib:${_LD_LIBRARY_PATH}
_LIBRARY_PATH=${_ONEAPI_ROOT}/vpl/2021.6.0/lib:${_LIBRARY_PATH}
_CPATH=${_ONEAPI_ROOT}/vpl/2021.6.0/include:${_CPATH}
_PKG_CONFIG_PATH=${_ONEAPI_ROOT}/vpl/2021.6.0/lib/pkgconfig:${_PKG_CONFIG_PATH}
_CMAKE_PREFIX_PATH=${_ONEAPI_ROOT}/vpl/2021.6.0:${_CMAKE_PREFIX_PATH}
# VTUNE
_VTUNE_PROFILER_2021_DIR=${_ONEAPI_ROOT}/vtune/2021.7.1
_PATH=${_VTUNE_PROFILER_2021_DIR}/bin64:${_PATH}
_PKG_CONFIG_PATH=${_VTUNE_PROFILER_2021_DIR}/include/pkgconfig/lib64:${_PKG_CONFIG_PATH}

# personal build
_PATH=/usr/local/intel/bin:${_PATH}
_LD_LIBRARY_PATH=/usr/local/intel/lib:${_LD_LIBRARY_PATH}

読み込み

#! /bin/zsh
[ ! -d $HOME/.config/intel ] || rsync -auvz $HOME/.config/intel $HOME/
set_intel_vars
## valiables
typeset -gx ONEAPI_ROOT=${_ONEAPI_ROOT}
typeset -gx SETVARS_VARS_PATH=${_SETVARS_VARS_PATH}
typeset -gx ADVISOR_2021_DIR=${_ADVISOR_2021_DIR}
typeset -gx APM=${_APM}
typeset -gx CCL_ROOT=${_CCL_ROOT}
typeset -gx CCL_CONFIGURATION=${_CCL_CONFIGURATION}
typeset -gx CLCK_ROOT=${_CLCK_ROOT}
typeset -gx INTEL_LICENSE_FILE=${_INTEL_LICENSE_FILE}
typeset -gx CMPLR_ROOT=${_CMPLR_ROOT}
typeset -gx OCL_ICD_FILENAMES=${_OCL_ICD_FILENAMES}
typeset -gx ACL_BOARD_VENDOR_PATH=${_ACL_BOARD_VENDOR_PATH}
typeset -gx FPGA_VARS_DIR=${_FPGA_VARS_DIR}
typeset -gx FPGA_VARS_ARGS=${_FPGA_VARS_ARGS}
typeset -gx INTELFPGAOCLSDKROOT=${_INTELFPGAOCLSDKROOT}
typeset -gx DALROOT=${_DALROOT}
typeset -gx DAALROOT=${_DAALROOT}
typeset -gx DAL_MAJOR_BINARY=1
typeset -gx DAL_MINOR_BINARY=1
typeset -gx INTEL_PYTHONHOME=${_INTEL_PYTHONHOME}
typeset -gx INFOPATH=${_INFOPATH}
typeset -gx GDB_INFO=${_GDB_INFO}
typeset -gx DNNLROOT=${_DNNLROOT}
typeset -gx DPCT_BUNDLE_ROOT=${_DPCT_BUNDLE_ROOT}
typeset -gx INSPECTOR_2021_DIR=${_INSPECTOR_2021_DIR}
typeset -gx CONDA_PREFIX=${_CONDA_PREFIX}
typeset -gx CONDA_EXE=${_CONDA_EXE}
typeset -gx CONDA_PYTHON_EXE=${_CONDA_PYTHON_EXE}
typeset -gx CONDA_SHLVL=1
typeset -gx CE_M=
typeset -gx CE_CONDA=
typeset -gx CONDA_DEFAULT_ENV=${_CONDA_DEFAULT_ENV}
typeset -gx CONDA_PROMPT_MODIFIER=${_CONDA_PROMPT_MODIFIER}
typeset -gx IPPROOT=${_IPPROOT}
typeset -gx IPP_TARGET_ARCH=${_IPP_TARGET_ARCH}
typeset -gx IPPCRYPTOROOT=${_IPPCRYPTOROOT}
typeset -gx IPPCP_TARGET_ARCH=${_IPPCP_TARGET_ARCH}
typeset -gx VT_ROOT=${_VT_ROOT}
typeset -gx VT_MPI=${_VT_MPI}
typeset -gx VT_LIB_DIR=${_VT_LIB_DIR}
typeset -gx VT_SLIB_DIR=${_VT_SLIB_DIR}
typeset -gx VT_ADD_LIBS=${_VT_ADD_LIBS}
typeset -gx MKLROOT=${_MKLROOT}
typeset -gx I_MPI_ROOT=${_I_MPI_ROOT}
typeset -gx FI_PROVIDER_PATH=${_FI_PROVIDER_PATH}
typeset -gx TBBROOT=${_TBBROOT}
typeset -gx VTUNE_PROFILER_2021_DIR=${_VTUNE_PROFILER_2021_DIR}
## PATH
typeset -gx CLASSPATH=${_CLASSPATH}:${CLASSPATH}
typeset -gx CPATH=${_CPATH}:${CPATH}
typeset -gx INFOPATH=${_INFOPATH}:${INFOPATH}
typeset -gx LD_LIBRARY_PATH=${_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}
typeset -gx LIBRARY_PATH=${_LIBRARY_PATH}:${LIBRARY_PATH}
typeset -gx MANPATH=${_MNAPATH}:${MANPATH}
typeset -gx NLSPATH=${_NLSPATH}:${NLSPATH}
typeset -gx PATH=${_PATH}:${PATH}
typeset -gx PKG_CONFIG_PATH=${_PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}
# typeset -gx NONRPM_DB_DIR=$HOME/.intel

typeset -U classpath cpath infopath ld_library_path library_path
typeset -U manpath lnspath path pkg_config_path

## complete
typeset -gx SETVARS_COMPLETED=1

読み込んだ設定をクリア

#! /bin/zsh
[ ! -d $HOME/intel ] || rsync -auvz $HOME/intel/ $HOME/.config/intel/
rm -fr ${HOME}/intel
## clear PATH...
typeset -gx INFOPATH=${INFOPATH//$_INFOPATH:}
typeset -gx CLASSPATH=${CLASSPATH//$_CLASSPATH:}
typeset -gx CPATH=${CPATH//$_CPATH:}
typeset -gx LD_LIBRARY_PATH=${LD_LIBRARY_PATH//$_LD_LIBRARY_PATH:}
typeset -gx LIBRARY_PATH=${LIBRARY_PATH//$_LIBRARY_PATH:}
typeset -gx MANPATH=${MANPATH//$_MNAPATH:}
typeset -gx NLSPATH=${NLSPATH//$_NLSPATH$}
typeset -gx PATH=${PATH//$_PATH:}
typeset -gx PKG_CONFIG_PATH=${PKG_CONFIG_PATH//$_PKG_CONFIG_PATH:}
# update
typeset -U infopath classpath cpath ld_library_path library_path
typeset -U manpath nlspath path pkg_config_path
## unset vars
unset ONEAPI_ROOT
unset SETVARS_VARS_PATH
unset ADVISOR_2021_DIR
unset APM
unset CCL_ROOT
unset CCL_CONFIGURATION
unset CLCK_ROOT
unset INTEL_LICENSE_FILE
unset CMPLR_ROOT
unset OCL_ICD_FILENAMES
unset ACL_BOARD_VENDOR_PATH
unset FPGA_VARS_DIR
unset FPGA_VARS_ARGS
unset INTELFPGAOCLSDKROOT
unset DALROOT
unset DAALROOT
unset DAL_MAJOR_BINARY
unset DAL_MINOR_BINARY
unset INTEL_PYTHONHOME
unset INFOPATH
unset GDB_INFO
unset DNNLROOT
unset DPCT_BUNDLE_ROOT
unset INSPECTOR_2021_DIR
unset CONDA_PREFIX
unset CONDA_EXE
unset CONDA_PYTHON_EXE
unset CONDA_SHLVL
unset CE_M
unset CE_CONDA
unset CONDA_DEFAULT_ENV
unset CONDA_PROMPT_MODIFIER
unset IPPROOT
unset IPP_TARGET_ARCH
unset IPPCRYPTOROOT
unset IPPCP_TARGET_ARCH
unset VT_ROOT
unset VT_MPI
unset VT_LIB_DIR
unset VT_SLIB_DIR
unset VT_ADD_LIBS
unset MKLROOT
unset I_MPI_ROOT
unset FI_PROVIDER_PATH
unset TBBROOT
unset VTUNE_PROFILER_2021_DIR
## cleanup working vars
unset _ONEAPI_ROOT
unset _SETVARS_VARS_PATH
unset _ADVISOR_2021_DIR
unset _APM
unset _CCL_ROOT
unset _CCL_CONFIGURATION
unset _CLCK_ROOT
unset _INTEL_LICENSE_FILE
unset _CMPLR_ROOT
unset _OCL_ICD_FILENAMES
unset _ACL_BOARD_VENDOR_PATH
unset _FPGA_VARS_DIR
unset _FPGA_VARS_ARGS
unset _INTELFPGAOCLSDKROOT
unset _DALROOT
unset _DAALROOT
unset _DAL_MAJOR_BINARY
unset _DAL_MINOR_BINARY
unset _INTEL_PYTHONHOME
unset _INFOPATH
unset _GDB_INFO
unset _DNNLROOT
unset _DPCT_BUNDLE_ROOT
unset _INSPECTOR_2021_DIR
unset _CONDA_PREFIX
unset _CONDA_EXE
unset _CONDA_PYTHON_EXE
unset _CONDA_SHLVL
unset _CE_M
unset _CE_CONDA
unset _CONDA_DEFAULT_ENV
unset _CONDA_PROMPT_MODIFIER
unset _IPPROOT
unset _IPP_TARGET_ARCH
unset _IPPCRYPTOROOT
unset _IPPCP_TARGET_ARCH
unset _VT_ROOT
unset _VT_MPI
unset _VT_LIB_DIR
unset _VT_SLIB_DIR
unset _VT_ADD_LIBS
unset _MKLROOT
unset _I_MPI_ROOT
unset _FI_PROVIDER_PATH
unset _TBBROOT
unset _VTUNE_PROFILER_2021_DIR
## cleanup
unset SETVARS_COMPLETED

公式で切り替え(というか, 汚した環境変数の消去)も提供してくれないモンかねぇ.

NetCDF

依存するモノが多くてなかなか大変.

圧縮に szip libaec, zlib, 仮想の I/O に HDF5, その上に NetCDF というソフトウェア構造 この順にインストールしていく.

szip -> libaec

BSD-2-Clause の szip の互換ソフトウェアとしてlibeacがリリースされている.

"Please be aware that SZIP compression has been replaced by AEC compression as of HDF5-1.10.7. AEC is the open source version of SZIP."

というわけで, libeac を導入する. 同梱されている INSTALL.md に導入方法があるので, 基本はこれの通りに.

% sudo apt install gnulib
% wget https://gitlab.dkrz.de/k202009/libaec/-/archive/v1.0.6/libaec-v1.0.6.tar.gz
% tar xvf libaec-v1.0.6.tar.gz
% cd libeac-v1.0.6
% gnulib-tool --import lib-symbol-visibility
% autoreconf -iv
% mkdir build
% cd build
% AR=xiar LD=xild \
  CC=icc \
  CFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large" \
  ../configure --prefix=/usr/local/intel
% make
% make check
% make install

zlib

% wget https://zlib.net/zlib-1.2.11.tar.gz
% tar xvf zlib-1.2.11.tar.gz
% cd zlib-1.2.11
% mkdir build
% cd build
% AR=xiar LD=xild \
  CC=icc \
  CFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large" \
  ../configure --prefix=/usr/local/intel
% make
% make test
% make install
# /usr/local/intel/lib/libz.so* は消しても OK.

HDF5

あいかわらず, ダウンロードリンクは直接叩けないので おとなしく Web の URL をポチっとして落としてくる.

hdf5 v1.12 には以前の版と非互換の変更があるため, 互換APIを有効にしてビルドすることに. NetCDF側では対応済みみたいだけれど, これリリースされてるのかな….

必要なのは C API だけなので, 素のビルドで OK. ビルドもテストもかなり時間がかかるので, 適宜休憩挟みつつ進めると良いかと.

% tar xvf hdf5-1.12.1.tar.gz
% cd hdf5-1.12.1
% mkdir build
% cd build
% AR=xiar LD=xild \
  CXX=icpc \
  FC=ifort \
  CC=icc \
  CFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  LIBS="-L/usr/local/intel/lib -laec" \
  ../configure \
    --prefix=/usr/local/intel \
    --with-zlib=/usr/local/intel/lib \
    --with-szlib=/usr/local/intel/lib \
    --enable-hl \
    --with-default-api-version=v110
% make
% make check
% make install
% make check-install

NetCDF C

HDF5 の後に NetCDF C ライブラリを導入 (OPeNDAP を利用する気は無いので, curl は不要).

static でビルドする際には HDF5 のインストール時に生成された C コンパイラの wrapper である h5cc の中身を見て, 設定されているライブラリの情報を適宜 LIBS に指定すると良い. libhdf5.settings の中身も参考になるかと.

雑にやるなら CCh5cc を指定する, という方法もあるが, 今後 nc-config の出力を使って他のライブラリをビルドしたりすることを考えたりすると, 真面目(?)に configure を走らせた方が良い気がする.

% wget https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.8.1.tar.gz \
  -O netcdf-c-4.8.1.tar.gz
% tar xvf netcdf-c-4.8.1.tar.gz
% cd netcdf-c-4.8.1
% mkdir build
% cd build
% AR=xiar LD=xild \
  CC=icc
  CFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  LIBS="-L/usr/local/intel/lib -lhdf5_hl -lhdf5 -lsz -lz-laec" \
  ../configure \
  --prefix=/usr/local/intel \
  --disable-dap
% make
% make check
% make install

NetCDF Fortran

C版同様に LIBS に必要なライブラリを列挙するのを忘れずに.

% wget https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.5.3.tar.gz -O netcdf-fortran-4.5.3.tar.gz
% tar xvf netcdf-fortran-4.5.3.tar.gz
% cd netcdf-fortran-4.5.3
% mkdir build
% cd build
% AR=xiar LD=xild \
  CC=icc \
  CFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  FC=ifort
  FCFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  F77=ifort
  FFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  LIBS="-L/usr/local/intel/lib -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -laec"
  ../configure \
  --prefix=/usr/local/intel \
  --disable-dap
% make
% make check
% make install

gtool5

gtool5: 20160613版

現在の「安定版」は configure を直す前の版なので, 一度 configure を走らせた後に手動で Config.mk の修正が必要である.

% wget http://www.gfd-dennou.org/library/gtool/gtool5/gtool5_current.tgz
% tar xvf gtool5_current.tgz
% cd gtool5-20160613/
% AR=xiar LD=xild \
  FC=mpiifort \
  SYSFFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  ./configure \
    --with-netcdff=/usr/local/stow/intel/lib/libnetcdff.so \
    --with-netcdf=/usr/local/stow/intel/lib/libnetcdf.so \
    --with-mpiexec=mpiexec
# Config.mk の修正, 該当行は以下(修正後)
SYSFFLAGS=-O3 -xHost -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include  -I/opt/intel/oneapi/mpi/2021.4.0//include -I/opt/intel/oneapi/mpi/20
21.4.0/include
SYSLDFLAGS=-L/usr/local/intel/lib -L/opt/intel/oneapi/mpi/2021.4.0/lib/release -L/opt/intel/oneapi/mpi/2021.4.0/lib
SYSLDLIBS=-lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -laec -lmpifort -lmpi -ldl -lrt -lpthread
% make
% make test
% make test-mpi

そのままコレを使う場合は make install しておく.

gtool5: GIT HEAD

configure 周りを全面的に書き替えているので よくある変数を指定するだけで良い.

% git clone https://www.gfd-dennou.org/library/gtool/git_repos/gtool5.git
% cd gtool5
% git submodule update --init
% ./autogen.sh
% mkdir build
% cd build
% AR=xiar LD=xild \
  CPP="gcc -E" \
  CC=mpiicc \
  CFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  FC=mpiifort \
  FCFLAGS="-fPIC -O3 -xCORE-AVX2 -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  LIBS="-L/usr/local/intel/lib -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -laec" \
  ../configure \
  --prefix=/usr/local/intel \
  --with-nf-config=/usr/local/intel/bin/nf-config
% make
% make test

こちらを使う場合は make install まで行なう.

SPML: v0.8.0

ISPACK: v1

% wget https://www.gfd-dennou.org/arch/ispack/ispack-1.0.4.tar.gz
% tar xvf ispack-1.0.4.tar.gz
% cd ispack-1.0.4
% vim Mkinclude    # 以下を修正
FC              = ifort
FFLAGS          = -fPIC -O3 -xCORE-AVX2 -qopenmp -prec-div -fp-model precise -align array64byte
MPIFC           = mpiifort
MPIFFLAGS       = $(FFLAGS)
CC              = mpiicc
CFLAGS          = -fPIC -O3 -xCORE-AVX2 -qopenmp -prec-div -fp-model precise
CPPFLAGS        = -DDIRECT -DFORMAT -DIEEE -DASCII -DLEN
SSE             = avx
# NVCC          = nvcc
# NVCFLAGS      = -arch=sm_20 -O3
% make
% cp libisp.a /usr/local/intel/lib/

SPML: v0.8.0

リリースの tar.gz 生成に利用した環境が古い(libtool が古い)ので, そのままでは intel compiler に渡す -rpath のフラグが変になる. configure 実行前に autoreconf -ficonfigure を生成する必要がある.

% wget https://www.gfd-dennou.org/library/spmodel/spml_current.tar.gz
% tar xvf spml_current.tar.gz
% cd spml-0.8.0
% autoreconf -fi
% AR=xiar LD=xild CPP="gcc -E" \
  CC=mpiicc \
  CFLAGS="-fPIC -O3 -xCORE-AVX2 -qopenmp -prec-div -fp-model precise -mcmodel=large -I/usr/local/intel/include" \
  FC=mpiifort \
  FCFLAGS="-fPIC -O3 -xCORE-AVX2 -qopenmp -prec-div -fp-model precise -mcmodel=large -align array64byte -I/usr/local/intel/include -I${MKLROOT}/include " \
  LIBS="-L/usr/local/intel/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -laec -L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread -lifcore" \
  ../configure \
  --prefix=/usr/local/intel \
  --with-ispack=/usr/local/intel/lib/libisp.a \
  --with-netcdff=/usr/local/intel/lib/libnetcdff.a \
  --with-netcdf=/usr/local/intel/lib/libnetcdf.a \
  --with-gtool5=/usr/local/intel/lib/libgtool.a \
  --with-mpifc=mpiifort \
  --with-mpiexec=mpiexec \
  --with-lapack=${MKLROOT}/lib/intel64/libmkl_lapack95_lp64.a
% make
% make test

これを使うなら make install する.

TODO SPML: v2 (Git HEAD)

ISPACK v3