Is there a way to create fortran MEX files using Intel OneAPI?
Show older comments
I have some fortran codes that i need to turn into mex files for a project. The issue is that the fotran compiler i have on my mac (Intel OneAPI) is not supported by MATLAB and any other compiler that is supported is nott available anymore since OneAPI replaced Intell Parallel studio XE.
Is there a way to compile and create mex funtions using OneAPi as a compiler?
1 Comment
luca guerrieri
on 28 Apr 2022
I just installed the latest Intel Fortran, version 2021.5.0. I am running Monterey 12.3.1 and Matlab 2019b. I managed to compile a mex function combining a few tricks:
1) At the XQuartz prompt, I have to set the environmental variables for ifort by running the command
source /opt/intel/oneapi/setvars.sh
(Unfortunately, I have not found a good way to avoid running this command every time I want to use ifort.)
2) Start Matlab from XQuartz with the command
/Applications/MATLAB_R2019b.app/bin/matlab &
Here you will have to change the command depending on the version of Matlab you are using
3) grab the modified mex setup xml file attached here, unzip it and save it somewhere where you can find it again --- you can put it with the other setup files under /Applications/MATLAB_R2019b.app/bin/maci64/mexopts, or anywhere else.
The only change I had to make relative to the intel_fortran.xml file that came with the version of Matlab that I am running is at the end of the file. I jsut had to delete a line that was checking for the existence of a library that the latest versions of the linker will find even if they are not in the directory where they are supposed to be. I learned about this issue and solution on from a post on the Apple Developer Forum. This is the modified snippet of the XML file.
<CLANGRT_DIR>
<and>
<cmdReturns name="xcode-select -print-path"/>
<dirExists name="$$" />
</and>
</CLANGRT_DIR>
4) Use the xml file under 3 to run the mex setup with the following command:
mex -v -setup:/Applications/MATLAB_R2019b.app/bin/maci64/mexopts/intel_fortran_luca.xml
Of course, if you have saved it somewhere else, you need to change the path used above
5) Every other time you want to compile a mex function, you will have to repeat steps 1) and 2) above.
Answers (1)
Anshika Chourasia
on 11 Aug 2021
Edited: Anshika Chourasia
on 11 Aug 2021
0 votes
It is my understanding that R2021a doesn’t currently support Intel OneAPI.
Our developers are aware of the issue and the enhancement/support for Intel OneAPI might be considered for a future release of MATLAB.
7 Comments
Arwel
on 22 Oct 2021
This is an unacceptable answer. When you look at the list of supported Fortran compilers, it states that the supported compilers are 'Intel Parallel Studio XE...'
These are no longer available except as a part of oneAPI. As things stand it is not possible to download a Matlab compatable fortan compiler for mac.
I'm sorry, it's not acceptable to say that you might consider it for a future release, you need to fix this now, because as things stand you might as well change your website to say there are no supported fortan compilers. At least then you would be being honest.
When are you going to fix this??
Anshika Chourasia
on 27 Oct 2021
I understand that you are trying to compile a fortan mex file using Intel OneAPI which is't mentioned as a supported compiler in the documenation. This issue is going to be fixed soon for the reflection of enhancement in the future update or release of MATLAB.
Xavier Drevelle
on 27 Jan 2022
Hi,
Is there any chance that the issue was solved recently ? I also need to compile mex files with OneAPI.
Thank you
Anshika Chourasia
on 8 Feb 2022
Hi Xavier,
The support for Intel OneAPI has already been added to R2021b.
Developers are assessing and might consider for prior release.
Osmar Tormena Júnior
on 25 Feb 2022
Hello there,
Just a correction: The support for Intel OneAPI has definitively not already been added to R2021b.
Which is quite telling, since the community was able to do it with a simple XML hack! We're entering the third year of Intel transitioning to oneAPI. The lack of official support from MATLAB is quite umbecoming.
For macOS, consider adding support for Command Line Tools, which is more streamlined than full Xcode (quite bloated IMHO, with all the SDKs etc.). The lack of GCC support on macOS is nothing short of arbitrary.
Vince Virgilio
on 12 May 2022
Edited: Vince Virgilio
on 12 May 2022
I also need mex to support Intel OneAPI Fortran, specifically version 2022.2.0173. Matlab 2022a does not appear to support it.
Alessandro D
on 10 Jul 2022
Does Matlab R2022a support Intel one api for Fortran? I have Microsoft Visual Studio 2022 and the Intel Fortran compiler one api
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!