Skip to content

Commit 6848cb4

Browse files
committed
return_status.hpp
update update update, bugfix
1 parent 711d059 commit 6848cb4

18 files changed

Lines changed: 377 additions & 531 deletions

apps/test_suite_runner/AbstractTestSuiteRunner.hpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ limitations under the License.
2828
#include <string>
2929
#include <vector>
3030

31-
#include <boost/property_tree/json_parser.hpp>
32-
#include <boost/property_tree/ptree.hpp>
3331
#include "ConfigParser.hpp"
3432
#include "StatsModules/IStatsModule.hpp"
35-
#include "osp/bsp/model/BspInstance.hpp"
3633
#include "osp/auxiliary/io/arch_file_reader.hpp"
3734
#include "osp/auxiliary/io/general_file_reader.hpp"
35+
#include "osp/auxiliary/return_status.hpp"
36+
#include "osp/bsp/model/BspInstance.hpp"
37+
#include <boost/property_tree/json_parser.hpp>
38+
#include <boost/property_tree/ptree.hpp>
3839

39-
//#define EIGEN_FOUND 1
40+
// #define EIGEN_FOUND 1
4041

4142
#ifdef EIGEN_FOUND
4243
#include <Eigen/Sparse>
@@ -83,7 +84,7 @@ class AbstractTestSuiteRunner {
8384

8485
if (write_target_object_to_file) {
8586
output_target_object_dir_path = parser.global_params.get_child("scheduleDirectory")
86-
.get_value<std::string>();
87+
.get_value<std::string>();
8788
if (output_target_object_dir_path.substr(0, 1) != "/")
8889
output_target_object_dir_path = executable_dir + output_target_object_dir_path;
8990
if (!output_target_object_dir_path.empty() && !std::filesystem::exists(output_target_object_dir_path)) {
@@ -167,13 +168,13 @@ class AbstractTestSuiteRunner {
167168
}
168169
}
169170

170-
virtual RETURN_STATUS compute_target_object_impl(const BspInstance<GraphType> &instance, std::unique_ptr<TargetObjectType>& target_object,
171-
const pt::ptree &algo_config,
172-
long long &computation_time_ms) = 0;
171+
virtual RETURN_STATUS compute_target_object_impl(const BspInstance<GraphType> &instance, std::unique_ptr<TargetObjectType> &target_object,
172+
const pt::ptree &algo_config,
173+
long long &computation_time_ms) = 0;
173174

174175
virtual void create_and_register_statistic_modules(const std::string &module_name) = 0;
175176

176-
virtual void write_target_object_hook(const TargetObjectType&, const std::string &, const std::string &,
177+
virtual void write_target_object_hook(const TargetObjectType &, const std::string &, const std::string &,
177178
const std::string &) {
178179
} // default in case TargetObjectType cannot be written to file
179180

@@ -268,12 +269,12 @@ class AbstractTestSuiteRunner {
268269
SM_csc_int64 L_csc_int64{};
269270

270271
if constexpr (std::is_same_v<GraphType, sparse_matrix_graph_int32_t> || std::is_same_v<GraphType, sparse_matrix_graph_int64_t>) {
271-
if (ext != "mtx"){
272+
if (ext != "mtx") {
272273
log_stream << "Error: Only .mtx file is accepted for SpTRSV" << std::endl;
273274
return 0;
274275
}
275-
276-
if constexpr (std::is_same_v<GraphType, sparse_matrix_graph_int32_t>){
276+
277+
if constexpr (std::is_same_v<GraphType, sparse_matrix_graph_int32_t>) {
277278
graph_status = Eigen::loadMarket(L_csr_int32, filename_graph);
278279
if (!graph_status) {
279280
std::cerr << "Failed to read matrix from " << filename_graph << std::endl;
@@ -297,7 +298,7 @@ class AbstractTestSuiteRunner {
297298
}
298299
} else {
299300
#endif
300-
graph_status = file_reader::readGraph(filename_graph, bsp_instance.getComputationalDag());
301+
graph_status = file_reader::readGraph(filename_graph, bsp_instance.getComputationalDag());
301302

302303
#ifdef EIGEN_FOUND
303304
}
@@ -309,22 +310,20 @@ class AbstractTestSuiteRunner {
309310

310311
for (auto &algorithm_config_pair : parser.scheduler) {
311312
const pt::ptree &algo_config = algorithm_config_pair.second;
312-
313-
314313

315314
std::string current_algo_name = algo_config.get_child("name").get_value<std::string>();
316315
log_stream << "Start Algorithm " + current_algo_name + "\n";
317316

318317
long long computation_time_ms;
319-
std::unique_ptr<TargetObjectType> target_object;
320-
318+
std::unique_ptr<TargetObjectType> target_object;
319+
321320
RETURN_STATUS exec_status = compute_target_object_impl(bsp_instance, target_object, algo_config, computation_time_ms);
322321

323322
if (exec_status != RETURN_STATUS::OSP_SUCCESS && exec_status != RETURN_STATUS::BEST_FOUND) {
324323
if (exec_status == RETURN_STATUS::ERROR)
325324
log_stream << "Error computing with " << current_algo_name << "." << std::endl;
326325
else if (exec_status == RETURN_STATUS::TIMEOUT)
327-
log_stream << "Scheduler " << current_algo_name << " timed out." << std::endl;
326+
log_stream << "Scheduler " << current_algo_name << " timed out." << std::endl;
328327
continue;
329328
}
330329

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2024 Huawei Technologies Co., Ltd.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
@author Toni Boehnlein, Benjamin Lozes, Pal Andras Papp, Raphael S. Steiner
17+
*/
18+
19+
#pragma once
20+
21+
#include <iostream>
22+
23+
namespace osp {
24+
25+
enum class RETURN_STATUS { OSP_SUCCESS,
26+
BEST_FOUND,
27+
TIMEOUT,
28+
ERROR };
29+
30+
/**
31+
* @brief Converts the enum to a string literal.
32+
* Returns const char* to avoid std::string allocation overhead.
33+
*/
34+
inline const char *to_string(const RETURN_STATUS status) {
35+
switch (status) {
36+
case RETURN_STATUS::OSP_SUCCESS:
37+
return "SUCCESS";
38+
case RETURN_STATUS::BEST_FOUND:
39+
return "BEST FOUND";
40+
case RETURN_STATUS::TIMEOUT:
41+
return "TIMEOUT";
42+
case RETURN_STATUS::ERROR:
43+
return "ERROR";
44+
default:
45+
return "UNKNOWN";
46+
}
47+
}
48+
49+
/**
50+
* @brief Stream operator overload using the helper function.
51+
*/
52+
inline std::ostream &operator<<(std::ostream &os, RETURN_STATUS status) {
53+
return os << to_string(status);
54+
}
55+
56+
} // namespace osp

include/osp/bsp/model/BspArchitecture.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ class BspArchitecture {
636636

637637
/**
638638
* @brief Returns the send costs between two processors. Does not perform bounds checking.
639+
* Does not the communication costs into account.
639640
*
640641
* @param p1 The index of the first processor.
641642
* @param p2 The index of the second processor.

0 commit comments

Comments
 (0)