Skip to content

Commit

Permalink
Refs #4606 mpi script that runs on lens interactively but not in jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Janik Zikovsky committed Jan 22, 2012
1 parent 4ac9da2 commit 9f680ab
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Code/Mantid/Framework/MPIAlgorithms/scripts/CNCS_mpi_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#############################################################################################
#
# Example script to demonstrate the use of MPI in Mantid.
# This requires the boost.mpi python bindings, which can be obtained from
# http://mathema.tician.de/software/boostmpi and obviously an MPI-enabled Mantid build.
#
#############################################################################################

from MantidFramework import *
from mpi4py import MPI
mtd.initialise()

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.size

print "Running on rank %d of %d" % (rank, size)

eventfile="/ccs/home/8oz/Code/Mantid/Test/AutoTestData/CNCS_7860_event.nxs"
wksp="partial"
binning="40e3, 100, 70e3"

Load(Filename=eventfile, OutputWorkspace=wksp)

# Find which chunk to process
w = mtd[wksp]
chunk = w.getNumberHistograms() / size
startWI = rank*chunk
endWI = startWI + chunk - 1

# Do some processing (something silly for now)
SumSpectra(InputWorkspace=wksp, OutputWorkspace=wksp, StartWorkspaceIndex="%d"%startWI, EndWorkspaceIndex="%d"%endWI)
Rebin(InputWorkspace=wksp, OutputWorkspace=wksp, Params=binning)


# BroadcastWorkspace(InputWorkspace=van,OutputWorkspace="Vanadium",BroadcasterRank=len(runs))
GatherWorkspaces(InputWorkspace=wksp, OutputWorkspace="total")

if rank == 0:
SaveNexus(InputWorkspace="total",Filename="mpi.nxs")

22 changes: 22 additions & 0 deletions Code/Mantid/Framework/MPIAlgorithms/scripts/cncs_script.pbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#PBS -A CSC035
#PBS -N Mantid_CNCS_mpi_example
#PBS -j oe
#PBS -l walltime=00:10:00
#PBS -l nodes=2:ppn=16
# Email when it ends #PBS -m e

module load hdf5
module load ompi/1.4.3-gnu4.4.4
module load gcc/4.4.4

# Setup environment to point to home directory
export PATH=$HOME/bin:$PATH
export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$HOME/lib/python2.7/site-packages/

echo $LD_LIBRARY_PATH

cd /ccs/home/8oz/Code/Mantid/Code/Mantid/Framework/MPIAlgorithms/scripts
export MANTIDPATH=$HOME/Code/Mantid/framework/bin
export PYTHONPATH=$MANTIDPATH
mpirun ~/bin/python2.7 CNCS_mpi_example.py

0 comments on commit 9f680ab

Please sign in to comment.