Skip to content

Commit

Permalink
change run.sh to allow for MPI typechecking tests
Browse files Browse the repository at this point in the history
When executed with --mpi_intercept the script now uses mpic++ to
compile the source files and mpirun -n 2 to run the resulting
program.
  • Loading branch information
alexanderlinne committed Jun 16, 2021
1 parent b8295b9 commit 82c6a64
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
22 changes: 13 additions & 9 deletions scripts/run.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ if [ "$extension" == "c" ]; then
omp_flags="@OpenMP_C_FLAGS@" # -I@OpenMP_C_INCLUDE_DIRS@
fi
else
compiler=clang++
if [[ $with_intercept != 1 ]]; then
compiler=clang++
else
compiler=mpic++
fi
if [ $with_omp == 1 ]; then
omp_flags="@OpenMP_CXX_FLAGS@" # -I@OpenMP_CXX_INCLUDE_DIRS@
fi
Expand All @@ -74,22 +78,22 @@ sanitizer_flags="@TYPEART_SAN_FLAGS@"
function make_no_optim() {
# Order: heap and stack/global together, no optimization pass
if [ $skip_typeart == 0 ]; then
$compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_combined_mode_args $ta_more_args | llc -x=ir -filetype=obj -o "$tmpfile".o
OMPI_CXX=clang++ $compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_combined_mode_args $ta_more_args | llc -x=ir -filetype=obj -o "$tmpfile".o
else
# First create types.yaml:
$compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_combined_mode_args $ta_more_args > /dev/null
$compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | llc -x=ir -filetype=obj -o "$tmpfile".o
OMPI_CXX=clang++ $compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_combined_mode_args $ta_more_args > /dev/null
OMPI_CXX=clang++ $compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | llc -x=ir -filetype=obj -o "$tmpfile".o
fi
}

function make_with_optim() {
# Order: heap, optimize, alloca with additional args.
if [ $skip_typeart == 0 ]; then
$compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_heap_mode_args $ta_more_args | opt $optimize -S | opt $typeart_plugin $typeart_stack_mode_args $ta_more_args | llc -x=ir -filetype=obj -o "$tmpfile".o
OMPI_CXX=clang++ $compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_heap_mode_args $ta_more_args | opt $optimize -S | opt $typeart_plugin $typeart_stack_mode_args $ta_more_args | llc -x=ir -filetype=obj -o "$tmpfile".o
else
# First create types.yaml:
$compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_heap_mode_args $ta_more_args | opt $optimize -S | opt $typeart_plugin $typeart_stack_mode_args $ta_more_args > /dev/null
$compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $optimize | llc -x=ir -filetype=obj -o "$tmpfile".o
OMPI_CXX=clang++ $compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin $typeart_heap_mode_args $ta_more_args | opt $optimize -S | opt $typeart_plugin $typeart_stack_mode_args $ta_more_args > /dev/null
OMPI_CXX=clang++ $compiler $typeart_includes $omp_flags $sanitizer_flags -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $optimize | llc -x=ir -filetype=obj -o "$tmpfile".o
fi
}

Expand All @@ -106,7 +110,7 @@ function compile() {
make_with_optim
fi

$compiler "$tmpfile".o $omp_flags $threads_flags $sanitizer_flags -L@TYPEART_RT_DIR@ -ltypeart-rt -o "$tmpfile".exe
OMPI_CXX=clang++ $compiler "$tmpfile".o $omp_flags $threads_flags $sanitizer_flags -L@TYPEART_RT_DIR@ -ltypeart-rt -o "$tmpfile".exe
}

compile
Expand All @@ -117,7 +121,7 @@ fi

if [ $with_intercept == 1 ]; then
echo -e Executing with runtime and interceptor lib
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@TYPEART_RT_DIR@" LD_PRELOAD=@TYPEART_MPI_INTERCEPT_DIR@/@TYPEART_MPI_INTERCEPT_LIB@ ./"$tmpfile".exe
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@TYPEART_RT_DIR@" LD_PRELOAD=@TYPEART_MPI_INTERCEPT_DIR@/@TYPEART_MPI_INTERCEPT_LIB@ mpirun -n 2 "$tmpfile".exe
else
echo -e Executing with runtime lib
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@TYPEART_RT_DIR@" ./"$tmpfile".exe
Expand Down
29 changes: 29 additions & 0 deletions test/mpi_typecheck/01_MPI_Double.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: %run %s --mpi_intercept 2>&1 | FileCheck %s

#include <mpi.h>
#include <stdlib.h>

int main(int argc, char** argv) {
MPI_Init(&argc, &argv);

// CHECK: [Trace] TypeART Runtime Trace

// CHECK: [Trace] Alloc 0x{{.*}} double 8 16
const auto n = 16;
auto f = new double[n];

int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

if (rank == 0) {
MPI_Send(f, n, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD);
} else {
MPI_Recv(f, n, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}

// CHECK: [Trace] Free 0x{{.*}}
delete[] f;

MPI_Finalize();
return 0;
}

0 comments on commit 82c6a64

Please sign in to comment.