# Omni Compiler for XMP

**URL:** <https://fortran-lang.discourse.group/t/omni-compiler-for-xmp/818>\
**Category:** Uncategorized\
**Created:** [March 12, 2021, 4:50am UTC](https://fortran-lang.discourse.group/t/omni-compiler-for-xmp/818 "2021-03-12T04:50:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [March 12, 2021, 4:50am UTC](https://fortran-lang.discourse.group/t/omni-compiler-for-xmp/818/1 "2021-03-12T04:50:08Z")

</div>

The [Omni Compiler](https://github.com/omni-compiler/omni-compiler), primarily a Japanese effort, was recently updated on GitHub, so I decided to try it on Windows Subysystem for Linux.

> # [What is Omni Compiler ?](https://omni-compiler.org/manual/en/overview.html)
> 
> Omni Compiler is a compiler for code including [XcalableMP](http://xcalablemp.org/), [XcalableACC](http://xcalablemp.org/XACC.html), and [OpenACC](http://www.openacc.org/) directives. The base languages supported by Omni Compiler are C language (C99) and Fortran 2008 in XcalableMP, and C language (C99) in XcalableACC and OpenACC.
> 
> Omni Compiler is one of source-to-source compilers that translate from code including directives to code including runtime calls. In Omni Compiler, [XcodeML](http://omni-compiler.org/xcodeml.html) is used to analyze code in an intermediate code format of XML expression.

My installation advice for the Omni Compiler on WSL, based on a few failed attempts, is

If java not installed, run `sudo apt install default-jre`.  
If javac not installed, run `sudo apt install default-jdk`.  
To avoid an error about a missing parser.h file, run `sudo apt-get install libxml2-dev libxml2-doc`  
(I found this advice at [linux - Compiler can't find libxml/parser.h - Stack Overflow](https://stackoverflow.com/questions/29847814/compiler-cant-find-libxml-parser-h/29847909))

Then the installation instructions at GitHub worked for me.

I know little about parallel programming. Is the purpose of this compiler to run multiple instances of a program in parallel? I can see the use of that for a Monte Carlo program but not a deterministic one, since the instances should give the same result.

Running the xnegloglik program from another [thread](https://fortran-lang.discourse.group/t/tips-to-make-this-toy-program-faster/803), with `n = 1000000, niter = 100` I get the folllowing timings. Shown first are the timings with gfortran -O2. The last gives results from 4 different instances, with different random numbers used.

```
$ time ./gf.out
real	0m4.005s
user	0m4.003s
sys	0m0.000s

$ time mpirun -np 1 ./a.out
real	0m4.323s
user	0m4.044s
sys	0m0.036s

$ time mpirun -np 4 ./a.out
real	0m5.002s
user	0m18.724s
sys	0m0.101s

```

---

<div class="post-metadata">

**Author:** ![Arjen](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Arjen](https://fortran-lang.discourse.group/u/Arjen)\
**Post date:** [March 12, 2021, 7:57am UTC](https://fortran-lang.discourse.group/t/omni-compiler-for-xmp/818/2 "2021-03-12T07:57:13Z")

</div>

Given the specifications I would say that this compiler can be use to build Fortran programs that use coarrays and MPI to obtain parallellism. While both paradigms result in a single program that is run as multiple processes, these processes can communicate with each other and as they have a distinguishable identity (image number for coarrays, rank in MPI) you can have each process do its own things via that identity.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [March 12, 2021, 8:17am UTC](https://fortran-lang.discourse.group/t/omni-compiler-for-xmp/818/3 "2021-03-12T08:17:52Z")

</div>

[https://omni-compiler.org/index.html](https://omni-compiler.org/index.html)

> Omni Compiler is to translate C and Fortran programs with XcalableMP and OpenACC directives into parallel code suitable for compiling with a native compiler linked with Omni Compiler runtime library.

If I understand, it is not a compiler in the usual sense of that term, but a program (a meta-compiler?) that transforms a “Fortan+directives” code into a “Fortran+library calls” code that can be compiled by any compiler. And you need the Omni Compiler library for running the executable. Am I right?

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [March 12, 2021, 8:34am UTC](https://fortran-lang.discourse.group/t/omni-compiler-for-xmp/818/4 "2021-03-12T08:34:47Z")

</div>

Springer has published a book about it, which is available as a PDF for free: [XcalableMP PGAS Programming Language: From Programming Model to Applications | SpringerLink](https://link.springer.com/book/10.1007%2F978-981-15-7683-6)

The XMP parallel programming language directives are influenced by high-performance Fortran, and co-array syntax is also supported. In the about the book it says XMP code is run on the [Fugaku](https://en.wikipedia.org/wiki/Fugaku_(supercomputer)) supercomputer, which according to the TOP500 list is the fastest supercomputer in the world since June 2020.

From the TOP500 web page:

> Supercomputer Fugaku, a system based on Fujitsu’s custom ARM A64FX processor remains the new No. 1. It is installed at the RIKEN Center for Computational Science (R-CCS) in Kobe, Japan, the location of the former K-Computer. It was co-developed in close partnership by Riken and Fujitsu and uses Fujitsu’s Tofu D interconnect to transfer data between nodes.

I wonder which compilers they are using. My brother used to run Fortran on Fujitsu (super-)computers at ANL in Canberra or perhaps at CSIRO.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [March 13, 2021, 2:09am UTC](https://fortran-lang.discourse.group/t/omni-compiler-for-xmp/818/5 "2021-03-13T02:09:32Z")

</div>

I have found that the Omni compiler greatly speeds up a coarray program from a [tutorial by Intel](https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-coarray-tutorial/top.html). The codes are in [coarray\_tutorial.zip](https://community.intel.com/t5/Intel-Fortran-Compiler/Code-for-Coarray-Fortran-tutorial/m-p/1255923#M154460). For the program mcpi\_sequential.f90, compiled with gfortran -O2, computing pi using 600000000 trials sequentially takes 8.2 s on my machine running WSL. For the analogous program using coarrays, running

```
$ xmpf90 -O2 mcpi_coarray_final.f90
$ mpirun -np 4 ./a.out

```

takes 3.2s.

On Windows (not WSL), the sequential program compiled with Intel Fortran

`ifort -O2 mcpi_sequential.f90`

takes 13.2 s, and the coarray program compiled with

`ifort -Qcoarray mcpi_coarray_final.f90`

takes 3.8 s.

So Omni is the fastest here, although Intel coarrays are also fast. I wonder if this is generally true.

In my first message I described what was needed to install the Omni compiler, discovered by trial and error. The [manual lists these dependencies](https://omni-compiler.org/manual/en/install.html#software-dependencies):

- Yacc
- Lex
- C Compiler (supports C90)
- Fortran Compiler (supports Fortran 90)
- C++ Compiler
- Java Compiler
- MPI Implementation (supports MPI-2 or over)
- libxml2
- make
