Previous: , Up: Examples   [Contents][Index]


5.5 Calling MPI functions

The coNCePTuaL language is designed to be highly portable. Any coNCePTuaL program can be compiled using any of the backends listed in Supplied backends. A consequence of this portability is that coNCePTuaL does not include primitives that are specific to any particular target language or communication library.

The BACKEND EXECUTES and BACKEND DECLARES statements (see Injecting arbitrary code, and Backend-specific declarations) give a programmer the ability to sacrifice portability for the ability to measure the performance of features provided by a specific target language or communication library. Hence, it is possible to write the core parts of a benchmark in a lower-level language while letting coNCePTuaL handle the setup, measurement, logging, and other mundane operations.

The following program uses BACKEND EXECUTES to measure the performance of the MPI_Allgather() function provided by an MPI library. Because it utilizes C code to call an MPI function, the code builds only with the c_mpi backend.

# Measure the performance of MPI_Allgather()
# By Scott Pakin <pakin@lanl.gov>
#
# N.B. Requires the c_mpi backend.

Require language version "1.5".

# Parse the command line.
numwords is "Message size (words)" and comes from "--msgsize" or "-s" with
default 1.

# Allocate a send buffer and a receive buffer.
Task 0 multicasts a numwords-word message from buffer 0 to all other tasks.
Task 0 multicasts a numwords*num_tasks word message from buffer 1 to all
other tasks.

# Measure the performance of MPI_Allgather().
Task 0 resets its counters then
for 100 repetitions plus 3 warmup repetitions
  all tasks backend execute "
    MPI_Allgather([MESSAGE BUFFER 0], (int)" and numwords and ", MPI_INT,
                  [MESSAGE BUFFER 1], (int)" and numwords and ", MPI_INT,
                  MPI_COMM_WORLD);
  " then
task 0 logs elapsed_usecs/100 as "Gather time (us)".

The preceding code demonstrates a few useful techniques:


Previous: , Up: Examples   [Contents][Index]

Scott Pakin, pakin@lanl.gov