Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifx to wasm

dhn
Beginner
713 Views

I would like to know if there is a plan for Intel Fortran Compiler (ifx) to compile fortran code to webassembly  (wasm) in the future. Of if ifx can emit LLVM bit code since it uses LLVM backend compiler technology.

Thank you.

0 Kudos
1 Solution
Ron_Green
Moderator
382 Views

I can answer this question for Intel:  we have no plans to provide the capability to emit LLVM bitcode from the Intel Fortran Compiler (ifx).

As @dhn suggests, Flang-new and LFortran are great alternatives.

 

View solution in original post

0 Kudos
5 Replies
David_Kinniburgh
Beginner
418 Views

I am also interested in this. Can anyone answer the original query now...

 

thanks

0 Kudos
dhn
Beginner
395 Views

Here are some workarounds that we have tried:

  1. use flang-new-15: https://niconiconi.neocities.org/tech-notes/fortran-in-webassembly-and-field-solver/
  2. use LFortran: https://lfortran.org/
  3. convert a small portion of our code from Fortran to C and use emscripten to compile the C code to wasm

1 and 2 aren't mature enough to support all the features we implemented in our pretty big Fortran program (100K+ LOC).  3 works well but isn't practical since we would need to convert all of our code from Fortran to C, and then  maintain two different Fortran/C baselines to support both desktop and web applications.

ifx already uses LLVM backend so it must already compile Fortran code to LLVM-IR. Not sure how hard that is to compile LLVM-IR to WebAssembly (just like what llc does).

0 Kudos
Ron_Green
Moderator
383 Views

I can answer this question for Intel:  we have no plans to provide the capability to emit LLVM bitcode from the Intel Fortran Compiler (ifx).

As @dhn suggests, Flang-new and LFortran are great alternatives.

 

0 Kudos
dhn
Beginner
377 Views

Thanks  for your prompt response!

As I understand, your current icx and dpcpp are able to emit LLVM bitcode. I was wondering why you have no plans to provide that same capability to the ifx? 

Thanks!

0 Kudos
Ron_Green
Moderator
297 Views

For ICX, we support emitting bitcode is as an output from the pre-link phase of LTO compilation, and we embed bitcode into fat binaries for offload scenarios. In those cases we haven’t run any optimizations.  Our optimizations are proprietary.

 

For IFX, one may think that the LTO case would give a path to what you're trying to do, but in many cases it wouldn’t really help since we use intrinsics and other IR constructs that are unknown to open source LLVM tools.  The Intel dialect of LLVM IR is not 100% cross-compatible with open source LLVM IR and we currently have no intention of supporting any such cross-compatibility.  Fortran front end uses such extensions more often than the C/C++ front end.  It works in some cases, but that’s entirely dependent on whether we’ve used any of our proprietary extensions.

0 Kudos
Reply