Unified Parallel C (UPC) is an extension of the C language designed for high-performance computing on large-scale parallel machines. The language represents a single program model for systems with shared and shared memory. The amount of parallelism is fixed at the start of the program, usually with one thread per processor core.
At one time, certain difficulties arose with the deployment of UPC and the absence of any prompts for the first steps in either the Russian or English segments of the Internet, except for the official INSTALL.TXT instruction, which had to be digested.
So that this experience was not in vain, I decided to write an article on installing UPC in various environments.
In case of difficulties or questions you can contact the creators for technical support . They answer fairly quickly (given the fact that they are on the other side of the planet). A big thanks to Paul Hargrove and Dan Bonachea for helping to figure it all out.
')
Installing Berkeley UPC on Windows
Environment preparation
Basically, the UPC is sharpened for Linux, so the first thing to do is install a Linux-like console and the necessary packages:
1. Install Cygwin (better in a folder with a name without spaces, for example, C: \ Programs \ Cygwin64)
→ www.cygwin.com/setup-x86.exe
→ www.cygwin.com/setup-x86_64.exe
In addition to the default installation, you will need to add gcc packages (gcc-core, gcc-g ++). You can check the installation with the command:
cygcheck -s
2. Install Perl or download it among Cygwin packages.
Installing Berkeley UPC
1. Download Berkeley UPC (C: \ Programs \ berkeley_upc-2.22.3 \ setup)
2. Create a build subdirectory (C: \ Programs \ berkeley_upc-2.22.3 \ setup \ build)
3. Start Cygwin
4. Run the configure script. To specify the installation directory, you need to use the option --prefix=dir
, to specify the default network --with-default-network=smp
(Symmetric Multiprocessing, local multi-core machine):
cd /cygdrive/c/Programs/berkeley_upc-2.22.3/setup/build ../configure --prefix=/cygdrive/c/Programs/berkeley_upc-2.22.3 --with-default-network=smp
SUCCESS! The configure step is now complete. You should now proceed with:
gmake; gmake install
5. Compile UPC:
make
6. Install UPC:
make install
Folders opt, dbg contain various build runtime libraries used by UPC code. The opt folder contains optimizations and is used by default. The dbg folder is used for debugging when using the –g option in upcc. Do not directly use the contents of these folders. You must use the upcc and upcrun utilities in the build folder or the bin subfolder in the installation folder.
In order not to specify the path to the utilities each time, you can add the bin path to the PATH environment variable (Computer Properties -> Advanced System Settings -> Environment Settings).
UPC configuration tests (optional)
0. Each build subfolder contains the upcc.conf configuration file. If necessary, check it and edit.
1. Minimum configuration test (from the build folder):
env UPCC_FLAGS= ./upcc --norc --version
This is the upcc (the Berkeley Unified Parallel C compiler), v. 2.22.3
(getting remote translator settings ...)
---------------------- + --------------------------- ------------------------------
UPC Runtime | v. 2.22.3, built on Oct 26 2016 at 10:22:58
---------------------- + --------------------------- ------------------------------
UPC-to-C translator | v. 2.22.2, built on May 12 2016 at 15:50:34
| host aphid linux-x86_64 / 64
| gcc v4.2.4 (Ubuntu 4.2.4-1ubuntu4)
---------------------- + --------------------------- ------------------------------
Translator location | upc-translator.lbl.gov/upcc-2.22.2.cgi
---------------------- + --------------------------- ------------------------------
networks supported | udp smp
---------------------- + --------------------------- ------------------------------
default network | smp
---------------------- + --------------------------- ------------------------------
pthreads support | available (if used, default is 2 pthreads per process)
---------------------- + --------------------------- ------------------------------
2. Compile tests:
make tests-hello
==== UPC "HELLO WORLD" TESTS SUCCESSFULLY COMPILED ====
Your UPC Compilation Setup: udp smp
UPC runtime operation for each network of interest.
Start by testing the single-node smp / pthreaded network, with a command like:
./upcrun -n 2 libupcr-smp-par-test
3. Check the results for each type of network:
./upcrun -n 2 ./opt/libupcr-smp-par-test
UPCR: UPC threads 0..1 of 2 on SERAVKIN-PC (process 0 of 1, pid = 17100)
Welcome to Berkeley UPC !!!
- Hello from thread 0
- Hello from thread 1
./upcrun -n 2 ./opt/libupcr-udp-par-test
upcrun: nodes not specified! See RUNNING UDP-BASED UPC JOBS in 'man upcrun'
Example
cd /cygdrive/c/Programs/berkeley_upc-2.22.3/bin ./upcc /cygdrive/c/Programs/berkeley_upc-2.22.3/upc-examples/hello.upc -o hello -pthreads ./upcrun -n 4 hello
UPCR: UPC threads 0..3 of 4 on SERAVKIN-PC (process 0 of 1, pid = 32016)
Welcome to Berkeley UPC !!!
- Hello from thread 2 !!!
- Hello from thread 1 !!!
- Hello from thread 3 !!!
- Hello from thread 0 !!!
Unpleasant restrictions
In the Windows environment, only the online UPC-to-C translator can be used (it is used by default). Therefore, you need to be online, it works slower. But the most stressful thing is that potentially Berkeley has the ability to intercept all programs. If the tasks are educational, then it’s okay, and if something serious, then it’s somehow uncomfortable. Plus, there are concerns that debugging only works on Linux. That all this business was got on Windows it is possible to install the virtual computer
Virtual ROSA Fresh
1. First you need to install a virtual manager, for example, Oracle VM VirtualBox .
2. Download the Linux image. The choice fell on ROSA Fresh KDE , because This is a domestic development.
3. Add a new machine Other Linux, allocate memory as much as you do not mind.
4. Configure:
System - Processor: processors - all cores, 90% limit (otherwise the main system will stop responding under heavy load).
Display - Screen: 96 MB video memory
Media - add image with linux
The network is a network bridge.
5. Start the virtual machine. Select Install ROSA Desktop, follow the system prompts. First impressions are positive.
Installing on Linux
Environment preparation
Rosa
1. Install g ++ by running the following command in the terminal:
urpmi gcc-c++
Alt linux
1. Install g ++ (via the repository or find the latest version):
apt-cache search gcc-c++ apt-get install gcc5-c++
2. Install perl-Term-ReadLine-Gnu
apt-get install perl-Term-ReadLine-Gnu
Installing Berkeley UPC-to-C translator
1. Download Berkeley UPC-to-C translator and open the terminal in a folder (via the context menu).
2. Run the make command:
make
- *** Build complete! ***
You may now install the compiler with:
make install PREFIX = / prefix / to / use
3. Run install with elevated privileges:
sudo make install
- *** Installation complete! ***
To use this translator LOCALLY, insert the following pathname:
/ usr / local / bupc_translator / targ
in the 'translator' setting of upcc.conf or ~ / .upccrc,
or pass it to upcc -translator = path
Build Berkeley UPC
1. Download Berkeley UPC
2. Create a build subfolder, open a terminal in a folder (via the context menu)
3. Run the configuration file with the local translator and the default smp network (Symmetric Multiprocessing, local multi-core machine):
../configure BUPC_TRANS=/usr/local/bupc_translator/targ --with-default-network=smp
SUCCESS! The configure step is now complete. You should now proceed with:
gmake; gmake install
4. Compile UPC:
make
UPC configuration tests (optional)
0. Each build subfolder contains the upcc.conf configuration file. Check it and edit as necessary.
1. Run the configuration test from the build folder:
env UPCC_FLAGS= ./upcc --norc --version
This is the upcc (the Berkeley Unified Parallel C compiler), v. 2.22.3
---------------------- + --------------------------- ------------------------------
UPC Runtime | v. 2.22.3, built on Oct 26 2016 at 14:01:01
---------------------- + --------------------------- ------------------------------
UPC-to-C translator | v. 2.22.2, built on Oct 25 2016 at 16:22:01
| host Rosa-VB linux-x86_64 / 64
| gcc v4.9.2 20140811 (ROSA)
---------------------- + --------------------------- ------------------------------
Translator location | / usr / local / bupc_translator / targ
---------------------- + --------------------------- ------------------------------
networks supported | udp smp
---------------------- + --------------------------- ------------------------------
default network | smp
---------------------- + --------------------------- ------------------------------
pthreads support | available (if used, default is 2 pthreads per process)
---------------------- + --------------------------- ------------------------------
2. Start the test compilation:
make tests-hello
==== UPC "HELLO WORLD" TESTS SUCCESSFULLY COMPILED ====
Your UPC Compilation Setup: udp smp
UPC runtime operation for each network of interest.
Start by testing the single-node smp / pthreaded network, with a command like:
./upcrun -n 2 libupcr-smp-par-test
3. Check the results for each type of network:
./upcrun -n 2 ./opt/libupcr-smp-par-test
UPCR: UPC threads 0..1 of 2 on Rosa-VB (pshm node 0 of 1, process 0 of 1, pid = 12494)
Welcome to Berkeley UPC !!!
- Hello from thread 1
- Hello from thread 0
./upcrun -n 2 ./opt/libupcr-udp-par-test
upcrun: nodes not specified! See RUNNING UDP-BASED UPC JOBS in 'man upcrun'
Installing Berkeley UPC
1. Run the make install command from build with elevated permissions. The default installation is in the / usr / local / berkeley_upc directory. To change the directory you can use the option --prefix=dir
sudo make install
2. Add the path to the environment variable. To do this, add a line to the /home/user/.bashrc file (automatic start when opening the terminal), or apply for the current session:
export PATH=$PATH:/usr/local/berkeley_upc/bin
3. Check the launch:
upcc --version
This is the upcc (the Berkeley Unified Parallel C compiler), v. 2.22.3
Example
1. Open a terminal in the upc-examples folder.
2. Execute commands:
upcc ./hello.upc -o hello -pthreads upcrun -n 4 hello
UPCR: UPC threads 0..1 of 4 on Rosa-VB (pshm node 0 of 1, process 0 of 2, pid = 13295)
UPCR: UPC threads 2..3 of 4 on Rosa-VB (pshm node 0 of 1, process 1 of 2, pid = 13320)
Welcome to Berkeley UPC !!!
- Hello from thread 1
- Hello from thread 3
- Hello from thread 0
- Hello from thread 2
Eclipse development environment
The Eclipse development environment has support for the Berkeley UPC language. Just unzip from the Eclipse for Parallel Application Developers archive. Read more about the Eclipse Parallel Tools Platform (PTP) project here .
After unpacking, you must perform the following settings:
0. Install Java Runtime Environment
1. Check for updates: Open the menu Help → Check For Updates. Update C / C ++ Berkeley UPC (Unified Parallel C) Toolchain Support
2. Create a new project “Hello World UPC Project”, Toolchains: Linux Berkeley UPC (many useful default settings)
3. Specify the path includes: open Project Properties → C / C ++ General → Path and Symbols. For UPC, add include paths:
Release Configuration:
/usr/local/berkeley_upc/opt/include/upcr_preinclude /usr/include
Debug configuration:
/usr/local/berkeley_upc/dbg/include/upcr_preinclude /usr/include
4. Disable spell checking for Russian comments. Right click on the comment, select Disable spell check.
5. Add quick buttons on the Russian layout. Window menu - Preferences - General - Editors - Keys. Copy the “Copy”, “Cut”, “Paste” items and add your own combination to the Binding field
Notes
Using
Many built-in manual:
man upcc man upcrun
Debugging
UPDATE: Berkeley Unified Parallel C (UPC). Debugging with the GNU gdb C debbuger. Call stack
Thank you for attention! I hope someone will come in handy