Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
2273 Discussions

Static linkage of MKL + MPI + OpenMP fails with multiple definition

foxtran
New Contributor II
1,314 Views

Hello!

I have an MPI application which, unfortunately, I can not link. The minimal example (main.f90) which still fails:

 

program main
  use mpi
  implicit none
  integer :: ierr
  call mpi_init(ierr)
  call dgemm("I", "DO", "NOT", "CARE", "ABOUT", "ARGS")
  call mpi_finalize(ierr)
end program main

 

 I'm trying to link it statically with ifx as follows:

 

ifx -qopenmp-link=static -static-intel -qmkl=parallel -lm main.f90 -I/opt/intel/oneapi/2025.0/include/mpi -lmpifort -lmpi

And then I get:

ld: /opt/intel/oneapi/2025.0/lib/libiomp5.a(memattrs.o): in function `hwloc_internal_memattr_set_value':
(.text+0x1a80): multiple definition of `hwloc_internal_memattr_set_value'; /opt/intel/oneapi/mpi/2021.14/lib/libmpi.a(memattrs.o):/build/impi/_buildspace/release/src/hwloc/hwloc/../../../../../src/hwloc/hwloc/memattrs.c:926: first defined here

 

This command comes from mpiifx, which was called as follows:

 

mpiifx -qopenmp-link=static -static-intel -qmkl=parallel -lm main.f90

 


Looks like `hwloc_internal_memattr_set_value` is used both in MPI and OpenMP runtimes. I'm not sure that I can use `-Wl,--allow-multiple-definition` flag to avoid this error since these functions can be different.

show command gives me:

 

$ mpiifx -qopenmp-link=static -static-intel -qmkl=parallel -lm main.f90 -show
ifx '-qopenmp-link=static' '-static-intel' '-qmkl=parallel' '-lm' 'main.f90' -I"/opt/intel/oneapi/2025.0/include/mpi" -I"/opt/intel/oneapi/2025.0/include" -I"/opt/intel/oneapi/2025.0/include/mpi" -L"/opt/intel/oneapi/2025.0/lib" -L"/opt/intel/oneapi/2025.0/lib" -Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker "/opt/intel/oneapi/2025.0/lib" -Xlinker -rpath -Xlinker "/opt/intel/oneapi/2025.0/lib" -lmpifort -lmpi -ldl -lrt -lpthread

 

that was simplified. 

Loading of Intel oneAPI stack:

source /opt/intel/oneapi/2025.0/oneapi-vars.sh
source /opt/intel/oneapi/mpi/2021.14/env/vars.sh

 

 

As I can see, the latest oneAPI is used. ifx (mpiifx, TBH) version is:

 

$ mpiifx --version
ifx (IFX) 2025.0.4 20241205
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

 


Moving `-lm` flag at the end of ifx command solves this issue. Unfortunately, I cannot do it because mpiifx has its own opinion about order of flags.

NOTE: ifx says warnings about -lm, but it is only for ifx call which is presented here, we use mpiifx.

Labels (2)
0 Kudos
1 Solution
TobiasK
Moderator
858 Views

@foxtran

 

Can you please check with 2025.1 HPC toolkit again?

 

I don't see an error:

 

mpiifx -what -qopenmp-link=static -static-intel -qmkl=parallel main.f90 

 Intel(R) Fortran 25.0-1373.1

mpiifx -v

mpiifx for the Intel(R) MPI Library 2021.15 for Linux*

Copyright Intel Corporation.

ifx version 2025.1.0

 

View solution in original post

2 Replies
TobiasK
Moderator
859 Views

@foxtran

 

Can you please check with 2025.1 HPC toolkit again?

 

I don't see an error:

 

mpiifx -what -qopenmp-link=static -static-intel -qmkl=parallel main.f90 

 Intel(R) Fortran 25.0-1373.1

mpiifx -v

mpiifx for the Intel(R) MPI Library 2021.15 for Linux*

Copyright Intel Corporation.

ifx version 2025.1.0

 

foxtran
New Contributor II
836 Views

Hi, @TobiasK!

With 2024.1 I have this issue. With 2025.1 I do not have it! Hooray!

My congratulations with new release!

0 Kudos
Reply