BLAS(Basic Linear Algebra Subprograms)は,行列演算,ベクトル演算の機能をもったプログラム群である.
OpenBLAS のインストールを行う. Build Tools for Visual Studio でも gcc でも使えるようにすることを目標とする.
【目次】
【サイト内の関連ページ】
下に書いているように,vcpkg を利用してインストールすることができる. 特に問題がない場合には vcpkg の利用してのインストールを検討しよう. vcpkg を使わずにインストールする必要がある場合は,このページの手順によりインストールを行うことができる.
Windows での Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022) のインストール: 別ページ »で説明
次のコマンドを実行
if not exist c:\vcpkg ( cd c:\ rmdir /s /q vcpkg git clone https://github.com/microsoft/vcpkg cd c:\vcpkg git pull .\vcpkg update .\bootstrap-vcpkg.bat .\vcpkg integrate install call powershell -command "[System.Environment]::SetEnvironmentVariable(\"VCPKG_ROOT\", \"c:\vcpkg\", \"Machine\")" call powershell -command "[System.Environment]::SetEnvironmentVariable(\"CMAKE_TOOLCHAIN_FILE\", \"c:/vcpkg/scripts/buildsystems/vcpkg.cmake\", \"Machine\")" call powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"LIB\", \"Machine\"); $oldpath += \";c:\vcpkg\installed\x64-windows\lib\"; [System.Environment]::SetEnvironmentVariable(\"LIB\", $oldpath, \"Machine\")" call powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"INCLUDE\", \"Machine\"); $oldpath += \";c:\vcpkg\installed\x64-windows\include\"; [System.Environment]::SetEnvironmentVariable(\"INCLUDE\", $oldpath, \"Machine\")" call powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\vcpkg\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")" call powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\vcpkg\installed\x64-windows\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")" )
次のコマンドを実行
c:\vcpkg\vcpkg search openblas c:\vcpkg\vcpkg install --triplet x64-windows openblas[threads] call powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\vcpkg\installed\x64-windows\lib\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")" call powershell -command "[System.Environment]::SetEnvironmentVariable(\"OpenBLAS\", \"C:\vcpkg\installed\x64-windows\", \"Machine\")" call powershell -command "[System.Environment]::SetEnvironmentVariable(\"OpenBLAS_ROOT\", \"C:\vcpkg\installed\x64-windows\", \"Machine\")"
【サイト内の関連ページ】
Windows での Git のインストール: 別ページ »で説明
【関連する外部ページ】
Git の公式ページ: https://git-scm.com/
Windows でのMSYS2 の MINGW64 環境のインストールと,LLVM(Clang, Flang, LLD, LLDB)のインストールと,GNU ツールチェーン類 (gcc, g++, gfortran, gdb, make, ninja, ccache, svn 等) のインストール(MSYS2 を利用 ): 別ページ »で説明
【関連する外部ページ】 https://github.com/xianyi/OpenBLAS/wiki/Installation-Guide
必ず、最新情報を確認すること
C: cd %HOMEPATH% rmdir /s /q OpenBLAS cd %HOMEPATH% git clone --recursive https://github.com/xianyi/OpenBLAS.git
where gcc where gfortran
https://github.com/xianyi/OpenBLAS/wiki/Installation-Guide の記述による
cd %HOMEPATH% cd OpenBLAS make FC=gfortran BINARY=64
エラーメッセージが出なければ OK.
「make install」でインストール.
make PREFIX="C:/OpenBLAS" install
エラーメッセージが出なければ OK.
dir C:\OpenBLAS dir C:\OpenBLAS\include dir C:\OpenBLAS\lib dir C:\OpenBLAS\bin
コマンドプロンプトを管理者として実行: 別ページ »で説明
call powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\OpenBLAS\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
コマンドプロンプトを管理者として実行: 別ページ »で説明
call powershell -command "[System.Environment]::SetEnvironmentVariable(\"OpenBLAS\", \"C:\OpenBLAS\", \"Machine\")" call powershell -command "[System.Environment]::SetEnvironmentVariable(\"OpenBLAS_ROOT\", \"C:\OpenBLAS\", \"Machine\")"
https://gist.github.com/xianyi/6930656 に掲載の プログラムを利用
Windows での確認手順と結果は次の通り
https://gist.github.com/xianyi/6930656 に掲載の プログラムを利用. hoge.cのようなファイル名で保存.
gcc -I"C:\OpenBLAS\include" -c -o hoge.o hoge.c gcc -L"C:\OpenBLAS\lib" -o a.exe hoge.o -lopenblas .\a.exe
https://gist.github.com/xianyi/6930656 に掲載の プログラムを利用
Windows での確認手順と結果は次の通り
https://gist.github.com/xianyi/6930656 に掲載の プログラムを利用. hoge.cのようなファイル名で保存.
cl /I"C:\OpenBLAS\include" hoge.c /link /LIBPATH:"C:\OpenBLAS\lib" libopenblas.dll.a .\hoge.exe
eig_lapack.c を使用
Windows での確認手順と結果は次の通り
eig_lapack.c を使用
gcc -I"C:\OpenBLAS\include" -c -o eig_lapack.o eig_lapack.c gcc -L"C:\OpenBLAS\lib" -o a.exe eig_lapack.o -lopenblas .\a.exe
https://gist.github.com/xianyi/6930656 に掲載の プログラムを利用
Windows での確認手順と結果は次の通り
eig_lapack.c を使用
cl /I"C:\OpenBLAS\include" eig_lapack.c /link /LIBPATH:"C:\OpenBLAS\lib" libopenblas.dll.a .\eig_lapack.exe