00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef COMPONENTS_TRIG_CPU_BARRIER_DISSEMINATION_H
00014 #define COMPONENTS_TRIG_CPU_BARRIER_DISSEMINATION_H
00015
00016 #include "algorithm.h"
00017 #include "trig_cpu.h"
00018
00019 class barrier_dissemination : public algorithm {
00020 public:
00021 barrier_dissemination(trig_cpu *cpu) : algorithm(cpu)
00022 {
00023 radix = cpu->getRadix();
00024 }
00025
00026 bool
00027 operator()(Event *ev)
00028 {
00029 int handle;
00030 crBegin();
00031
00032
00033 start_time = cpu->getCurrentSimTimeNano();
00034 cpu->addBusyTime("200ns");
00035 crReturn();
00036
00037 shiftval = floorLog2(radix);
00038 if (my_id == 0) printf("radix: %d, shiftval: %d\n", radix, shiftval);
00039
00040 for (level = 0x1 ; level < num_nodes ; level <<= shiftval) {
00041 for (i = 0 ; i < (radix - 1) ; i++) {
00042 cpu->isend((my_id + level + i) % num_nodes, NULL, 0);
00043 crReturn();
00044 while (!cpu->irecv((my_id + num_nodes - (level + i)) % num_nodes,
00045 NULL, handle)) { crReturn(); }
00046 crReturn();
00047 while (!cpu->waitall()) { crReturn(); }
00048 crReturn();
00049 }
00050 }
00051
00052 trig_cpu::addTimeToStats(cpu->getCurrentSimTimeNano()-start_time);
00053
00054 crFinish();
00055 return true;
00056 }
00057
00058 private:
00059 barrier_dissemination();
00060 barrier_dissemination(const algorithm& a);
00061 void operator=(barrier_dissemination const&);
00062
00063 SimTime_t start_time;
00064 int radix;
00065 int shiftval;
00066
00067 int i;
00068 int level;
00069 };
00070
00071 #endif // COMPONENTS_TRIG_CPU_BARRIER_DISSEMINATION_H