Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] oneMKL #23364

Open
valgur opened this issue Apr 4, 2024 · 4 comments
Open

[request] oneMKL #23364

valgur opened this issue Apr 4, 2024 · 4 comments

Comments

@valgur
Copy link
Contributor

valgur commented Apr 4, 2024

Package Name/Version

oneMKL

Webpage

https://spec.oneapi.io/versions/latest/elements/oneMKL/source/index.html

Source code

https://github.com/oneapi-src/oneMKL

Description of the library/tool

The oneAPI Math Kernel Library (oneMKL) defines a set of fundamental mathematical routines for use in high-performance computing and other applications. As part of oneAPI, oneMKL is designed to allow execution on a wide variety of computational devices: CPUs, GPUs, FPGAs, and other accelerators. The functionality is subdivided into several domains: dense linear algebra, sparse linear algebra, discrete Fourier transforms, random number generators and vector math.

oneMKL would provide an alternative to BLAS and LAPACK currently provided by OpenBLAS, but optimized heavily for Intel CPU-s.

@Nekto89
Copy link
Contributor

Nekto89 commented Apr 5, 2024

I'm currently trying to repack libraries from oneMKL installers that are provided by Intel on Windows/Linux. oneMKL seems to be using circular dependencies and conan doesn't support it
conan-io/conan#4928
conan-io/conan#6530
conan-io/conan#10935

@valgur
Copy link
Contributor Author

valgur commented Apr 5, 2024

@Nekto89 Thanks for looking into it! That circular dependencies issue might be a pretty hard blocker for now. 😐

I started experimenting with a oneMKL recipe (the non-interfaces one) as well, here: https://github.com/valgur/conan-center-index/blob/new/onemkl/recipes/onemkl/all/conanfile.py

Sounds like you have something much more complete in the works. I would gladly collaborate on it, if you can share your current state.

@Nekto89
Copy link
Contributor

Nekto89 commented Apr 5, 2024

@Nekto89 Thanks for looking into it! That circular dependencies issue might be a pretty hard blocker for now. 😐

I started experimenting with a oneMKL recipe (the non-interfaces one) as well, here: https://github.com/valgur/conan-center-index/blob/new/onemkl/recipes/onemkl/all/conanfile.py

Sounds like you have something much more complete in the works. I would gladly collaborate on it, if you can share your current state.

My version is worse than yours.
I need small subset of functionality so my recipe solves only my problem. I didn't find fast way to unpack files from installers so I installed them on my machine before running conan.

conan export-pkg -nr -of "C:\Program Files (x86)\Intel\oneAPI\mkl\2024.1" -pr:b ... -pr:h ... --name onemkl --version 2021.4.0 -s os=Windows -s build_type=Release C:/.../recipes/onemkl/all/conanfile.py
conan export-pkg -nr -of "~/intel/oneapi/mkl/2024.1" -pr:b ... -pr:h ... --name onemkl --version 2021.4.0 "$recipe_dir/conanfile.py"
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy
import os

required_conan_version = ">=2.0.17"


class onemklConan(ConanFile):
    name = "onemkl"
    description = "The fastest and most-used math library for Intel®-based systems."
    homepage = "https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html"
    license = "Intel Simplified Software License"
    topics = ("intel")
    package_type = "static-library"
    settings = "os", "arch", "compiler", "build_type"
    build_policy = "never"

    def layout(self):
        pass

    def requirements(self):
        self.requires("onetbb/2021.9.0")

    def package_id(self):
        if self.info.settings.os == "Windows":
            self.info.settings.build_type = "Debug" if self.info.settings.build_type == "Debug" else "Release"
        else:
            del self.info.settings.build_type
        self.info.requires.unrelated_mode()
        del self.info.settings.compiler

    def validate(self):
        if self.settings.arch != "x86_64":
            raise ConanInvalidConfiguration(f"{self.ref} supports only x86_64")
        if not self.settings.os in ["Windows", "Linux"]:
            raise ConanInvalidConfiguration(f"{self.ref} supports only Windows and Linux")

    def source(self):
        pass

    def generate(self):
        VirtualBuildEnv(self)
        VirtualRunEnv(self)

    def build(self):
        pass

    def package(self):
        lib_suffix = "lib" if self.settings.os == "Windows" else "a"
        lib_prefix = "" if self.settings.os == "Windows" else "lib"
        debug_suffix = "d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else ""
        source_lib_folder = os.path.join(self.build_folder, "lib")
        target_lib_folder = os.path.join(self.package_folder, "lib")
        copy(self, f"{lib_prefix}mkl_intel_ilp64.{lib_suffix}", source_lib_folder, target_lib_folder)
        copy(self, f"{lib_prefix}mkl_core.{lib_suffix}", source_lib_folder, target_lib_folder)
        copy(self, f"{lib_prefix}mkl_tbb_thread{debug_suffix}.{lib_suffix}", source_lib_folder, target_lib_folder)
        source_include_folder = os.path.join(self.build_folder, "include")
        target_include_folder = os.path.join(self.package_folder, "include")
        copy(self, "*", source_include_folder, target_include_folder)
        source_license_folder = os.path.join(self.build_folder, "share", "doc", "mkl", "licensing")
        target_license_folder = os.path.join(self.package_folder, "licenses")
        copy(self, "*", source_license_folder, target_license_folder)

        #ugly workaround. conan doesn't support circular dependencies
        if self.settings.os == "Linux":
            os.symlink("libmkl_core.a", os.path.join(self.package_folder, "lib", "libmkl_core2.a"))
            os.symlink("libmkl_core.a", os.path.join(self.package_folder, "lib", "libmkl_core3.a"))
            os.symlink("libmkl_tbb_thread.a", os.path.join(self.package_folder, "lib", "libmkl_tbb_thread2.a"))

    def package_info(self):
        debug_suffix = "d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else ""
        self.cpp_info.libs = ["mkl_intel_ilp64", "mkl_core", f"mkl_tbb_thread{debug_suffix}"]
        if self.settings.os == "Linux":
            #ugly workaround. conan doesn't support circular dependencies
            self.cpp_info.libs.extend(["mkl_core2", "mkl_tbb_thread2", "mkl_core3"])
        self.cpp_info.set_property("cmake_file_name", "MKL")
        self.cpp_info.set_property("cmake_target_name", "MKL::MKL")
        self.cpp_info.defines.append("MKL_ILP64")

@Croydon
Copy link
Contributor

Croydon commented Apr 10, 2024

FYI, upstream just dropped Conan

uxlfoundation/oneMath#267
uxlfoundation/oneMath@8c907b4

But was broken for 3 years anyway: uxlfoundation/oneMath#117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants