Next: , Previous: Selective Instrumentation, Up: Managing Overhead


7.2 Selective Measurement

PPW also supports a simple API for turning measurement on and off for particular parts of your program code. This API does not affect the instrumentation process, so it is not as effective of an overhead reduction technique as the techniques described in Selective Instrumentation. However, since the technique is API-based, it does offer a lot of flexibility.

Listed below is a quick example of how to use the UPC measurement controls:

     #include <upc.h>
     #include <pupc.h>
     
     int main() {
       /* turn off measurement for initialization process */
       pupc_control(0);
       do_init();
       /* now record data about computation... */
       pupc_control(1);
       do_computation();
       /* ignore data collection and presentation phase */
       pupc_control(0);
       do_process_results();
       /* finally, turn control back on to dump out performance data */
       pupc_control(1);
       return 0;
     }

Since the GASP ‘pupc’ functions are not part of the UPC specification, you'll probably want to protect any code that uses these functions with an ‘#ifdef __UPC_PUPC__’. For example, you could do something like this:

     #ifdef __UPC_PUPC__
     #define PUPC_CONT(a) pupc_control(a)
     #else
     #define PUPC_CONT(a)
     #endif

and use the ‘PUPC_CONT’ macro in place of ‘pupc_control’ function calls. That way, your program code still compiles on systems without GASP support.

It is important to keep in mind that the ‘pupc_control’ function does not change the instrumentation code added to your program in any way; rather, it tells PPW to ignore performance information for parts of your program's execution.

The C and SHMEM API provides similar functions (‘cprof_control’ and ‘pshmem_control’, respectively) to control measurement for particular regions of code. See API Reference for more details on the measurement API provided by PPW.