oneapi-src / oneMKL

oneAPI Math Kernel Library (oneMKL) Interfaces
Apache License 2.0
624 stars 159 forks source link

[CMake] oneMKL version macros #538

Open hjabird opened 4 months ago

hjabird commented 4 months ago

Summary

There is currently no way to find the version of oneMKL interfaces from the headers. oneMKL interfaces should provide version macros.

This suggestion comes from a GROMACS PR - https://gitlab.com/gromacs/gromacs/-/merge_requests/4252#note_2000153975

Problem statement

The behaviour and features of oneMKL change depending on version. Whilst the version of oneMKL is discoverable from the CMake, it is not discoverable from source including oneMKL Interfaces. Consequently, it is difficult to enable or disable code according to version.

Preferred solution

@al42and suggests:

diff --git src/config.hpp.in src/config.hpp.in
index 5698abf..8c295d2 100644
--- src/config.hpp.in
+++ src/config.hpp.in
@@ -40,5 +40,9 @@
 #cmakedefine BUILD_SHARED_LIBS
 #cmakedefine REF_BLAS_LIBNAME "@REF_BLAS_LIBNAME@"
 #cmakedefine REF_CBLAS_LIBNAME "@REF_CBLAS_LIBNAME@"
+#define ONEMKL_VERSION "@PROJECT_VERSION@"
+#define ONEMKL_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
+#define ONEMKL_VERSION_MINOR @PROJECT_VERSION_MINOR@
+#define ONEMKL_VERSION_PATCH @PROJECT_VERSION_PATCH@

This is (helpfully) different from the macros exported by Intel oneMKL.

hjabird commented 4 months ago

My only thought is that we might follow Intel MKL with the version being a number:

+#define ONEMKL_VERSION (@PROJECT_VERSION_MAJOR@*100+@PROJECT_VERSION_MINOR@)*100+@PROJECT_VERSION_PATCH@
Rbiessy commented 2 months ago

This is being discussed in https://github.com/uxlfoundation/oneAPI-spec/pull/561