• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/portals4_sm/trig_cpu/apps/barrier_tree.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
00011 
00012 
00013 #ifndef COMPONENTS_TRIG_CPU_BARRIER_TREE_H
00014 #define COMPONENTS_TRIG_CPU_BARRIER_TREE_H
00015 
00016 #include "sst/elements/portals4_sm/trig_cpu/application.h"
00017 #include "sst/elements/portals4_sm/trig_cpu/trig_cpu.h"
00018 
00019 class barrier_tree :  public application {
00020 public:
00021     barrier_tree(trig_cpu *cpu) : application(cpu)
00022     {
00023         radix = cpu->getRadix();
00024 
00025         // compute my root and children
00026         boost::tie(my_root, my_children) = buildBinomialTree(radix);
00027         num_children = my_children.size();
00028     }
00029 
00030     bool
00031     operator()(Event *ev)
00032     {
00033         int handle;
00034 
00035         crBegin();
00036         start_noise_section();
00037 
00038         // 200ns startup time
00039         start_time = cpu->getCurrentSimTimeNano();
00040         cpu->addBusyTime("200ns");
00041         crReturn();
00042 
00043         for (i = 0 ; i < num_children ; ++i) { 
00044             while (!cpu->irecv(my_children[i] , NULL, handle)) { crReturn(); }
00045             crReturn();
00046         }
00047         if (num_children != 0) {
00048             while (!cpu->waitall()) { crReturn(); }
00049             crReturn();
00050         }
00051         if (my_root != my_id) {
00052             cpu->isend(my_root, NULL, 0);
00053             crReturn();
00054             while (!cpu->irecv(my_root, NULL, handle)) { crReturn(); }
00055             crReturn();
00056             while (!cpu->waitall()) { crReturn(); }
00057             crReturn();
00058         }
00059         for (i = 0 ; i < num_children ; ++i) { 
00060             cpu->isend(my_children[i], NULL, 0);
00061             crReturn();
00062         }
00063 
00064         trig_cpu::addTimeToStats(cpu->getCurrentSimTimeNano()-start_time);
00065 
00066         crFinish();
00067         return true;
00068     }
00069 
00070 private:
00071     barrier_tree();
00072     barrier_tree(const application& a);
00073     void operator=(barrier_tree const&);
00074 
00075     SimTime_t start_time;
00076     int radix;
00077     int i;
00078 
00079     int my_root;
00080     std::vector<int> my_children;
00081     int num_children;
00082 };
00083 
00084 #endif // COMPONENTS_TRIG_CPU_BARRIER_TREE_H

Generated on Fri Oct 22 2010 11:02:25 for SST by  doxygen 1.7.1