MPI provides a name-shifted interface that allows a performance tool to intercept any MPI call in a portable manner without requiring a vendor to supply the proprietary source code of the library and without requiring any modifications to the source code. This is provided by providing hooks into the native MPI library with a name-shifted PMPI interface and employing weak bindings. We have developed a TAU MPI wrapper library that acts as an interposition library that internally invokes the name-shifted MPI interface. Wrapped around the call, before and after, is TAU performance instrumentation. TAU and several other tools such as Upshot, VampirTrace, and EPILOG  use this approach.
Cray Inc. provides similar profiling interfaces to its SHMEM interface. We have created a TAU wrapper library for the Cray XT3 that targets its PSHMEM interface for profiling all SHMEM calls. In both cases, an application needs to be re-linked with the TAU MPI or SHMEM wrapper library.