
300 Designing Scientific Applications on GPUs
Listing 12.1. calculation of monotone spline knots and coefficients.
te mpl at e<typename Tx , typename Ty>
g l o b a l void C a l c u l a t e B e t a ( Tx ∗ u , Ty ∗ v , do uble ∗ b , i nt N)
{
in t t i d = t h r e ad I d x . x + b l o c k I d x . x ∗ blockDim . x ;
5 while ( t i d <=(N−2) ) {
b [ t i d ] =( v [ t i d +1]−v [ t i d ] ) / fmax (1 e −20 , double ( u [ t i d +1]−u [ t i d ] ) ) ;
t i d += blockDim . x ∗ gridDim . x ;
}
s y n c t h r e a d s ( ) ;
10 }
g l o b a l void C al c ul a te D G en e ra l ( double ∗ b , double ∗ c , i n t N)
{
in t t i d = t h r e ad I d x . x + b l o c k I d x . x ∗ bloc