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

sst/elements/portals4_sm/trig_cpu/apps/test_mpi.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_MPI_H
00014 #define COMPONENTS_TRIG_CPU_TEST_MPI_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 TEST_MPI_BUF_SIZE 32
00020 
00021 class test_mpi :  public application {
00022 public:
00023     test_mpi(trig_cpu *cpu) : application(cpu)
00024     {
00025         ptl = cpu->getPortalsHandle();
00026     }
00027 
00028     bool
00029     operator()(Event *ev)
00030     {
00031         int handle;
00032 //      printf("state = %d\n",state); */
00033         switch (state) {
00034         case 0:
00035             printf("%5d: Inializing...\n",my_id);
00036             recv_buffer = new uint64_t[TEST_MPI_BUF_SIZE];
00037             send_buffer = new uint64_t[TEST_MPI_BUF_SIZE];
00038 
00039             {
00040                 int temp = my_id;
00041                 for ( int i = 0; i < TEST_MPI_BUF_SIZE; i++ ) {
00042                     recv_buffer[i] = temp;
00043                     send_buffer[i] = temp++;
00044                 }
00045             }
00046 
00047             state = 1;
00048             break;
00049 
00050         case 1:
00051           cpu->isend((my_id + 1) % num_nodes,send_buffer,TEST_MPI_BUF_SIZE*8/4);
00052           start_time = cpu->getCurrentSimTimeNano();
00053             state = 2;
00054             break;
00055             
00056         case 2:
00057           cpu->irecv((my_id + num_nodes - 1) % num_nodes,recv_buffer,handle);
00058             state = 3;
00059             break;
00060 
00061         case 3:
00062           cpu->irecv((my_id + num_nodes - 1) % num_nodes,&recv_buffer[TEST_MPI_BUF_SIZE/2],handle);
00063           start_time = cpu->getCurrentSimTimeNano();
00064             state = 4;
00065             break;
00066             
00067         case 4:
00068           cpu->isend((my_id + 1) % num_nodes,send_buffer,TEST_MPI_BUF_SIZE*8/4);
00069             state = 5;
00070             break;
00071 
00072         case 5:
00073           if ( cpu->waitall() )
00074             state = 6;
00075           break;
00076             
00077         case 6:
00078         {
00079           for ( int i = 0; i < 32; i++ ) {
00080             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]);
00081           }
00082           uint64_t elapsed_time = cpu->getCurrentSimTimeNano()-start_time;
00083           trig_cpu::addTimeToStats(elapsed_time);
00084           return true;
00085           state = 7;
00086         }
00087           break;
00088             
00089         case 7:
00090             state = 7;
00091             break;
00092 
00093         case 8:
00094             return false;
00095             break;
00096         default:
00097           break;
00098         }
00099         return false;
00100     }
00101 
00102 private:
00103     test_mpi();
00104     test_mpi(const application& a);
00105     void operator=(test_mpi const&);
00106 
00107     trig_cpu *cpu;
00108     portals *ptl;
00109     ptl_handle_ct_t ct_handle;
00110     int state;
00111     int my_id;
00112     int num_nodes;
00113     
00114     ptl_handle_md_t md_handle;
00115 
00116     uint64_t* send_buffer;
00117     uint64_t* recv_buffer;
00118 
00119     SimTime_t start_time;
00120     
00121 };
00122 
00123 #endif // COMPONENTS_TRIG_CPU_TEST_MPI_H

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