From d1be2a5b812a8a9232ae98c9ee014bebc8e01082 Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Thu, 21 Mar 2024 14:43:19 +0100 Subject: [PATCH] chore(tfhe): make sure the GPU module is present during doc compilation - fix lints --- Makefile | 8 ++++++-- backends/tfhe-cuda-backend/build.rs | 15 +++++++++++++++ tfhe/Cargo.toml | 2 +- tfhe/src/integer/gpu/mod.rs | 2 +- tfhe/src/integer/gpu/server_key/radix/mod.rs | 20 ++++++++++++-------- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 4b8a90e51b..e291ab12b7 100644 --- a/Makefile +++ b/Makefile @@ -629,18 +629,22 @@ test_concrete_csprng: .PHONY: doc # Build rust doc doc: install_rs_check_toolchain + @# Even though we are not in docs.rs, this allows to "just" build the doc + DOCS_RS=1 \ RUSTDOCFLAGS="--html-in-header katex-header.html" \ cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" doc \ - --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache --no-deps -p $(TFHE_SPEC) + --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,gpu,internal-keycache --no-deps -p $(TFHE_SPEC) .PHONY: docs # Build rust doc alias for doc docs: doc .PHONY: lint_doc # Build rust doc with linting enabled lint_doc: install_rs_check_toolchain + @# Even though we are not in docs.rs, this allows to "just" build the doc + DOCS_RS=1 \ RUSTDOCFLAGS="--html-in-header katex-header.html -Dwarnings" \ cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" doc \ - --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache -p $(TFHE_SPEC) --no-deps + --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,gpu,internal-keycache -p $(TFHE_SPEC) --no-deps .PHONY: lint_docs # Build rust doc with linting enabled alias for lint_doc lint_docs: lint_doc diff --git a/backends/tfhe-cuda-backend/build.rs b/backends/tfhe-cuda-backend/build.rs index 95ce40300a..e64822c648 100644 --- a/backends/tfhe-cuda-backend/build.rs +++ b/backends/tfhe-cuda-backend/build.rs @@ -2,6 +2,21 @@ use std::env; use std::process::Command; fn main() { + match env::var("DOCS_RS") { + Ok(val) => { + let val = val.parse::(); + match val { + Ok(val) => { + if val == 1 { + return; + } + } + Err(_) => (), + } + } + Err(_) => (), + } + println!("Build tfhe-cuda-backend"); if env::consts::OS == "linux" { let output = Command::new("./get_os_name.sh").output().unwrap(); diff --git a/tfhe/Cargo.toml b/tfhe/Cargo.toml index 081b523700..cc6f94d724 100644 --- a/tfhe/Cargo.toml +++ b/tfhe/Cargo.toml @@ -144,7 +144,7 @@ aarch64-unix = ["aarch64", "seeder_unix"] [package.metadata.docs.rs] # TODO: manage builds for docs.rs based on their documentation https://docs.rs/about -features = ["x86_64-unix", "boolean", "shortint", "integer"] +features = ["x86_64-unix", "boolean", "shortint", "integer", "gpu"] rustdoc-args = ["--html-in-header", "katex-header.html"] ########### diff --git a/tfhe/src/integer/gpu/mod.rs b/tfhe/src/integer/gpu/mod.rs index b6f9eadffa..1cabcc68d0 100644 --- a/tfhe/src/integer/gpu/mod.rs +++ b/tfhe/src/integer/gpu/mod.rs @@ -115,7 +115,7 @@ where /// Generate a couple of client and server keys with given parameters /// -/// Contrary to [gen_keys], this returns a [RadixClientKey] +/// Contrary to [gen_keys_gpu], this returns a [RadixClientKey] /// /// ```rust /// use tfhe::core_crypto::gpu::{CudaDevice, CudaStream}; diff --git a/tfhe/src/integer/gpu/server_key/radix/mod.rs b/tfhe/src/integer/gpu/server_key/radix/mod.rs index 62dbcd5bf2..28a30df164 100644 --- a/tfhe/src/integer/gpu/server_key/radix/mod.rs +++ b/tfhe/src/integer/gpu/server_key/radix/mod.rs @@ -254,8 +254,9 @@ impl CudaServerKey { } /// Prepend trivial zero LSB blocks to an existing [`CudaUnsignedRadixCiphertext`] or - /// [`CudaSignedRadixCiphertext`] and returns the result as a new ciphertext on GPU. - /// This can be useful for casting operations. + /// [`CudaSignedRadixCiphertext`](`crate::integer::gpu::ciphertext::CudaSignedRadixCiphertext`) + /// and returns the result as a new ciphertext on GPU. This can be useful for casting + /// operations. /// /// # Example /// @@ -327,8 +328,9 @@ impl CudaServerKey { } /// Append trivial zero MSB blocks to an existing [`CudaUnsignedRadixCiphertext`] or - /// [`CudaSignedRadixCiphertext`] and returns the result as a new ciphertext on GPU. - /// This can be useful for casting operations. + /// [`CudaSignedRadixCiphertext`](`crate::integer::gpu::ciphertext::CudaSignedRadixCiphertext`) + /// and returns the result as a new ciphertext on GPU. This can be useful for casting + /// operations. /// /// # Example /// @@ -390,8 +392,9 @@ impl CudaServerKey { } /// Remove LSB blocks from an existing [`CudaUnsignedRadixCiphertext`] or - /// [`CudaSignedRadixCiphertext`] and returns the result as a new ciphertext on GPU. - /// This can be useful for casting operations. + /// [`CudaSignedRadixCiphertext`](`crate::integer::gpu::ciphertext::CudaSignedRadixCiphertext`) + /// and returns the result as a new ciphertext on GPU. This can be useful for casting + /// operations. /// /// # Example /// @@ -453,8 +456,9 @@ impl CudaServerKey { } /// Remove MSB blocks from an existing [`CudaUnsignedRadixCiphertext`] or - /// [`CudaSignedRadixCiphertext`] and returns the result as a new ciphertext on GPU. - /// This can be useful for casting operations. + /// [`CudaSignedRadixCiphertext`](`crate::integer::gpu::ciphertext::CudaSignedRadixCiphertext`) + /// and returns the result as a new ciphertext on GPU. This can be useful for casting + /// operations. /// /// # Example ///