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

sst/elements/portals4_sm/trig_cpu/apps/test_portals.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_TEST_PORTALS_H
00014 #define COMPONENTS_TRIG_CPU_TEST_PORTALS_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 BUF_SIZE 32
00020 
00021 class test_portals :  public application {
00022 public:
00023     test_portals(trig_cpu *cpu) : application(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             // initialize things
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,(long long unsigned)send_buffer[i],i,(long long unsigned)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 //          ptl->PtlTriggeredGet(md_handle,0,32,(my_id + 1) % num_nodes,0,0,NULL,128,ct_handle,2);
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             // Send to my neighbor one bigger
00099 //          ptl->PtlPut(md_handle,0,128,0,( my_id + 1 ) % num_nodes,0,0,0,NULL,0);
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,(long long unsigned)send_buffer[i],i,(long long unsigned)recv_buffer[i]);
00108                 }
00109                 uint64_t elapsed_time = cpu->getCurrentSimTimeNano()-start_time;
00110                 trig_cpu::addTimeToStats(elapsed_time);
00111 //              if (my_id == 0) {
00112 //                  double bw = ((double)(BUF_SIZE * 8)) / ((double)(elapsed_time));
00113 //                  printf("Approximate BW = %3.2lf GB/s\n",my_id,bw);
00114 //              }
00115                 return true;
00116             }
00117             return false;
00118 //             // Now send a message to the guy just bigger than me
00119 //             ptl->PtlTriggeredCTInc(ct_handle,4,ct_handle,3);
00120 //             ptl->PtlTriggeredPut(1,1,1,0,(my_id + 2) % num_nodes,0,0xdeadbeafabcdefabLL,0,NULL,0,ct_handle,1);
00121 //             ptl->PtlTriggeredAtomic(1,1,1,0,(my_id + 3) % num_nodes,0,0,0,NULL,0,PTL_MIN,PTL_LONG,ct_handle,2);
00122 //             ptl->PtlPut(1,1,1,0,(my_id + 1) % num_nodes,0,0,0,NULL,0);
00123 //             state = 3;
00124             break;
00125 //         case 3:
00126 //             if ( ptl->PtlCTWait(ct_handle,7) ) {
00127 //                 trig_cpu::addTimeToStats(1);
00128 //                 state = 4;
00129 //                 return true;
00130 //             }
00131 //             cpu->addBusyTime("100ns");
00132 //             break;
00133 //         default:
00134 //             cpu->addBusyTime("100ns");
00135 //             break;
00136         }
00137         return false;
00138     }
00139 
00140 private:
00141     test_portals();
00142     test_portals(const application& 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

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