Skip to content

Intel Math Kernel Library (MKL) #116

Description

@Oceania2018

Performance-sensitive algorithms can be swapped with alternative implementations by the concept of providers like Intel MKL.
https://software.intel.com/en-us/performance-libraries

Activity

  1. dotChris90 commented on Dec 12, 2018

    @dotChris90
    Member

    Intels MKL library implement the LAPACK interfaces - so it would be logical to think about a layer with different LAPACK providers - in other words - a strategy pattern. Let users decide which LAPACK provider they want to use.

    It will be not much work since LAPACK usual means --> all interfaces are the same. So the PInvoke class would be the same - just the native lib is different.

    As fdncred already said. :)

  2. Oceania2018 commented on Dec 12, 2018

    @Oceania2018
    MemberAuthor

    Sounds great.

  3. fdncred commented on Dec 12, 2018

    @fdncred
    Contributor

    This is exactly what I was saying in #145 when I mentioned and linked to Armadillo.

  4. dotChris90 commented on Dec 13, 2018

    @dotChris90
    Member

    @fdncred sorry yes i know but I want to mention it here at this place ;)

  5. Oceania2018 commented on Dec 13, 2018

    @Oceania2018
    MemberAuthor

    @dotChris90 Please add MKL as a new provider when you have a chance.

  6. dotChris90 commented on Dec 13, 2018

    @dotChris90
    Member

    yes. but after seeing Intel website I think we go strategy that mkl provider expects the lib installed. on their site they said u have to registry etc..... So.... I don't wanna quarrel with them. in case we simple copy their DLLs and publish them with NumSharp.... think Intel will be not happy.

    so installation must be done manually by user.

    At moment not sure what is most comfortable way to change providers.

    My suggestion is that static numpy class has a static property lapack provider which is an enum.

    The static lapack class will check this enum and will call the specific static lapack provider classes.

    The user can change provider global. I think most comfortable.

  7. fdncred commented on Dec 13, 2018

    @fdncred
    Contributor

    @dotChris90, I'll research this a bit because other people, namely microsoft, point to dlls such as this https://docs.microsoft.com/en-us/cognitive-toolkit/setup-mkl-on-windows.

    Now that I look closer, this one ls mklml and is opensource by intel. Perhaps that is different.

  8. fdncred commented on Dec 13, 2018

    @fdncred
    Contributor

    Check this out. Intel allows one to redistribute MKL. It's in the license.
    https://software.intel.com/en-us/mkl/license-faq

    And here is the full license.
    https://software.intel.com/en-us/license/intel-simplified-software-license

  9. fdncred commented on Dec 13, 2018

    @fdncred
    Contributor

    Here's a few Github projects that wrap MKL in C#. May be easier just to use something that already exists.
    https://github.com/DNRY/CSIntelPerfLibs
    https://github.com/Rafka86/SharpMKL
    https://github.com/Proxem/BlasNet

  10. dotChris90 commented on Dec 13, 2018

    @dotChris90
    Member

    @fdncred much thanks for investigation. This makes the situation much better. 👍

  11. 24 remaining items

  12. dotChris90 commented on Jan 8, 2019

    @dotChris90
    Member

    @fdncred definitely. I am just highly confused about the mkl libraries out there.

    is anaconda mkl the same like normal mkl and why there is no package for windows... the apt get installer also just download the file and put at specific locations...

    drives me crazy....

  13. fdncred commented on Jan 8, 2019

    @fdncred
    Contributor

    @dotChris90 it appears to me that anaconda's MKL is just the regular MKL. It also looks to me like there is a windows package. See the links below.
    https://anaconda.org/anaconda/mkl
    https://docs.anaconda.com/accelerate/mkl-overview/
    https://repo.anaconda.com/pkgs/main/win-64/
    For my two cents, I think Proxem's BlasNet is the best wrapper for MKL. It looks pretty mature.
    https://github.com/Proxem/BlasNet

  14. dotChris90 commented on Jan 8, 2019

    @dotChris90
    Member

    @fdncred Thanks for the update. ;)

    From the URL I agree with you. 👍
    I already downloaded the package via pip and checked it but the package brings multiple MKL dlls. In anaconda location you will find binaries with mkl_corem mkl_xyz, …. about 6 or 7 files. But I though the mkl thing is one single DLL …. but anaconda shows multiple .... this is extrem strange behaviour...

    I agree Proxems BlasNet looks fine but it does not solve our main problem. Proxem just brings Wrapper code in C# - please do not misunderstand me but I am not very impressed by this …. because there are a lot of C# Code-Generators who do the same job - e.g. ClangSharp, T4, SWIG and if I check the Mono team I am 100% sure I can find more generators. xD Such automatic wrapper always simple take a C header file and generate Code …. I really do not see any benefit to use it BlasNet. I saw the Code and as far as I can see the main methods we can use could be also generated automaticly by ClangSharp (or T4) so not sure why add package for something we can auto generate xD.

    Our (at least what makes me feel uncomfortable) problem is : Proxem does not bring a native MKL Lib package. I have to install it manually. In Linux its easy - "sudo apt-get install" but on windows it is impossible to do this. This makes CI Testing impossible. How do we want to do unit testing or automatic benchmark testing on Appveyor? Unfortunately -.- we can not do this - except we package this MKL DLL into a nuget package. damn windows has no apt get....

  15. fdncred commented on Jan 8, 2019

    @fdncred
    Contributor

    Probably not impossible for CI. Have you looked at using chocolatey to install MKL? It looks like one of microsoft's packages includes it https://chocolatey.org/packages/microsoft-r-open. It may not be perfect but it may work.

    I've had a lot of experience with ClangSharp and NClang as well as other generators to take a C/C++ library to C# and I'm quite sure that they are not easy. I've found with one for months trying to get the library ported and it's very time consuming. You can get close pretty easily but you can't get complete easily. It'll take work for sure.

  16. dotChris90 commented on Jan 9, 2019

    @dotChris90
    Member

    damn choco package management didn't think on it yes. can try. thanks.

    If u say it is hard maybe I was too easy thinking. the only complex thing we could have with code generation is.... lapack 100 % uses pointer. so generator can not know what's array and what pass by reference.

    hm...yes could be trickier. but as long as we just using some few functions from lapack.... writing own is easier. but yes maybe later need some more professional things.

  17. fdncred commented on Jan 9, 2019

    @fdncred
    Contributor

    Yes, IntPtr from C/C++ can be tricky and requires hand massaging for every call, from my experience. Marshalling arrays isn't too complex if you know the count of the array and the size of the array. Ref, In, Out params can be tricky, especially if you have an [In, Out] parameter in C/C++, where you pass in out value in a parameter and you return a different value out of the same parameter. If you get stuck on something reach out to me and I may be able to help.

  18. Oceania2018 commented on Jan 9, 2019

    @Oceania2018
    MemberAuthor
  19. fdncred commented on Jan 9, 2019

    @fdncred
    Contributor

    @Oceania2018, yes, i'll look at it. I'm not promising i can fix it but I'll try. ;)

  20. Oceania2018 commented on Jan 9, 2019

    @Oceania2018
    MemberAuthor

    Anyway I’d appreciate. Try to make it work. Enjoy tensorflow.net.

  21. dotChris90 commented on Jan 10, 2019

    @dotChris90
    Member

    for traceability. Intel just offer you help if u have customer service.. yeah every company need money I know....

    But post in forum and got answer direct from Intel.

    https://software.intel.com/en-us/comment/1932183#comment-1932183

    as we can read there. don't worry take the mkl lib.

    answers was (2019 Jan 10th, 7:09 Berlin time)

    please refer here : license FAQ

    you won't have a problem redistributing it.

  22. mzhukova commented on May 2, 2019

    @mzhukova

    Hi folks,
    I saw on the Intel forum that you were asking about distributing MKL via nuget.
    It is available now in nuget channel as well. I was just wondering, if this may be useful to you: https://www.nuget.org/packages?q=intelmkl

    Best regards,
    Maria

  23. Nucs commented on Sep 7, 2026

    @Nucs
    Member

    @Oceania2018, we shipped this as OpenBLAS rather than MKL - the pluggable provider you described. Referencing the package assigns TensorEngine.Blas from a [ModuleInitializer], so the reference is the whole opt-in (0.70.0, #628):

    // dotnet add package NumSharp.Interop.OpenBLAS
    OpenBlasEngine.Enable();
    Console.WriteLine(OpenBlasEngine.Enabled);   // True
    
    // products / factorisations now route through OpenBLAS, byte-identical to NumPy
    var c = np.matmul(a, b);

    Requires NumSharp.Interop.OpenBLAS (dotnet add package NumSharp.Interop.OpenBLAS). An MKL backend could implement the same IBlasBackend seam if anyone wants it. Closing.

  24. Nucs commented on Sep 7, 2026

    @Nucs
    Member

    Keeping this open for a day we will extend to NumSharp.Interop.IntelMKL

  25. reopened this on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions