-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IO] Add experimental/freight-netl-ep output format
- Loading branch information
1 parent
e6c11ab
commit 412241d
Showing
5 changed files
with
83 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "kagen/io/freight-netl.h" | ||
|
||
#include "kagen/io/buffered_writer.h" | ||
|
||
namespace kagen { | ||
FreightNetlEpWriter::FreightNetlEpWriter( | ||
const OutputGraphConfig& config, Graph& graph, const GraphInfo info, const PEID rank, const PEID size) | ||
: StandardGraphWriter(config, graph, info, rank, size) {} | ||
|
||
void FreightNetlEpWriter::WriteHeader(const std::string& filename, const SInt n, const SInt m) { | ||
BufferedTextOutput<> out(tag::append, filename); | ||
out.WriteInt(m / 2).WriteChar(' ').WriteInt(n).WriteChar(' ').WriteString("11").WriteChar('\n').Flush(); | ||
} | ||
|
||
bool FreightNetlEpWriter::WriteBody(const std::string& filename) { | ||
BufferedTextOutput<> out(tag::append, filename); | ||
|
||
// Ignores edge and node weights | ||
|
||
for (SInt e = 0; e < graph_.edges.size(); ++e) { | ||
const auto& [from, to] = graph_.edges[e]; | ||
if (from >= to) { | ||
continue; | ||
} | ||
|
||
out.WriteChar('1') | ||
.WriteChar(' ') | ||
.WriteInt(from) | ||
.WriteChar(' ') | ||
.WriteChar('1') | ||
.WriteChar(' ') | ||
.WriteInt(to) | ||
.WriteChar(' ') | ||
.WriteChar('1') | ||
.WriteChar('\n') | ||
.Flush(); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
std::unique_ptr<GraphWriter> FreightNetlEpFactory::CreateWriter( | ||
const OutputGraphConfig& config, Graph& graph, const GraphInfo info, const PEID rank, const PEID size) const { | ||
return std::make_unique<FreightNetlEpWriter>(config, graph, info, rank, size); | ||
} | ||
} // namespace kagen |
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,29 @@ | ||
#pragma once | ||
|
||
#include "kagen/io/graph_format.h" | ||
|
||
#include <mpi.h> | ||
|
||
#include <string> | ||
|
||
namespace kagen { | ||
class FreightNetlEpWriter : public StandardGraphWriter { | ||
public: | ||
FreightNetlEpWriter(const OutputGraphConfig& config, Graph& graph, GraphInfo info, PEID rank, PEID size); | ||
|
||
protected: | ||
void WriteHeader(const std::string& filename, SInt n, SInt m) final; | ||
|
||
bool WriteBody(const std::string& filename) final; | ||
}; | ||
|
||
class FreightNetlEpFactory : public FileFormatFactory { | ||
public: | ||
std::vector<std::string> DefaultExtensions() const final { | ||
return {"ep.netl"}; | ||
} | ||
|
||
std::unique_ptr<GraphWriter> CreateWriter( | ||
const OutputGraphConfig& config, Graph& graph, GraphInfo info, const PEID rank, const PEID size) const final; | ||
}; | ||
} // namespace kagen |
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