This small gist contains the required steps to compile and install Berkeley's UPC implementation.
This script is far from being fail-safe, but worked on my end. Good luck!
To build UPC, you will need to have autoconf
and a set of C
/C++
compilers.
The script defaults to using gcc
/g++
and will install UPC
in ~/.berkeley
. If you wish to change this behavior, you will have to edit the first lines of the script.
You will also need a version of perl
installed, accessible through the perl
command.
The main component of Berkeley's UPC toolset is upc-runtime
. It provides the command upcc
, to compile UPC code to bytecode, and upcrun
, to create the threads and run the code.
The script compile-upc.sh
included with this gist will download the sources, build and install upc-runtime
. You can manually download, edit and run it, or run the following commands to do it from the terminal:
curl -o compile-upc.sh https://gist.githubusercontent.com/adri326/471d02e55bc541f8eb158e004cd1582d/raw/compile-upc.sh
chmod +x compile-upc.sh
# Optionally edit `compile-upc.sh` now!
./compile-upc.sh
# Edit your bashrc/zshrc to add the installation directory to your PATH if the build succeeded and if you haven't done so already.
You can safely skip this step if you do not care about compilation speed and internet requirement.
By default, upcc
(the included compiler) does not actually do the translation from UPC to C. This task is offloaded to one of Berkeley Lab's servers through HTTPS. Their argument is that the compilation step from C to bytecode will certainly take longer than the HTTPS request. The server runs an instance of upc-translator
, which takes approximately 200MB of space on the disk (no idea why it's so big, especially since Intrepid's deprecated upc2c is much smaller).
The compile-translator.sh
script aims to fetch upc-translator
, compile it, install it and tweak upcc
's config file to use it instead.
For unknown reasons, make
cannot be run in multithreaded mode for upc-translator
(it inevitably fails at random points of the compilation process). The compilation step should only take approximately 10 minutes on modern hardware.
To compile upc-translator
, you will need gcc <= 10
(as of writing this, their codebase relies on older C++ versions); on Arch Linux, you can install gcc9 from the AUR. The script defaults to gcc9
's binary paths.
You will also need csh
(on Arch Linux, install tcsh
).
Sometimes, the build randomly fails because of a missing "YYLEX" variable; this happens because the build script modifies one of the source files which cannot be built with modern versions of yacc/bison. To counter this, when an error occur the affected file is restored and the compilation is resumed.
You may manually download, edit and run compile-translator.sh
, or run the following commands:
curl -o compile-translator.sh https://gist.githubusercontent.com/adri326/471d02e55bc541f8eb158e004cd1582d/raw/compile-translator.sh
chmod +x compile-translator.sh
# Optionally edit `compile-translator.sh` now!
./compile-translator.sh
# Edit ~/.upccrc to point to the newly-installed translator if you haven't done that yet!