Open FredericGava opened 3 years ago
To complete. Now, with the following code :
void bubbleSort(vector
int main() {
CiContext::set_config(make_shared
vector
for (int i = 0; i < listsize; ++i) a[i].read("a" + to_string(i));
bubbleSort(a,list_size);
....
I got :
[ 61%] Generating bfv-wifsSort.blif [ 62%] Generating bfv-wifsSort-opt.blif Input circuit x depth 0, x gates 216, + gates 426 Executing optimization command "" x depth 0, x gates 0, + gates 0 * Executing optimization command "resyn2" x depth 0, x gates 0, + gates 0 Executing optimization command "resyn2rs" x depth 0, x gates 0, + gates 0 Executing optimization command "recadd3;resyn2rs" !!! ABC optimization: something went wrong !!! [ 63%] Generating fhe_params.xml TEST_NAME=bfv-wifsSort MODE=static The parameters with lwe-estimator commit fb7deba are not in CinguParam. DESIRED_PARAMS=0_bkz_sieve_128_2 STATIC_CHOICE=0_bkz_sieve_128_2 (using LWE-Estimator commit=3019847) Parameter set automatically found in CinguParam: '0_bkz_sieve_128_2' -> '/cingu/build_bfv/tests/bfv/wifsSort/fhe_params.xml'
Did I miss something?
Thanks in advance, Frédéric Gava
Executing optimization command "resyn2rs" x depth 0, x gates 0, + gates 0
In your second example, you are trying to sort a plaintext vector. That's why the multiplicative depth is 0
In the first example the multiplicative depth is 25 and it's huge! BFV schemes are suited for small depth circuits where you can batch data in a SIMD way. You shall really use the TFHE scheme for sorting encrypted number.
Thanks. By replacing "void bubbleSort(vector arr, int size)" by "void bubbleSort(vector
But I still get this strange error message :
62%] Generating bfv-wifsSort-opt.blif Input circuit x depth 25, x gates 216, + gates 426 Executing optimization command "" x depth 25, x gates 162, + gates 186 * Executing optimization command "resyn2" x depth 40, x gates 588, + gates 9 Executing optimization command "resyn2rs" x depth 45, x gates 611, + gates 4 Executing optimization command "recadd3;resyn2rs" x depth 42, x gates 791, + gates 4 [ 63%] Generating fhe_params.xml TEST_NAME=bfv-wifsSort MODE=static The parameters with lwe-estimator commit fb7deba are not in CinguParam. DESIRED_PARAMS=25_bkz_sieve_128_2 No parameter found with static mode. Automatically switch to interactive mode. MODE=interactive 1) Select a parameter set in CinguParam (using LWE-Estimator commit=3019847) 2) Quit Please enter your choice: 1 INTERACTIVE_CHOICE= COMMIT_ID=3019847 Invalid choice. You can generate suitable parameter sets using CinguParam module. [ 63%] Built target bfv-wifsSort
Thanks in advance, Frédéric
ps: For TFHE, I will wait the thfe=>bliff output
Hi,
when compiling a program of sorting (from thfe) using docker run -it --rm -v $(pwd):/cingu cingulata:bfv
I get the following message :
[ 63%] Generating fhe_params.xml TEST_NAME=bfv-wifsSort MODE=static The parameters with lwe-estimator commit fb7deba are not in CinguParam. DESIRED_PARAMS=25_bkz_sieve_128_2 No parameter found with static mode. Automatically switch to interactive mode. MODE=interactive 1) Select a parameter set in CinguParam (using LWE-Estimator commit=3019847) 2) Quit Please enter your choice: 1 INTERACTIVE_CHOICE= COMMIT_ID=3019847 Invalid choice. You can generate suitable parameter sets using CinguParam module.
And then the execution using bvf mode is very very slow (2 minutes for sorting 4 integers with 10 cores!)
Thanks Frédéric Gava
The cxx file :
/ local includes / //#include
//#include <bit_exec/decorator/attach.hxx> //#include <bit_exec/decorator/depth.hxx> //#include <bit_exec/decorator/stat.hxx>
include <bit_exec/tracker.hxx>
include
include
include
include <int_op_gen/mult_depth.hxx>
/ namespaces / using namespace std; using namespace cingulata;
int main() {
CiContext::set_config(make_shared(),
make_shared());
vector a(list_size, CiInt::u8);
CiInt t{CiInt::u8};
CiBit swap;
for (int i = 0; i < listsize; ++i) a[i].read("a" + to_string(i));
for (int i = 0; i < list_size-1; ++i) { for (int j = i+1; j < list_size; ++j) { swap = a[i] > a[j]; t = select(swap, a[i], a[j]); a[i] = select(swap, a[j], a[i]); a[j] = t; } }
for (int i = 0; i < listsize; ++i) a[i].write("r" + to_string(i));
/ Export to file the "tracked" circuit / CiContext::get_bit_exec_t()->export_blif(blif_name, "wifsSort");
}
and the Cmake file
cmake_minimum_required(VERSION 3.0)
set(TEST_NAME bfv-wifsSort)
set(SRCS wifsSort.cxx) set(LIST_SIZE 4) set(BLIF_NAME ${TEST_NAME}.blif) set(BLOP_NAME ${TEST_NAME}-opt.blif)
add_compile_options(-Dlist_size=${LIST_SIZE} -Dblif_name="${BLIF_NAME}")
set(GEN_NAME ${TEST_NAME}-gen)
add_executable(${GEN_NAME} ${SRCS})
target_link_libraries(${GEN_NAME} common)
add_custom_command(OUTPUT ${BLIF_NAME} COMMAND ./${GEN_NAME} DEPENDS ${GEN_NAME})
add_custom_command(OUTPUT ${BLOP_NAME} COMMAND python3 ${OPTIM_DIR}/abc_optimize.py -i ${BLIF_NAME} -o ${BLOP_NAME} -v DEPENDS abc ${BLIF_NAME})
set(XML_PARAMS fhe_params.xml) set(MUL_DEPTH_SCRIPT ${OPTIM_DIR}/graph_info.py)
add_custom_command(OUTPUT ${XML_PARAMS} COMMAND bash ${SCRIPT_DIR}/selectParams.sh ${TEST_NAME}
python3 ${MUL_DEPTH_SCRIPT} ${BLOP_NAME} --mult_depth_max
${MODEL} ${MIN_SECU} ${POLITIC} DEPENDS ${BLOP_NAME})add_custom_target(${TEST_NAME} ALL DEPENDS ${XML_PARAMS} runtime)
set(APPS_DIR ${CMAKE_BINARY_DIR}/apps) set(CIRCUIT ${BLOP_NAME}) configure_file("run.sh.in" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/run.sh" @ONLY) file(COPY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/run.sh" DESTINATION . FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) file(COPY "README.md" DESTINATION .) file(COPY "data.txt" DESTINATION .)