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