我試圖用ISHFT()
函數來使用CUDA FORTRAN並行地移位一些32位整數。CUDA FORTRAN:函數給出不同的答案,如果我通過變量而不是數字
問題是我對ISHFT(-4,-1)
和ISHFT(var,-1)
得到了不同的答案,儘管var = -4
。這是測試代碼,我已經寫了:
module testshift
integer :: test
integer, device :: d_test
contains
attributes(global) subroutine testshft()
integer :: var
var = -4
d_test = ISHFT(var,-1)
end subroutine testshft
end module testshift
program foo
use testshift
integer :: i
call testshft<<<1,1>>>() ! carry out ishft on gpu
test = d_test ! copy device result to host
i = ISHFT(-4,-1) ! carry out ishft on cpu
print *, i, test ! print the results
end program foo
我然後編譯並執行:
pgf90 testishft.f90 -Mcuda
./a.out
2147483646 -2
兩個應該是2147483646,如果工作正常。如果我用4
代替var
,我會得到正確的答案。
我該如何解決這個問題? 感謝您的幫助
嗯,你有沒有試過使用仿真模式追蹤問題'-Mcuda = emu`? – steabert 2011-03-22 10:55:32