[OpenACC, f2py] Importing OpenACC code in python gives me __offload_func_table error

Vikram Singh vikramsingh001@gmail.com
Mon Nov 7 15:32:00 GMT 2016


Anyone?

On Mon, Oct 31, 2016 at 2:04 PM, Vikram Singh <vikramsingh001@gmail.com> wrote:
> I am trying to test how I can use fortran codes using openacc from python.
>
> I wrote a simple test code
>
> 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 have to compile the code 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
>
> It compiles fine and makes the .so file but when I try to import in
> python, I get the error,
>
> /home/Experiments/fortran_python/hello.cpython-35m-x86_64-linux-gnu.so:
> undefined symbol: __offload_func_table
>
> I tried to search where __offload_func_table is defined but I only got
> crtoffloadtable.o, but no library where it is defined and I can link
> to.
>
> Any pointers?



More information about the Fortran mailing list