Hi everybody,
I need some help with CUDA and Fortran. I am writing 2 programs : one in Fortran and the other in CUDA.
testF.f :
program test
parameter(n = 3)
integer a(n)
a = (/ 1, 2, 3 /)
call doubleTAB(a, n)
do i = 1, 3
write(*,*) i, a(i)
enddo
stop
end
testCU.cu
#include <stdio.h>
__global__
void cudaDoubletab(int * tab, int n) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) tab[idx] *= 2;
}
int doubletab_(int * h_tab, int * n)
{
int * d_tab;
size_t memSize = *n * sizeof(int);
cudaMalloc((void **) &d_tab, memSize);
cudaMemcpy(d_tab, h_tab, memSize, cudaMemcpyHostToDevice);
dim3 dimGrid(1);
dim3 dimBlock(3);
cudaDoubletab<<< 1, 3 >>>(d_tab, 3);
cudaMemcpy(h_tab, d_tab, memSize, cudaMemcpyDeviceToHost);
return (1);
}
But when I try to compil and to link, I have a lot of errors :
testF.o(.text+0x2c6): In function `MAIN__':
: undefined reference to `doubleijk_'
testF.o(.text+0x3f8): In function `MAIN__':
: undefined reference to `doublem_'
testF.o(.text+0x480): In function `MAIN__':
: undefined reference to `doubletab_'
testCU.o(.text+0x1d): In function `doubletab_(int*, int*)':
: undefined reference to `cudaMalloc'
testCU.o(.text+0x30): In function `doubletab_(int*, int*)':
: undefined reference to `cudaMemcpy'
testCU.o(.text+0x90): In function `doubletab_(int*, int*)':
: undefined reference to `cudaConfigureCall'
testCU.o(.text+0xb7): In function `doubletab_(int*, int*)':
: undefined reference to `cudaMemcpy'
testCU.o(.text+0xd8): In function `__cudaUnregisterBinaryUtil':
: undefined reference to `__cudaUnregisterFatBinary'
testCU.o(.text+0x4b34): In function `__iAtomicAdd':
: undefined reference to `__cudaMutexOperation'
testCU.o(.text+0x4b54): In function `__iAtomicAdd':
: undefined reference to `__cudaMutexOperation'
testCU.o(.text+0x4b6c): In function `__uAtomicAdd':
: undefined reference to `__cudaMutexOperation'
testCU.o(.text+0x4b8c): In function `__uAtomicAdd':
: undefined reference to `__cudaMutexOperation'
testCU.o(.text+0x4ba4): In function `__iAtomicExch':
: undefined reference to `__cudaMutexOperation'
testCU.o(.text+0x4bc1): more undefined references to `__cudaMutexOperation' follow
testCU.o(.text+0x70c9): In function `__itexfetchi':
: undefined reference to `__cudaTextureFetch'
testCU.o(.text+0x70ef): In function `__utexfetchi':
: undefined reference to `__cudaTextureFetch'
testCU.o(.text+0x7115): In function `__ftexfetchi':
: undefined reference to `__cudaTextureFetch'
testCU.o(.text+0x713b): In function `__itexfetch':
: undefined reference to `__cudaTextureFetch'
testCU.o(.text+0x7161): In function `__utexfetch':
: undefined reference to `__cudaTextureFetch'
testCU.o(.text+0x7187): more undefined references to `__cudaTextureFetch' follow
testCU.o(.text+0xc526): In function `__device_stub__Z13cudaDoubletabPii':
: undefined reference to `cudaSetupArgument'
testCU.o(.text+0xc53f): In function `__device_stub__Z13cudaDoubletabPii':
: undefined reference to `cudaSetupArgument'
testCU.o(.text+0xc591): In function `__sti____cudaRegisterAll_41_tmpxft_00000163_00000000_4_t
estCU_cpp1_ii_95e70681':
: undefined reference to `__cudaRegisterFatBinary'
testCU.o(.text+0xc5d2): In function `__sti____cudaRegisterAll_41_tmpxft_00000163_00000000_4_t
estCU_cpp1_ii_95e70681':
: undefined reference to `__cudaRegisterFunction'
testCU.o(.gnu.linkonce.t._Z10cudaLaunchIcE9cudaErrorPT_+0xd): In function `cudaError cudaLaunch<char>(char*)':
: undefined reference to `cudaLaunch'
testCU.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld a retourné 1 code d'état d'exécution
PS : I use :
gfortran -c testF.f
nvcc -c testCU.cu
gfortran -o test testF.o testCU.o