Skip to content

Commit 62960ca

Browse files
authored
feat: add FFI_USE_CUDA_SUPRASEAL env variable (#425)
Make it possible to build the FFI with SupraSeal enabled, which should lead to better performance during C2.
1 parent 4548462 commit 62960ca

File tree

5 files changed

+75
-5
lines changed

5 files changed

+75
-5
lines changed

.circleci/config.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ jobs:
107107
- run: cd rust && cargo install cargo-lipo
108108
- build_project
109109
- compile_tests
110+
111+
# SupraSeal pulls in a C++ code base, make sure everything compiles properly.
112+
build_linux_supraseal:
113+
executor: golang
114+
resource_class: medium
115+
working_directory: ~/go/src/github.com/filecoin-project/filecoin-ffi
116+
steps:
117+
- configure_environment_variables
118+
- prepare
119+
- run:
120+
name: Build project with `FFI_USE_CUDA_SUPRASEAL=1`
121+
command: FFI_BUILD_FROM_SOURCE=1 FFI_USE_CUDA_SUPRASEAL=1 make
122+
110123
publish_linux_x86_64_staticlib:
111124
executor: golang
112125
resource_class: medium
@@ -172,6 +185,7 @@ workflows:
172185
- build_and_test_aarch64_linux_cgo_bindings:
173186
run_leak_detector: false
174187
- build_darwin_cgo_bindings
188+
- build_linux_supraseal
175189
- publish_linux_x86_64_staticlib:
176190
filters:
177191
tags:
@@ -208,7 +222,12 @@ commands:
208222
condition: << parameters.linux >>
209223
steps:
210224
- run: sudo apt-get update
211-
- run: sudo apt-get install --no-install-recommends -y valgrind ocl-icd-opencl-dev libssl-dev libhwloc-dev nvidia-cuda-toolkit
225+
- run: sudo apt-get install --no-install-recommends -y valgrind ocl-icd-opencl-dev libssl-dev libhwloc-dev nvidia-cuda-toolkit g++-10
226+
- run:
227+
name: Downgrade to GCC 10, as CUDA 11 doesn't play nice with GCC 11
228+
command: |
229+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-10 10
230+
sudo update-alternatives --set c++ /usr/bin/g++-10
212231
- when:
213232
condition: << parameters.darwin >>
214233
steps:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ rm .install-filcrypto \
4848

4949
CUDA for GPU support is now enabled by default in the proofs library. This feature can optionally be replaced by OpenCL by using `FFI_USE_OPENCL=1` set in the environment when building from source. Alternatively, if the CUDA toolkit (such as `nvcc`) cannot be located in the environment, OpenCL support is used instead. To disable GPU support entirely, set `FFI_USE_GPU=0` in the environment when building from source.
5050

51+
There is experimental support for faster C2 named "SupraSeal". To enable it, set `FFI_USE_CUDA_SUPRASEAL=1`. It's specific to CUDA and won't work with OpenCL.
52+
5153
```shell
5254
rm .install-filcrypto \
5355
; make clean \

install-filcrypto

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@ build_from_source() {
176176
# Check if GPU support is disabled.
177177
if [ "${FFI_USE_GPU}" == "0" ]; then
178178
gpu_flags=""
179+
elif [ "${FFI_USE_CUDA_SUPRASEAL}" == "1" ]; then
180+
# If SupraSeal is enabled, just use the `cuda-supraseal` eature and
181+
# nothing else GPU related.
182+
gpu_flags=",cuda-supraseal"
179183
else
180-
# If not, default to CUDA support where possible.
181-
# First ensure that nvcc (as part of the CUDA toolkit) is
182-
# available -- if it's not warn that we are defaulting GPU to
183-
# OpenCL instead.
184+
# If GPUs are enabled and SupraSeal is not, default to CUDA support
185+
# where possible.
186+
# First ensure that nvcc (as part of the CUDA toolkit) is available --
187+
# if it's not warn that we are defaulting GPU to OpenCL instead.
184188
gpu_flags=",cuda"
185189

186190
# Unless OpenCL support is specified or we're building on Darwin.

rust/Cargo.lock

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ tempfile = "3.0.8"
5757
default = ["cuda", "multicore-sdr" ]
5858
blst-portable = ["bls-signatures/blst-portable", "blstrs/portable"]
5959
cuda = ["filecoin-proofs-api/cuda", "rust-gpu-tools/cuda", "fvm3/cuda", "fvm2/cuda"]
60+
cuda-supraseal = ["filecoin-proofs-api/cuda-supraseal", "rust-gpu-tools/cuda", "fvm3/cuda-supraseal"]
6061
opencl = ["filecoin-proofs-api/opencl", "rust-gpu-tools/opencl", "fvm3/opencl", "fvm2/opencl"]
6162
multicore-sdr = ["filecoin-proofs-api/multicore-sdr"]
6263
c-headers = ["safer-ffi/headers"]

0 commit comments

Comments
 (0)