Commit Graph

349 Commits

Author SHA1 Message Date
youben11
91d41a2ff8 fix: add call to init dfr from python
Co-authored-by: Antoniu Pop <antoniu.pop@zama.ai>
2023-01-11 14:45:14 +01:00
youben11
8c6a0859cd refactor(rust): add Rust wrapper for every CStruct
we want to wrap CStructs in RustStructs to own them, and free memeory
when they are no longer used. Users won't have to deal with the direct
binded CAPI, but the new wrappers
2023-01-02 12:10:14 +01:00
Antoniu Pop
aa2e0479b3 feat(compiler): add a parallel loop coalescing pass. 2023-01-02 12:04:34 +01:00
rudy
e17bbcbab5 fix: macos compiling issue with extra ; 2022-12-22 20:08:28 +01:00
rudy
de779b2f6f fix: display compilation error in benchmark
the checking of llvm expected was not correct
2022-12-14 09:21:18 +01:00
rudy
bb756a6426 fix: default is global-error-probability=1/100_000 2022-12-14 09:21:18 +01:00
rudy
4ed0c01d8e feat(optimizer): option to disable optimizer cache
--optimizer-no-cache-on-disk
2022-12-13 18:54:40 +01:00
Quentin Bourgerie
d15c9822db fix(rust-bindings): Fix rust bindings after raise-encoding 2022-12-13 17:01:52 +01:00
aPere3
2fd9b6f0e3 refactor(encodings): raise plaintext/lut encodings higher up in the pipeline 2022-12-13 17:01:52 +01:00
Andi Drebes
e2e6df322e feat(compiler): Add support for full unrolling of loops with SDFG-convertible ops
This adds a new option `--unroll-loops-with-sdfg-convertible-ops`,
which causes loops containing SDFG-convertible operations to be fully
unrolled upon the extraction of SDFG-operations using the
`--emit-sdfg-ops` switch. This avoids constant roundtrips between an
SDFG-capable accelerator and the host during execution of a loop.

The option is limited to `scf.for` loops with static bounds and a
static step size. Since full unrolling of loops with large bounds
results in a large number of operations, the option is disabled by
default.
2022-12-13 12:03:51 +01:00
Quentin Bourgerie
07aa334d8d chore(benchmarks): Refactor the benchmark tools 2022-12-09 09:51:23 +01:00
Antoniu Pop
0dbb86bb36 feat(compiler): add lowering and bufferization for SDFG dialect, generate code to Stream Emulator API. 2022-12-08 14:54:14 +01:00
Antoniu Pop
752f0feb75 feat(runtime): add a stream emulator. 2022-12-08 14:54:14 +01:00
Andi Drebes
ee2f743a78 feat(compiler): Add new action dump-sdfg
Add a new action `dump-sdfg` to `concretecompiler` that causes the IR
to be dumpred right after the extraction of SDFG operations.
2022-12-08 14:54:14 +01:00
Andi Drebes
3da32560b7 feat(compiler): Add pass converting operations into SDFG processes
This adds a new pass `ExtractSDGOps`, which scans a function for
operations that implement `SDFGConvertibleOpInterface`, replaces them
with SDFG processes and constructs an SDFG graph around the processes.

Initialization and teardown of the SDFG graph are embedded into the
function and take place at the beginning of the function and before
the function's terminator, respectively.

The pass can be invoked using concretecompiler by specifying the new
compilation option `--emit-sdfg-ops` or programmatically on a
`CompilerEngine` using the new compilation option `extractSDFGOps`.
2022-12-08 14:54:14 +01:00
Andi Drebes
9ea6c0e8a3 enhance(compiler): Declare tensor-based BConcrete operations as side-effect-free 2022-12-08 14:54:14 +01:00
Andi Drebes
b7805f00d3 feat(compiler): Add op interface SDFGConvertibleOpInterface
This adds a new operation interface `SDFGConvertibleOpInterface` that
allows an operation to specify how it is converted to an SDFG
process. The interface consists of a single method `convert` that
receives as the arguments the DFG created using `SDFG.init`, a set of
SDFG input streams corresponding to the operands and a set of output
streams for results. The order of the input and output streams
corresponds to the order of the operands and output values,
respectively.
2022-12-08 14:54:14 +01:00
Andi Drebes
9f3615513b feat(compiler): Add new dialect SDFG for static data flow graphs
This adds a new dialect called "SDFG" for data flow graphs. An SDFG
data flow graph is composed of a set of processes, connected through
data streams. Special streams allow for data to be injected into and
to be retrieved from the data flow graph.

