I‘m trying to implement a prime factorization algorithm leveraging the GPU/CUDA for parallelization as a pet project.
I‘m using python with numpy and numba for the parallelization part.
My problem is now that I hit the 64 bit integer boundary quite fast and I am searching for solutions to work around this. Since numpy/numba only supports integers up to 64 bit (compared to arbitrary large numbers in python itself), this is where I‘m stuck at the moment.
In essence the part on the GPU mainly uses the modulo operation and a bit of iteration.
I found that I can use bigger dividends on the modulo by splitting the modulo into multiple operations with a smaller dividend.
Example:
Let’s assume we cannot use numbers bigger than 10^3.
I would like do do the following operation on the GPU:
1019 % 17 = 16
I can do so by splitting the dividend 1019 into multiple arbitary sizes chunks, for example:
1019 = 500 + 519
And then calculating the modulo on all chunks separately and taking the modulo on the sum of the results again.
((500 % 17) + (519 % 17)) % 17 = 16
My question is now:
Is there a similar operation I can perform to work with a bigger divisor and quotient (for example 2037 % 1019)? Or even better, a way to use arbitrary sized numbers in numpy/numba without precision loss?
Bear with me if I didn’t use proper math slang.