2022-09-22 01:17:05 +02:00
|
|
|
import os
|
|
|
|
from lib.shell import get_from_command
|
|
|
|
|
2022-09-22 01:51:47 +02:00
|
|
|
|
2022-09-22 01:17:05 +02:00
|
|
|
def get_compiler_version(compiler):
|
|
|
|
if compiler == "gnu":
|
2022-09-22 01:51:47 +02:00
|
|
|
cc = "gcc"
|
2022-09-22 01:17:05 +02:00
|
|
|
elif compiler == "intel":
|
2022-09-22 01:51:47 +02:00
|
|
|
cc = "icc"
|
2022-09-22 01:17:05 +02:00
|
|
|
elif compiler == "aocc":
|
2022-09-22 01:51:47 +02:00
|
|
|
cc = "clang"
|
|
|
|
compstr = get_from_command([cc, "-dumpversion"]).strip()
|
2022-09-22 01:17:05 +02:00
|
|
|
return compstr
|
|
|
|
|
2022-09-22 01:51:47 +02:00
|
|
|
|
2022-09-22 01:17:05 +02:00
|
|
|
def get_mpi_version(mpi):
|
|
|
|
if mpi == "hpcx":
|
|
|
|
hpcx_dir = os.getenv('HPCX_DIR')
|
|
|
|
ver_file = hpcx_dir + "/" + "VERSION"
|
|
|
|
with open(ver_file) as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
mpistr = lines[0].split()[1].strip()
|
|
|
|
elif mpi == "openmpi":
|
|
|
|
rawstr = get_from_command(["ompi_info"]).splitlines()[1]
|
|
|
|
mpistr = rawstr[rawstr.find(":")+2:]
|
|
|
|
elif mpi == "intelmpi":
|
2022-09-28 15:40:49 +02:00
|
|
|
rawstr = get_from_command(["mpirun","--version"])
|
|
|
|
mpistr = rawstr.split()[7]
|
2022-09-22 01:17:05 +02:00
|
|
|
elif mpi == "mpich":
|
2022-09-22 01:51:47 +02:00
|
|
|
rawstr = get_from_command(["mpirun", "--version"])
|
2022-09-22 01:17:05 +02:00
|
|
|
mpistr = rawstr.split()[4]
|
|
|
|
return mpistr
|
|
|
|
|
|
|
|
|
2022-09-22 01:51:47 +02:00
|
|
|
def set_toolchain(compiler, mpi):
|
2022-09-22 01:17:05 +02:00
|
|
|
if compiler == "gnu":
|
|
|
|
if mpi == "hpcx" or mpi == "openmpi" or mpi == "mpich":
|
|
|
|
cc = "mpicc"
|
|
|
|
cxx = "mpic++"
|
|
|
|
fc = "mpifort"
|
2022-09-28 15:40:49 +02:00
|
|
|
elif mpi == "intelmpi":
|
2022-09-22 01:17:05 +02:00
|
|
|
cc = "mpicc"
|
|
|
|
cxx = "mpicxx"
|
|
|
|
fc = "mpif90"
|
|
|
|
elif compiler == "aocc":
|
|
|
|
if mpi == "hpcx" or mpi == "openmpi":
|
|
|
|
cc = "mpicc"
|
|
|
|
cxx = "mpic++"
|
|
|
|
fc = "mpifort"
|
|
|
|
os.environ["OMPI_MPICC"] = "clang"
|
|
|
|
os.environ["OMPI_MPICXX"] = "clang++"
|
|
|
|
os.environ["OMPI_MPIFC"] = "flang"
|
|
|
|
os.environ["OMPI_MPIF90"] = "flang"
|
|
|
|
os.environ["OMPI_MPIF77"] = "flang"
|
2022-09-28 15:40:49 +02:00
|
|
|
elif (mpi == "intelmpi"):
|
2022-09-22 01:17:05 +02:00
|
|
|
cc = "\"mpicc -cc=clang\""
|
|
|
|
cxx = "\"mpicxx -cxx=clang++\""
|
|
|
|
fc = "\"mpif90 -fc=flang\""
|
|
|
|
elif compiler == "intel":
|
|
|
|
if mpi == "hpcx" or mpi == "openmpi":
|
|
|
|
cc = "mpicc"
|
|
|
|
cxx = "mpic++"
|
|
|
|
fc = "mpifort"
|
|
|
|
os.environ["OMPI_MPICC"] = "icc"
|
|
|
|
os.environ["OMPI_MPICXX"] = "icpc"
|
|
|
|
os.environ["OMPI_MPIFC"] = "ifort"
|
|
|
|
os.environ["OMPI_MPIF90"] = "ifort"
|
|
|
|
os.environ["OMPI_MPIF77"] = "ifort"
|
2022-09-28 15:40:49 +02:00
|
|
|
elif mpi == "intelmpi":
|
2022-09-22 01:17:05 +02:00
|
|
|
cc = "mpiicc"
|
|
|
|
cxx = "mpiicpc"
|
|
|
|
fc = "mpiifort"
|
2022-09-28 15:40:49 +02:00
|
|
|
|
2022-09-22 01:17:05 +02:00
|
|
|
# set environment variables
|
|
|
|
os.environ["CC"] = cc
|
|
|
|
os.environ["CXX"] = cxx
|
|
|
|
os.environ["FC"] = fc
|
|
|
|
os.environ["F90"] = fc
|
|
|
|
os.environ["F77"] = fc
|
|
|
|
|
2022-09-28 15:40:49 +02:00
|
|
|
return cc, cxx, fc
|