-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into bug-140-dart-memleaks
- Loading branch information
Showing
9 changed files
with
323 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <libdash.h> | ||
#include <gtest/gtest.h> | ||
#include "TestBase.h" | ||
#include "DARTCollectiveTest.h" | ||
|
||
TEST_F(DARTCollectiveTest, Send_Recv) { | ||
// we need an even amount of participating units | ||
const int units = (_dash_size / 2) * 2; | ||
|
||
std::vector<int> data(units); | ||
for(int i = 0; i < units; ++i) { | ||
data[i] = i; | ||
} | ||
|
||
// only use non-excess units | ||
if(_dash_id < units) { | ||
// every other unit sends data to the next unit | ||
if(_dash_id % 2 == 0) { | ||
dart_unit_t send_to = _dash_id + 1; | ||
dart_send(&data[_dash_id], 1, DART_TYPE_INT, 0, send_to); | ||
} else { | ||
int recv; | ||
dart_unit_t recv_from = _dash_id - 1; | ||
dart_recv(&recv, 1, DART_TYPE_INT, 0, recv_from); | ||
ASSERT_EQ(recv, data[recv_from]); | ||
} | ||
} | ||
} | ||
|
||
TEST_F(DARTCollectiveTest, Sendrecv) { | ||
const int units = (_dash_size / 2) * 2; | ||
|
||
std::vector<int> data(units); | ||
for(int i = 0; i < units; ++i) { | ||
data[i] = i; | ||
} | ||
|
||
if(_dash_id < units) { | ||
int recv; | ||
dart_unit_t partner; | ||
if(_dash_id % 2 ==0) { | ||
partner = _dash_id + 1; | ||
} else { | ||
partner = _dash_id - 1; | ||
} | ||
// each pair of units send data to each other | ||
dart_sendrecv(&data[_dash_id], 1, DART_TYPE_INT, 0, partner, | ||
&recv, 1, DART_TYPE_INT, 0, partner); | ||
ASSERT_EQ(recv, data[partner]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef DASH__TEST__DART_ONESIDED_TEST_H_ | ||
#define DASH__TEST__DART_ONESIDED_TEST_H_ | ||
|
||
#include <gtest/gtest.h> | ||
#include <libdash.h> | ||
|
||
/** | ||
* Test fixture for onesided operations provided by DART. | ||
*/ | ||
class DARTCollectiveTest : public ::testing::Test { | ||
protected: | ||
size_t _dash_id; | ||
size_t _dash_size; | ||
|
||
DARTCollectiveTest() | ||
: _dash_id(0), | ||
_dash_size(0) { | ||
LOG_MESSAGE(">>> Test suite: DARTCollectiveTest"); | ||
} | ||
|
||
virtual ~DARTCollectiveTest() { | ||
LOG_MESSAGE("<<< Closing test suite: DARTCollectiveTest"); | ||
} | ||
|
||
virtual void SetUp() { | ||
_dash_id = dash::myid(); | ||
_dash_size = dash::size(); | ||
LOG_MESSAGE("===> Running test case with %d units ...", | ||
_dash_size); | ||
} | ||
|
||
virtual void TearDown() { | ||
dash::Team::All().barrier(); | ||
LOG_MESSAGE("<=== Finished test case with %d units", | ||
_dash_size); | ||
} | ||
}; | ||
|
||
#endif // DASH__TEST__DART_ONESIDED_TEST_H_ |
Oops, something went wrong.