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

sst/elements/portals4_sm/trig_cpu/apps/test_atomics.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_ATOMICS_H
00014 #define COMPONENTS_TRIG_CPU_TEST_ATOMICS_H
00015 
00016 #include "sst/elements/portals4_sm/trig_cpu/application.h"
00017 #include "sst/elements/portals4_sm/trig_cpu/trig_cpu.h"
00018 #include "sst/elements/portals4_sm/trig_cpu/portals.h"
00019 
00020 class test_atomics :  public application {
00021 public:
00022     test_atomics(trig_cpu *cpu) : application(cpu), init(false)
00023     {
00024         ptl = cpu->getPortalsHandle();
00025 
00026     }
00027 
00028     bool
00029     operator()(Event *ev)
00030     {
00031         ptl_md_t md;
00032         ptl_me_t me;
00033 
00034         crBegin();
00035 
00036         // setup md handles
00037         ptl->PtlCTAlloc(PTL_CT_OPERATION, ct_h);
00038         crReturn();
00039         
00040         accum = my_id;
00041         me.start = &accum;
00042         me.length = 8;
00043         me.match_bits = 0;
00044         me.ignore_bits = 0;
00045         me.ct_handle = ct_h;
00046         ptl->PtlMEAppend(1, me, PTL_PRIORITY_LIST, NULL, up_tree_me_h);
00047         crReturn();
00048 
00049         md.start = &accum;
00050         md.length = 8;
00051         md.eq_handle = PTL_EQ_NONE;
00052         md.ct_handle = PTL_EQ_NONE;
00053         ptl->PtlMDBind(md, &my_md_h);
00054         crReturn();
00055         
00056 
00057         // 200ns startup time
00058         start_time = cpu->getCurrentSimTimeNano();
00059         cpu->addBusyTime("200ns");
00060         crReturn();
00061 
00062         ptl->PtlTriggeredAtomic(my_md_h, 0, 8, 0, (my_id+2) % num_nodes, 1, 0, 0, NULL, 0, PTL_SUM, PTL_INT, ct_h, 1);
00063         crReturn();
00064 
00065         ptl->PtlAtomic(my_md_h, 0, 8, 0, (my_id+1) % num_nodes, 1, 0, 0, NULL, 0, PTL_SUM, PTL_INT);
00066         crReturn();
00067         
00068         
00069         while (!ptl->PtlCTWait(ct_h, 2)) { crReturn(); }
00070         crReturn();
00071 
00072         printf("%d: %lld\n",my_id,accum);
00073 
00074 
00075         trig_cpu::addTimeToStats(cpu->getCurrentSimTimeNano()-start_time);
00076 
00077         crFinish();
00078         return true;
00079     }
00080 
00081 private:
00082     test_atomics();
00083     test_atomics(const application& a);
00084     void operator=(test_atomics const&);
00085 
00086     portals *ptl;
00087 
00088     int64_t accum;
00089     
00090     SimTime_t start_time;
00091     int radix;
00092     bool init;
00093 
00094     ptl_handle_ct_t ct_h;
00095     ptl_handle_me_t up_tree_me_h;
00096 
00097     ptl_handle_ct_t down_tree_ct_h;
00098     ptl_handle_me_t down_tree_me_h;
00099 
00100     ptl_handle_md_t my_md_h;
00101 
00102     int i;
00103     int my_root;
00104     std::vector<int> my_children;
00105     int num_children;
00106 
00107     static const int PT_UP = 0;
00108     static const int PT_DOWN = 1;
00109 };
00110 
00111 #endif // COMPONENTS_TRIG_CPU_TEST_ATOMICS_H

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