Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch SVT-AV1-PSY build to Clang-CL for faster Windows builds #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions docs/encoders/SVT-AV1-PSY.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,41 +159,37 @@ Building & installing SVT-AV1-PSY is the same as building & installing mainline
```
</TabItem>
<TabItem value="windows" label="Windows">
**MSYS2** is the best option for building in Windows, as it provides a Unix-like environment for building SVT-AV1-PSY. This makes the compilation procedure the same as described for Linux & macOS. The full build process is detailed here.
**Clang-CL** is the best option for building in Windows, as it results in faster binaries than building with MSYS2 (either GCC/Clang) and MSVC. The full build process is detailed here.

0. Make sure you have downloaded & installed MSYS2 from [the MSYS2 website](https://www.msys2.org/) before beginning the build process.
0. Make sure you have the following prerequisites before beginning the build process:
- [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools): Inside Build Tools, select "Desktop development with C++" and under optional, select "C++ Clang tools"
- [CMake](https://cmake.org/download)
- [NASM](https://nasm.us)
- [Git](https://git-scm.com/downloads)

1. Start the UCRT64 console & install the required dependencies:
```bash
pacman -Syu --needed git mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-yasm
```
1. Clone the SVT-AV1-PSY repository:

2. \[Optional\] Clang is the recommended compiler for SVT-AV1 & SVT-AV1-PSY, so you may wish to download it with the following command:

```bash
pacman -Syu --needed mingw-w64-ucrt-x86_64-clang
```bash title="Clone SVT-AV1-PSY"
git clone https://github.com/gianni-rosato/svt-av1-psy.git
cd svt-av1-psy
```

3. Now, we may follow the steps for Linux & macOS to complete building. Please note that CMake may require you to include `-G "Ninja"` in any CMake commands.
2. Configure compilation:

```bash title="Clone SVT-AV1-PSY"
git clone https://github.com/gianni-rosato/svt-av1-psy
cd SVT-AV1/Build/linux
```bash title="Configure SVT-AV1-PSY"
cmake --fresh -B svt_build -T ClangCL -DENABLE_AVX512=OFF -DBUILD_SHARED_LIBS=OFF -DSVT_AV1_LTO=OFF -DCMAKE_CXX_FLAGS_RELEASE="-flto /clang:-O2 /DNDEBUG -march=native" -DCMAKE_C_FLAGS_RELEASE="-flto /clang:-O2 /DNDEBUG -march=native"
```
**Note**: On Ryzen 5000, `-march=native` actually decrease performance. Please use `-march=znver2` instead.
**Note**: If your CPU supports AVX512, you can enable it by changing `-DENABLE_AVX512=OFF` to `-DENABLE_AVX512=ON` for better performance.

In the directory, simply run `./build.sh [flags]` to build. Be aware that building requires CMake version 3.16 or higher and either GCC or Clang. It is recommended to use Clang, and ideally it will be installed as per Step 2.
3. Compile:

```bash title="Build release"
./build.sh release
cmake --build svt_build --config Release --parallel
```

```bash title="Statically build just the encoder with clang and enable link-time optimization"
./build.sh jobs=8 all cc=clang cxx=clang++ no-dec enable-lto static native
```

The compiled binaries will be in the `Bin/Release` directory, including SvtAv1EncApp. If you just want the encoder, adding the `no-dec` flag will skip building SvtAv1DecApp and save on compilation time.

If you'd like to build from the latest release (2.1.0 at the time of writing - last updated 23 May 2024) please run `git reset --hard 5471bd78311d70ab4691af1ae54fd80e25f214f5` in the cloned directory.
The compiled binary will be in the `Bin/Release` directory.
For more information, findings and discussions about the builds (including the Ryzen 5000 case, parameters used and tested, Windows 10/11, Clang 17-19, Ninja, and **PGO**), check the [Community Builds Thread for v2.2.1-A](https://github.com/gianni-rosato/svt-av1-psy/discussions/69)
</TabItem>
</Tabs>

Expand Down