@@ -20,10 +20,11 @@ limitations under the License.
2020
2121#include " AbstractTestSuiteRunner.hpp"
2222#include " StringToScheduler/run_partitioner.hpp"
23+ #include " osp/auxiliary/io/mtx_hypergraph_file_reader.hpp"
24+ #include " osp/bsp/model/BspSchedule.hpp"
2325#include " osp/graph_implementations/adj_list_impl/computational_dag_vector_impl.hpp"
2426#include " osp/partitioning/model/partitioning.hpp"
2527#include " osp/partitioning/model/partitioning_replication.hpp"
26- #include " osp/bsp/model/BspSchedule.hpp"
2728
2829namespace osp {
2930
@@ -32,7 +33,7 @@ class PartitioningStatsModule : public IStatisticModule<Partitioning<HypergraphD
3233 std::vector<std::string> GetMetricHeaders () const override { return {" Cost" , " CutNet" }; }
3334
3435 std::map<std::string, std::string> RecordStatistics (const Partitioning<HypergraphDefT> &partitioning,
35- std::ofstream & /* log_stream*/ ) const override {
36+ std::ofstream & /* log_stream*/ ) const override {
3637 std::map<std::string, std::string> stats;
3738 stats[" Cost" ] = std::to_string (partitioning.ComputeConnectivityCost ());
3839 stats[" CutNet" ] = std::to_string (partitioning.ComputeCutNetCost ());
@@ -43,13 +44,12 @@ class PartitioningStatsModule : public IStatisticModule<Partitioning<HypergraphD
4344template <typename GraphType>
4445class PartitioningTestSuiteRunner : public AbstractTestSuiteRunner <Partitioning<HypergraphDefT>, GraphType> {
4546 private:
46-
4747 protected:
4848 ReturnStatus ComputeTargetObjectImpl (const BspInstance<GraphType> &instance,
49- std::unique_ptr<Partitioning<HypergraphDefT> > &targetObject,
50- const pt::ptree &algoConfig,
51- long long &computationTimeMs) override {
52- return ReturnStatus::ERROR; // unused
49+ std::unique_ptr<Partitioning<HypergraphDefT>> &targetObject,
50+ const pt::ptree &algoConfig,
51+ long long &computationTimeMs) override {
52+ return ReturnStatus::ERROR; // unused
5353 }
5454
5555 void CreateAndRegisterStatisticModules (const std::string &moduleName) override {
@@ -102,7 +102,7 @@ int PartitioningTestSuiteRunner<GraphType>::Run(int argc, char *argv[]) {
102102 continue ;
103103 }
104104 this ->logStream_ << " Start Machine: " + filenameMachine + " \n " ;
105-
105+ std::cout << " Start Machine: " + filenameMachine + " \n " ;
106106
107107 for (const auto &graphEntry : std::filesystem::recursive_directory_iterator (this ->graphDirPath_ )) {
108108 if (std::filesystem::is_directory (graphEntry)) {
@@ -115,24 +115,42 @@ int PartitioningTestSuiteRunner<GraphType>::Run(int argc, char *argv[]) {
115115 nameGraph = nameGraph.substr (0 , nameGraph.rfind (' .' ));
116116 }
117117 this ->logStream_ << " Start Hypergraph: " + filenameGraph + " \n " ;
118+ std::cout << " Start Hypergraph: " + filenameGraph + " \n " ;
118119
119120 bool graphStatus = false ;
120121 GraphType dag;
121- graphStatus = file_reader::ReadGraph (filenameGraph, dag);
122+
123+ std::string fileEnding = filename.substr (filenameGraph.rfind (" ." ) + 1 );
124+
125+ PartitioningProblem<HypergraphT>
126+ instance; // (ConvertFromCdagAsHyperdag<HypergraphT, GraphType>(dag), arch.NumberOfProcessors());
127+ instance.SetNumberOfPartitions (arch.NumberOfProcessors ());
128+ instance.SetMaxWorkWeightViaImbalanceFactor (static_cast <double >(arch.CommunicationCosts ()) / 100.0 );
129+
130+ if (fileEnding == " mtx" ) {
131+ graphStatus = file_reader::ReadHypergraphMartixMarketFormat (
132+ filenameGraph, instance.getHypergraph (), MatrixToHypergraphFormat::FINE_GRAINED);
133+
134+ } else if (fileEnding == " mtx2" ) {
135+ graphStatus = file_reader::ReadHypergraphMartixMarketFormat (
136+ filenameGraph, instance.getHypergraph (), MatrixToHypergraphFormat::ROW_NET);
137+
138+ } else {
139+ graphStatus = file_reader::ReadGraph (filenameGraph, dag);
140+ instance.setHypergraph (ConvertFromCdagAsHyperdag<HypergraphT, GraphType>(dag));
141+ }
122142
123143 if (!graphStatus) {
124144 this ->logStream_ << " Reading graph file " << filenameGraph << " failed." << std::endl;
125145 continue ;
126146 }
127147
128- PartitioningProblem<HypergraphT> instance (ConvertFromCdagAsHyperdag<HypergraphT, GraphType>(dag), arch.NumberOfProcessors ());
129- instance.SetMaxWorkWeightViaImbalanceFactor (static_cast <double >(arch.CommunicationCosts ()) / 100.0 );
130-
131148 for (auto &algorithmConfigPair : this ->parser_ .scheduler_ ) {
132149 const pt::ptree &algoConfig = algorithmConfigPair.second ;
133150
134151 std::string currentAlgoName = algoConfig.get_child (" name" ).get_value <std::string>();
135152 this ->logStream_ << " Start Algorithm " + currentAlgoName + " \n " ;
153+ std::cout << " Start Algorithm " + currentAlgoName + " \n " ;
136154
137155 long long computationTimeMs;
138156 const auto startTime = std::chrono::high_resolution_clock::now ();
@@ -164,7 +182,8 @@ int PartitioningTestSuiteRunner<GraphType>::Run(int argc, char *argv[]) {
164182 currentRowValues[" CutNet" ] = std::to_string (cost.second );
165183
166184 for (size_t i = 0 ; i < this ->allCsvHeaders_ .size (); ++i) {
167- this ->statsOutStream_ << currentRowValues[this ->allCsvHeaders_ [i]] << (i == this ->allCsvHeaders_ .size () - 1 ? " " : " ," );
185+ this ->statsOutStream_ << currentRowValues[this ->allCsvHeaders_ [i]]
186+ << (i == this ->allCsvHeaders_ .size () - 1 ? " " : " ," );
168187 }
169188 this ->statsOutStream_ << " \n " ;
170189 }
0 commit comments