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

sst/elements/portals4_sm/trig_cpu/apps/barrier_dissem.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_DISSEMINATION_H
00014 #define COMPONENTS_TRIG_CPU_BARRIER_DISSEMINATION_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_dissemination :  public application {
00020 public:
00021     barrier_dissemination(trig_cpu *cpu) : application(cpu)
00022     {
00023         radix = cpu->getRadix();
00024     }
00025 
00026     bool
00027     operator()(Event *ev)
00028     {
00029         int handle;
00030         crBegin();
00031 
00032         // 200ns startup time
00033         start_time = cpu->getCurrentSimTimeNano();
00034         cpu->addBusyTime("200ns");
00035         crReturn();
00036 
00037         shiftval = floorLog2(radix);
00038 
00039         for (level = 0x1 ; level < num_nodes ; level <<= shiftval) {
00040             for (i = 0 ; i < (radix - 1) ; i++) {
00041                 cpu->isend((my_id + level + i) % num_nodes, NULL, 0);
00042                 crReturn();
00043                 while (!cpu->irecv((my_id + num_nodes - (level + i)) % num_nodes, 
00044                                    NULL, handle)) { crReturn(); }
00045                 crReturn();
00046                 while (!cpu->waitall()) { crReturn(); }
00047                 crReturn();
00048             }
00049         }
00050 
00051         trig_cpu::addTimeToStats(cpu->getCurrentSimTimeNano()-start_time);
00052 
00053         crFinish();
00054         return true;
00055     }
00056 
00057 private:
00058     barrier_dissemination();
00059     barrier_dissemination(const application& a);
00060     void operator=(barrier_dissemination const&);
00061 
00062     SimTime_t start_time;
00063     int radix;
00064     int shiftval;
00065 
00066     int i;
00067     int level;
00068 };
00069 
00070 #endif // COMPONENTS_TRIG_CPU_BARRIER_DISSEMINATION_H

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