问题
I am working on a project where Intel MKL is nice to have, but not available on all the targeted platforms, so I have to check for its presence to behave accordingly.
I have enabled the Intel Performance Libraries
in my Visual Studio project's properties, as explained in Compiling and Linking Intel® Math Kernel Library with Microsoft* Visual C++* and in Intel® Math Kernel Library (Intel® MKL) 2018 Getting Started but I'm not getting any of the preprocessor definitions described in Using Predefined Preprocessor Symbols for Intel® MKL Version-Dependent Compilation, e.g. __INTEL_MKL__
is not defined.
Any ideas how I can have these? Or any other means to detect Intel MKL?
回答1:
I found a way that is a good compromise yet not very elegant.
Apparently we can check values of Property Pages settings in Build Events. After discovering a macro named UseIntelMKL
I decided to tie a config.h
to the value of it accordingly, and use the preprocessor directives defined in this config.h
instead.
Here is roughly the script that acts as Pre-build Event
. I am basically defining __INTEL_MKL__
myself in config-mkl.h
.
if "$(UseIntelMKL)"=="Parallel" (
xcopy /Y /I $(ProjectDir)config-mkl.h $(ProjectDir)config.h
) else (
xcopy /Y /I $(ProjectDir)config-nomkl.h $(ProjectDir)config.h
)
来源:https://stackoverflow.com/questions/51481915/detecting-if-intel-mkl-is-enabled-in-visual-studio-projects-properties