
{"id":972,"date":"2022-11-13T22:59:58","date_gmt":"2022-11-13T20:59:58","guid":{"rendered":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/?page_id=972"},"modified":"2025-12-15T17:13:48","modified_gmt":"2025-12-15T15:13:48","slug":"ompi-ppg-basic-installation-usage","status":"publish","type":"page","link":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/software\/ompi\/documentation\/ompi-ppg-basic-installation-usage\/","title":{"rendered":"OMPi @ ppg &#8212; basic installation &#038; usage"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-493 size-full\" style=\"margin-bottom: 1em;\" src=\"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-content\/uploads\/2015\/02\/ompi-64-o.png\" width=\"160\" height=\"64\" \/>Here you can find short installation and usage guides, as well as some documents about OMPi internals. More documentation is provided within the source distribution, found in our <a title=\"OMPi @ ppg downloads\" href=\"https:\/\/paragroup.cse.uoi.gr\/wpsite\/software\/ompi\/download\/\">download page<\/a>.<\/p>\n<h3><a id=\"prerequisites\"><\/a>Prerequisites<\/h3>\n<p>The basic requirements for building and installing OMPi on your system are:<\/p>\n<ol>\n<li>The <b>meson<\/b> build system (version <b>0.58.0<\/b> or later required)<\/li>\n<li>A C compiler (e.g. <code>gcc<\/code>)<\/li>\n<\/ol>\n<h3><a id=\"installation\"><\/a>Quick Installation Guide<\/h3>\n<ol>\n<li>Extract the package\n<pre>  tar xvf ompi-X.Y.Z.tar.xz\r\n<\/pre>\n<\/li>\n<li>Prepare for building and installing (see below for <a href=\"#confoptions\">advanced configuration options<\/a>)\n<pre>  meson setup build --prefix=\u2039install-dir\u203a\r\n<\/pre>\n<p>This will create a directory named <code>build<\/code> where OMPi will be built; <code>install-dir<\/code> is the directory OMPi will be installed at. If omitted, <code>\/usr\/local\/<\/code> will be used by default.<\/p>\n<div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-anchor=\"confoptions\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>More configuration options<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<p>If you want to enable debugging, give the <code>-Denable-debug=true<\/code> option to <code>meson setup<\/code> (turned off by default).<\/p>\n<p>The compiler flags used to build the compiler &amp; the libraries are just <code>-O2<\/code>. In case you want to use different\/additional ones, edit the top-level <code>meson.build<\/code> file and put your flags in the <code>standard_cflags<\/code> array.<\/p>\n<p>The default compiler is determined by <code>meson<\/code> itself. If you want to use a different compiler you need to set the <code>CC<\/code> environment variable before executing the <code>meson setup<\/code> command<\/p>\n<\/div><\/div>\n <div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-anchor=\"confoptions\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Advanced configuration: portable OMPi<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<p>You can have a portable build of OMPi in linux as follows:<\/p>\n<pre>  meson setup build -Dportable=true --prefix=\u2039install-dir\u203a ...<\/pre>\n<p>You can then build and install OMPi as normal, but now you can move the <code>install_dir<\/code> contents anywhere you like; you can execute <code>ompicc<\/code> within the new directory, or by giving the full path as in:<\/p>\n<pre>  \/new\/path\/bin\/ompicc myfile.c\r\n<\/pre>\n<p>Everything will work as normal, even if it has been moved away from the initial <code>install-dir<\/code>.<\/p>\n<\/div><\/div>\n <div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-anchor=\"confoptions\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Advanced configuration: thread libraries<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<p>OMPi comes with multiple thread libraries, and can support even more (see the bundled <code>doc\/runtime.txt<\/code>); &#8220;pthreads&#8221;, based on POSIX threads, is the default one. You can choose which one OMPi will be built with as follows:<\/p>\n<pre>  meson setup build -Dortlib=\u2039name\u203a ...\r\n<\/pre>\n<p>where \u2039name\u203a is any of the included libraries, or any other library you have developed.<\/p>\n<\/div><\/div>\n <div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-anchor=\"confoptions\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Advanced configuration: devices\/modules<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<p>OMPi can support multiple OpenMP devices through device <em>modules<\/em>; by default, at configuration time it checks and builds all device modules that may be supported. You can choose which ones OMPi should be built with as follows:<\/p>\n<pre>  meson setup build -Dmodules=\"\u2039name\u203a \u2039name\u203a ...\" ...\r\n<\/pre>\n<p>i.e. space-seperated module names, where each \u2039name\u203a is any of the modules OMPi ships with, or any other module you may have developed.<\/p>\n<\/div><\/div>\n <div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-anchor=\"confoptions\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Advanced configuration: kernel bundling<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<p>OMPi generates kernel binaries from\u00a0<code>#pragma omp target<\/code> constructs, and can either (a) bundle them\u00a0<em>into<\/em> the main\u00a0executable (<code>a.out<\/code>), or (b) output them as separate files in the working directory, <em>alongside<\/em> the main executable. By default, OMPi goes with option (a). To\u00a0change the default behavior, you can set up the compiler with the <code>-Dkernel-bundling=&lt;opt&gt;<\/code>\u00a0option:<\/p>\n<pre>  meson setup build -Dkernel-bundling=&lt;opt&gt; ...<\/pre>\n<p>where <code>&lt;opt&gt;<\/code> can be <code>true<\/code> (enable kernel bundling), <code>false<\/code> (disable kernel bundling) and\u00a0<code>auto<\/code> (current default behavior; equal to\u00a0<code>true<\/code>).<\/p>\n<\/div><\/div>\n<\/li>\n<li>Compile and install the package\n<pre>  cd build\/\r\n  meson compile\r\n  meson install\r\n<\/pre>\n<\/li>\n<li>Make sure <code>\u2039install-dir\u203a\/bin<\/code> is in your PATH<\/li>\n<\/ol>\n<h3><a id=\"usage\"><\/a>Quick Usage Guide<\/h3>\n<p>Usage: <code>ompicc [options] files.c<\/code><\/p>\n<p>Example:<\/p>\n<pre>  ompicc -o executable file1.c file2.c\r\n<\/pre>\n<p>Basic options:<\/p>\n<ul style=\"list-style-type: none;\">\n<li>all (g)cc flags<\/li>\n<li><code>-k <\/code>: <em>the generated (transformed) file is kept after compilation<\/em><\/li>\n<li><code>-K <\/code>: <em>all intermediate generated files are kept after compilation<\/em><\/li>\n<li><code>-v <\/code>: <em>be verbose (shows all steps of the translation process)<\/em><\/li>\n<li><code>--options <\/code>: <em>show all available options (see below for some of them)<\/em><\/li>\n<\/ul>\n<div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Some handy options<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<ul style=\"list-style-type: none;\">\n<li><code>--info envs\u00a0<\/code>\n<ul style=\"list-style-type: none;\">\n<li><em>show all OpenMP and extra OMPi environmental variables names<br \/>\n <\/em><\/li>\n<\/ul>\n<\/li>\n<li><code>--info clause &lt;name&gt; <br \/>\n <\/code><\/p>\n<ul style=\"list-style-type: none;\">\n<li><em>show all OpenMP directives that accept &lt;name&gt; as a clause<\/em><\/li>\n<\/ul>\n<\/li>\n<li><code>--taskopt=&lt;type&gt; <br \/>\n <\/code><\/p>\n<ul style=\"list-style-type: none;\">\n<li><em>select tasking optimization type among <code>size<\/code>, <code>speed<\/code>, <code>speed+<\/code> (speed is the default)<\/em><\/li>\n<\/ul>\n<\/li>\n<li><code>--nolineno\u00a0<\/code>\n<ul style=\"list-style-type: none;\">\n<li><em>useful when debugging compiler errors; as a source-to-source compiler,\u00a0OMPi may not always produce very accurate position information for problematic transformed code. This option makes OMPi produce exact source line information but requires all the intermediate files to be kept (with the <code>-K<\/code> option).<\/em><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div><\/div>\n<div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Device options<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<p>Following OpenMP 4.0, OMPi supports attached devices that can execute offloaded code. Automatically configured devices are shown with the <code>ompiconf<\/code> utility, as follows:<\/p>\n<ul style=\"list-style-type: none;\">\n<li><code>ompiconf --devinfo[=devs]\u00a0<\/code>: <em>show short information about configured devices.<\/em><\/li>\n<li><code>ompiconf --devvinfo[=devs]\u00a0<\/code>: <em>show longer information about configured devices.<\/em><\/li>\n<\/ul>\n<p>To target specific devices when compiling an application, pass the <code>--devs<\/code> option to <code>ompicc<\/code>, as shown below.<\/p>\n<ul style=\"list-style-type: none;\">\n<li><code>--devs=\"\u2039name\u203a \u2039name\u203a ...\" <\/code>: <em>target the given devices<\/em><\/li>\n<li><code>--devopt [options] <\/code>: <em>options for particular devices.<\/em><\/li>\n<\/ul>\n<\/div><\/div>\n<div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>More usage details<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<p>OMPi is a source-to-source compiler, so after generating the multithreaded C program, it runs the system compiler &#8212; which by default is the one used during OMPi&#8217;s installation.<\/p>\n<p>If you want to play with different system compilers, and different compilation flags, you can set three environmental variables to whatever you like: <code>OMPI_CPP<\/code>, <code>OMPI_CC<\/code>, <code>OMPI_CPPFLAGS<\/code>, <code>OMPI_CFLAGS<\/code> and <code>OMPI_LDFLAGS<\/code>. The first two specify the system preprocessor and compiler you like to use and the last three ones the particular flags you want. Make sure you set their values <em>before<\/em> running <code>ompicc<\/code>.<\/p>\n<p>The\u00a0<code>--ort=\u2039libname\u203a<\/code> option lets you select any runtime library you might have built. For more information on this topic, please refer to the bundled <code>doc\/runtime.txt<\/code> file.<\/p>\n<p>The <code>--bundle-kernels<\/code> and\u00a0<code>--no-bundle-kernels<\/code> options let you override the default kernel bundling behavior, enabling\/disabling it only for a specific compilation.<\/p>\n<\/div><\/div>\n<p>Don&#8217;t forget to consult the implementation-specific OpenMP behaviors which are bundled with the OMPi source code package.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here you can find short installation and usage guides, as well as some documents about OMPi internals. More documentation is provided within the source distribution, found in our download page. Prerequisites The basic requirements for building and installing OMPi on your system are: The meson build system (version 0.58.0 or later required) A C compiler [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":120,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-972","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/pages\/972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/comments?post=972"}],"version-history":[{"count":33,"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/pages\/972\/revisions"}],"predecessor-version":[{"id":1453,"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/pages\/972\/revisions\/1453"}],"up":[{"embeddable":true,"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/pages\/120"}],"wp:attachment":[{"href":"https:\/\/paragroup.cse.uoi.gr\/wpsite\/wp-json\/wp\/v2\/media?parent=972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}