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

sst/elements/portals4_sm/trig_cpu/apps/barrier_recdbl.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_RECDBL_H
00014 #define COMPONENTS_TRIG_CPU_BARRIER_RECDBL_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_recdbl :  public application {
00020 public:
00021     barrier_recdbl(trig_cpu *cpu) : application(cpu)
00022     {
00023         int adj;
00024 
00025         /* Initialization case */
00026         for (adj = 0x1; adj <= num_nodes ; adj  <<= 1); adj = adj >> 1;
00027         if (adj != num_nodes) {
00028             printf("recursive_doubling requires power of 2 nodes (%d)\n",
00029                    num_nodes);
00030             exit(1);
00031         }
00032     }
00033 
00034     bool
00035     operator()(Event *ev)
00036     {
00037         int handle;
00038 
00039         crBegin();
00040 
00041         // 200ns startup time
00042         start_time = cpu->getCurrentSimTimeNano();
00043         cpu->addBusyTime("200ns");
00044         crReturn();
00045 
00046         for (level = 0x1 ; level < num_nodes ; level <<= 1) {
00047             remote = my_id ^ level;
00048             while (!cpu->irecv(remote, NULL, handle)) { crReturn(); }
00049             crReturn();
00050             cpu->isend(remote, NULL, 0);
00051             crReturn();
00052 
00053             while (!cpu->waitall()) { crReturn(); }
00054             crReturn();
00055         }
00056 
00057         trig_cpu::addTimeToStats(cpu->getCurrentSimTimeNano()-start_time);
00058 
00059         crFinish();
00060         return true;
00061     }
00062 
00063 private:
00064     barrier_recdbl();
00065     barrier_recdbl(const application& a);
00066     void operator=(barrier_recdbl const&);
00067 
00068     SimTime_t start_time;
00069     int level;
00070     int remote;
00071 };
00072 
00073 #endif // COMPONENTS_TRIG_CPU_BARRIER_RECDBL_H

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