Hey,
I tried to program my first CUDA Source with the PGI Cuda Fortran Compiler . The compute capability of the my card ist 1.0 (GeForce 8800 GTS). In the fortran settings i have set the compute capabilty to 1.0.
In the Emulation Mode my program works, but if i want to built the source without the emulation mode i get a windows message that my program does not work. I hope anyone can help me. My Code:
program prog
use m_ConDet
implicit none
real,allocatable,dimension(:,:) :: RPP
real,allocatable,dimension(:) :: test
integer,allocatable,dimension(:,:):: ContactList
integer :: NumRPP = 4
integer :: i,ii,NumPart
open(1,file=‘Partikel.txt’,status=‘UNKNOWN’)
read(1,*)
i=0
Do
read(1,*,END=100) ii
i=i+1
Enddo
100 rewind(1)
NumPart = i
allocate(RPP(NumRPP,NumPart))
allocate(ContactList(NumPart,NumPart))
ContactList = 1
read(1,)
Do i=1,NumPart
read(1,)RPP(1:4,i)
enddo
close(1)
Call h_ConDet(NumPart,NumRPP,RPP,ContactList)
open(1,file=‘ContactList.txt’,status=‘UNKNOWN’)
Do i=1,NumPart
write(1,‘(10i20.8)’)ContactList(i,:)
enddo
close(1)
end program prog
module m_ConDet
use cudafor
contains
!-----------kernel subroutine---------------
attributes(global) subroutine k_ConDet(NumPart,NumRPP,RPPdev,ContactListdev)
integer :: i,ii
integer,value :: NumRPP,NumPart
integer :: Px=1,Py=2,Pz=3,Rad=4
real :: RPPdev(NumRPP,NumPart)
integer :: ContactListdev(NumPart,NumPart)
i=(blockidx%x-1)blockdim%x+threadidx%x
if(i.lt.NumPart)then
do ii=1,NumPart
if(.not.ii.eq.i)then
dx = RPPdev(Px,i)-RPPdev(Px,ii)
dy = RPPdev(Py,i)-RPPdev(Py,ii)
dz = RPPdev(Pz,i)-RPPdev(Pz,ii)
d = sqrt(dxdx+dydy+dzdz)
If(d.le.(RPPdev(Rad,i)+RPPdev(Rad,ii)))then
ContactListdev(i,ii) = 1
Endif
endif
enddo
endif
end subroutine k_ConDet
!-----------host subroutine---------------
subroutine h_ConDet(NumPart,NumRPP,RPP,ContactList)
implicit none
integer :: NumIPP,NumRPP,NumPart
type(dim3) :: dimGrid,dimBlock
real,dimension(:,:) :: RPP
integer,dimension(:,:) :: ContactList
real,device,allocatable,dimension(:,:) :: RPPdev
integer,device,allocatable,dimension(:,:) :: ContactListdev
allocate(RPPdev(NumRPP,NumPart),ContactListdev(NumPart,NumPart))
RPPdev = RPP
ContactListdev = 0
dimGrid = dim3(1,1,1)
dimBlock = dim3(NumPart/2,NumPart/2,1)
call k_ConDet<<<dimGrid,dimBlock>>>(NumPart,NumRPP,RPPdev,ContactListdev)
ContactList(:,:)=ContactListdev(:,:)
deallocate(RPPdev,ContactListdev)
end subroutine h_ConDet
end module m_ConDet