diff --git a/darshan-runtime/Makefile.am b/darshan-runtime/Makefile.am index cdc4527b3..562b83896 100644 --- a/darshan-runtime/Makefile.am +++ b/darshan-runtime/Makefile.am @@ -8,9 +8,6 @@ ACLOCAL_AMFLAGS = -I ../maint/config SUBDIRS = lib pkgconfig share test bin_SCRIPTS = darshan-config \ - darshan-gen-cc.pl \ - darshan-gen-cxx.pl \ - darshan-gen-fortran.pl \ darshan-mk-log-dirs.pl EXTRA_DIST = darshan-config.in \ diff --git a/darshan-runtime/configure.ac b/darshan-runtime/configure.ac index 4d3618410..fbed43197 100644 --- a/darshan-runtime/configure.ac +++ b/darshan-runtime/configure.ac @@ -985,9 +985,6 @@ AM_CONDITIONAL(HAVE_LDMS, [test "x$enable_ldms_mod" = xyes]) AC_CONFIG_FILES(Makefile \ darshan-config \ darshan-mk-log-dirs.pl \ - darshan-gen-cc.pl \ - darshan-gen-cxx.pl \ - darshan-gen-fortran.pl \ lib/Makefile \ test/Makefile \ pkgconfig/Makefile \ diff --git a/darshan-runtime/darshan-gen-cc.pl.in b/darshan-runtime/darshan-gen-cc.pl.in deleted file mode 100644 index da4c07fe0..000000000 --- a/darshan-runtime/darshan-gen-cc.pl.in +++ /dev/null @@ -1,373 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (C) 2015 University of Chicago. -# See COPYRIGHT notice in top-level directory. -# - -# takes a standard mpicc script as an argument and tried to generate a -# darshan-enabled mpicc script to mimic it's behavior - -use Getopt::Long; -use English; - -my $PREFIX="@prefix@"; - -my $input_file = ""; -my $output_file = ""; -my $trim_exe_path = 0; -my $xl_check=0; - -process_args(); - -# run original mpicc with -show argument to capture command line for -# compilation and linking -my $compile_cmd = `$input_file -show -c foo.c`; -if (!($compile_cmd)) -{ - printf STDERR "Error: failed to invoke $input_file with -show\n"; - exit(1); -} - -my $link_cmd = `$input_file -show foo.o -o foo`; -if (!($link_cmd)) -{ - printf STDERR "Error: failed to invoke $input_file with -show\n"; - exit(1); -} - -# we just want the first line of output from the mpi script's -v argument; -# the rest we assume will be generated by the underlying compiler -my $version_out = `$input_file -v 2>/dev/null |head -n 1`; -if (!($version_out)) -{ - printf STDERR "Error: failed to invoke $input_file with -v\n"; - exit(1); -} - -# check command lines for accuracy -if(!($compile_cmd =~ /-c foo.c/) || !($link_cmd =~ /foo.o -o foo/)) -{ - printf STDERR "Error: faulty output from $input_file with -show.\n"; - exit(1); -} -chomp($compile_cmd); -chomp($link_cmd); -chomp($version_out); - -# -# Incomprehensible re to eat the leading path of the compiler command -# and only give the basename. -# -# /cmd -> cmd -# cmd -> cmd -# /x/y/x/z/cmd -> cmd -# -if ($trim_exe_path) -{ - $compile_cmd =~ s/\/*([^\/ ]+\/)*//; - $link_cmd =~ s/\/*([^\/ ]+\/)*//; -} - -open (OUTPUT, ">$output_file") || die("Error opening output file: $!"); - -# split the link command from the original mpicc script so that we have the -# part before the "foo.o -o foo", which is assumed to be CC, and the part -# that comes afterwards, which is assumed to be the required link flags and -# libraries. -if(!($link_cmd =~ /(\S+)(.+)(foo.o -o foo)\s+(.*)/)) -{ - printf STDERR "Error: improperly formatted link cmd: $link_cmd\n"; - exit(1); -} -$CC_from_link=$1; -$link_cmd_prefix=$2; -$base_link_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4"; -$link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$PREFIX/bin/darshan-config --pre-ld-flags` $4 `$PREFIX/bin/darshan-config --post-ld-flags`"; -$dyn_link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$PREFIX/bin/darshan-config --dyn-ld-flags` $4"; - -# repeat the above step for the compilation command line -if(!($compile_cmd =~ /(\S+)(.+)(-c foo.c)\s+(.*)/)) -{ - printf STDERR "Error: improperly formatted compile cmd: $compile_cmd\n"; - exit(1); -} -$CC_from_compile=$1; -$compile_cmd_prefix=$2; -$compile_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4"; - -# we expect to see the same CC command in both the link and compile steps -if($CC_from_link ne $CC_from_compile) -{ - printf STDERR "Error: cannot find matching CC from: $compile_cmd\n"; - printf STDERR "and: $link_cmd\n"; - exit(1); -} -$CC=$CC_from_compile; - -# create link cmd with noshrargs variable -$link_cmd_no_shared_suffix = $base_link_cmd_suffix; -$link_cmd_no_shared_suffix =~ s/allargs/noshrargs/; - -print OUTPUT<<"EOF"; -#!/bin/bash -# -# Auto-generated mpicc script from darshan-gen-cc.pl -# -# -# Internal variables -# Show is set to echo to cause the compilation command to be echoed instead -# of executed. -Show= -CC=\${MPICH_CC:-"$CC"} - -EOF - -if ($xl_check == 1) -{ -print OUTPUT<<'EOF'; -# -# Check for IBM XL Linker Parameters -# -# If IPA linker is used, we must disable darshan -# because the IPA linker doesn't support -wrap. -# -function check_XL() -{ - arg=$1; - ipa_enabled=0; - - if [ "$arg" = "-O5" ]; then - ipa_enabled=1; - fi - if [ "$arg" = "-O4" ]; then - ipa_enabled=1; - fi - if [ "$arg" = "-qipa" ]; then - ipa_enabled=1; - fi - - return $ipa_enabled; -} -EOF -} - -print OUTPUT<<'EOF'; -linking=yes -allargs=("$@") -argno=0 -for arg in "$@" ; do - # Set addarg to no if this arg should be ignored by the C compiler - addarg=yes - case "$arg" in - # ---------------------------------------------------------------- - # Compiler options that affect whether we are linking or no - -c|-S|-E|-M|-MM) - # The compiler links by default - linking=no - ;; - -v) - # Pass this argument to the compiler as well. -EOF -print OUTPUT<<"EOF"; - echo "$version_out" -EOF -print OUTPUT<<'EOF'; - # if there is only 1 argument, it must be -v. - if [ "$#" -eq "1" ] ; then - linking=no - fi - ;; - -cc=*) - CC=`echo A$arg | sed -e 's/A-cc=//g'` - addarg=no - ;; - -show) - addarg=no - Show=echo - ;; - esac - if [ $addarg = no ] ; then - unset allargs[$argno] - fi - # Some versions of bash do not accept ((argno++)) - argno=`expr $argno + 1` -done -if [ "$linking" = yes ] ; then - if [ -n "$C_LINKPATH_SHL" ] ; then - # prepend the path for the shared libraries to the library list - mpilibs="$C_LINKPATH_SHL$libdir $mpilibs" - fi -EOF -print OUTPUT<<"EOF"; - - # if allargs includes any libraries, then we need to get - # -ldarshan in there first - argno=0; - once=0; - compiler_check=0; - newallargs=\("\$\{allargs\[\@\]\}"\); - for arg in "\$\{newallargs\[\@\]\}"; do - res=`expr match "\$arg" "-l"`; - if [ \$res -gt 0 -a \$once -lt 1 ]; then - newallargs[\$argno]=-ldarshan - argno=`expr \$argno + 1` - newallargs[\$argno]=\$arg; - once=1; - else - newallargs[\$argno]=\$arg; - fi -EOF - -# -# Add any functional tests for linker parameters -# - if ($xl_check) - { -print OUTPUT<<"EOF"; - check_XL "\$arg"; - if [ \$? -ne 0 ]; then - compiler_check=1; - fi -EOF - } - -print OUTPUT<<"EOF"; - argno=`expr \$argno + 1` - done - - used_darshan=0 - - # Perform a test link before the real link. This allows us to check - # for two things: - # 1) Are MPI symbols present? Technically Darshan should not harm - # non-MPI programs, but it may bring in unwanted dependencies or - # interfere with autoconf checks. - # 2) Is this link command line going to produce a static or dynamic - # linked executable? We will adjust Darshan link strategy accordingly. - - # create a temporary file - tmpfile=`mktemp` - binfile=`mktemp` - # generate a map of the symbol names - # don't use -shared for this step - argno=0 - noshrargs=\("\$\{allargs\[\@\]\}"); - for arg in "\$\{noshrargs\[\@\]\}"; do - if [ "\$arg" = "-shared" ]; then - unset noshrarg[\$argno]; - fi - argno=`expr \$argno + 1` - done - \$CC $link_cmd_prefix $link_cmd_no_shared_suffix -Wl,-Map,\$tmpfile \$LDFLAGS -o \$binfile >& /dev/null - - # is MPI in there? - grep MPI \$tmpfile >& /dev/null - rc_mpi=\$? - - # did the link options produce a dynamic executable? - # we look for dynamic MPI_Init symbol to confirm - nm --dynamic \$binfile | grep MPI_Init >& /dev/null - rc_dyn=\$? - - rm \$tmpfile >& /dev/null - rm \$binfile >& /dev/null - - # disable darshan if the executable is not an MPI program or we've - # detected an incompatible compiler - if [ \$rc_mpi -eq 0 ] && [ \$compiler_check -eq 0 ]; then - if [ \$rc_dyn -eq 0 ]; then - \$Show \$CC $link_cmd_prefix $dyn_link_cmd_suffix - else - \$Show \$CC $link_cmd_prefix $link_cmd_suffix - fi - used_darshan=1 - fi - - # otherwise use the normal command line - if [ "\$used_darshan" = "0" ] ; then - \$Show \$CC $link_cmd_prefix $base_link_cmd_suffix - fi - rc=\$? -else - \$Show \$CC $compile_cmd_prefix $compile_cmd_suffix - rc=\$? -fi - -exit \$rc -EOF - -close(OUTPUT); - -chmod(0755, $output_file); - -exit(0); - -sub process_args -{ - use vars qw( $opt_help $opt_output $opt_trim $opt_xl ); - - Getopt::Long::Configure("no_ignore_case", "bundling"); - GetOptions( "help", - "output=s", - "trim", - "xl"); - - if($opt_help) - { - print_help(); - exit(0); - } - - if($opt_trim) - { - $trim_exe_path=1; - } - - if($opt_xl) - { - $xl_check=1; - } - - if($opt_output) - { - $output_file = $opt_output; - } - else - { - print_help(); - exit(1); - } - - # there should only be one remaining argument: the input file - if($#ARGV != 0) - { - print "Error: invalid arguments.\n"; - print_help(); - exit(1); - } - $input_file = $ARGV[0]; - - return; -} - -sub print_help -{ - print<<"EOF"; - -Usage: $PROGRAM_NAME --output - - --help Prints this help message - --output Specifies name of output script - --trim Trim the compilers path - --xl Disables darshan if certain linker parameters are used - (Intended for IBM XL Compilers) - -Purpose: - - This script takes an existing mpicc script as input and generates a - modified version that includes Darshan support. - -EOF - return; -} - diff --git a/darshan-runtime/darshan-gen-cxx.pl.in b/darshan-runtime/darshan-gen-cxx.pl.in deleted file mode 100644 index b030de608..000000000 --- a/darshan-runtime/darshan-gen-cxx.pl.in +++ /dev/null @@ -1,374 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (C) 2015 University of Chicago. -# See COPYRIGHT notice in top-level directory. -# - -# takes a standard mpicxx script as an argument and tried to generate a -# darshan-enabled mpicxx script to mimic it's behavior - -use Getopt::Long; -use English; - -my $PREFIX="@prefix@"; - -my $input_file = ""; -my $output_file = ""; -my $trim_exe_path = 0; -my $xl_check = 0; - -process_args(); - -# run original mpicc with -show argument to capture command line for -# compilation and linking -my $compile_cmd = `$input_file -show -c foo.c`; -if (!($compile_cmd)) -{ - printf STDERR "Error: failed to invoke $input_file with -show\n"; - exit(1); -} - -my $link_cmd = `$input_file -show foo.o -o foo`; -if (!($link_cmd)) -{ - printf STDERR "Error: failed to invoke $input_file with -show\n"; - exit(1); -} - -# we just want the first line of output from the mpi script's -v argument; -# the rest we assume will be generated by the underlying compiler -my $version_out = `$input_file -v 2>/dev/null |head -n 1`; -if (!($version_out)) -{ - printf STDERR "Error: failed to invoke $input_file with -v\n"; - exit(1); -} - -# check command lines for accuracy -if(!($compile_cmd =~ /-c foo.c/) || !($link_cmd =~ /foo.o -o foo/)) -{ - printf STDERR "Error: faulty output from $input_file with -show.\n"; - exit(1); -} -chomp($compile_cmd); -chomp($link_cmd); -chomp($version_out); - -# -# Incomprehensible re to eat the leading path of the compiler command -# and only give the basename. -# -# /cmd -> cmd -# cmd -> cmd -# /x/y/x/z/cmd -> cmd -# -if($trim_exe_path) -{ - $compile_cmd =~ s/\/*([^\/ ]+\/)*//; - $link_cmd =~ s/\/*([^\/ ]+\/)*//; -} - -open (OUTPUT, ">$output_file") || die("Error opening output file: $!"); - -# split the link command from the original mpicc script so that we have the -# part before the "foo.o -o foo", which is assumed to be CXX, and the part -# that comes afterwards, which is assumed to be the required link flags and -# libraries. -if(!($link_cmd =~ /(\S+)(.+)(foo.o -o foo)\s+(.*)/)) -{ - printf STDERR "Error: improperly formatted link cmd: $link_cmd\n"; - exit(1); -} -$CXX_from_link=$1; -$link_cmd_prefix=$2; -$base_link_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4"; -$link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$PREFIX/bin/darshan-config --pre-ld-flags` $4 `$PREFIX/bin/darshan-config --post-ld-flags`"; -$dyn_link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$PREFIX/bin/darshan-config --dyn-ld-flags` $4"; - -# repeat the above step for the compilation command line -if(!($compile_cmd =~ /(\S+)(.+)(-c foo.c)\s+(.*)/)) -{ - printf STDERR "Error: improperly formatted compile cmd: $compile_cmd\n"; - exit(1); -} -$CXX_from_compile=$1; -$compile_cmd_prefix=$2; -$compile_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4"; - -# we expect to see the same CXX command in both the link and compile steps -if($CXX_from_link ne $CXX_from_compile) -{ - printf STDERR "Error: cannot find matching CXX from: $compile_cmd\n"; - printf STDERR "and: $link_cmd\n"; - exit(1); -} -$CXX=$CXX_from_compile; - -# create link cmd with noshrargs variable -$link_cmd_no_shared_suffix = $base_link_cmd_suffix; -$link_cmd_no_shared_suffix =~ s/allargs/noshrargs/; - -print OUTPUT<<"EOF"; -#!/bin/bash -# -# Auto-generated mpicc script from darshan-gen-cc.pl -# -# -# Internal variables -# Show is set to echo to cause the compilation command to be echoed instead -# of executed. -Show= -CXX=\${MPICH_CXX:-"$CXX"} - -EOF - -if ($xl_check == 1) -{ -print OUTPUT<<'EOF'; -# -# Check for IBM XL Linker Parameters -# -# If IPA linker is used, we must disable darshan -# because the IPA linker doesn't support -wrap. -# -function check_XL() -{ - arg=$1; - ipa_enabled=0; - - if [ "$arg" = "-O5" ]; then - ipa_enabled=1; - fi - if [ "$arg" = "-O4" ]; then - ipa_enabled=1; - fi - if [ "$arg" = "-qipa" ]; then - ipa_enabled=1; - fi - - return $ipa_enabled; -} -EOF -} - -print OUTPUT<<'EOF'; -linking=yes -allargs=("$@") -argno=0 -for arg in "$@" ; do - # Set addarg to no if this arg should be ignored by the C compiler - addarg=yes - case "$arg" in - # ---------------------------------------------------------------- - # Compiler options that affect whether we are linking or no - -c|-S|-E|-M|-MM) - # The compiler links by default - linking=no - ;; - -v) - # Pass this argument to the compiler as well. -EOF -print OUTPUT<<"EOF"; - echo "$version_out" -EOF -print OUTPUT<<'EOF'; - # if there is only 1 argument, it must be -v. - if [ "$#" -eq "1" ] ; then - linking=no - fi - ;; - -cxx=*) - CXX=`echo A$arg | sed -e 's/A-cxx=//g'` - addarg=no - ;; - -show) - addarg=no - Show=echo - ;; - esac - if [ $addarg = no ] ; then - unset allargs[$argno] - fi - # Some versions of bash do not accept ((argno++)) - argno=`expr $argno + 1` -done -if [ "$linking" = yes ] ; then - if [ -n "$C_LINKPATH_SHL" ] ; then - # prepend the path for the shared libraries to the library list - mpilibs="$C_LINKPATH_SHL$libdir $mpilibs" - fi -EOF -print OUTPUT<<"EOF"; - - # if allargs includes any libraries, then we need to get - # -ldarshan in there first - argno=0; - once=0; - compiler_check=0; - newallargs=\("\$\{allargs\[\@\]\}"\); - for arg in "\$\{newallargs\[\@\]\}"; do - res=`expr match "\$arg" "-l"`; - if [ \$res -gt 0 -a \$once -lt 1 ]; then - newallargs[\$argno]=-ldarshan - argno=`expr \$argno + 1` - newallargs[\$argno]=\$arg; - once=1; - else - newallargs[\$argno]=\$arg; - fi -EOF - -# -# Add any functional tests for linker parameters -# - if ($xl_check) - { -print OUTPUT<<"EOF"; - check_XL "\$arg"; - if [ \$? -ne 0 ]; then - compiler_check=1; - fi -EOF - } - -print OUTPUT<<"EOF"; - - argno=`expr \$argno + 1` - done - - used_darshan=0 - - # Perform a test link before the real link. This allows us to check - # for two things: - # 1) Are MPI symbols present? Technically Darshan should not harm - # non-MPI programs, but it may bring in unwanted dependencies or - # interfere with autoconf checks. - # 2) Is this link command line going to produce a static or dynamic - # linked executable? We will adjust Darshan link strategy accordingly. - - # create a temporary file - tmpfile=`mktemp` - binfile=`mktemp` - # generate a map of the symbol names - # don't use -shared for this step - argno=0 - noshrargs=\("\$\{allargs\[\@\]\}"); - for arg in "\$\{noshrargs\[\@\]\}"; do - if [ "\$arg" = "-shared" ]; then - unset noshrarg[\$argno]; - fi - argno=`expr \$argno + 1` - done - \$CXX $link_cmd_prefix $link_cmd_no_shared_suffix -Wl,-Map,\$tmpfile \$LDFLAGS -o \$binfile >& /dev/null - - # is MPI in there? - grep MPI \$tmpfile >& /dev/null - rc_mpi=\$? - - # did the link options produce a dynamic executable? - # we look for dynamic MPI::Init symbol to confirm, but we have to be wary of mangling... - nm --demangle --dynamic \$binfile | grep "MPI::Init" >& /dev/null - rc_dyn=\$? - - rm \$tmpfile >& /dev/null - rm \$binfile >& /dev/null - - # disable darshan if the executable is not an MPI program or we've - # detected an incompatible compiler - if [ \$rc_mpi -eq 0 ] && [ \$compiler_check -eq 0 ]; then - if [ \$rc_dyn -eq 0 ]; then - \$Show \$CXX $link_cmd_prefix $dyn_link_cmd_suffix - else - \$Show \$CXX $link_cmd_prefix $link_cmd_suffix - fi - used_darshan=1 - fi - - # otherwise use the normal command line - if [ "\$used_darshan" = "0" ] ; then - \$Show \$CXX $link_cmd_prefix $base_link_cmd_suffix - fi - rc=\$? -else - \$Show \$CXX $compile_cmd_prefix $compile_cmd_suffix - rc=\$? -fi - -exit \$rc -EOF - -close(OUTPUT); - -chmod(0755, $output_file); - -exit(0); - -sub process_args -{ - use vars qw( $opt_help $opt_output $opt_trim $opt_xl ); - - Getopt::Long::Configure("no_ignore_case", "bundling"); - GetOptions( "help", - "output=s", - "trim", - "xl"); - - if($opt_help) - { - print_help(); - exit(0); - } - - if($opt_trim) - { - $trim_exe_path=1; - } - - if($opt_xl) - { - $xl_check=1; - } - - if($opt_output) - { - $output_file = $opt_output; - } - else - { - print_help(); - exit(1); - } - - # there should only be one remaining argument: the input file - if($#ARGV != 0) - { - print "Error: invalid arguments.\n"; - print_help(); - exit(1); - } - $input_file = $ARGV[0]; - - return; -} - -sub print_help -{ - print<<"EOF"; - -Usage: $PROGRAM_NAME --output - - --help Prints this help message - --output Specifies name of output script - --trim Trim the compilers path - --xl Disables darshan if certain linker parameters are used - (Intended for IBM XL Compilers) - -Purpose: - - This script takes an existing mpicxx script as input and generates a - modified version that includes Darshan support. - -EOF - return; -} - diff --git a/darshan-runtime/darshan-gen-fortran.pl.in b/darshan-runtime/darshan-gen-fortran.pl.in deleted file mode 100644 index aaf32ea18..000000000 --- a/darshan-runtime/darshan-gen-fortran.pl.in +++ /dev/null @@ -1,382 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (C) 2015 University of Chicago. -# See COPYRIGHT notice in top-level directory. -# - -# takes a standard mpif* script as an argument and tried to generate a -# darshan-enabled mpif* script to mimic it's behavior - -use Getopt::Long; -use English; - -my $PREFIX="@prefix@"; - -my $input_file = ""; -my $output_file = ""; -my $trim_exe_path=0; -my $xl_check = 0; - -process_args(); - -# run original mpicc with -show argument to capture command line for -# compilation and linking -my $compile_cmd = `$input_file -show -c foo.c`; -if (!($compile_cmd)) -{ - printf STDERR "Error: failed to invoke $input_file with -show\n"; - exit(1); -} - -my $link_cmd = `$input_file -show foo.o -o foo`; -if (!($link_cmd)) -{ - printf STDERR "Error: failed to invoke $input_file with -show\n"; - exit(1); -} - -# we just want the first line of output from the mpi script's -v argument; -# the rest we assume will be generated by the underlying compiler -my $version_out = `$input_file -v 2>/dev/null |head -n 1`; -if (!($version_out)) -{ - printf STDERR "Error: failed to invoke $input_file with -v\n"; - exit(1); -} - -# check command lines for accuracy -if(!($compile_cmd =~ /-c foo.c/) || !($link_cmd =~ /foo.o -o foo/)) -{ - printf STDERR "Error: faulty output from $input_file with -show.\n"; - exit(1); -} -chomp($compile_cmd); -chomp($link_cmd); -chomp($version_out); - -# -# Incomprehensible re to eat the leading path of the compiler command -# and only give the basename. -# -# /cmd -> cmd -# cmd -> cmd -# /x/y/x/z/cmd -> cmd -# -if($trim_exe_path) -{ - $compile_cmd =~ s/\/*([^\/ ]+\/)*//; - $link_cmd =~ s/\/*([^\/ ]+\/)*//; -} - -open (OUTPUT, ">$output_file") || die("Error opening output file: $!"); - -# split the link command from the original mpicc script so that we have the -# part before the "foo.o -o foo", which is assumed to be FC, and the part -# that comes afterwards, which is assumed to be the required link flags and -# libraries. -if(!($link_cmd =~ /(\S+)(.+)(foo.o -o foo)\s+(.*)/)) -{ - printf STDERR "Error: improperly formatted link cmd: $link_cmd\n"; - exit(1); -} -$FC_from_link=$1; -$link_cmd_prefix=$2; -$base_link_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4"; -$link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$PREFIX/bin/darshan-config --pre-ld-flags` $4 `$PREFIX/bin/darshan-config --post-ld-flags`"; -$dyn_link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$PREFIX/bin/darshan-config --dyn-ld-flags` $4"; - -# repeat the above step for the compilation command line -if(!($compile_cmd =~ /(\S+)(.+)(-c foo.c)\s+(.*)/)) -{ - printf STDERR "Error: improperly formatted compile cmd: $compile_cmd\n"; - exit(1); -} -$FC_from_compile=$1; -$compile_cmd_prefix=$2; -$compile_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4"; - -# we expect to see the same FC command in both the link and compile steps -if($FC_from_link ne $FC_from_compile) -{ - printf STDERR "Error: cannot find matching FC from: $compile_cmd\n"; - printf STDERR "and: $link_cmd\n"; - exit(1); -} -$FC=$FC_from_compile; - -# create link cmd with noshrargs variable -$link_cmd_no_shared_suffix = $base_link_cmd_suffix; -$link_cmd_no_shared_suffix =~ s/allargs/noshrargs/; - -print OUTPUT<<"EOF"; -#!/bin/bash -# -# Auto-generated mpicc script from darshan-gen-cc.pl -# -# -# Internal variables -# Show is set to echo to cause the compilation command to be echoed instead -# of executed. -Show= -FC=\${MPICH_F77:-"$FC"} - -EOF - -if ($xl_check == 1) -{ -print OUTPUT<<'EOF'; -# -# Check for IBM XL Linker Parameters -# -# If IPA linker is used, we must disable darshan -# because the IPA linker doesn't support -wrap. -# -function check_XL() -{ - arg=$1; - ipa_enabled=0; - - if [ "$arg" = "-O5" ]; then - ipa_enabled=1; - fi - if [ "$arg" = "-O4" ]; then - ipa_enabled=1; - fi - if [ "$arg" = "-qipa" ]; then - ipa_enabled=1; - fi - - return $ipa_enabled; -} -EOF -} - -print OUTPUT<<'EOF'; -linking=yes -allargs=("$@") -argno=0 -for arg in "$@" ; do - # Set addarg to no if this arg should be ignored by the C compiler - addarg=yes - case "$arg" in - # ---------------------------------------------------------------- - # Compiler options that affect whether we are linking or no - -c|-S|-E|-M|-MM) - # The compiler links by default - linking=no - ;; - -v) - # Pass this argument to the compiler as well. -EOF -print OUTPUT<<"EOF"; - echo "$version_out" -EOF -print OUTPUT<<'EOF'; - # if there is only 1 argument, it must be -v. - if [ "$#" -eq "1" ] ; then - linking=no - fi - ;; - -f77=*) - FC=`echo A$arg | sed -e 's/A-f77=//g'` - addarg=no - ;; - -f90=*) - FC=`echo A$arg | sed -e 's/A-f90=//g'` - addarg=no - ;; - -fc=*) - FC=`echo A$arg | sed -e 's/A-fc=//g'` - addarg=no - ;; - -show) - addarg=no - Show=echo - ;; - esac - if [ $addarg = no ] ; then - unset allargs[$argno] - fi - # Some versions of bash do not accept ((argno++)) - argno=`expr $argno + 1` -done -if [ "$linking" = yes ] ; then - if [ -n "$C_LINKPATH_SHL" ] ; then - # prepend the path for the shared libraries to the library list - mpilibs="$C_LINKPATH_SHL$libdir $mpilibs" - fi -EOF -print OUTPUT<<"EOF"; - - # if allargs includes any libraries, then we need to get - # -ldarshan in there first - argno=0; - once=0; - compiler_check=0; - newallargs=\("\$\{allargs\[\@\]\}"\); - for arg in "\$\{newallargs\[\@\]\}"; do - res=`expr match "\$arg" "-l"`; - if [ \$res -gt 0 -a \$once -lt 1 ]; then - newallargs[\$argno]=-ldarshan - argno=`expr \$argno + 1` - newallargs[\$argno]=\$arg; - once=1; - else - newallargs[\$argno]=\$arg; - fi -EOF - -# -# Add any functional tests for linker parameters -# - if ($xl_check) - { -print OUTPUT<<"EOF"; - check_XL "\$arg"; - if [ \$? -ne 0 ]; then - compiler_check=1; - fi -EOF - } - -print OUTPUT<<"EOF"; - - argno=`expr \$argno + 1` - done - - used_darshan=0 - - # Perform a test link before the real link. This allows us to check - # for two things: - # 1) Are MPI symbols present? Technically Darshan should not harm - # non-MPI programs, but it may bring in unwanted dependencies or - # interfere with autoconf checks. - # 2) Is this link command line going to produce a static or dynamic - # linked executable? We will adjust Darshan link strategy accordingly. - - # create a temporary file - tmpfile=`mktemp` - binfile=`mktemp` - # generate a map of the symbol names - # don't use -shared for this step - argno=0 - noshrargs=\("\$\{allargs\[\@\]\}"); - for arg in "\$\{noshrargs\[\@\]\}"; do - if [ "\$arg" = "-shared" ]; then - unset noshrarg[\$argno]; - fi - argno=`expr \$argno + 1` - done - \$FC $link_cmd_prefix $link_cmd_no_shared_suffix -Wl,-Map,\$tmpfile \$LDFLAGS -o \$binfile >& /dev/null - - # is MPI in there? - grep -i MPI \$tmpfile >& /dev/null - rc_mpi=\$? - - # did the link options produce a dynamic executable? - # we look for dynamic MPI_Init symbol to confirm, but we have to be wary of mangling... - nm --dynamic \$binfile | grep mpi_init >& /dev/null - rc_dyn=\$? - - rm \$tmpfile >& /dev/null - rm \$binfile >& /dev/null - - # disable darshan if the executable is not an MPI program or we've - # detected an incompatible compiler - if [ \$rc_mpi -eq 0 ] && [ \$compiler_check -eq 0 ]; then - if [ \$rc_dyn -eq 0 ]; then - \$Show \$FC $link_cmd_prefix $dyn_link_cmd_suffix - else - \$Show \$FC $link_cmd_prefix $link_cmd_suffix - fi - used_darshan=1 - fi - - # otherwise use the normal command line - if [ "\$used_darshan" = "0" ] ; then - \$Show \$FC $link_cmd_prefix $base_link_cmd_suffix - fi - rc=\$? -else - \$Show \$FC $compile_cmd_prefix $compile_cmd_suffix - rc=\$? -fi - -exit \$rc -EOF - -close(OUTPUT); - -chmod(0755, $output_file); - -exit(0); - -sub process_args -{ - use vars qw( $opt_help $opt_output $opt_trim $opt_xl ); - - Getopt::Long::Configure("no_ignore_case", "bundling"); - GetOptions( "help", - "output=s", - "trim", - "xl"); - - if($opt_help) - { - print_help(); - exit(0); - } - - if($opt_trim) - { - $trim_exe_path=1; - } - - if($opt_xl) - { - $xl_check=1; - } - - if($opt_output) - { - $output_file = $opt_output; - } - else - { - print_help(); - exit(1); - } - - # there should only be one remaining argument: the input file - if($#ARGV != 0) - { - print "Error: invalid arguments.\n"; - print_help(); - exit(1); - } - $input_file = $ARGV[0]; - - return; -} - -sub print_help -{ - print<<"EOF"; - -Usage: $PROGRAM_NAME --output - - --help Prints this help message - --output Specifies name of output script - --trim Trim the compilers path - --xl Disables darshan if certain linker parameters are used - (Intended for IBM XL Compilers) - -Purpose: - - This script takes an existing mpif* script as input and generates a - modified version that includes Darshan support. - -EOF - return; -} - diff --git a/darshan-runtime/doc/darshan-runtime.rst b/darshan-runtime/doc/darshan-runtime.rst index 78da86a25..886ee6404 100644 --- a/darshan-runtime/doc/darshan-runtime.rst +++ b/darshan-runtime/doc/darshan-runtime.rst @@ -330,6 +330,9 @@ straightforward method to apply transparently system-wide. It works by injecting additional libraries and options into the linker command line to intercept relevant I/O calls. +Using the Cray programming environment +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + On Cray platforms you can enable the compile time instrumentation by simply loading the Darshan module. It can then be enabled for all users by placing that module in the default environment. As of Darshan 3.2.0 this will @@ -337,47 +340,9 @@ instrument both static and dynamic executables, while in previous versions of Darshan this was only sufficient for static executables. See the Cray installation recipe for more details. -For other general MPICH-based MPI implementations, you can generate -Darshan-enabled variants of the standard mpicc/mpicxx/mpif90/mpif77 wrappers -using the following commands: - - .. code-block:: bash - - darshan-gen-cc.pl `which mpicc` --output mpicc.darshan - darshan-gen-cxx.pl `which mpicxx` --output mpicxx.darshan - darshan-gen-fortran.pl `which mpif77` --output mpif77.darshan - darshan-gen-fortran.pl `which mpif90` --output mpif90.darshan - - -The resulting ``*.darshan`` wrappers will transparently inject Darshan -instrumentation into the link step without any explicit user intervention. -They can be renamed and placed in an appropriate PATH to enable automatic -instrumentation. This method also works correctly for both static and dynamic -executables as of Darshan 3.2.0. - -For other systems you can enable compile-time instrumentation by either -manually adding the appropriate link options to your command line or modifying -your default MPI compiler script. The ``darshan-config`` command line tool can -be used to display the options that you should use: - - .. code-block:: bash - - # Linker options to use for dynamic linking (default on most platforms) - # These arguments should go *before* the MPI libraries in the underlying - # linker command line to ensure that Darshan can be activated. It should - # also ideally go before other libraries that may issue I/O function calls. - darshan-config --dyn-ld-flags - - # linker options to use for static linking - # The first set of arguments should go early in the link command line - # (before MPI, while the second set should go at the end of the link command - # line - darshan-config --pre-ld-flags - darshan-config --post-ld-flags - .. _Sec Use Profile: -Using a profile configuration +Using an MPICH profile configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The MPICH MPI implementation supports the specification of a profiling library @@ -405,13 +370,37 @@ Examples for command line use: mpif90 -profile=$DARSHAN_PREFIX/share/mpi-profile/darshan-f -Note that unlike the previously described methods in this section, this method -*will not* automatically adapt to static and dynamic linking options. The -example profile configurations show above only support dynamic linking. +Note that this method *will not* automatically adapt to static and dynamic +linking options. The example profile configurations show above only support +dynamic linking. Example profile configurations are also provided with a "-static" suffix if you need examples for static linking. +Other systems +^^^^^^^^^^^^^ + +For other systems you can enable compile-time instrumentation by either +manually adding the appropriate link options to your command line or +modifying your default MPI compiler script. The `darshan-config` command +line tool can be used to display the options that you should use: + + .. code-block:: bash + + # Linker options to use for dynamic linking (default on most platforms) + # These arguments should go *before* the MPI libraries in the underlying + # linker command line to ensure that Darshan can be activated. It should + # also ideally go before other libraries that may issue I/O function calls. + darshan-config --dyn-ld-flags + + # linker options to use for static linking + # The first set of arguments should go early in the link command line + # (before MPI, while the second set should go at the end of the link command + # line + darshan-config --pre-ld-flags + darshan-config --post-ld-flags + + Option 2: Instrumenting MPI applications at runtime -------------------------------------------------------- @@ -982,11 +971,8 @@ using mpicc with GNU compilers to compile Darshan. ./configure --with-log-path=/darshan-logs --with-jobid-env=PBS_JOBID CC=mpicc - -The ``darshan-gen-*`` scripts described earlier in this document can be used to -create variants of the standard mpicc/mpicxx/mpif77/mpif90 scripts that are -Darshan enabled. These scripts will work correctly for both dynamic and -statically linked executables. +The MPICH profile configuration method described earlier in this document +can be used to add Darshan instrumentation to executables at compile time. Linux clusters using Intel MPI ----------------------------------------