Skip to content

Commit

Permalink
Enable OpenBLAS (#13)
Browse files Browse the repository at this point in the history
- OpenBLAS latest release version (v0.3.27) is being built with MSVC. 
- OpenBLAS is enabled as a BLAS option to Unit Test and Release workflows. 
- A Pytorch with OpenBLAS build is added to Daily Release workflow.
- Instructions to use OpenBLAS when building manually are also added.
- OpenBLAS with Clang is disabled for now.
  • Loading branch information
iremyux authored Jul 3, 2024
1 parent e00400b commit eff3fe8
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 91 deletions.
7 changes: 4 additions & 3 deletions .github/scripts/bootstrap_openblas.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
echo %JOB_DIR%
echo %DEPENDENCIES_DIR%

del %DEPENDENCIES_DIR%\openblas\build /s /q /f
del %DEPENDENCIES_DIR%\openblas\install /s /q /f

del %JOB_DIR%\openblas\build /s /q /f
del %JOB_DIR%\openblas\install /s /q /f
27 changes: 21 additions & 6 deletions .github/scripts/build_openblas_msvc.bat
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
set "vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
set visualstudio=
for /f "delims=" %%v in ('"%vswhere%" -latest -property installationPath') do set "visualstudio=%%v"
for /f "delims=" %%v in ('"%vswhere%" -latest -products * -property installationPath') do set "visualstudio=%%v"
if "%visualstudio%" == "" (
echo Visual Studio not found!
goto :eof
)

call "%visualstudio%\VC\Auxiliary\Build\vcvarsall.bat" arm64

mkdir %JOB_DIR%\openblas\build
cd %JOB_DIR%\openblas\build
mkdir %DEPENDENCY_OPENBLAS_DIR%\build
cd %DEPENDENCY_OPENBLAS_DIR%\build

set CMAKE_BUILD_TYPE=RelWithDebInfo

cmake .. -G Ninja -DBUILD_TESTING=0
echo Building OpenBLAS...
cmake .. -G Ninja ^
-DBUILD_TESTING=0 ^
-DBUILD_BENCHMARKS=0 ^
-DC_LAPACK=1 ^
-DNOFORTRAN=1 ^
-DDYNAMIC_ARCH=0 ^
-DARCH=arm64 ^
-DBINARY=64 ^
-DTARGET=GENERIC ^
-DUSE_OPENMP=0 ^
-DCMAKE_VERBOSE_MAKEFILE=1 ^
-DCMAKE_SYSTEM_PROCESSOR=ARM64 ^
-DCMAKE_SYSTEM_NAME=Windows
cmake --build . --config Release

echo Installing OpenBLAS...
cmake --install . --prefix ../install

echo Dependency OpenBLAS installation is finished.
10 changes: 7 additions & 3 deletions .github/scripts/build_pytorch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
sccache --zero-stats

:: environment variables
:: TODO: OpenBLAS implementation will be applied
set BLAS=APL
if "%ENABLE_APL%"=="1" (
set BLAS=APL
set PATH=%DEPENDENCY_APL_DIR%;%PATH%
) else if "%ENABLE_OPENBLAS%"=="1" (
set BLAS=OpenBLAS
set OpenBLAS_HOME=%DEPENDENCY_OPENBLAS_DIR%\install
)
set REL_WITH_DEB_INFO=1
set CMAKE_BUILD_TYPE=RelWithDebInfo
set USE_LAPACK=1
Expand All @@ -14,7 +19,6 @@ set CMAKE_CXX_COMPILER_LAUNCHER=sccache

:: TODO: Dependencies
set PATH=%DEPENDENCY_SCCACHE_DIR%;%PATH%
set PATH=%DEPENDENCY_APL_DIR%;%PATH%

:: change to source directory
cd %PYTORCH_SOURCES_DIR%
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/wipe_openblas_build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo on

if exist [%OPENBLAS__BUILD_DIR%] (
rmdir /s /q %OPENBLAS__BUILD_DIR%
if exist [%OPENBLAS_BUILD_DIR%] (
rmdir /s /q %OPENBLAS_BUILD_DIR%
)
46 changes: 27 additions & 19 deletions .github/workflows/daily-release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
name: Release

# Controls when the workflow will run
# OpenBLAS is disabled for now
# Schedule doesn't accept inputs. So, this has hardcoded values for repository / branch
on:
schedule:
- cron: "7 0 * * *"

jobs:
create_release:
name: Create Release
uses: ./.github/workflows/release.yml
with:
blass_type: 'apl'
pytorch_repository: 'iremyux/pytorch'
pytorch_branch: 'apl-tests'
wheel_name: 'torch-2.4.0a-cp311-cp311-win_arm64.whl'
release_prefix: 'Daily Release'
name: Daily Release

# Controls when the workflow will run
# Schedule doesn't accept inputs. So, this has hardcoded values for repository / branch
on:
schedule:
- cron: "0 9 * * *"

jobs:
create_release_apl:
name: Create Release with APL
uses: ./.github/workflows/release.yml
with:
blas_type: 'apl'
pytorch_repository: 'iremyux/pytorch'
pytorch_branch: 'apl-tests'
wheel_name: 'torch-2.4.0a-cp311-cp311-win_arm64.whl'
release_prefix: 'Daily Release - APL'
create_release_openblas:
name: Create Release with OpenBLAS
uses: ./.github/workflows/release.yml
with:
blas_type: 'openblas'
pytorch_repository: 'iremyux/pytorch'
pytorch_branch: 'apl-tests'
wheel_name: 'torch-2.4.0a-cp311-cp311-win_arm64.whl'
release_prefix: 'Daily Release - OpenBLAS'
29 changes: 22 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: Release

# Controls when the workflow will run
# OpenBLAS is disabled for now

on:
# for manual releases
workflow_dispatch:
inputs:
blass_type:
description: "Choose BLAS type (for now only APL)"
blas_type:
description: "Choose BLAS type"
required: true
default: 'apl'
type: choice
options:
- apl
- openblas
pytorch_repository:
description: "PyTorch repository"
required: true
Expand All @@ -37,7 +38,7 @@ on:
# for daily releases
workflow_call:
inputs:
blass_type:
blas_type:
type: string
pytorch_repository:
type: string
Expand All @@ -57,9 +58,11 @@ env:
WHEEL_DIR: ${{ github.workspace }}\pytorch-job\src\${{ inputs.pytorch_repository }}\${{ inputs.pytorch_branch }}\dist
WHEEL_NAME: ${{ inputs.wheel_name }}
ENABLE_BUILD_WHEEL: 1
ENABLE_APL: ${{ inputs.blass_type == 'apl' && '1' || '0' }}
DEPENDENCY_SCCACHE_DIR: C:\_WORK\dependencies\sccache
DEPENDENCY_APL_DIR: C:\_WORK\dependencies\apl\armpl_24.04\bin
ENABLE_APL: ${{ inputs.blas_type == 'apl' && '1' || '0' }}
ENABLE_OPENBLAS: ${{ (inputs.blas_type == 'openblas' || inputs.blas_type == 'openblas_clang') && '1' || '0' }}
DEPENDENCY_SCCACHE_DIR: ${{ github.workspace }}\pytorch-job\dependencies\sccache
DEPENDENCY_APL_DIR: ${{ github.workspace }}\pytorch-job\dependencies\apl\armpl_24.04\bin
DEPENDENCY_OPENBLAS_DIR: ${{ github.workspace }}\pytorch-job\dependencies\openblas

jobs:
create_release:
Expand All @@ -73,6 +76,18 @@ jobs:
uses: actions/checkout@v4
with:
path: ${{ env.JOB_DIR }}/workflow
- name: Git checkout OpenBLAS
if: ${{ env.ENABLE_OPENBLAS }}
uses: actions/checkout@v4
with:
repository: "OpenMathLib/OpenBLAS"
ref: "v0.3.27"
path: ${{ env.DEPENDENCY_OPENBLAS_DIR }}
submodules: recursive
- name: Build OpenBLAS with MSVC
if: ${{ inputs.blas_type == 'openblas'}}
run: |
& ${{ env.SCRIPTS_DIR }}\build_openblas_msvc.bat
- name: Git checkout PyTorch
uses: actions/checkout@v4
with:
Expand Down
60 changes: 27 additions & 33 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
name: Build and run tests

# 1. OpenBLAS is disabled for now
# 2. APL and sccache bootstrap is pre-installed. bootstrap scripts can be used for portability.
# 1. APL and sccache bootstrap is pre-installed. bootstrap scripts can be used for portability.

on:
workflow_dispatch:
inputs:
# openblas_repository:
# description: "OpenBLAS repository"
# required: true
# default: "OpenMathLib/OpenBLAS"
# type: string
# openblas_branch:
# description: "OpenBLAS branch"
# required: true
# default: "release-0.3.0"
# type: string
blass_type:
blas_type:
description: "Choose BLAS type"
required: true
default: 'apl'
type: choice
options:
- apl
# - openblas_msvc
- openblas
# - openblas_clang
pytorch_repository:
description: "PyTorch repository"
Expand Down Expand Up @@ -76,8 +66,11 @@ env:
DEPENDENCIES_DIR: ${{ github.workspace }}\pytorch-job\dependencies
SCRIPTS_DIR: ${{ github.workspace }}\pytorch-job\workflow\.github\scripts
PYTORCH_SOURCES_DIR: ${{ github.workspace }}\pytorch-job\src\${{ inputs.pytorch_repository }}\${{ inputs.pytorch_branch }}
ENABLE_APL: ${{ inputs.blass_type == 'apl' && '1' || '0' }}
# ENABLE_OPENBLAS: ${{ (inputs.blass_type == 'openblas_msvc' || inputs.blass_type == 'openblas_clang') && '1' || '0' }}
ENABLE_APL: ${{ inputs.blas_type == 'apl' && '1' || '0' }}
ENABLE_OPENBLAS: ${{ (inputs.blas_type == 'openblas' || inputs.blas_type == 'openblas_clang') && '1' || '0' }}
DEPENDENCY_SCCACHE_DIR: ${{ github.workspace }}\pytorch-job\dependencies\sccache
DEPENDENCY_APL_DIR: ${{ github.workspace }}\pytorch-job\dependencies\apl\armpl_24.04\bin
DEPENDENCY_OPENBLAS_DIR: ${{ github.workspace }}\pytorch-job\dependencies\openblas

jobs:

Expand All @@ -90,6 +83,22 @@ jobs:
uses: actions/checkout@v4
with:
path: ${{ env.JOB_DIR }}/workflow
- name: Git checkout OpenBLAS
if: ${{ env.ENABLE_OPENBLAS }}
uses: actions/checkout@v4
with:
repository: "OpenMathLib/OpenBLAS"
ref: "v0.3.27"
path: ${{ env.DEPENDENCY_OPENBLAS_DIR }}
submodules: recursive
- name: Bootstrap OpenBLAS build
if: ${{ env.ENABLE_OPENBLAS }}
run: |
& ${{ env.SCRIPTS_DIR }}\bootstrap_openblas.bat
- name: Build OpenBLAS with MSVC
if: ${{ inputs.blas_type == 'openblas'}}
run: |
& ${{ env.SCRIPTS_DIR }}\build_openblas_msvc.bat
- name: Git checkout PyTorch
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -128,31 +137,16 @@ jobs:
path: ${{ env.JOB_DIR }}/pytorch/test/test-reports/*
retention-days: 7
# TEMPORARILY DISABLED FOR FUTURE WORK
# - name: Git checkout OpenBLAS
# if: ${{ env.ENABLE_OPENBLAS }}
# uses: actions/checkout@v4
# with:
# repository: ${{ inputs.openblas_repository }}
# ref: ${{ inputs.openblas_branch }}
# path: ${{ env.JOB_DIR }}/openblas
# submodules: recursive

# - name: Bootstrap sccache binaries
# run: |
# & ${{ env.SCRIPTS_DIR }}\bootstrap_sccache.bat
# - name: Bootstrap APL binaries
# if: ${{ env.ENABLE_APL }}
# run: |
# & ${{ env.SCRIPTS_DIR }}\bootstrap_apl.bat
# - name: Bootstrap OpenBLAS build
# if: ${{ env.ENABLE_OPENBLAS }}
# run: |
# & ${{ env.SCRIPTS_DIR }}\bootstrap_openblas.bat
# - name: Build OpenBLAS with MSVC
# if: ${{ inputs.blass_type == 'openblas_msvc'}}
# run: |
# & ${{ env.SCRIPTS_DIR }}\build_openblas_msvc.bat
# - name: Build OpenBLAS with Clang
# if: ${{ inputs.blass_type == 'openblas_clang'}}
# if: ${{ inputs.blas_type == 'openblas_clang'}}
# run: |
# & ${{ env.SCRIPTS_DIR }}\build_openblas_clang.bat
# - name: Archive OpenBLAS
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/wipe-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name: Wipe runner caches
on:
workflow_dispatch:
inputs:
# is_openblas_sources:
# description: "Enable wipe OpenBLAS sources?"
# required: false
# default: false
# type: boolean
# is_openblas_build:
# description: "Enable wipe OpenBLAS build?"
# required: false
# default: false
# type: boolean
is_openblas_sources:
description: "Enable wipe OpenBLAS sources?"
required: false
default: false
type: boolean
is_openblas_build:
description: "Enable wipe OpenBLAS build?"
required: false
default: false
type: boolean
is_pytorch_sources:
description: "Enable wipe PyTorch sources?"
required: false
Expand All @@ -27,8 +27,8 @@ env:
JOB_DIR: ${{ github.workspace }}\pytorch-job
SCRIPTS_DIR: ${{ github.workspace }}\pytorch-job\workflow\.github\scripts
PYTORCH_SOURCES_DIR: ${{ github.workspace }}\pytorch-job\src
# OPENBLAS_SOURCES_DIR: ${{ github.workspace }}\pytorch-job\openblas
# OPENBLAS_BUILD_DIR: ${{ github.workspace }}\pytorch-job\openblas\build
OPENBLAS_SOURCES_DIR: ${{ github.workspace }}\pytorch-job\dependencies\openblas
OPENBLAS_BUILD_DIR: ${{ github.workspace }}\pytorch-job\dependencies\openblas\build

jobs:
wipe:
Expand All @@ -40,12 +40,12 @@ jobs:
uses: actions/checkout@v4
with:
path: ${{ env.JOB_DIR }}\workflow
- name: Wipe OpenBLAS sources
if: ${{ inputs.is_openblas_sources }}
run: ${{ env.SCRIPTS_DIR }}\wipe_openblas_sources.bat
- name: Wipe OpenBLAS build
if: ${{ inputs.is_openblas_build }}
run: ${{ env.SCRIPTS_DIR }}\wipe_openblas_build.bat
- name: Wipe OpenBLAS sources
if: ${{ inputs.is_openblas_sources }}
run: ${{ env.SCRIPTS_DIR }}\wipe_openblas_sources.bat
- name: Wipe PyTorch sources
if: ${{ inputs.is_pytorch_sources }}
run: ${{ env.SCRIPTS_DIR }}\wipe_pytorch_sources.bat
Loading

0 comments on commit eff3fe8

Please sign in to comment.