LCOV - code coverage report
Current view: top level - src - Init.cc (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 32 34 94.1 %
Date: 2016-06-29 12:30:40 Functions: 8 8 100.0 %

          Line data    Source code
       1             : #include <dash/Init.h>
       2             : #include <dash/Team.h>
       3             : #include <dash/util/Locality.h>
       4             : #include <dash/util/Config.h>
       5             : 
       6             : namespace dash {
       7             :   static int  _myid        = -1;
       8             :   static int  _size        = -1;
       9             :   static bool _initialized = false;
      10             : }
      11             : 
      12           4 : void dash::init(int *argc, char ***argv)
      13             : {
      14             :   DASH_LOG_DEBUG("dash::init()");
      15             : 
      16             :   DASH_LOG_DEBUG("dash::init", "dash::util::Config::init()");
      17           4 :   dash::util::Config::init();
      18             : 
      19             :   DASH_LOG_DEBUG("dash::init", "dart_init()");
      20           4 :   dart_init(argc,argv);
      21           4 :   dash::_initialized = true;
      22             : 
      23             :   DASH_LOG_DEBUG("dash::init", "dash::util::Locality::init()");
      24           4 :   dash::util::Locality::init();
      25             :   DASH_LOG_DEBUG("dash::init >");
      26           4 : }
      27             : 
      28           4 : void dash::finalize()
      29             : {
      30             :   DASH_LOG_DEBUG("dash::finalize()");
      31             :   // Check init status of DASH
      32           4 :   if (!dash::is_initialized()) {
      33             :     // DASH has not been initalized or multiple calls of finalize, ignore:
      34             :     DASH_LOG_DEBUG("dash::finalize", "not initialized, ignore");
      35           0 :     return;
      36             :   }
      37             : 
      38             :   // Wait for all units:
      39           4 :   dash::barrier();
      40             : 
      41             :   // Deallocate global memory allocated in teams:
      42             :   DASH_LOG_DEBUG("dash::finalize", "free team global memory");
      43           4 :   dash::Team::finalize();
      44             : 
      45             :   // Wait for all units:
      46           4 :   dash::barrier();
      47             : 
      48             :   // Finalize DASH runtime:
      49             :   DASH_LOG_DEBUG("dash::finalize", "finalize DASH runtime");
      50           4 :   dart_exit();
      51             : 
      52             :   // Mark DASH as finalized (allow subsequent dash::init):
      53           4 :   dash::_initialized = false;
      54             : 
      55             :   DASH_LOG_DEBUG("dash::finalize >");
      56             : }
      57             : 
      58    21649910 : bool dash::is_initialized()
      59             : {
      60    21649910 :   return dash::_initialized;
      61             : }
      62             : 
      63         476 : void dash::barrier()
      64             : {
      65         476 :   dash::Team::All().barrier();
      66         476 : }
      67             : 
      68    12982275 : int dash::myid()
      69             : {
      70    12982275 :   if (dash::_myid < 0 && dash::is_initialized()) {
      71             :     // First call of dash::myid() after dash::init():
      72             :     dart_unit_t myid;
      73           4 :     dart_myid(&myid);
      74           4 :     dash::_myid = myid;
      75    12982271 :   } else if (!dash::is_initialized()) {
      76             :     // First call of dash::myid() after dash::finalize():
      77          16 :     dash::_myid = -1;
      78             :   }
      79    12982275 :   return dash::_myid;
      80             : }
      81             : 
      82         790 : size_t dash::size()
      83             : {
      84         790 :   if (dash::_size < 0 && dash::is_initialized()) {
      85             :     // First call of dash::size() after dash::init():
      86             :     size_t size;
      87           4 :     dart_size(&size);
      88           4 :     dash::_size = size;
      89         786 :   } else if (!dash::is_initialized()) {
      90             :     // First call of dash::size() after dash::finalize():
      91           0 :     dash::_size = -1;
      92             :   }
      93         790 :   return dash::_size;
      94          12 : }
      95             : 

Generated by: LCOV version 1.12