Julia中GPU上的BigInt计算

问题描述 投票:0回答:1

我需要对非常大的整数的随机批次执行计算。我有一个比较某些属性的数字并根据这些属性返回值的函数。由于批次和数量本身可能非常大,因此我想通过利用GPU来加快此过程。这是我现在纯粹在CPU上运行的内容的简短版本。

using Statistics

function check(M)
    val = 0
    #some code that calculates val based on M, e.g. the mean
    val = mean(M) 
    return val
end

function distribution(N, n, exp) # N=batchsize, n=# of batches, exp=exponent of the upper limit of the integers
    avg = 0
    M = zeros(BigInt, N)
    for i = 1 : n
        M = rand(1 : BigInt(10) ^ exp, N)
        avg += check(M)
    end
    avg /= n
    println(avg, ":", N)
end

#example
distribution(10 ^ 3, 10 ^ 6, 100)

我曾在Julia中短暂使用过CUDAnative,但我不知道如何实现BigInt计算。该软件包将是首选,但其他软件包也可以。任何帮助表示赞赏。

julia biginteger
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.