# Integer

This document details the CPU performance benchmarks of homomorphic operations on integers using **TFHE-rs**.

By their nature, homomorphic operations run slower than their cleartext equivalents.

{% hint style="info" %}
All CPU benchmarks were launched on an `AWS hpc7a.96xlarge` instance equipped with two 96-core `AMD EPYC 9R14 CPU @ 2.60GHz` and 740GB of RAM.
{% endhint %}

The following tables benchmark the execution time of some operation sets using `FheUint` (unsigned integers). The `FheInt` (signed integers) performs similarly.

## Pfail: $$2^{-128}$$

The next tables show the operation timings on CPU when all inputs are encrypted:

### Encrypted/encrypted operations latency

![](https://1494127778-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRgga9WgQ59wXc5YVUpb%2Fuploads%2Fgit-blob-6bb9b6ba5c35eb39f0438a5aed09aa1c9af65041%2Fcpu-integer-benchmark-tuniform-2m128-latency-ciphertext.svg?alt=media)

### Encrypted/encrypted operations throughput

![](https://1494127778-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRgga9WgQ59wXc5YVUpb%2Fuploads%2Fgit-blob-3017d2320bf2c3ebf2cde6b717db7288a3b493ad%2Fcpu-integer-benchmark-tuniform-2m128-throughput-ciphertext.svg?alt=media)

The next tables show the operation timings on CPU when the left input is encrypted and the right is a clear scalar of the same size:

### Encrypted/clear operations latency

![](https://1494127778-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRgga9WgQ59wXc5YVUpb%2Fuploads%2Fgit-blob-ac23567620a7640663ba1c131e2a605d7c929bf8%2Fcpu-integer-benchmark-tuniform-2m128-latency-plaintext.svg?alt=media)

### Encrypted/clear operations throughput

![](https://1494127778-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRgga9WgQ59wXc5YVUpb%2Fuploads%2Fgit-blob-6c50a37ffb9d1ac246d04cdf7ead0ad3fac43287%2Fcpu-integer-benchmark-tuniform-2m128-throughput-plaintext.svg?alt=media)

All timings are based on parallelized Radix-based integer operations where each block is encrypted using the default parameters `PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128`. To ensure predictable timings, we perform operations in the `default` mode, which ensures that the input and output encoding are similar (i.e., the carries are always emptied).

You can minimize operational costs by selecting from 'unchecked', 'checked', or 'smart' modes from [the fine-grained APIs](https://docs.zama.org/tfhe-rs/references/fine-grained-apis/quick-start), each balancing performance and correctness differently. For more details about parameters, see [here](https://docs.zama.org/tfhe-rs/references/fine-grained-apis/shortint/parameters). You can find the benchmark results on GPU for all these operations on GPU [here](https://docs.zama.org/tfhe-rs/get-started/benchmarks/gpu) and on HPU [here](https://docs.zama.org/tfhe-rs/hardware-acceleration/run-on-hpu/benchmark).

## Reproducing TFHE-rs benchmarks

**TFHE-rs** benchmarks can be easily reproduced from the [source](https://github.com/zama-ai/tfhe-rs).

{% hint style="info" %}
AVX512 is now enabled by default for benchmarks when available
{% endhint %}

The following example shows how to reproduce **TFHE-rs** benchmarks:

```shell
#Integer benchmarks:
make bench_integer
```
