Skip to content

Commit

Permalink
(#4482) - add openmpi/4.1.0
Browse files Browse the repository at this point in the history
* - add openmpi/4.1.0

Signed-off-by: SSE4 <tomskside@gmail.com>

* Update recipes/openmpi/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/openmpi/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/openmpi/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/openmpi/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/openmpi/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* - remove dependency on SSH

Signed-off-by: SSE4 <tomskside@gmail.com>

* Update recipes/openmpi/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/openmpi/all/test_package/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/openmpi/all/test_package/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/openmpi/all/conanfile.py

* Update recipes/openmpi/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
SSE4 and SpaceIm authored Mar 1, 2021
1 parent a5c090f commit 5716325
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/openmpi/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"4.1.0":
sha256: 73866fb77090819b6a8c85cb8539638d37d6877455825b74e289d647a39fd5b5
url: https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.0.tar.bz2
97 changes: 97 additions & 0 deletions recipes/openmpi/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from conans import ConanFile, tools, AutoToolsBuildEnvironment
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.29.1"


class OpenMPIConan(ConanFile):
name = "openmpi"
homepage = "https://www.open-mpi.org"
url = "https://github.com/conan-io/conan-center-index"
topics = ("conan", "mpi", "openmpi")
description = "A High Performance Message Passing Library"
license = "BSD-3-Clause"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"fortran": ["yes", "mpifh", "usempi", "usempi80", "no"]
}
default_options = {
"shared": False,
"fPIC": True,
"fortran": "no"
}

_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.settings.os == "Windows":
raise ConanInvalidConfiguration("OpenMPI doesn't support Windows")

def requirements(self):
# FIXME : self.requires("libevent/2.1.12") - try to use libevent from conan
self.requires("zlib/1.2.11")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self)
args = ["--disable-wrapper-rpath", "--disable-wrapper-runpath"]
if self.settings.build_type == "Debug":
args.append("--enable-debug")
if self.options.shared:
args.extend(["--enable-shared", "--disable-static"])
else:
args.extend(["--enable-static", "--disable-shared"])
args.append("--with-pic" if self.options.get_safe("fPIC", True) else "--without-pic")
args.append("--enable-mpi-fortran={}".format(str(self.options.fortran)))
args.append("--with-zlib={}".format(self.deps_cpp_info["zlib"].rootpath))
args.append("--with-zlib-libdir={}".format(self.deps_cpp_info["zlib"].lib_paths[0]))
args.append("--datarootdir=${prefix}/res")
self._autotools.configure(args=args)
return self._autotools

def build(self):
with tools.chdir(self._source_subfolder):
autotools = self._configure_autotools()
autotools.make()

def package(self):
self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses")
with tools.chdir(self._source_subfolder):
autotools = self._configure_autotools()
autotools.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "etc"))
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")

def package_info(self):
self.cpp_info.libs = ['mpi', 'open-rte', 'open-pal']
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["dl", "pthread", "rt", "util"]

self.output.info("Creating MPI_HOME environment variable: {}".format(self.package_folder))
self.env_info.MPI_HOME = self.package_folder
self.output.info("Creating OPAL_PREFIX environment variable: {}".format(self.package_folder))
self.env_info.OPAL_PREFIX = self.package_folder
mpi_bin = os.path.join(self.package_folder, 'bin')
self.output.info("Creating MPI_BIN environment variable: {}".format(mpi_bin))
self.env_info.MPI_BIN = mpi_bin
self.output.info("Appending PATH environment variable: {}".format(mpi_bin))
self.env_info.PATH.append(mpi_bin)
10 changes: 10 additions & 0 deletions recipes/openmpi/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(MPI REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
18 changes: 18 additions & 0 deletions recipes/openmpi/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
mpiexec = os.path.join(os.environ['MPI_BIN'], 'mpiexec')
command = '%s -mca plm_rsh_agent yes -np 2 %s' % (mpiexec, os.path.join("bin", "test_package"))
self.run(command, run_environment=True)
23 changes: 23 additions & 0 deletions recipes/openmpi/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <mpi.h>
#include <iostream>

int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);

int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
int value = 17;
int result = MPI_Send(&value, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
if (result == MPI_SUCCESS)
std::cout << "Rank 0 OK!" << std::endl;
} else if (rank == 1) {
int value;
int result = MPI_Recv(&value, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
if (result == MPI_SUCCESS && value == 17)
std::cout << "Rank 1 OK!" << std::endl;
}
MPI_Finalize();
return 0;
}
3 changes: 3 additions & 0 deletions recipes/openmpi/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"4.1.0":
folder: all

0 comments on commit 5716325

Please sign in to comment.