2017-02-14 18 views
0

큐빅 스플라인에서 얻은 큰 조각 별 다항식의 점을 계산하려고합니다. GPU에서이 작업을 시도하고 있는데 메모리 제한이 있습니다.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에 저장할 수 없지만 일괄 처리를 위해 분할하는 방법이 있습니까?

답변

0

도움이되는 스레드 here 대신 조각 방식의 다항식 평행화에 대해 설명합니다. 이 솔루션은 일괄 처리를 위해 GPU에 포팅 될 수 있습니다.