Image on Docker Hub - https://hub.docker.com/r/olehkurpiak/openapi-kma
- added host file. gives ability to simulate more processors, then available on machine. #1
- Initial release
Run Docker image using docker run -it -v PROJECT_LOCATION:/tmp/project -v LOCAL_M2_PATH:/root/.m2 --name openmpi-kma olehkurpiak/openapi-kma:1.1
PROJECT_LOCATION
- path to java project on your local machine
LOCAL_M2_PATH
- path to yours .m2
folder(usually under ~/.m2
) - this will allow to cache maven dependencies, otherwise maven would require to download them on each new container start
File mpi.jar
is located under path /tmp/openmpi/lib/mpi.jar
inside container. You can extract it to your local machine using command docker cp openmpi-kma:/tmp/openmpi/lib/mpi.jar MY_LOCAL_PATH/mpi.jar
. Then you can add it to IDEA project as a jar dependency
You can also build java project using Maven with-in docker container.
- Add following dependency to you maven project
<dependency>
<groupId>mympi</groupId>
<artifactId>mympi</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/tmp/openmpi/lib/mpi.jar</systemPath>
</dependency>
- Go to
cd /tmp/project
inside container (Note that this is a path in container where project was mounted from local machine. This is from first command) - Run
mvn clean install
/mvn clean compile
Inside container run command mpirun -np 1 java -cp /tmp/project/target/classes com/mathpar/NAUKMA/examples/HelloWorldParallel
(Note: /tmp/project
as a root of classpath)
Initially docker could run only 5 processors but it can be increased.
The file which sets the number of available processors is located under path /root/hostfile
inside a container.
By default number of processors is set to 40.
Inside container run command mpirun --hostfile /root/hostfile -np 20 java -cp /tmp/project/target/classes com/mathpar/NAUKMA/examples/HelloWorldParallel
(Note: /tmp/project
as a root of classpath)