Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • So is there any other way to implement this to make it extremely fast? I am trying to implement RSA algorithm for large numbers. But for say for a 50 digit prime number it takes about 1 hour to decrypt. This function is taking too much time. Commented Nov 5, 2011 at 8:15
  • Since you can't parallelize here, you'll need to do it at a higher level. If you have multiple of these powermods to do (and they are independent), you can do those in parallel. Though I'm not too familiar with the RSA algorithm so I don't know how much parallelism there is at higher levels. Commented Nov 5, 2011 at 8:20
  • Ok i will check into that. Thank you so much. What about this loop? Is it possible to parallelize? for(i=0,k=0;i<n;i++,k++) { c=msg(a[i]); b[k++]=msg(c); } There is no dependency, so it should be possible to work out Commented Nov 5, 2011 at 8:27
  • As long as msg() is re-entrant, then yes, it's parallelizable. (also, make sure that a and b don't overlap) Commented Nov 5, 2011 at 8:32
  • Actually, no reduction is needed. So just use #pragma omp parallel for. Reductions are only needed when the result of the iterations will "reduce" to a variable. (such as summing up all the elements) But in your example, you aren't doing that. You're writing into different elements of array b. So there is no reduction. Commented Nov 5, 2011 at 8:41