00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
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
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