Problem with compiling openacc with f2py
![](https://secure.gravatar.com/avatar/f63923ff5b2990635848cfacfa4e1578.jpg?s=120&d=mm&r=g)
I am a newbie to f2py so I have been creating simple test cases. Eventually I want to be able to use openacc subroutine from python. So here's the test case module test use iso_c_binding, only: sp => C_FLOAT, dp => C_DOUBLE, i8 => C_INT use omp_lib use openacc implicit none contains subroutine add_acc (a, b, n, c) integer(kind=i8), intent(in) :: n real(kind=dp), intent(in) :: a(n) real(kind=dp), intent(in) :: b(n) real(kind=dp), intent(out) :: c(n) integer(kind=i8) :: i !$acc kernels do i = 1, n c(i) = a(i) + b(i) end do !$acc end kernels end subroutine add_acc subroutine add_omp (a, b, n, c) integer(kind=i8), intent(in) :: n real(kind=dp), intent(in) :: a(n) real(kind=dp), intent(in) :: b(n) real(kind=dp), intent(out) :: c(n) integer(kind=i8) :: i, j !$omp parallel do do i = 1, n c(i) = a(i) + b(i) end do !$omp end parallel do end subroutine add_omp subroutine nt (c) integer(kind=i8), intent(out) :: c c = omp_get_max_threads() end subroutine nt subroutine mult (a, b, c) real(kind=dp), intent(in) :: a real(kind=dp), intent(in) :: b real(kind=dp), intent(out) :: c c = a * b end subroutine mult end module test I compile using f2py -c -m --f90flags='-fopenacc -foffload=nvptx-none -foffload=-O3 -O3 -fPIC' hello hello.f90 -L/usr/local/cuda/lib64 -lcublas -lcudart -lgomp Now, until I add the acc directives everything works fine. But as soon as I add the acc directives I get this error. gfortran:f90: /tmp/tmpld6ssow3/src.linux-x86_64-3.5/hello-f2pywrappers2.f90 /home//Experiments/Nvidia/OpenACC/OLCFHack15/gcc6/install/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmpld6ssow3/tmp/tmpld6ssow3/src.linux-x86_64-3.5/hellomodule.o /tmp/tmpld6ssow3/tmp/tmpld6ssow3/src.linux-x86_64-3.5/fortranobject.o /tmp/tmpld6ssow3/hello.o /tmp/tmpld6ssow3/tmp/tmpld6ssow3/src.linux-x86_64-3.5/hello-f2pywrappers2.o -L/usr/local/cuda/lib64 -L/home//usr/local/miniconda/lib -lcublas -lcudart -lgomp -lpython3.5m -lgfortran -o ./hello.cpython-35m-x86_64-linux-gnu.so /usr/bin/ld: /tmp/cc2yQ89d.target.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /tmp/cc2yQ89d.target.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status /usr/bin/ld: /tmp/cc2yQ89d.target.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /tmp/cc2yQ89d.target.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status error: Command "/home//Experiments/Nvidia/OpenACC/OLCFHack15/gcc6/install/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmpld6ssow3/tmp/tmpld6ssow3/src.linux-x86_64-3.5/hellomodule.o /tmp/tmpld6ssow3/tmp/tmpld6ssow3/src.linux-x86_64-3.5/fortranobject.o /tmp/tmpld6ssow3/hello.o /tmp/tmpld6ssow3/tmp/tmpld6ssow3/src.linux-x86_64-3.5/hello-f2pywrappers2.o -L/usr/local/cuda/lib64 -L/home//usr/local/miniconda/lib -lcublas -lcudart -lgomp -lpython3.5m -lgfortran -o ./hello.cpython-35m-x86_64-linux-gnu.so" failed with exit status 1 I don't get why just putting acc directives should create errors, when omp does not. Vikram
![](https://secure.gravatar.com/avatar/f63923ff5b2990635848cfacfa4e1578.jpg?s=120&d=mm&r=g)
Ok, I got it to compile using f2py -c -m --f90flags='-fopenmp -fopenacc -foffload=nvptx-none -foffload=-O3 -O3 -fPIC' hello hello.f90 -L/usr/local/cuda/lib64 -lcublas -lcudart -lgomp But now I get the import error, /home/Experiments/fortran_python/hello.cpython-35m-x86_64-linux-gnu.so: undefined symbol: __offload_func_table Seems to me I have to link another library. But where is __offload_func_table On Thu, Oct 27, 2016 at 1:30 PM, Vikram Singh <vikramsingh001@gmail.com> wrote:
![](https://secure.gravatar.com/avatar/f63923ff5b2990635848cfacfa4e1578.jpg?s=120&d=mm&r=g)
Ok, I got it to compile using f2py -c -m --f90flags='-fopenmp -fopenacc -foffload=nvptx-none -foffload=-O3 -O3 -fPIC' hello hello.f90 -L/usr/local/cuda/lib64 -lcublas -lcudart -lgomp But now I get the import error, /home/Experiments/fortran_python/hello.cpython-35m-x86_64-linux-gnu.so: undefined symbol: __offload_func_table Seems to me I have to link another library. But where is __offload_func_table On Thu, Oct 27, 2016 at 1:30 PM, Vikram Singh <vikramsingh001@gmail.com> wrote:
participants (1)
-
Vikram Singh