-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Select a parameter set in CinguParam" ? #40
Comments
To complete. Now, with the following code : void bubbleSort(vector a, int size) { int main() { CiContext::set_config(make_shared(), vector a(list_size, CiInt::u8); for (int i = 0; i < list_size; ++i) bubbleSort(a,list_size); .... I got : [ 61%] Generating bfv-wifsSort.blif Did I miss something? Thanks in advance, |
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 &arr, int size)", It works. I was thinking that there is a kind of "flow analysis" inside Cingulata so that I can write generic methods and Cingulata will be able to find that the used vector is not a plaintext one. But I still get this strange error message : 62%] Generating bfv-wifsSort-opt.blif
Thanks in advance, 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
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 <ci_context.hxx>
#include <ci_fncs.hxx>
#include <ci_int.hxx>
#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 < list_size; ++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 < list_size; ++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 .)
The text was updated successfully, but these errors were encountered: