solo-io / unik

The Unikernel & MicroVM Compilation and Deployment Platform
Apache License 2.0
2.7k stars 193 forks source link

Run OpenFOAM on Rump Unikernel #88

Open miha-plesko opened 7 years ago

miha-plesko commented 7 years ago

So we are interested in running an OpenFOAM benchmark on Rump unikernel using UniK. OpenFOAM is a C++ library (for running physical simulations) that we are currently able to run on OSv. We have it statically compiled and now we run it with the following command (on the OSv):

--env=WM_PROJECT_DIR=/openfoam /usr/bin/simpleFoam.so -help

Attached please find HDD content of the OSv image with the OpenFOAM shared object: mpm-pkg.zip

We are unfamiliar with Rump unikernel so we would kindly ask you to help us port it also there. Could you please try to run it on Rump and check if you get same result as we do:

Usage: simpleFoam.so [OPTIONS]
options:
  -case <dir>       specify alternate case directory, default is the cwd
  -noFunctionObjects
                    do not execute functionObjects
  -parallel         run in parallel
  -roots <(dir1 .. dirN)>
                    slave root directories for distributed running
  -srcDoc           display source code in browser
  -doc              display application documentation in browser
  -help             print the usage

Using: OpenFOAM-2.4.0 (see www.OpenFOAM.org)
Build: 2.4.0-d38eb626a18c

This is, ofcourse, only the "hello world" for the OpenFOAM. Once this works we should try to run it with some data.

miha-plesko commented 7 years ago

I'm gonna CC a collegue of mine below. He has a lot of experience with compiling libraries so he could help if any problem arises.

/cc @justinc1

justinc1 commented 7 years ago

About how is OpenFOAM compield for OSv - is more or less the same as for Linux, we just added "-fPIC -fpic" to CFLAGS, and when linking .o files we add "-shared" flag. In short, the required steps are:

VERSION=2.4.0
BASEDIR=$PWD
ROOTFS=$BASEDIR/ROOTFS
SRCDIR=$BASEDIR/OpenFOAM-$VERSION

wget http://downloads.sourceforge.net/foam/OpenFOAM-$VERSION.tgz
tar zxf OpenFOAM-$VERSION.tgz

export MAKEFLAGS="-j `nproc`"
export FOAM_INST_DIR=$BASEDIR
. $SRCDIR/etc/bashrc

# First, compile the wmake used to build OpenFOAM sources.
cd $SRCDIR/wmake/src
make

# Make the OpenFOAM library
cd $SRCDIR/src
./Allwmake

# already compiled, I think
cd $SRCDIR/applications/solvers/incompressible/simpleFoam
wmake

# simpleFoam binary is in
$SRCDIR/platforms/$WM_OPTIONS/bin/simpleFoam

PS: the above lines are from https://github.com/mikelangelo-project/mike-apps/blob/master/OpenFOAM/GET

Before running any of OpenFOAM solvers (simpleFoam is just one of them), you need to source the $SRCDIR/etc/bashrc file to set PATH and other environ variables. Hope this helps.

@miha-plesko you should assigned someone to the issue