00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef COMPONENTS_TRIG_CPU_TEST_PORTALS_H
00014 #define COMPONENTS_TRIG_CPU_TEST_PORTALS_H
00015
00016 #include "algorithm.h"
00017 #include "trig_cpu.h"
00018
00019 #define BUF_SIZE 32
00020
00021 class test_portals : public algorithm {
00022 public:
00023 test_portals(trig_cpu *cpu) : algorithm(cpu)
00024 {
00025 ptl = cpu->getPortalsHandle();
00026 }
00027
00028 bool
00029 operator()(Event *ev)
00030 {
00031 ptl_md_t md;
00032 ptl_me_t me;
00033
00034 ptl_handle_me_t me_handle;
00035
00036 printf("state = %d\n",state);
00037 switch (state) {
00038 case 0:
00039 printf("%5d: Inializing...\n",my_id);
00040
00041 ptl->PtlCTAlloc(PTL_CT_OPERATION,ct_handle);
00042 state = 1;
00043 break;
00044
00045 case 1:
00046 recv_buffer = new uint64_t[BUF_SIZE];
00047 send_buffer = new uint64_t[BUF_SIZE];
00048
00049 {
00050 int temp = my_id;
00051 for ( int i = 0; i < BUF_SIZE; i++ ) {
00052 recv_buffer[i] = temp;
00053 send_buffer[i] = temp++;
00054 }
00055 }
00056
00057 md.start = send_buffer;
00058 md.length = 8*BUF_SIZE;
00059 md.eq_handle = PTL_EQ_NONE;
00060 md.ct_handle = PTL_CT_NONE;
00061 md.ct_handle = ct_handle;
00062 ptl->PtlMDBind(md, &md_handle);
00063
00064 state = 2;
00065 break;
00066
00067 case 2:
00068
00069
00070 me.start = recv_buffer;
00071 me.length = 8*BUF_SIZE;
00072 me.ignore_bits = ~0x0;
00073 me.ct_handle = ct_handle;
00074 start_time = cpu->getCurrentSimTimeNano();
00075 ptl->PtlMEAppend(0, me, PTL_PRIORITY_LIST, NULL, me_handle);
00076
00077 for ( int i = 0; i < 16; i++ ) {
00078 printf("%5d: start -> send_buffer[%d] = %llu recv_buffer[%d] = %llu\n",my_id,i,send_buffer[i],i,recv_buffer[i]);
00079 }
00080
00081
00082 state = 3;
00083 break;
00084
00085 case 3:
00086 ptl->PtlTriggeredCTInc(ct_handle,1,ct_handle,1);
00087 state = 4;
00088 break;
00089
00090 case 4:
00091
00092
00093 ptl->PtlTriggeredPut(md_handle,0,0,0,(my_id + 1) % num_nodes,0,0,0,NULL,0,ct_handle,3);
00094 state = 5;
00095 break;
00096
00097 case 5:
00098
00099
00100 ptl->PtlPut(md_handle,0,128,0,( my_id + 1 ) % num_nodes,0,0,0,NULL,0);
00101 state = 6;
00102 break;
00103
00104 case 6:
00105 if ( ptl->PtlCTWait(ct_handle,5) ) {
00106 for ( int i = 0; i < 32; i++ ) {
00107 printf("%5d: end -> send_buffer[%d] = %llu recv_buffer[%d] = %llu\n",my_id,i,send_buffer[i],i,recv_buffer[i]);
00108 }
00109 uint64_t elapsed_time = cpu->getCurrentSimTimeNano()-start_time;
00110 trig_cpu::addTimeToStats(elapsed_time);
00111
00112
00113
00114
00115 return true;
00116 }
00117 return false;
00118
00119
00120
00121
00122
00123
00124 break;
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 }
00137 return false;
00138 }
00139
00140 private:
00141 test_portals();
00142 test_portals(const algorithm& a);
00143 void operator=(test_portals const&);
00144
00145 trig_cpu *cpu;
00146 portals *ptl;
00147 ptl_handle_ct_t ct_handle;
00148 int state;
00149 int my_id;
00150 int num_nodes;
00151
00152 ptl_handle_md_t md_handle;
00153
00154 uint64_t* send_buffer;
00155 uint64_t* recv_buffer;
00156
00157 SimTime_t start_time;
00158
00159 };
00160
00161 #endif // COMPONENTS_TRIG_CPU_TEST_PORTALS_H