Skip to content

Commit

Permalink
make rust features disable instead of enable and use in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yshekel committed Aug 21, 2024
1 parent 6c25fc1 commit f5a998e
Show file tree
Hide file tree
Showing 39 changed files with 163 additions and 144 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/v3_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
if: needs.check-changed-files.outputs.rust == 'true' || needs.check-changed-files.outputs.cpp_cuda == 'true'
# tests are split to phases since NTT domain is global but tests have conflicting requirements
run: |
cargo build --release --verbose --features=g2,ec_ntt
cargo test --workspace --release --verbose --features=g2,ec_ntt,cuda_backend -- --skip phase
cargo test phase2 --workspace --release --verbose --features=g2,ec_ntt,cuda_backend
cargo test phase3 --workspace --release --verbose --features=g2,ec_ntt,cuda_backend
cargo build --release --features=cuda_backend
cargo test --workspace --release --verbose --features=cuda_backend -- --skip phase
cargo test phase2 --workspace --release --verbose --features=cuda_backend
cargo test phase3 --workspace --release --verbose --features=cuda_backend
27 changes: 13 additions & 14 deletions docs/docs/icicle/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ You can customize your ICICLE build with the following flags:

#### Features

By default, all [features](./libraries.md#supported-curves-and-operations) are enabled.

:::note
Installed backends may implement and register all APIs, therefore by default we include them in the frontend part too.
:::
By default, all [features](./libraries.md#supported-curves-and-operations) are enabled.
This is since installed backends may implement and register all APIs. Missing APIs in the frontend would cause linkage to fail due to missing symbols. Therefore by default we include them in the frontend part too.

To disable features, add the following to the cmake command.
- ntt: `-DNTT=OFF`
Expand All @@ -103,6 +100,10 @@ To disable features, add the following to the cmake command.
- ecntt: `-DECNTT=OFF`
- extension field: `-DEXT_FIELD=OFF`

:::tip
Disabling features is useful when developing with a backend that is slow to compile (e.g. CUDA backend);
:::

### Rust: Build, Test, and Install

To build and test ICICLE in Rust, follow these steps:
Expand All @@ -116,19 +117,17 @@ cd wrappers/rust # or go to a specific field/curve 'cd wrappers/rust/icicle-fiel
```bash
cargo build --release
```
By default, all [features](./libraries.md#supported-curves-and-operations) are enabled.
In rust we have the following features:
- `g2` for G2 MSM
- `ec_ntt` for ECNTT
By default, all [supported features](./libraries.md#supported-curves-and-operations) are enabled. [See here for more details.](#features)
To disable, use the following cargo features:
- `no_g2` to disable G2 MSM
- `no_ecntt` to disable ECNTT

They can be disabled by
They can be disabled as follows:
```bash
cargo build --release --no-default-features # disable all features
cargo build --release --no-default-features --features "ec_ntt" # disable all except ec_ntt
cargo build --release --no-default-features --features "g2" # disable all except g2
cargo build --release --no-default-features --features=no_ecntt,no_g2
```

:::tip
:::note
If you have access to cuda backend repo, it can be built along ICICLE frontend by using the following cargo features:
- `cuda_backend` : if the cuda backend resides in `icicle/backend/cuda`
- `pull_cuda_backend` : to pull main branch and build it
Expand Down
4 changes: 2 additions & 2 deletions examples/c++/best-practice-ntt/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -DG2=OFF -DECNTT=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -S "${ICILE_DIR}" -B build/icicle
fi
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build/example

Expand Down
4 changes: 2 additions & 2 deletions examples/c++/msm/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DG2=ON -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DECNTT=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DG2=ON -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -S "${ICILE_DIR}" -B build/icicle
fi
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build/example

Expand Down
4 changes: 2 additions & 2 deletions examples/c++/ntt/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -DG2=OFF -DECNTT=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -S "${ICILE_DIR}" -B build/icicle
fi
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build/example

Expand Down
2 changes: 1 addition & 1 deletion examples/c++/pedersen-commitment/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DG2=OFF -DECNTT=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
Expand Down
2 changes: 1 addition & 1 deletion examples/c++/polynomial-api/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void example_device_memory_view()
auto coset_evals = std::make_unique<scalar_t[]>(size);
auto ntt_config = default_ntt_config<scalar_t>();
ntt_config.are_inputs_on_device = true; // using the device data directly as a view
ntt_config.coset_gen = get_root_of_unity<scalar_t>(size * 2);
ICICLE_CHECK(get_root_of_unity<scalar_t>(size * 2, &ntt_config.coset_gen));
ntt(d_coeffs.get(), size, NTTDir::kForward, ntt_config, coset_evals.get());
}

Expand Down
2 changes: 1 addition & 1 deletion examples/c++/polynomial-api/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DG2=OFF -DECNTT=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
Expand Down
4 changes: 2 additions & 2 deletions examples/c++/polynomial_multiplication/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -DG2=OFF -DECNTT=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DMSM=OFF -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -S "${ICILE_DIR}" -B build/icicle
fi
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build/example

Expand Down
2 changes: 1 addition & 1 deletion examples/c++/risc0/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cmake -DCMAKE_BUILD_TYPE=Release -DFIELD=babybear -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
cmake -DCMAKE_BUILD_TYPE=Release -DFIELD=babybear -DMSM=OFF -DG2=OFF -DECNTT=OFF -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
Expand Down
9 changes: 7 additions & 2 deletions examples/rust/msm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ edition = "2018"
[dependencies]
icicle-runtime = { path = "../../../wrappers/rust_v3/icicle-runtime" }
icicle-core = { path = "../../../wrappers/rust_v3/icicle-core" }
icicle-bn254 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bn254", features = ["g2"] }
icicle-bn254 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bn254" }
icicle-bls12-377 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bls12-377" }
clap = { version = "<=4.4.12", features = ["derive"] }

[features]
cuda = ["icicle-runtime/cuda_backend", "icicle-bn254/cuda_backend", "icicle-bls12-377/cuda_backend"]
cuda = ["icicle-runtime/cuda_backend",
"icicle-bn254/cuda_backend",
"icicle-bls12-377/cuda_backend",
"icicle-bn254/no_ecntt",
"icicle-bls12-377/no_ecntt"
]
11 changes: 9 additions & 2 deletions examples/rust/ntt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ edition = "2018"
[dependencies]
icicle-runtime = { path = "../../../wrappers/rust_v3/icicle-runtime" }
icicle-core = { path = "../../../wrappers/rust_v3/icicle-core" }
icicle-bn254 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bn254", features = ["g2"] }
icicle-bn254 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bn254" }
icicle-bls12-377 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bls12-377" }

clap = { version = "<=4.4.12", features = ["derive"] }

[features]
cuda = ["icicle-runtime/cuda_backend", "icicle-bn254/cuda_backend", "icicle-bls12-377/cuda_backend"]
cuda = ["icicle-runtime/cuda_backend",
"icicle-bn254/cuda_backend",
"icicle-bn254/no_ecntt",
"icicle-bn254/no_g2",
"icicle-bls12-377/cuda_backend",
"icicle-bls12-377/no_ecntt",
"icicle-bls12-377/no_g2"
]
9 changes: 7 additions & 2 deletions examples/rust/polynomials/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ edition = "2018"
[dependencies]
icicle-runtime = { path = "../../../wrappers/rust_v3/icicle-runtime" }
icicle-core = { path = "../../../wrappers/rust_v3/icicle-core" }
icicle-bn254 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bn254", features = ["g2"] }
icicle-bn254 = { path = "../../../wrappers/rust_v3/icicle-curves/icicle-bn254" }
icicle-babybear = { path = "../../../wrappers/rust_v3/icicle-fields/icicle-babybear" }

clap = { version = "<=4.4.12", features = ["derive"] }

[features]
cuda = ["icicle-runtime/cuda_backend", "icicle-bn254/cuda_backend", "icicle-babybear/cuda_backend"]
cuda = ["icicle-runtime/cuda_backend",
"icicle-bn254/cuda_backend",
"icicle-babybear/cuda_backend",
"icicle-bn254/no_ecntt",
"icicle-bn254/no_g2",
]

4 changes: 2 additions & 2 deletions examples/rust/polynomials/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ ICICLE_CUDA_SOURCE_DIR="${ICILE_DIR}/backend/cuda"
# Build Icicle and the example app that links to it
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_SOURCE_DIR}" ]; then
echo "Building icicle with CUDA backend"
cargo build --release --features=cuda
cargo build --release --no-default-features --features=cuda
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "./target/release/deps/icicle/lib/backend")
cargo run --release --features=cuda -- --device-type "${DEVICE_TYPE}"
cargo run --release --no-default-features --features=cuda -- --device-type "${DEVICE_TYPE}"
else
echo "Building icicle without CUDA backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}"
export ICICLE_BACKEND_INSTALL_DIR="$ICICLE_BACKEND_INSTALL_DIR";
Expand Down
2 changes: 1 addition & 1 deletion icicle_v3/cmake/curve.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function(check_curve CURVE CURVE_INDEX_OUT FEATURES_STRING_OUT)

if (CURVE STREQUAL CURVE_NAME)
set(IS_CURVE_SUPPORTED TRUE)
message(STATUS "building CURVE_NAME=${CURVE_NAME} ; CURVE_INDEX=${CURVE_INDEX} ; FEATURES=${FEATURES_STRING}")
message(STATUS "building CURVE_NAME=${CURVE_NAME} ; CURVE_INDEX=${CURVE_INDEX} ; SUPPORTED_FEATURES=${FEATURES_STRING}")
# Output the CURVE_INDEX and FEATURES_STRING
set(${CURVE_INDEX_OUT} "${CURVE_INDEX}" PARENT_SCOPE)
set(${FEATURES_STRING_OUT} "${FEATURES_STRING}" PARENT_SCOPE)
Expand Down
2 changes: 1 addition & 1 deletion icicle_v3/cmake/field.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function(check_field FIELD FIELD_INDEX_OUT FEATURES_STRING_OUT)

if (FIELD STREQUAL FIELD_NAME)
set(IS_FIELD_SUPPORTED TRUE)
message(STATUS "building FIELD_NAME=${FIELD_NAME} ; FIELD_INDEX=${FIELD_INDEX} ; FEATURES=${FEATURES_STRING}")
message(STATUS "building FIELD_NAME=${FIELD_NAME} ; FIELD_INDEX=${FIELD_INDEX} ; SUPPORTED_FEATURES=${FEATURES_STRING}")
# Output the FIELD_INDEX and FEATURES_STRING
set(${FIELD_INDEX_OUT} "${FIELD_INDEX}" PARENT_SCOPE)
set(${FEATURES_STRING_OUT} "${FEATURES_STRING}" PARENT_SCOPE)
Expand Down
11 changes: 5 additions & 6 deletions icicle_v3/cmake/target_editor.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ endfunction()

function(handle_ntt TARGET FEATURE_LIST)
if(NTT AND "NTT" IN_LIST FEATURE_LIST)
target_compile_definitions(${TARGET} PUBLIC NTT=${NTT})
target_compile_definitions(${TARGET} PUBLIC NTT=${NTT})
target_sources(${TARGET} PRIVATE
src/ntt.cpp
src/polynomials/polynomials.cpp
src/polynomials/polynomials_c_api.cpp
src/polynomials/polynomials_abstract_factory.cpp
)
set(NTT ON CACHE BOOL "Enable NTT feature" FORCE)
else()
set(NTT OFF CACHE BOOL "NTT not available for this field" FORCE)
message(STATUS "NTT not available for this field")
endif()
set(NTT ON CACHE BOOL "Enable NTT feature" FORCE)
else()
set(NTT OFF CACHE BOOL "NTT not available for this field" FORCE)
endif()
endfunction()

function(handle_ext_field TARGET FEATURE_LIST)
Expand Down
2 changes: 1 addition & 1 deletion icicle_v3/src/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ extern "C" eIcicleError icicle_load_backend(const char* path, bool is_recursive)

auto load_library = [](const char* filePath) {
ICICLE_LOG_DEBUG << "Attempting load: " << filePath;
void* handle = dlopen(filePath, RTLD_LAZY | RTLD_GLOBAL);
void* handle = dlopen(filePath, RTLD_LAZY);
if (!handle) { ICICLE_LOG_ERROR << "Failed to load " << filePath << ": " << dlerror(); }
};

Expand Down
4 changes: 2 additions & 2 deletions wrappers/rust_v3/icicle-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ serial_test = "3.0.0"
once_cell = "1.10.0"

[features]
g2 = []
ec_ntt = []
no_g2 = []
no_ecntt = []
7 changes: 3 additions & 4 deletions wrappers/rust_v3/icicle-curves/icicle-bls12-377/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ serial_test = "3.0.0"
cmake = "0.1.50"

[features]
default = ["g2", "ec_ntt"]
default = []
bw6-761 = []
bw6-761-g2 = ["bw6-761"]
g2 = ["icicle-core/g2"]
ec_ntt = ["icicle-core/ec_ntt"]
no_g2 = ["icicle-core/no_g2"]
no_ecntt = ["icicle-core/no_ecntt"]
cuda_backend = ["icicle-runtime/cuda_backend"]
pull_cuda_backend = ["icicle-runtime/pull_cuda_backend"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[cfg(feature = "ec_ntt")]
#[cfg(not(feature = "no_ecntt"))]
use icicle_bls12_377::curve::{CurveCfg, ScalarField};

#[cfg(feature = "ec_ntt")]
#[cfg(not(feature = "no_ecntt"))]
use icicle_core::impl_ecntt_bench;
#[cfg(feature = "ec_ntt")]
#[cfg(not(feature = "no_ecntt"))]
impl_ecntt_bench!("bls12_377", ScalarField, CurveCfg);

#[cfg(not(feature = "ec_ntt"))]
Expand Down
44 changes: 24 additions & 20 deletions wrappers/rust_v3/icicle-curves/icicle-bls12-377/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ fn main() {
.define("CMAKE_BUILD_TYPE", "Release")
.define("CMAKE_INSTALL_PREFIX", &icicle_install_dir);

#[cfg(feature = "cuda_backend")]
config.define("CUDA_BACKEND", "local");

#[cfg(feature = "pull_cuda_backend")]
config.define("CUDA_BACKEND", "main");

// build (or pull and build) cuda backend if feature enabled.
// Note: this requires access to the repo
if cfg!(feature = "cuda_backend") {
config.define("CUDA_BACKEND", "local");
} else if cfg!(feature = "pull_cuda_backend") {
config.define("CUDA_BACKEND", "main");
}
// Optional Features that are default ON (so that default matches any backend)
if !cfg!(feature = "g2") {
if cfg!(feature = "no_g2") {
config.define("G2", "OFF");
}
if !cfg!(feature = "ec_ntt") {
if cfg!(feature = "no_ecntt") {
config.define("ECNTT", "OFF");
}

Expand All @@ -61,18 +62,21 @@ fn main() {
.define("CMAKE_BUILD_TYPE", "Release")
.define("CMAKE_INSTALL_PREFIX", &icicle_install_dir);

#[cfg(feature = "cuda_backend")]
config_bw.define("CUDA_BACKEND", "local");

#[cfg(feature = "pull_cuda_backend")]
config_bw.define("CUDA_BACKEND", "main");

// Optional Features
#[cfg(feature = "bw6-761-g2")]
config_bw.define("G2", "ON");

#[cfg(feature = "ec_ntt")]
config_bw.define("ECNTT", "OFF");
// build (or pull and build) cuda backend if feature enabled.
// Note: this requires access to the repo
if cfg!(feature = "cuda_backend") {
config.define("CUDA_BACKEND", "local");
} else if cfg!(feature = "pull_cuda_backend") {
config.define("CUDA_BACKEND", "main");
}

// Optional Features that are default ON (so that default matches any backend)
if cfg!(feature = "no_g2") {
config.define("G2", "OFF");
}
if cfg!(feature = "no_ecntt") {
config.define("ECNTT", "OFF");
}

// Build
let _ = config_bw
Expand Down
Loading

0 comments on commit f5a998e

Please sign in to comment.