snucrypto / HEAAN

Other
353 stars 95 forks source link

How to use multithreading in HEAAN #11

Open Luidy opened 5 years ago

Luidy commented 5 years ago

Hello. I'm trying to use multithreading with the SetNumThreads () function. After setting up a multithread, how can I use each thread?

I'll wait for your answer. Thank you.

kimandrik commented 5 years ago

Hello, SetNumThreads is a method from NTL library (BasicThreadPool.cpp class). We used it for multithreading in 'for' loop:

Instead of: for (long i = 0; i < n; ++i) { dosmth(); }

we do:

NTL_EXEC_RANGE(n, first, last); for (long i = first; i < last; ++i) { dosmth(); } NTL_EXEC_RANGE_END;

But I think you can also use each thread separately. Please refer to NTL documentation for this: https://www.shoup.net/ntl/doc/BasicThreadPool.cpp.html