LCOV - code coverage report
Current view: top level - home/fuchsto/workspaces/dash-development/dart-impl/mpi/src - dart_locality.c (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 33 44 75.0 %
Date: 2016-06-29 12:30:40 Functions: 8 10 80.0 %

          Line data    Source code
       1             : /**
       2             :  * \file dart_locality.c
       3             :  *
       4             :  */
       5             : #include <dash/dart/base/config.h>
       6             : #include <dash/dart/base/macro.h>
       7             : #include <dash/dart/base/assert.h>
       8             : #include <dash/dart/base/logging.h>
       9             : #include <dash/dart/base/locality.h>
      10             : #include <dash/dart/base/internal/unit_locality.h>
      11             : 
      12             : #include <dash/dart/if/dart_types.h>
      13             : #include <dash/dart/if/dart_locality.h>
      14             : 
      15             : #include <mpi.h>
      16             : 
      17             : #include <unistd.h>
      18             : #include <stdio.h>
      19             : #include <sched.h>
      20             : 
      21             : /* ======================================================================== *
      22             :  * Domain Locality                                                          *
      23             :  * ======================================================================== */
      24             : 
      25          26 : dart_ret_t dart_domain_team_locality(
      26             :   dart_team_t                     team,
      27             :   const char                    * domain_tag,
      28             :   dart_domain_locality_t       ** team_domain_out)
      29             : {
      30             :   DART_LOG_DEBUG("dart_domain_locality() team(%d) domain(%s)",
      31             :                  team, domain_tag);
      32             :   dart_ret_t ret;
      33             : 
      34             :   dart_domain_locality_t * team_domain;
      35          26 :   ret = dart__base__locality__team_domain(team, &team_domain);
      36          26 :   if (ret != DART_OK) {
      37           0 :     DART_LOG_ERROR("dart_domain_locality: "
      38             :                    "dart__base__locality__team_domain failed (%d)", ret);
      39           0 :     return ret;
      40             :   }
      41          26 :   *team_domain_out = team_domain;
      42             : 
      43          26 :   if (strcmp(domain_tag, team_domain->domain_tag) != 0) {
      44             :     dart_domain_locality_t * team_subdomain;
      45           8 :     ret = dart__base__locality__domain(
      46             :             team_domain, domain_tag, &team_subdomain);
      47           8 :     if (ret != DART_OK) {
      48           0 :       DART_LOG_ERROR("dart_domain_locality: "
      49             :                      "dart__base__locality__domain failed (%d)", ret);
      50           0 :       return ret;
      51             :     }
      52           8 :     *team_domain_out = team_subdomain;
      53             :   }
      54             : 
      55             :   DART_LOG_DEBUG("dart_domain_locality > team(%d) domain(%s) -> %p",
      56             :                  team, domain_tag, *team_domain_out);
      57          26 :   return DART_OK;
      58             : }
      59             : 
      60           0 : dart_ret_t dart_domain_find(
      61             :   const dart_domain_locality_t  * domain_in,
      62             :   const char                    * domain_tag,
      63             :   dart_domain_locality_t       ** subdomain_out)
      64             : {
      65           0 :   return dart__base__locality__domain(
      66             :            domain_in, domain_tag, subdomain_out);
      67             : }
      68             : 
      69          15 : dart_ret_t dart_domain_copy(
      70             :   const dart_domain_locality_t  * domain_in,
      71             :   dart_domain_locality_t        * domain_out)
      72             : {
      73          15 :   return dart__base__locality__copy_domain(domain_in, domain_out);
      74             : }
      75             : 
      76          14 : dart_ret_t dart_domain_destruct(
      77             :   dart_domain_locality_t        * domain)
      78             : {
      79          14 :   return dart__base__locality__destruct_domain(domain);
      80             : }
      81             : 
      82           1 : dart_ret_t dart_domain_select(
      83             :   dart_domain_locality_t        * domain_in,
      84             :   int                             num_subdomain_tags,
      85             :   const char                   ** subdomain_tags)
      86             : {
      87           1 :   return dart__base__locality__domain_select_subdomains(
      88             :            domain_in, subdomain_tags, num_subdomain_tags);
      89             : }
      90             : 
      91           0 : dart_ret_t dart_domain_exclude(
      92             :   dart_domain_locality_t        * domain_in,
      93             :   int                             num_subdomain_tags,
      94             :   const char                   ** subdomain_tags)
      95             : {
      96           0 :   return dart__base__locality__domain_exclude_subdomains(
      97             :            domain_in, subdomain_tags, num_subdomain_tags);
      98             : }
      99             : 
     100           2 : dart_ret_t dart_domain_split(
     101             :   const dart_domain_locality_t  * domain_in,
     102             :   dart_locality_scope_t           scope,
     103             :   int                             num_parts,
     104             :   dart_domain_locality_t        * domains_out)
     105             : {
     106             :   DART_LOG_DEBUG("dart_domain_split() team(%d) domain(%s) "
     107             :                  "into %d parts at scope %d",
     108             :                  domain_in->team, domain_in->domain_tag, num_parts, scope);
     109             : 
     110           2 :   int    * group_sizes       = NULL;
     111           2 :   char *** group_domain_tags = NULL;
     112             : 
     113             :   /* Get domain tags for a split, grouped by locality scope.
     114             :    * For 4 domains in the specified scope, a split into 2 parts results
     115             :    * in a grouping of domain tags like:
     116             :    *
     117             :    *   group_domain_tags = {
     118             :    *     { split_domain_0, split_domain_1 },
     119             :    *     { split_domain_2, split_domain_3 }
     120             :    *   }
     121             :    */
     122           2 :   DART_ASSERT_RETURNS(
     123             :     dart__base__locality__domain_split_tags(
     124             :       domain_in, scope, num_parts, &group_sizes, &group_domain_tags),
     125             :     DART_OK);
     126             : 
     127             :   /* Use grouping of domain tags to create new locality domain
     128             :    * hierarchy:
     129             :    */
     130           6 :   for (int p = 0; p < num_parts; p++) {
     131             :     DART_LOG_DEBUG("dart_domain_split: split %d / %d",
     132             :                    p + 1, num_parts);
     133             : 
     134             : #ifdef DART_ENABLE_LOGGING
     135             :     DART_LOG_TRACE("dart_domain_split: groups[%d] size: %d",
     136             :                    p, group_sizes[p]);
     137             :     for (int g = 0; g < group_sizes[p]; g++) {
     138             :       DART_LOG_TRACE("dart_domain_split:            |- tags[%d]: %s",
     139             :                      g, group_domain_tags[p][g]);
     140             :     }
     141             : #endif
     142             : 
     143             :     /* Deep copy of grouped domain so we do not have to recalculate
     144             :      * groups for every split group : */
     145             :     DART_LOG_TRACE("dart_domain_split: copying input domain");
     146           4 :     DART_ASSERT_RETURNS(
     147             :       dart__base__locality__copy_domain(
     148             :         domain_in,
     149             :         domains_out + p),
     150             :       DART_OK);
     151             : 
     152             :     /* Drop domains that are not in split group: */
     153             :     DART_LOG_TRACE("dart_domain_split: selecting subdomains");
     154           4 :     DART_ASSERT_RETURNS(
     155             :       dart__base__locality__domain_select_subdomains(
     156             :         domains_out + p,
     157             :         (const char **)(group_domain_tags[p]),
     158             :         group_sizes[p]),
     159             :       DART_OK);
     160             :   }
     161             : 
     162             :   DART_LOG_DEBUG("dart_domain_split >");
     163           2 :   return DART_OK;
     164             : }
     165             : 
     166           2 : dart_ret_t dart_domain_scope_tags(
     167             :   const dart_domain_locality_t  * domain_in,
     168             :   dart_locality_scope_t           scope,
     169             :   int                           * num_domains_out,
     170             :   char                        *** domain_tags_out)
     171             : {
     172           2 :   *num_domains_out = 0;
     173           2 :   *domain_tags_out = NULL;
     174             : 
     175           2 :   return dart__base__locality__scope_domains(
     176             :            domain_in,
     177             :            scope,
     178             :            num_domains_out,
     179             :            domain_tags_out);
     180             : }
     181             : 
     182           2 : dart_ret_t dart_domain_group(
     183             :   dart_domain_locality_t        * domain_in,
     184             :   int                             num_group_subdomains,
     185             :   const char                   ** group_subdomain_tags,
     186             :   char                          * group_domain_tag_out)
     187             : {
     188           2 :   return dart__base__locality__domain_group(
     189             :            domain_in,
     190             :            num_group_subdomains,
     191             :            group_subdomain_tags,
     192             :            group_domain_tag_out);
     193             : }
     194             : 
     195             : /* ====================================================================== *
     196             :  * Unit Locality                                                          *
     197             :  * ====================================================================== */
     198             : 
     199          69 : dart_ret_t dart_unit_locality(
     200             :   dart_team_t                     team,
     201             :   dart_unit_t                     unit,
     202             :   dart_unit_locality_t         ** locality)
     203             : {
     204             :   DART_LOG_DEBUG("dart_unit_locality() team(%d) unit(%d)", team, unit);
     205             : 
     206          69 :   dart_ret_t ret = dart__base__locality__unit(team, unit, locality);
     207          69 :   if (ret != DART_OK) {
     208           0 :     DART_LOG_ERROR("dart_unit_locality: "
     209             :                    "dart__base__unit_locality__get(unit:%d) failed (%d)",
     210             :                    unit, ret);
     211           0 :     *locality = NULL;
     212           0 :     return ret;
     213             :   }
     214             : 
     215             :   DART_LOG_DEBUG("dart_unit_locality > team(%d) unit(%d) -> %p",
     216             :                  team, unit, *locality);
     217          69 :   return DART_OK;
     218             : }
     219             : 

Generated by: LCOV version 1.12