The dialect is intended to be lowered to API calls that allow for
offloading of the graph on hardware accelerators.
2022-12-08 14:54:14 +01:00
rudy
5516a55c1c feat: option to force cyphertext encoding 2022-12-08 14:42:25 +01:00
Quentin Bourgerie
2a89f62c1a fix(cuda): Include cuda_runtime.h in device.h to include the defininition of cudaStream_t 2022-12-07 21:32:01 +01:00
Quentin Bourgerie
3c616af622 feat(compiler): Handle batched operators for gpu codegen 2022-12-07 21:32:01 +01:00
Quentin Bourgerie
792d46fa80 enhance(runtime/gpu): Cache keys copy to gpu 2022-12-07 21:32:01 +01:00
tmontaigu
f36e1fe882 feat(CAPI): use const ptrs to create tensor lambda arguments 2022-12-07 15:55:52 +01:00
youben11
7d785eebec feat(rust): support serialization 2022-12-05 17:17:53 +01:00
youben11
fbc60097ab refactor(rust): resolve artifacts' path and better stringRef mgmnt 2022-12-05 17:17:53 +01:00
youben11
ad988de9a3 feat(CAPI): add CompilationFeedback API 2022-12-05 17:17:53 +01:00
youben11
f05b1bd1ea feat(rust): support execution with tensor args 2022-12-02 14:03:02 +01:00
youben11
16f3b0bbf6 feat(rust): manage erros coming from compiler
C struct now contains an additonal char* pointer, which can be either
NULL in case there is no error, or a buffer containing the error
message. It's the responsability of destructor function to free that
memory.
2022-12-02 14:03:02 +01:00
youben11
15b4aac0a1 feat(rust): support keygen, encryption, execution 2022-12-02 14:03:02 +01:00
youben11
7f55385ea2 feat(rust): load server lambda for later execution 2022-12-02 14:03:02 +01:00
youben11
b00115f4ae feat(rust): compile mlir into library
CAPI covering a wider API of the Support library.
Better error handling. Could also be improved by returning an error
message back from C to rust (left TODO).
2022-12-02 14:03:02 +01:00
Quentin Bourgerie
50973a39bd refactor(compiler): Remove async offloading of BS/KS 2022-11-30 10:29:19 +01:00
Quentin Bourgerie
9e16f31b87 refactor(bconcrete): Separate bufferization and CAPI call generation 2022-11-30 10:29:19 +01:00
Quentin Bourgerie
5d89ad0f84 enhance(feedback): Add p_error and global_perror to the compiler feedback 2022-11-24 09:59:19 +01:00
Umut
722e4d2eba feat: give crt decomposition feedback 2022-11-24 09:59:19 +01:00
youben11
5661b758d7 feat(CAPI): add initial API to do round-tripping with CompilerEngine 2022-11-23 14:01:25 +01:00
youben11
824aaaeff5 refactor(rust): separate generated CAPI under ffi module 2022-11-23 14:01:25 +01:00
youben11
c0d007e396 refactor: separate python bindings wrapper from CAPI
current CAPI of CompilerEngine isn't really a CAPI. It's initial need
was for the python bindings to have access to the CompilerEngine through
a convenient API. So we now make a clear separation of CAPI and python
wrappers. So we now have wrappers functions, that can be implemented
using C/C++, and will be exposed to python via pybind11. And we have a
CAPI (still need fixing as it still contains C++ code), that can be used
as is, or to build bindings for other languages (such as Rust).
2022-11-23 14:01:25 +01:00
Andi Drebes
46366eec41 feat(compiler): Add fallback implementations for batched keyswitch and bootstrap
Add default implementations for batched keyswitch and bootstrap, which
simply call the scalar versions of these operations in a loop.
2022-11-18 12:06:07 +01:00
Andi Drebes
d46db1bf69 feat(compiler): BConcrete: Add batched keyswitch and bootstrap 2022-11-18 12:06:07 +01:00
Andi Drebes
c9bb6541e9 feat(compiler): Add option --batch-concrete-ops and action dump-concrete-with-loops
The new option `--batch-concrete-ops` invokes the batching pass after
lowering to the Concrete dialect and after lowering linalg operations
with operations from the Concrete dialect to loops.

The new action `dump-concrete-with-loops` dumps the IR right before
batching.
2022-11-18 12:06:07 +01:00
Andi Drebes
75b70054b2 feat(compiler): Make Concrete.bootstrap_lwe and Concrete.keyswitch_lwe batchable 2022-11-18 12:06:07 +01:00
Andi Drebes
c367a4b6fd feat(compiler): Add batching pass
This adds a new pass that is able to hoist operations implementing the
`BatchableOpInterface` out of a loop nest that applies the operation
to the elements of a tensor indexed by the loop induction variables.

Example:

  scf.for %i = c0 to %cN step %c1 {
    scf.for %j = c0 to %cM step %c1 {
      scf.for %k = c0 to %cK step %c1 {
        %s = tensor.extract %T[%i, %j, %k]
        %res = batchable_op %s
        ...
      }
    }
  }

is replaced with:

  %batchedSlice = tensor.extract_slice
       %T[%c0, %c0, %c0] [%cN, %cM, %cK] [%c1, %c1, %c1]
  %flatSlice = tensor.collapse_shape %batchedSlice
  %resTFlat = batchedOp %flatSlice
  %resT = tensor.expand_shape %resTFlat

  scf.for %i = c0 to %cN step %c1 {
    scf.for %j = c0 to %cM step %c1 {
      scf.for %k = c0 to %cK step %c1 {
        %res = tensor.extract %resT[%i, %j, %k]
        ...
      }
    }
  }

Every index of the tensor with the input values may be a quasi-affine
expression on a single loop induction variable, as long as the
difference between the results of the expression for any two
consecutive values of the referenced loop induction variable is
constant.
2022-11-18 12:06:07 +01:00
Andi Drebes
3ce7c96f3f feat(compiler): Add operation interface for batchable operations
This adds a new operation interface that allows an operation to
specify that a batched version of the operation exists that applies it
on the elements of a flat tensor in parallel.
2022-11-18 12:06:07 +01:00
youben11
5b46a74b7f feat(CAPI): API to get the width of an eint/esint 2022-11-17 09:54:51 +01:00
youben11
5576d1d176 feat(CAPI): expose encrypted signed int in CAPI 2022-11-17 09:54:51 +01:00
youben11
0a57af37af feat(rust): add API for FHEDialect's op creation 2022-11-17 09:54:51 +01:00
Samuel Tap
8a231974f7 chore(ffi): update to concrete-ffi without fftw 2022-11-16 11:44:46 +01:00
Mayeul@Zama
f26abad001 chore(compiler): fix return-type-c-linkage 2022-11-14 14:04:46 +01:00
Mayeul@Zama
28594db536 chore(compiler): fix c++11-narrowing 2022-11-14 14:04:46 +01:00