Example #1
0
def low_level_benchmarks(gates, types, contexts, max_depth=10):
    """
    call this function with lists of the Gates, input-types, and contexts to be benchmarked.
    this in turn calls run_single_benchmark for each combination.
    """
    for gate in gates:
        for input_type in types:
            bitwidth = get_bitwidth(input_type)
            signed = input_type.startswith("i")
            for depth in range(1, max_depth):
                circuit_file = CIRCUIT_FILE_DIR + "/circuit-" + gate + "-" + str(
                    depth) + ".sheep"

                ### inputs file depends on the gate now - most gates have depth+1 inputs, but SELECT and NEGATE have
                ### different requirements

                inputs_file = INPUT_FILE_DIR + "/inputs-"
                if gate == "SELECT":
                    inputs_file += "select-"
                elif gate == "NEGATE":
                    inputs_file += "1-to-1-"
                else:
                    inputs_file += "2-to-1-"
                inputs_file += input_type + "-" + str(depth) + ".inputs"
                ### loop over desired contexts
                for context in contexts:
                    print("Doing benchmark for %s %s %i %s" %
                          (context, gate, depth, input_type))
                    ### run the test
                    results = run_circuit(circuit_file, inputs_file,
                                          input_type, context, "serial",
                                          params, "debug_" + context + ".txt")
Example #2
0
def scan_3(contexts=["TFHE", "HElib_F2", "HElib_Fp", "SEAL"]):
    """
    all tests, with the levels set appropriately
    """
    for gate in ["ADD", "SUBTRACT", "MULTIPLY", "SELECT", "NEGATE"]:
        for input_type in ["bool", "uint8_t", "uint16_t", "uint32_t"]:
            for d in range(1, 9):
                for context in contexts:
                    param_file = params_for_level(context, d)
                    circuit_file = CIRCUIT_FILE_DIR + "/circuit-" + gate + "-" + str(
                        d) + ".sheep"
                    ### inputs file depends on the gate now - most gates have depth+1 inputs, but SELECT and NEGATE have
                    ### different requirements
                    inputs_file = INPUT_FILE_DIR + "/inputs-"
                    if gate == "SELECT":
                        inputs_file += "select-"
                    elif gate == "NEGATE":
                        inputs_file += "1-to-1-"
                    else:
                        inputs_file += "2-to-1-"
                    inputs_file += input_type + "-" + str(d) + ".inputs"
                    print("Doing benchmark for %s %s %s %i" %
                          (context, gate, input_type, d))
                    results = run_circuit(
                        circuit_file, inputs_file, input_type, context,
                        "serial", param_file, DEBUG_FILE_DIR + "/debug_" +
                        gate + str(d) + input_type + ".txt")