cuda - Fortran does not understand call statement -
i attempting use pgfortran cuda. installed pgfortran on computer , linked best of knowledge. going decided follow tutorial listed here. when trying compile code:
module mathops contains attributes(global) subroutine saxpy(x, y, a) implicit none real :: x(:), y(:) real, value :: integer :: i, n n = size(x) = blockdim%x * (blockidx%x - 1) + threadidx%x if (i <= n) y(i) = y(i) + a*x(i) end subroutine saxpy end module mathops program testsaxpy use mathops use cudafor implicit none integer, parameter :: n = 40000 real :: x(n), y(n), real, device :: x_d(n), y_d(n) type(dim3) :: grid, tblock tblock = dim3(256,1,1) grid = dim3(ceiling(real(n)/tblock%x),1,1) x = 1.0; y = 2.0; = 2.0 x_d = x y_d = y call saxpy<<<grid, tblock="">>>(x_d, y_d, a) y = y_d write(*,*) 'max error: ', maxval(abs(y-4.0)) end program testsaxpy i got:
pgf90-s-0034-syntax error @ or near identifier saxpy (main.cuf: 29) 0 inform, 0 warnings, 1 severes, 0 fatal testsaxpy the error points line call saxpy<<<grid, tblock="">>>(x_d, y_d, a). reason apparently hates fact using <<< , >>>? going tutorial triple chevrons meant there:
the information between triple chevrons execution configuration, dictates how many device threads execute kernel in parallel.
removing these chevrons not make sense since purpose of program. why pgfortran dislike this?
as compilation. have followed tutorial using pgf90 -o saxpy main.cuf. since gave error tried pgf90 -mcuda -o saxpy main.cuf. same results.
there seem text error in blog @ kernel invocation line:
call saxpy<<<grid, tblock="">>>(x_d, y_d, a) tblock="" not correct. you'll notice elsewhere in blog text, kernel invocation line given correctly as:
call saxpy<<<grid,tblock>>>(x_d, y_d, a) so if change line accordingly in actual code, think you'll have better results.
Comments
Post a Comment