I have binded the ViennaCL library to a FEM simulation library in order to solve the equations systems on a GPU. When I use BICGSTAB, GMRES, CG and any of the preconditioners NONE, ILUT, ILU0, BLOCKILU, ROWSCALING, JACOBI everything works fine and I can compute on NVIDIA GPUs with CUDA without any problems.
Now I also want to use the AMG preconditioner in Version 1.7.1 to compute on GPU with CUDA. The compilation of the ViennaCL library with the FEM library works, but during the final Linking I get the following error:
Linking CXX executable ../../bin/RHEL_6_X86_64/cfsbin
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function viennacl::linalg::cuda::amg::amg_agg_merge_undecided_2(unsigned int*, unsigned int)':
tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0x12ed0): multiple definition ofviennacl::linalg::cuda::amg::amg_agg_merge_undecided_2(unsigned int, unsigned int)'
../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x390): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function viennacl::linalg::cuda::amg::amg_pmis2_reset_state(unsigned int*, unsigned int)':
tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0x12e70): multiple definition ofviennacl::linalg::cuda::amg::amg_pmis2_reset_state(unsigned int, unsigned int)'
../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x330): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function viennacl::linalg::cuda::amg::amg_influence_trivial_kernel(unsigned int const*, unsigned int const*, unsigned int, unsigned int, unsigned int*, unsigned int*, unsigned int*)':
tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe650): multiple definition ofviennacl::linalg::cuda::amg::amg_influence_trivial_kernel(unsigned int const, unsigned int const, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'
../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x320): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function __device_stub__ZN8viennacl6linalg4cuda3amg25amg_agg_merge_undecided_2EPjj(unsigned int*, unsigned int)':
tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe490): multiple definition ofdevice_stubZN8viennacl6linalg4cuda3amg25amg_agg_merge_undecided_2EPjj(unsigned int, unsigned int)'
../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x160): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function __device_stub__ZN8viennacl6linalg4cuda3amg21amg_pmis2_reset_stateEPjj(unsigned int*, unsigned int)':
tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe4f0): multiple definition ofdevice_stubZN8viennacl6linalg4cuda3amg21amg_pmis2_reset_stateEPjj(unsigned int, unsigned int)'
../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x1c0): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function __device_stub__ZN8viennacl6linalg4cuda3amg28amg_influence_trivial_kernelEPKjS4_jjPjS5_S5_(unsigned int const*, unsigned int const*, unsigned int, unsigned int, unsigned int*, unsigned int*, unsigned int*)':
tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe550): multiple definition ofdevice_stubZN8viennacl6linalg4cuda3amg28amg_influence_trivial_kernelEPKjS4_jjPjS5_S5_(unsigned int const, unsigned int const, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'
../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x220): first defined here
collect2: ld returned 1 exit status
In summary this error concerns 'multiple definition of ' some functions in the AMG part of the VIennaCL library. And this error occurs as soon as I include the amg.hpp Header in my code from the 'viennacl/linalg' folder. Without including the amg.hpp file (and any code about AMG) everything compiles, links and runs fine as before without AMG.
As all other combinations of solvers and preconditioners from ViennaCL work fine and only the including of amg.hpp causes the problem, I guess my problem can be found in the implementation of the AMG in viennacl. Therefore, I would like you to ask if you have any idea concerning my problem.
Many thanks in advance!
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I have binded the ViennaCL library to a FEM simulation library in order to solve the equations systems on a GPU. When I use BICGSTAB, GMRES, CG and any of the preconditioners NONE, ILUT, ILU0, BLOCKILU, ROWSCALING, JACOBI everything works fine and I can compute on NVIDIA GPUs with CUDA without any problems.
Now I also want to use the AMG preconditioner in Version 1.7.1 to compute on GPU with CUDA. The compilation of the ViennaCL library with the FEM library works, but during the final Linking I get the following error:
Linking CXX executable ../../bin/RHEL_6_X86_64/cfsbin
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function
viennacl::linalg::cuda::amg::amg_agg_merge_undecided_2(unsigned int*, unsigned int)': tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0x12ed0): multiple definition of
viennacl::linalg::cuda::amg::amg_agg_merge_undecided_2(unsigned int, unsigned int)'../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x390): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function
viennacl::linalg::cuda::amg::amg_pmis2_reset_state(unsigned int*, unsigned int)': tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0x12e70): multiple definition of
viennacl::linalg::cuda::amg::amg_pmis2_reset_state(unsigned int, unsigned int)'../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x330): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function
viennacl::linalg::cuda::amg::amg_influence_trivial_kernel(unsigned int const*, unsigned int const*, unsigned int, unsigned int, unsigned int*, unsigned int*, unsigned int*)': tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe650): multiple definition of
viennacl::linalg::cuda::amg::amg_influence_trivial_kernel(unsigned int const, unsigned int const, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x320): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function
__device_stub__ZN8viennacl6linalg4cuda3amg25amg_agg_merge_undecided_2EPjj(unsigned int*, unsigned int)': tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe490): multiple definition of
device_stubZN8viennacl6linalg4cuda3amg25amg_agg_merge_undecided_2EPjj(unsigned int, unsigned int)'../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x160): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function
__device_stub__ZN8viennacl6linalg4cuda3amg21amg_pmis2_reset_stateEPjj(unsigned int*, unsigned int)': tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe4f0): multiple definition of
device_stubZN8viennacl6linalg4cuda3amg21amg_pmis2_reset_stateEPjj(unsigned int, unsigned int)'../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x1c0): first defined here
../../lib64/RHEL_6_X86_64/libviennacl-olas.a(viennacl-olas_generated_ViennaCLSolver.cu.o): In function
__device_stub__ZN8viennacl6linalg4cuda3amg28amg_influence_trivial_kernelEPKjS4_jjPjS5_S5_(unsigned int const*, unsigned int const*, unsigned int, unsigned int, unsigned int*, unsigned int*, unsigned int*)': tmpxft_0000953e_00000000-3_ViennaCLSolver.cudafe1.cpp:(.text+0xe550): multiple definition of
device_stubZN8viennacl6linalg4cuda3amg28amg_influence_trivial_kernelEPKjS4_jjPjS5_S5_(unsigned int const, unsigned int const, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'../../lib64/RHEL_6_X86_64/libsolver-olas.a(solver-olas_generated_generatesolver.cu.o):tmpxft_000095ea_00000000-3_generatesolver.cudafe1.cpp:(.text+0x220): first defined here
collect2: ld returned 1 exit status
In summary this error concerns 'multiple definition of ' some functions in the AMG part of the VIennaCL library. And this error occurs as soon as I include the amg.hpp Header in my code from the 'viennacl/linalg' folder. Without including the amg.hpp file (and any code about AMG) everything compiles, links and runs fine as before without AMG.
As all other combinations of solvers and preconditioners from ViennaCL work fine and only the including of amg.hpp causes the problem, I guess my problem can be found in the implementation of the AMG in viennacl. Therefore, I would like you to ask if you have any idea concerning my problem.
Many thanks in advance!
Daniel
Hi Daniel,
thanks for reporting the problem. It was due to an accidental external linkage of three CUDA kernels. A fix has just been pushed to the developer repository:
https://github.com/viennacl/viennacl-dev/commit/15e9e434fddb77b9922d054f3ddc8d37db3b76ce
Sorry for the inconvenience.
Thanks again and best regards,
Karli