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

sst/elements/portals4_sm/trig_cpu/apps/stream_bw.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_STREAM_BW_H
00014 #define COMPONENTS_TRIG_CPU_STREAM_BW_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 #define PP_BUF_SIZE 1
00020 
00021 class stream_bw :  public application {
00022 public:
00023     stream_bw(trig_cpu *cpu) : cpu(cpu), state(0)
00024     {
00025         my_id = cpu->getMyId();
00026         num_nodes = cpu->getNumNodes();
00027         ptl = cpu->getPortalsHandle();
00028     }
00029 
00030     bool
00031     operator()(Event *ev)
00032     {
00033         ptl_md_t md;
00034         ptl_me_t me;
00035 
00036         ptl_handle_me_t me_handle;
00037 
00038         printf("state = %d\n",state);
00039         switch (state) {
00040         case 0:
00041             printf("%5d: Inializing...\n",my_id);
00042 
00043             ptl->PtlCTAlloc(PTL_CT_OPERATION,ct_handle);
00044             state = 1;
00045             break;
00046 
00047         case 1:
00048             recv_buffer = new uint64_t[PP_BUF_SIZE];
00049             send_buffer = new uint64_t[PP_BUF_SIZE];
00050 
00051             {
00052                 int temp = my_id;
00053                 for ( int i = 0; i < PP_BUF_SIZE; i++ ) {
00054                     recv_buffer[i] = temp;
00055                     send_buffer[i] = temp++;
00056                 }
00057             }
00058 
00059             md.start = send_buffer;
00060             md.length = 8*PP_BUF_SIZE;
00061             md.eq_handle = PTL_EQ_NONE;
00062             md.ct_handle = PTL_CT_NONE;
00063 //          md.ct_handle = ct_handle;
00064             ptl->PtlMDBind(md, &md_handle);
00065 
00066             state = 2;
00067             break;
00068             
00069         case 2:
00070             
00071             // initialize things
00072             me.start = recv_buffer;
00073             me.length = 8*PP_BUF_SIZE;
00074             me.ignore_bits = ~0x0;
00075             me.ct_handle = ct_handle;
00076             ptl->PtlMEAppend(0, me, PTL_PRIORITY_LIST, NULL, me_handle);
00077 
00078             for ( int i = 0; i < PP_BUF_SIZE; i++ ) {
00079                 printf("%5d: start -> send_buffer[%d] = %llu   recv_buffer[%d] = %llu\n",my_id,i,send_buffer[i],i,recv_buffer[i]);
00080             }
00081 
00082             
00083             state = 3;
00084             break;
00085 
00086         case 3:
00087           start_time = cpu->getCurrentSimTimeNano();
00088           ptl->PtlPut(md_handle,0,PP_BUF_SIZE*8,0,(my_id + 1) % num_nodes,0,0,0,NULL,0);  
00089           state = 4;
00090             break;
00091 
00092         case 4:
00093           if ( ptl->PtlCTWait(ct_handle,1) ) {
00094             state = 5;
00095           }
00096             break;
00097             
00098         case 5:
00099           ptl->PtlPut(md_handle,0,PP_BUF_SIZE*8,0,(my_id + (num_nodes - 1)) % num_nodes,0,0,0,NULL,0);  
00100           state = 6;
00101             break;
00102 
00103         case 6:
00104             if ( ptl->PtlCTWait(ct_handle,2) ) {
00105                 for ( int i = 0; i < PP_BUF_SIZE; i++ ) {
00106                     printf("%5d: end -> send_buffer[%d] = %llu   recv_buffer[%d] = %llu\n",my_id,i,send_buffer[i],i,recv_buffer[i]);
00107                 }
00108                 uint64_t elapsed_time = cpu->getCurrentSimTimeNano()-start_time;
00109                 trig_cpu::addTimeToStats(elapsed_time);
00110                 return true;
00111             }
00112             return false;
00113             break;
00114         default:
00115           break;
00116         }
00117         return false;
00118     }
00119 
00120 private:
00121     stream_bw();
00122     stream_bw(const application& a);
00123     void operator=(stream_bw const&);
00124 
00125     trig_cpu *cpu;
00126     portals *ptl;
00127     ptl_handle_ct_t ct_handle;
00128     int state;
00129     int my_id;
00130     int num_nodes;
00131     
00132     ptl_handle_md_t md_handle;
00133 
00134     uint64_t* send_buffer;
00135     uint64_t* recv_buffer;
00136 
00137     SimTime_t start_time;
00138     
00139 };
00140 
00141 #endif // COMPONENTS_TRIG_CPU_TEST_PORTALS_H

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