Alert.png The wiki is deprecated and due to be decommissioned by the end of September 2022.
The content is being migrated to other supports, new updates will be ignored and lost.
If needed you can get in touch with EGI SDIS team using operations @ egi.eu.

MPI Certification Job template

From EGIWiki
Jump to navigation Jump to search

MPI Certification Job

Examples of needed files:

  • newmpi.jdl
JobType = "Normal";
CPUNumber = 2;
Executable = "mpi-start-wrapper.sh";
Arguments = "hello MPICH";
StdOutput = "mpi-test.out";
StdError = "mpi-test.err";
InputSandbox = {"mpi-start-wrapper.sh","mpi-hooks.sh","hello.c"};
OutputSandbox = {"mpi-test.err","mpi-test.out"};
#Requirements =
#  Member("MPICH", other.GlueHostApplicationSoftwareRunTimeEnvironment)
 # && Member("OPENMPI", other.GlueHostApplicationSoftwareRunTimeEnvironment);
#Requirements = other.GlueCEInfoLRMSType == "PBS" || other.GlueCEInfoLRMSType == "LSF";
Requirements  = other.GlueCEInfoHostName == "unipa-ce-01.pa.pi2s2.it";


$ less hello.c
#include <stdio.h>
#include <mpi.h>

int main(int argc, char *argv[]) {
  int numprocs, rank, namelen;
  char processor_name[MPI_MAX_PROCESSOR_NAME];

  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Get_processor_name(processor_name, &namelen);

  printf("Process %d on %s out of %d\n", rank, processor_name, numprocs);

  MPI_Finalize();
}


$ less mpi-hooks.sh 
#!/bin/sh

#
# This function will be called before the MPI executable is started.
# You can, for example, compile the executable itself.
#
pre_run_hook () {

  # Compile the program.
  echo "Compiling ${I2G_MPI_APPLICATION} with `which mpicc`"

  # Actually compile the program.
  cmd="mpicc ${MPI_MPICC_OPTS} -o ${I2G_MPI_APPLICATION} ${I2G_MPI_APPLICATION}.c"
  echo $cmd
  $cmd
  if [ ! $? -eq 0 ]; then
    echo "Error compiling program.  Exiting..."
    exit 1
  fi

  # Everything's OK.
  echo "Successfully compiled ${I2G_MPI_APPLICATION}"

  return 0
}
echo "zazzazzareo " hostname
#
# This function will be called before the MPI executable is finished.
# A typical case for this is to upload the results to a storage element.
#
post_run_hook () {

  echo "Executing post hook."
  echo "Finished the post hook."

  return 0
}


$ less mpi-start-wrapper.sh 
#!/bin/bash

# Pull in the arguments.
MY_EXECUTABLE=`pwd`/$1
MPI_FLAVOR=$2

# Convert flavor to lowercase for passing to mpi-start.
MPI_FLAVOR_LOWER=`echo $MPI_FLAVOR | tr '[:upper:]' '[:lower:]'`

# Pull out the correct paths for the requested flavor.
eval MPI_PATH=`printenv MPI_${MPI_FLAVOR}_PATH`

# Ensure the prefix is correctly set.  Don't rely on the defaults.
eval I2G_${MPI_FLAVOR}_PREFIX=$MPI_PATH
export I2G_${MPI_FLAVOR}_PREFIX

# Touch the executable.  It exist must for the shared file system check.
# If it does not, then mpi-start may try to distribute the executable
# when it shouldn't.
touch $MY_EXECUTABLE

# Setup for mpi-start.
export I2G_MPI_APPLICATION=$MY_EXECUTABLE
export I2G_MPI_APPLICATION_ARGS=
export I2G_MPI_TYPE=$MPI_FLAVOR_LOWER
export I2G_MPI_PRE_RUN_HOOK=mpi-hooks.sh
export I2G_MPI_POST_RUN_HOOK=mpi-hooks.sh

# If these are set then you will get more debugging information.
export I2G_MPI_START_VERBOSE=1
export I2G_MPI_START_DEBUG=1
export I2G_MPI_START_TRACE=1

# Invoke mpi-start.
$I2G_MPI_START

echo "Running on: $HOSTNAME"
echo "*************************************"
echo "ARCH=`arch`"
echo "*************************************"
echo "uname_out=`uname -a`"
echo "*************************************"
echo "mpicc_arch=`file /opt/mpich-1.2.7p1/bin/serv_p4`"
echo "*************************************"
echo "gcc_arch=$(file $(which gcc))"
echo "*************************************"
echo "infiniband=$(grep infiniband /proc/devices)"
echo "*************************************"
echo "cpu_info=`cat /proc/cpuinfo`"
echo "*************************************"

exit 0