-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge profiling, icommunicate, version, and installation changes
- Loading branch information
Showing
10 changed files
with
162 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef DIY_IO_SHARED_HPP | ||
#define DIY_IO_SHARED_HPP | ||
|
||
#include <sstream> | ||
#include <fstream> | ||
#include "../mpi.hpp" | ||
|
||
namespace diy | ||
{ | ||
namespace io | ||
{ | ||
|
||
class SharedOutFile: public std::ostringstream | ||
{ | ||
public: | ||
SharedOutFile(std::string filename, diy::mpi::communicator world, int root = 0): | ||
filename_(filename), | ||
world_(world), | ||
root_(root) {} | ||
|
||
~SharedOutFile() { close(); } | ||
|
||
void close() | ||
{ | ||
auto str = this->str(); | ||
std::vector<char> contents(str.begin(), str.end()); | ||
if (world_.rank() == root_) | ||
{ | ||
std::vector<std::vector<char>> all_contents; | ||
diy::mpi::gather(world_, contents, all_contents, root_); | ||
|
||
// write the file serially | ||
std::ofstream out(filename_); | ||
for (auto& contents : all_contents) | ||
out.write(contents.data(), contents.size()); | ||
} else | ||
diy::mpi::gather(world_, contents, root_); | ||
} | ||
|
||
private: | ||
std::string filename_; | ||
diy::mpi::communicator world_; | ||
int root_; | ||
}; | ||
|
||
} | ||
} | ||
|
||
#endif |
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,8 @@ | ||
#ifndef DIY_VERSION_HPP | ||
#define DIY_VERSION_HPP | ||
|
||
#define DIY_VERSION_MAJOR 3 | ||
#define DIY_VERSION_MINOR 5 | ||
#define DIY_VERSION_PATCH dev0 | ||
|
||
#endif |
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,12 @@ | ||
#include <diy/mpi.hpp> | ||
#include <diy/io/shared.hpp> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
diy::mpi::environment env(argc, argv); | ||
diy::mpi::communicator world; | ||
|
||
diy::io::SharedOutFile out("shared-output.txt", world); | ||
|
||
out << world.rank() << " out of " << world.size() << std::endl; | ||
} |