relic-toolkit / relic

Code
Other
452 stars 179 forks source link

test_ep fails with x64-pbc-bls12-381 preset #255

Closed JiaweiWang-AdrianA closed 1 year ago

JiaweiWang-AdrianA commented 1 year ago

When building the demo/public-stats based on default preset/x64-pbc-bls12-381.sh, the 'Segmentation fault' happened at running './main'. Besides, it failed in test_ep and pass all other tests from ctest.

build the demo/public-stats: cd ./demo/public-stats make ./main

run ctest: cd target ctest

dfaranha commented 1 year ago

Can you try increasing the stack size with ulimit -s unlimited? This particular demo is known to consume a lot of memory, something we are still working on to minimize.

JiaweiWang-AdrianA commented 1 year ago

Thanks, it works!!!

However, I have another issue when I try to run it on Mac M1. I modified the x64-pbc-bls12-381.sh to arm64-pbc-bls12-381.sh:

!/bin/sh

cmake -DARCH=A64 -DWSIZE=64 -DRAND=UDEV -DSHLIB=OFF -DSTBIN=ON -DTIMER=CYCLE -DCHECK=off -DVERBS=off -DARITH=gmp -DFP_PRIME=381 -DFP_METHD="INTEG;INTEG;INTEG;MONTY;LOWER;LOWER;SLIDE" -DCFLAGS="-O3 -funroll-loops -fomit-frame-pointer -mtune=native" -DFP_PMERS=off -DFP_QNRES=on -DFPX_METHD="INTEG;INTEG;LAZYR" -DEP_PLAIN=off -DEP_SUPER=off -DPP_METHD="LAZYR;OATEP" $1

When running 'make', the error occurred:

... [ 81%] Linking C executable ../bin/test_bn ld: library not found for -lcrt0.o clang: error: linker command failed with exit code 1 (use -v to see invocation) ...

dfaranha commented 1 year ago

Hi again,

The preset x64-pbc-bls12-381.sh cannot be simply renamed to ARM64 because it is accelerated with x86_64 Assembly code. This code will simply not function under ARM64.

JiaweiWang-AdrianA commented 1 year ago

Hi, I rewrote the arm64-pbc-bls12-381.sh, and used it to build demo/public-stats successfully. It may be used as a reference for other MacBook M1 users.

!/bin/sh

-DSTBIN=ON

cmake -DARCH=A64 -DARITH=gmp -DWSIZE=64 -DRAND=UDEV -DSHLIB=OFF -DTIMER=CYCLE -DCHECK=off -DVERBS=off -DFP_PRIME=381 -DFP_METHD="INTEG;INTEG;INTEG;MONTY;LOWER;LOWER;SLIDE" -DCFLAGS="-O3 -funroll-loops -fomit-frame-pointer -mtune=native" -DFP_PMERS=off -DFP_QNRES=on -DFPX_METHD="INTEG;INTEG;LAZYR" -DEP_PLAIN=off -DEP_SUPER=off -DPP_METHD="LAZYR;OATEP" $1