What is GNU UPC?

The GNU UPC compiler extends the capabilities of the GNU GCC compiler for programs written in UPC language and it is implemented as a C Language dialect translator.

Who maintains GNU UPC?

GNU UPC is being maintained by Intrepid Technology, Inc..

What is UPC?

UPC is a parallel extension to the C Standard. UPC follows the partitioned global address space [CAG93] programming model. The first version of UPC, known as version 0.9, was published in May of 1999 as technical report [CDC99] at the Institute for Defense Analyses Center for Computing Sciences.

Configuring GNU UPC

Missing UPC compiler after successful configure/build/install

By default GNU GCC builds C and C++ languages. As UPC is an optional language (same as Fortran, Ada, e.g.) it must be specified during the configuration time by providing an appropriate <i>--enable-languages</i> option (e.g. <b>--enable-languages=c,c++,upc</b>).

Libgcc library fails to configure

In some situations, in the process of building GNU UPC, you might see the following error while going through the process of building libgcc library:

configure: error: cannot compute suffix of \
object files: cannot compile

This is indicative that just built gcc is not able to compile and create object files. The most likely reason is that GCC is not able to find gmp/mpfr/mpc dynamic link libraries. In this case you need to add locations of those libraries to your LD_LIBRARY_PATH. For example:


Is GCC UPC available on Ubuntu Linux?

Yes, it is. Here are the steps you need to take for successful configuration and build of GCC UPC on Ubuntu Lucid (version 10).

  • Make sure gmp, mpfr, and mpc libraries are installed on the system
    $ aptitude search libgmp3 libmpfr libmpc
    i A libgmp3-dev     - Multiprecision arithmetic library developers tool
    p   libgmp3-doc     - Multiprecision arithmetic library example code   
    i   libgmp3c2       - Multiprecision arithmetic library                
    i   libmpc-dev      - multiple precision complex floating-point library
    i   libmpc2         - multiple precision complex floating-point library
    p   libmpcdec-dev   - Musepack (MPC) format library [development files]
    p   libmpcdec3      - Musepack (MPC) format library                    
    i A libmpfr-dev     - multiple precision floating-point computation dev
    p   libmpfr-doc     - multiple precision floating-point computation  
    On Ubuntu Lucid all the required libraries for GCC UPC are installed (gmp, mpfr) or available for installation (mpc). If necessary install mpc library with "aptitude install libmpc".
  • By default GCC UPC builds with with "multilib" option enabled that allows you to create object files for both 64 and 32 bits targets. Also, by default, Ubuntu does not install required 32-bit environment which makes the build of GCC UPC fail. Additional installation is required - "aptitude install ia32-libs".

Is GNU UPC available on CentOS Linux?

Here are the steps you need to take for successful configuration and build of GCC UPC on CentOS 5.5.

  • Make sure development tools and libraries are installed on your system. If not, install them, or make sure that system administrator does it, by using the following commands:
    yum groupinstall "Development Tools"
    yum groupinstall "Development Libraries"
  • Make sure gmp, mpfr, and mpc libraries are installed on the system
    $ rpm -qa gmp\*
    $ rpm -qa mpfr\*
    $ rpm -qa mpc\*
On CentOS 5.5 only gmp library is installed and it is bellow the required 4.2 version number. Please check "How do I install GCC UPC prerequisite libraries?" FAQ under GCC UPC Configuration for more details on building the necessary prerequisite libraries.

How do I install GNU UPC prerequisite libraries (GMP, MPFR, MPC)?

GUPC requires that correct versions of GMP, MPFR, and MPC libraries are installed on the system that you plan to use for the building process. In most cases, these libraries are already available or can be easily installed using the system update utilities (e.g. the 'yum' utility on Fedora Linux or the 'apt-get' on Debian/Ubuntu).

However, if for some reason you need to build them on your own, the easiest way to install the necessary pre-requisite library sources is to copy them under a directory called 'src', that is created directly below the GNU UPC top-level source tree.

For this purpose, a script 'contrib/download_prerequisites' is available in the GUPC source directory. Simply execute the script from the 'src' directory and appropriate source code of prerequisites will be downloaded.

If for some reason prerequisite libraries are installed in some other directories then default system libraries, you need to add them to your 'LD_LIBRARY_PATH' environment variable.



Usage of GDB UPC

GDB UPC fails to create a collective breakpoint

In some cases GDB UPC does not insert a collective breakpoint, even though UPC mode is enabled. This will create a situation where only one thread (current thread when breakpoint was inserted) stops while others complete the program or continue running the UPC barrier code.

The most likely cause of this behavior is that UPC program is compiled with NO debugging options. To successfully use all features of the GDB UPC, a program must be compiled with "-O0 -g -dwarf-2-upc" options.

GDB UPC Error Messages

In some instances the user may encounter an error while printing a shared variable. In most of the cases this is caused by GDB UPC's inability to read data from the running thread.

For example, if variable is declared as "shared int A[NTHREADS]" than GDB UPC command "p A" would fail if any of the threads is running. Use "interrupt" command in upc mode or "interrupt -a" otherwise to stop all threads.

Usage of GNU UPC

How do I specify the value of THREADS (dynamically) at runtime?

First do not compile any of the UPC source files in your application with a compile-time specified value. Then, at runtime, provide the -fupc-threads-n option on the command line, just after the executable program's file name. The UPC runtime strips off all of the initial command line arguments that begin with the prefix -fupc-, and passes the remaining arguments to your application's main program. The following example, shows how this is done:

% cat dynamic.upc
main () { if (MYTHREAD == 0)
printf ("There are %d UPC threads.\n", THREADS); } % upc dynamic.upc -o dynamic % dynamic -fupc-threads-7 There are 7 UPC threads.

My program terminates with the message

Any attempt to cast a shared pointer to a local per-thread pointer is considered erroneous if the thread component of the shared pointer does not equal the thread number of the referencing thread. This error can arise, even though the program doesn't try to dereference the invalid local pointer. The following example illustrates this situation.

% cat badptr.upc

shared int v[THREADS];

main ()
int *vp;
vp = (int *) &v[0];
if (MYTHREAD == 0)
printf ("v[0] = %d\n", *vp);
% upc -fupc-threads-4 badptr.upc -o badptr
% badptr
badptr: UPC error: Invalid conversion of shared address to local pointer.
Thread does not have affinity to shared address.
v[0] = 0
thread 3 terminated with signal: 'Aborted' Terminated

The error can be corrected by ensuring that the pointer conversion is made only in a valid context.

% cat goodptr.upc

shared int v[THREADS];

main ()
if (MYTHREAD == 0)
int *vp = (int *) &v[0];
printf ("v[0] = %d\n", *vp);
% upc -fupc-threads-4 goodptr.upc -o goodptr
% goodptr
v[0] = 0

How do I specify the value of THREADS (statically) at compile time?

<p>The <strong>-<span>fupc</span>-threads-n</strong> switch specifies the number of threads to be created. For example, the following command tells the UPC compiler to use a value of 32 for the value of THREADS, when compiling the source file <span><span>src.upc</span></span>.</p>
<pre id="source">% upc -fupc-threads-32 src.upc</pre>
<p><strong>NOTE:</strong> The same value of <strong>n</strong> must be specified for all UPC source files compiled into a given application.</p>

JSN Venture template designed by