I'm trying to implement some math function like My_AddMod, My_SubMod, My_MulMod, and put the result back to vec_long& - type data result.
When I'm calling both function of mine and NTL and using the result of NTL like:
long tmpt_My = My_AddMod(long a, long b, long n); //(a+b)%n
long tmpt_NTL = AddMod(long a, long b, long n); //function from NTL
vec_long& result[i] = tmpt_NTL; //choosing result from NTL_function
It worked good and fast, however, if I use the result of My_function:
long tmpt_My = My_AddMod(long a, long b, long n); //(a+b)%n
long tmpt_NTL = AddMod(long a, long b, long n); //function from NTL
vec_long& result[i] = tmpt_My; //choosing result from My_function
It worked good as well but caused a large latency in the code.
When printing out the value and data-type of tmpt_NTL
and tmpt_My
, they are the same value and data-type long
.
Since both functions are called(so it seems to have nothing to do with My_function execution time) and they generate the same value, what is the reason of causing a large latency or how can I fix it?
If you compile your code using e.g. -O3
it is possible, that the compiler removes the call of your function if the result is not used.
The functions of NTL should be highly optimized so it is unlikely that your function is faster than the NTL function.
If you want to check the performance, you should not call both functions at once but just call one function in a loop and measure the time and then the other function.