【问题标题】:Batchwise evaluation of piecewise polynomials on GPUGPU上分段多项式的批量评估
【发布时间】:2017-07-02 03:19:19
【问题描述】:

我正在尝试评估从三次样条获得的大型分段多项式中的点。我正在尝试在 GPU 上执行此操作,但我遇到了内存限制。

因此,我想分批评估分段多项式。

原码:

Y = some_matrix_of_data_values ;
X = some_vector_of_data_sites ;
pp = spline(X, Y) ; % get the piecewise polynomial form of the cubic spline. The resulting structure is very large.

for t = 1: big_number
    hcurrent = ppval(pp,t); %evaluate the piecewise polynomial at t
    y(t) = sum(x(t:t+M-1).*hcurrent,1) ; % do some operation of the interpolated value. Most likely not relevant to this question.
end

矢量化,希望在 GPU 批处理的路上:

Y = some_matrix_of_data_values ;
X = some_vector_of_data_sites ;
pp = spline(X, Y) ; % get the piecewise polynomial form of the cubic spline. Resulting structure is very large.
batchSize = 1024 ;

for tt = 1: batchSize: big_number
    if tt > big_number - batchSize % snatch up any remaining values at the end of the loop, and calculate those as well
        batchSize = big_number - tt ;
    end            
    hcurrent =  ppval(pp ,(tt:tt+batchSize-1) ) ;  %evaluate pp at a couple of data sites     

    ind = bsxfun(@plus, 1:M, (tt-1:1:tt+batchSize-2).')) ; %make an index matrix to help with next calculation. Most likely not relevant to this question.
    y(tt:tt+batchSize-1) = sum( x(ind).*hcurrent' , 2 ) ; % do some calculation, but now we have done it in batches!
end

在修改后的代码中,分段多项式在多个数据站点上进行评估,因此我们至少在路上。分段多项式 pp 太大而无法存储在 GPU 上,有没有办法将其分解以进行批处理?

【问题讨论】:

    标签: matlab gpu batch-processing interpolation spline


    【解决方案1】:

    有用的线程here,而是讨论分段多项式评估的并行化。此解决方案可以移植到 GPU 进行批处理。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      • 2020-08-23
      • 2020-01-31
      • 1970-01-01
      相关资源
      最近更新 更多