LCOV - code coverage report
Current view: top level - test - TeamSpecTest.cc (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 50 50 100.0 %
Date: 2016-06-29 12:30:40 Functions: 18 18 100.0 %

          Line data    Source code
       1             : #include <libdash.h>
       2             : #include <array>
       3             : #include <numeric>
       4             : #include <functional>
       5             : 
       6             : #include "TestBase.h"
       7             : #include "TeamSpecTest.h"
       8             : 
       9          20 : TEST_F(TeamSpecTest, DefaultConstrutor)
      10             : {
      11           4 :   int num_units = dash::Team::All().size();
      12             :   // Default constructor: All units in first dimension
      13           4 :   EXPECT_EQ_U(num_units, dash::TeamSpec<1>().size());
      14           4 :   EXPECT_EQ_U(1, dash::TeamSpec<1>().rank());
      15           4 :   if (num_units >= 2) {
      16           4 :     EXPECT_EQ_U(num_units, dash::TeamSpec<2>().size());
      17           4 :     EXPECT_EQ_U(num_units, dash::TeamSpec<2>().extent(0));
      18           4 :     EXPECT_EQ_U(1, dash::TeamSpec<2>().extent(1));
      19           4 :     EXPECT_EQ_U(1, dash::TeamSpec<2>().rank());
      20             :   }
      21           4 :   if (num_units >= 4) {
      22           4 :     EXPECT_EQ_U(num_units, dash::TeamSpec<4>().size());
      23           4 :     EXPECT_EQ_U(num_units, dash::TeamSpec<4>().extent(0));
      24           4 :     EXPECT_EQ_U(1, dash::TeamSpec<4>().extent(1));
      25           4 :     EXPECT_EQ_U(1, dash::TeamSpec<4>().extent(2));
      26           4 :     EXPECT_EQ_U(1, dash::TeamSpec<4>().extent(3));
      27           4 :     EXPECT_EQ_U(1, dash::TeamSpec<4>().rank());
      28             :   }
      29           4 : }
      30             : 
      31          20 : TEST_F(TeamSpecTest, TeamAndDistributionConstrutor)
      32             : {
      33           4 :   int num_units = dash::Team::All().size();
      34             :   // Team distributed in second dimension (y):
      35             :   dash::DistributionSpec<3> dist_blocked_y(
      36           4 :     dash::NONE, dash::BLOCKED, dash::NONE);
      37           4 :   dash::TeamSpec<3> ts_blocked_y(dist_blocked_y, dash::Team::All());
      38           4 :   EXPECT_EQ_U(num_units, ts_blocked_y.size());
      39           4 :   EXPECT_EQ_U(1, ts_blocked_y.extent(0));
      40           4 :   EXPECT_EQ_U(num_units, ts_blocked_y.extent(1));
      41           4 :   EXPECT_EQ_U(1, ts_blocked_y.extent(2));
      42             : 
      43             :   // Team distributed in third dimension (z):
      44             :   dash::DistributionSpec<3> dist_blocked_z(
      45           4 :     dash::NONE, dash::NONE, dash::BLOCKED);
      46           4 :   dash::TeamSpec<3> ts_blocked_z(dist_blocked_z, dash::Team::All());
      47           4 :   EXPECT_EQ_U(num_units, ts_blocked_z.size());
      48           4 :   EXPECT_EQ_U(1, ts_blocked_z.extent(0));
      49           4 :   EXPECT_EQ_U(1, ts_blocked_z.extent(1));
      50           4 :   EXPECT_EQ_U(num_units, ts_blocked_z.extent(2));
      51           4 : }
      52             : 
      53          20 : TEST_F(TeamSpecTest, ExtentAdjustingConstrutor)
      54             : {
      55           4 :   int num_units = dash::Team::All().size();
      56             :   dash::DistributionSpec<3> dist_blocked_y(
      57           4 :     dash::NONE, dash::BLOCKED, dash::NONE);
      58             : 
      59             :   // Test if extents of default-constructed team spec will
      60             :   // be adjusted according to distribution spec:
      61           4 :   dash::TeamSpec<3> ts_default;
      62           4 :   EXPECT_EQ_U(dash::Team::All().size(), ts_default.size());
      63             :   // Splitting teams in consecutive test runs not supported
      64             :   // for now
      65             :   // dash::Team & team_split = dash::Team::All().split(2);
      66             :   dash::TeamSpec<3> ts_adjusted(
      67             :     // Has extents [n,1,1]
      68             :     ts_default,
      69             :     // NONE, BLOCKED, NONE -> will adjust to extents [1,n,1]
      70             :     dist_blocked_y,
      71           4 :     dash::Team::All());
      72           4 :   EXPECT_EQ_U(1, ts_adjusted.extent(1));
      73           4 :   EXPECT_EQ_U(num_units, ts_adjusted.extent(0));
      74           4 :   EXPECT_EQ_U(1, ts_adjusted.extent(2));
      75           4 : }
      76             : 
      77          20 : TEST_F(TeamSpecTest, Ranks)
      78             : {
      79           7 :   DASH_TEST_LOCAL_ONLY();
      80             : 
      81           1 :   dash::TeamSpec<2> teamspec(dash::Team::All());
      82           1 :   ASSERT_EQ(1,            teamspec.rank());
      83           1 :   ASSERT_EQ(dash::size(), teamspec.num_units(0));
      84           1 :   ASSERT_EQ(1,            teamspec.num_units(1));
      85           1 :   ASSERT_EQ(dash::size(), teamspec.size());
      86             : 
      87          12 : }

Generated by: LCOV version 1.12