Linux Programming (Cilk, MPI, OpenGL)
Last Updated: September 30, 2014
The omicrons have been set up to support cilk, mpi and openGL development.
Cilk Plus
The cilk compiler version installed on the omicrons is:
omicron07: g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/share/cilk/gcc-cilk/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-cilk-src/configure --prefix=/usr/home/testit/cilk/gcc-cilk-obj/../gcc-cilk --enable-languages=c,c++ : (reconfigured) ../gcc-cilk-src/configure --prefix=/usr/home/testit/cilk/gcc-cilk-obj/../gcc-cilk --enable-languages=c,c++ Thread model: posix gcc version 4.9.0 20130520 (experimental) (GCC)
The path to the cilk g++ compiler is:
/usr/share/cilk/gcc-cilk/bin/g++
The cilk libraries are found here:
/usr/share/cilk/gcc-cilk/lib /usr/share/cilk/gcc-cilk/lib64 /usr/share/cilk/gcc-cilk/lib32
cilktools
The cilktools cilkscreen and cilkview are here:
/usr/share/cilk/cilktools-linux-004225/bin
cilk tutorials
The cilk tutorials are located here:
/usr/share/cilk/tutorial-src
Compiling
I was able to compile one of the tutorials as follows:
g++ cilk-reducers-demo.cpp -o cilkprogram -lcilkrts -ldl -std=c++11 -fcilkplus
csh Shell
On the omicron network your environment variables should be set by default. The default shell for users is the csh shell.
You can manually add csh variables so they run everytime you login by placing them in the file ~/.cshrc
To manually set the environment variables in csh:
setenv PATH "/usr/share/cilk/cilktools-linux-004225/bin:/usr/share/cilk/gcc-cilk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Set cilk compiler paths setenv CC /usr/share/cilk/gcc-cilk/bin/gcc setenv GCC /usr/share/cilk/gcc-cilk/bin/gcc setenv CXX /usr/share/cilk/gcc-cilk/bin/g++ # Library paths setenv LD_LIBRARY_PATH "/usr/share/cilk/gcc-cilk/lib:/usr/share/cilk/gcc-cilk/lib64:/usr/share/cilk/gcc-cilk/lib32:/usr/lib/openmpi" setenv LIBRARY_PATH "/usr/share/cilk/gcc-cilk/lib:/usr/share/cilk/gcc-cilk/lib64:/usr/share/cilk/gcc-cilk/lib32:/usr/lib/openmpi" # include paths setenv CPATH "/usr/share/cilk/gcc-cilk/include:/usr/include/openmpi:/usr/include/GL:/usr/share/cilk/cilktools-linux-004225/include" setenv CPLUS_INCLUDE_PATH "/usr/share/cilk/gcc-cilk/include:/usr/include/openmpi:/usr/include/GL:/usr/share/cilk/cilktools-linux-004225/include" setenv INCLUDE "/usr/share/cilk/gcc-cilk/include:/usr/include/openmpi:/usr/include/GL:/usr/share/cilk/cilktools-linux-004225/include"
bash Shell
Another common shell is the bash shell, the env syntax is a bit different. Again this should be set by default for you.
You can manually add env variables so they automatically are set everytime you launch bash using the file ~/.bashrc
To manually set the env in bash:
export PATH="/usr/share/cilk/cilktools-linux-004225/bin:/usr/share/cilk/gcc-cilk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Set cilk compiler paths ... miles export CC=/usr/share/cilk/gcc-cilk/bin/gcc export GCC=/usr/share/cilk/gcc-cilk/bin/gcc export CXX=/usr/share/cilk/gcc-cilk/bin/g++ # Library paths export LD_LIBRARY_PATH="/usr/share/cilk/gcc-cilk/lib:/usr/share/cilk/gcc-cilk/lib64:/usr/share/cilk/gcc-cilk/lib32:/usr/lib/openmpi" export LIBRARY_PATH="/usr/share/cilk/gcc-cilk/lib:/usr/share/cilk/gcc-cilk/lib64:/usr/share/cilk/gcc-cilk/lib32:/usr/lib/openmpi" # Sep. 15, 2014 added more include paths ... miles export CPATH="/usr/share/cilk/gcc-cilk/include:/usr/include/openmpi:/usr/include/GL:/usr/share/cilk/cilktools-linux-004225/include" export CPLUS_INCLUDE_PATH="/usr/share/cilk/gcc-cilk/include:/usr/include/openmpi:/usr/include/GL:/usr/share/cilk/cilktools-linux-004225/include" export INCLUDE="/usr/share/cilk/gcc-cilk/include:/usr/include/openmpi:/usr/include/GL:/usr/share/cilk/cilktools-linux-004225/include"
MPI
The following should be in your PATH and LD_LIBRARY_PATH:
/usr/lib/openmpi
ssh without a password
First generate a new keypair:
omicron07: ssh-keygen -t rsa
Then copy the authorized key file. There is an ubuntu program that assists in doing this:
omicron07: ssh-copy-id -i ~/.ssh/id_rsa.pub your_account_name@omicron05
Then you will have to log into every omicron and answer ‘yes’ once before you can ssh without a password:
omicron07:~/.ssh% ssh omicron01 pwd The authenticity of host 'omicron01 (134.117.27.134)' can't be established. ECDSA key fingerprint is 37:05:96:9e:31:39:80:fd:ef:7e:93:08:03:31:d2:1d. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'omicron01,134.117.27.134' (ECDSA) to the list of known hosts. /home/4user2/your_account_name
Next time you run the command no password is required:
omicron07:~/.ssh% ssh omicron01 pwd /home/4user2/your_account_name
Removing all processees
When your running jobs on the omicrons it can happen that you have runaway processees. This can potentially be a problem.
There is a way to kill all your processees off every omicron machine. Log into any omicron and run the command:
bigboot.bash
It will ask you:
Do you want to kill every one of your processees off the omicron network (y/n)?
if you select ‘y’ then kill all your processees.
It will ask you one more time to kill all the processees off the machine your running the script on.
OpenGL
OpenGL requires the following environemnt variables:
CPATH=/usr/include/GL CPLUS_INCLUDE_PATH=/usr/include/GL INCLUDE=/usr/include/GL
Here is a sample program which I called opengl.cpp:
#include "GL/freeglut.h" #include "GL/gl.h" /* display function - code from: http://fly.cc.fer.hr/~unreal/theredbook/chapter01.html This is the actual usage of the OpenGL library. The following code is the same for any platform */ void renderFunction() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } /* Main method - main entry point of application the freeglut library does the window creation work for us, regardless of the platform. */ int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE); glutInitWindowSize(500,500); glutInitWindowPosition(100,100); glutCreateWindow("OpenGL - First window demo"); glutDisplayFunc(renderFunction); glutMainLoop(); return 0; }
Then compiling it is done as follows:
g++ opengl.cpp -lglut -lGL
The output should look like: