|
| 1 | +#!/bin/bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +prefix=${PREFIX:-$PWD} |
| 5 | +export PATH=${prefix}/bin:$PATH |
| 6 | + |
| 7 | +case "$(uname)" in |
| 8 | + Linux) |
| 9 | + so=".so" |
| 10 | + ;; |
| 11 | + Darwin) |
| 12 | + ldd () { otool -L "$1"; } |
| 13 | + so=".dylib" |
| 14 | + ;; |
| 15 | +esac |
| 16 | + |
| 17 | +tempdir="$(mktemp -d)" |
| 18 | +trap 'rm -rf $tempdir' EXIT |
| 19 | +cd "$tempdir" || exit |
| 20 | + |
| 21 | +cat > helloworld.c << EOF |
| 22 | +#include <mpi.h> |
| 23 | +#include <stdio.h> |
| 24 | +int main(int argc, char *argv[]) |
| 25 | +{ |
| 26 | + int size, rank, len; |
| 27 | + char name[MPI_MAX_PROCESSOR_NAME]; |
| 28 | +
|
| 29 | + MPI_Init(&argc, &argv); |
| 30 | + MPI_Comm_size(MPI_COMM_WORLD, &size); |
| 31 | + MPI_Comm_rank(MPI_COMM_WORLD, &rank); |
| 32 | + MPI_Get_processor_name(name, &len); |
| 33 | + printf("Hello, World! I am process %d of %d on %s.\n", rank, size, name); |
| 34 | + MPI_Finalize(); |
| 35 | + return 0; |
| 36 | +} |
| 37 | +EOF |
| 38 | +ln -s helloworld.c helloworld.cxx |
| 39 | + |
| 40 | +command -v mpicc |
| 41 | +command -v mpicxx |
| 42 | +echo "$(mpicc -show-incdir)/mpi.h": |
| 43 | +grep -E 'MPI_(SUB)?VERSION' "$(mpicc -show-incdir)/mpi.h" |
| 44 | +echo "$(mpicc -show-libdir)/lib$(mpicc -show-libs)$so": |
| 45 | +ldd "$(mpicc -show-libdir)/lib$(mpicc -show-libs)$so" |
| 46 | + |
| 47 | +set -x |
| 48 | + |
| 49 | +RPATH=-Wl,-rpath,$(mpicc -show-libdir) |
| 50 | + |
| 51 | +mpicc -show |
| 52 | +mpicc -show-incdir |
| 53 | +mpicc -show-libdir |
| 54 | +mpicc -show-libs |
| 55 | +for cc in gcc clang; do |
| 56 | + "$cc" -v > cc.log 2>&1 |
| 57 | + mpicc -cc="$cc" -v > mpicc.log 2>&1 |
| 58 | + diff cc.log mpicc.log |
| 59 | + mpicc -cc="$cc" ./helloworld.c -c |
| 60 | + test -f helloworld.o && rm helloworld.o |
| 61 | + mpicc -cc="$cc" ./helloworld.c "$RPATH" |
| 62 | + ldd a.out && rm a.out |
| 63 | +done |
| 64 | + |
| 65 | +mpicxx -show |
| 66 | +mpicxx -show-incdir |
| 67 | +mpicxx -show-libdir |
| 68 | +mpicxx -show-libs |
| 69 | +for cxx in g++ clang++; do |
| 70 | + "$cxx" -v > cxx.log 2>&1 |
| 71 | + mpicxx -cxx="$cxx" -v > mpicxx.log 2>&1 |
| 72 | + diff cxx.log mpicxx.log |
| 73 | + mpicxx -cxx="$cxx" ./helloworld.cxx -c |
| 74 | + test -f helloworld.o && rm helloworld.o |
| 75 | + mpicxx -cxx="$cxx" ./helloworld.cxx "$RPATH" |
| 76 | + ldd a.out && rm a.out |
| 77 | +done |
0 commit comments