/* ==================================================================== */ /* MPIPE.C */ /* */ /* -------------------------------------------------------------------- */ /*************************************************************************** * * Copyright (c) 1989, 1990, 1991, 1992, 1993 * Rector and Visitors of the University of Virginia * All Rights Reserved * * This file is part of the Mentat system software library. This software * is intended for research and is available free of charge for that * purpose; however, all material is the proprietary source of the * University of Virginia, and may not be disclosed or copied in any * form without the explicit written permission of the Univeristy of * Virginia. * * This software is distributed WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. This software hereunder is provided on an "as is" basis, * and the University of Virginia has no obligation to provide maintenance, * support, updates, enhancements, or modifications. * * Send problems & suggestions to: * mentat@Virginia.EDU * ***************************************************************************/ /*-------------------------------------------------------------------------- * * This program shows a simple example of a pipeline * *------------------------------------------------------------------------*/ #include #include #include "generic.h" #include "gfilter.h" #include "graph_sink.h" main(int argc,char **argv) { if (argc!=4) { printf("usage: mpipe delay filter_delay iterations\n"); exit(0); } // Gather the command-line parameters int iterations, delay, fdelay; delay = atoi(argv[1]); delay*=10000; fdelay = atoi(argv[2]); fdelay*=10000; iterations = atoi(argv[3]); // Declare objects that measure timing information mentat_timer interval; timing_statistic stats; graph_sink sink; // Declare the nodes of the pipeline generic start_node; generic end_node; gfilter transform1; gfilter transform2; // Create the persistent objects (endnodes of the pipe) start_node.create(delay); end_node.create(delay); sink.create(end_node); stats = sink.initialize(iterations); interval.start(); for (int i = 0; i < iterations; i++) { // Execute the pipe by feeding the result of one // function call into the argument of another int j; j = start_node.one_arg(fdelay); j = transform1.one_arg(j); j = transform2.one_arg(j); j = end_node.one_arg(j); sink.sink(j); } long elapsed; elapsed = stats.TBO_msec; interval.stop(); elapsed = interval.msec(); elapsed = elapsed / iterations; // Report on timing statistics delay /=10000; fdelay /=10000; int totalunits=((2*delay)+(2*fdelay)); if (totalunits == 0) totalunits=1; printf(" mpipe %d %d work units %d",delay,fdelay,totalunits); printf(" Avg TIME = %d, time/unit = %d\n", elapsed, elapsed/totalunits); fflush(stdout); // Destroy the persistent objects start_node.destroy(); end_node.destroy(); sink.destroy(); }