Skip to content

Commit d6d40dc

Browse files
committed
vpr: Remove 'using namespace std'
1 parent 194a396 commit d6d40dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+385
-452
lines changed

vpr/src/base/SetupGrid.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <algorithm>
1212
#include <regex>
1313
#include <limits>
14-
using namespace std;
1514

1615
#include "vtr_assert.h"
1716
#include "vtr_math.h"

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <cstring>
22
#include <vector>
33
#include <sstream>
4-
using namespace std;
54

65
#include "vtr_assert.h"
76
#include "vtr_util.h"
@@ -60,7 +59,7 @@ void SetupVPR(const t_options* Options,
6059
t_router_opts* RouterOpts,
6160
t_analysis_opts* AnalysisOpts,
6261
t_det_routing_arch* RoutingArch,
63-
vector<t_lb_type_rr_node>** PackerRRGraphs,
62+
std::vector<t_lb_type_rr_node>** PackerRRGraphs,
6463
std::vector<t_segment_inf>& Segments,
6564
t_timing_inf* Timing,
6665
bool* ShowGraphics,

vpr/src/base/check_netlist.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <cstdio>
66
#include <cstring>
7-
using namespace std;
87

98
#include "vtr_assert.h"
109
#include "vtr_log.h"

vpr/src/base/echo_files.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <cstdio>
22
#include <cstring>
3-
using namespace std;
43

54
#include "vtr_util.h"
65
#include "vtr_memory.h"

vpr/src/base/place_and_route.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <climits>
66
#include <cstdlib>
77
#include <cmath>
8-
using namespace std;
98

109
#include "vtr_util.h"
1110
#include "vtr_memory.h"
@@ -394,7 +393,7 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
394393
for (size_t i = 0; i < grid.height(); ++i) {
395394
float y = float(i) / num_channels;
396395
chan_width.x_list[i] = (int)floor(cfactor * comp_width(&chan_x_dist, y, separation) + 0.5);
397-
chan_width.x_list[i] = max(chan_width.x_list[i], 1); //Minimum channel width 1
396+
chan_width.x_list[i] = std::max(chan_width.x_list[i], 1); //Minimum channel width 1
398397
}
399398
}
400399

@@ -407,22 +406,22 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
407406
float x = float(i) / num_channels;
408407

409408
chan_width.y_list[i] = (int)floor(cfactor * comp_width(&chan_y_dist, x, separation) + 0.5);
410-
chan_width.y_list[i] = max(chan_width.y_list[i], 1); //Minimum channel width 1
409+
chan_width.y_list[i] = std::max(chan_width.y_list[i], 1); //Minimum channel width 1
411410
}
412411
}
413412

414413
chan_width.max = 0;
415414
chan_width.x_max = chan_width.y_max = INT_MIN;
416415
chan_width.x_min = chan_width.y_min = INT_MAX;
417416
for (size_t i = 0; i < grid.height(); ++i) {
418-
chan_width.max = max(chan_width.max, chan_width.x_list[i]);
419-
chan_width.x_max = max(chan_width.x_max, chan_width.x_list[i]);
420-
chan_width.x_min = min(chan_width.x_min, chan_width.x_list[i]);
417+
chan_width.max = std::max(chan_width.max, chan_width.x_list[i]);
418+
chan_width.x_max = std::max(chan_width.x_max, chan_width.x_list[i]);
419+
chan_width.x_min = std::min(chan_width.x_min, chan_width.x_list[i]);
421420
}
422421
for (size_t i = 0; i < grid.width(); ++i) {
423-
chan_width.max = max(chan_width.max, chan_width.y_list[i]);
424-
chan_width.y_max = max(chan_width.y_max, chan_width.y_list[i]);
425-
chan_width.y_min = min(chan_width.y_min, chan_width.y_list[i]);
422+
chan_width.max = std::max(chan_width.max, chan_width.y_list[i]);
423+
chan_width.y_max = std::max(chan_width.y_max, chan_width.y_list[i]);
424+
chan_width.y_min = std::min(chan_width.y_min, chan_width.y_list[i]);
426425
}
427426

428427
#ifdef VERBOSE

vpr/src/base/read_blif.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <sstream>
2222
#include <unordered_set>
2323
#include <cctype> //std::isdigit
24-
using namespace std;
2524

2625
#include "blifparse.hpp"
2726
#include "atom_netlist.h"

vpr/src/base/read_netlist.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <cstring>
1010
#include <ctime>
1111
#include <map>
12-
using namespace std;
1312

1413
#include "pugixml.hpp"
1514
#include "pugixml_loc.hpp"

vpr/src/base/read_route.cpp

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <sstream>
1818
#include <string>
1919
#include <unordered_set>
20-
using namespace std;
2120

2221
#include "atom_netlist.h"
2322
#include "atom_netlist_utils.h"
@@ -43,13 +42,13 @@ using namespace std;
4342
#include "read_route.h"
4443

4544
/*************Functions local to this module*************/
46-
static void process_route(ifstream& fp, const char* filename, int& lineno);
47-
static void process_nodes(ifstream& fp, ClusterNetId inet, const char* filename, int& lineno);
48-
static void process_nets(ifstream& fp, ClusterNetId inet, string name, std::vector<std::string> input_tokens, const char* filename, int& lineno);
49-
static void process_global_blocks(ifstream& fp, ClusterNetId inet, const char* filename, int& lineno);
50-
static void format_coordinates(int& x, int& y, string coord, ClusterNetId net, const char* filename, const int lineno);
51-
static void format_pin_info(string& pb_name, string& port_name, int& pb_pin_num, string input);
52-
static string format_name(string name);
45+
static void process_route(std::ifstream& fp, const char* filename, int& lineno);
46+
static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* filename, int& lineno);
47+
static void process_nets(std::ifstream& fp, ClusterNetId inet, std::string name, std::vector<std::string> input_tokens, const char* filename, int& lineno);
48+
static void process_global_blocks(std::ifstream& fp, ClusterNetId inet, const char* filename, int& lineno);
49+
static void format_coordinates(int& x, int& y, std::string coord, ClusterNetId net, const char* filename, const int lineno);
50+
static void format_pin_info(std::string& pb_name, std::string& port_name, int& pb_pin_num, std::string input);
51+
static std::string format_name(std::string name);
5352

5453
/*************Global Functions****************************/
5554
bool read_route(const char* route_file, const t_router_opts& router_opts, bool verify_file_digests) {
@@ -61,9 +60,9 @@ bool read_route(const char* route_file, const t_router_opts& router_opts, bool v
6160
/* Begin parsing the file */
6261
VTR_LOG("Begin loading FPGA routing file.\n");
6362

64-
string header_str;
63+
std::string header_str;
6564

66-
ifstream fp;
65+
std::ifstream fp;
6766
fp.open(route_file);
6867

6968
int lineno = 0;
@@ -73,7 +72,7 @@ bool read_route(const char* route_file, const t_router_opts& router_opts, bool v
7372
"Cannot open %s routing file", route_file);
7473
}
7574

76-
getline(fp, header_str);
75+
std::getline(fp, header_str);
7776
++lineno;
7877

7978
std::vector<std::string> header = vtr::split(header_str);
@@ -94,7 +93,7 @@ bool read_route(const char* route_file, const t_router_opts& router_opts, bool v
9493
init_route_structs(router_opts.bb_factor);
9594

9695
/*Check dimensions*/
97-
getline(fp, header_str);
96+
std::getline(fp, header_str);
9897
++lineno;
9998
header.clear();
10099
header = vtr::split(header_str);
@@ -127,11 +126,11 @@ bool read_route(const char* route_file, const t_router_opts& router_opts, bool v
127126
return is_feasible;
128127
}
129128

130-
static void process_route(ifstream& fp, const char* filename, int& lineno) {
129+
static void process_route(std::ifstream& fp, const char* filename, int& lineno) {
131130
/*Walks through every net and add the routing appropriately*/
132-
string input;
131+
std::string input;
133132
std::vector<std::string> tokens;
134-
while (getline(fp, input)) {
133+
while (std::getline(fp, input)) {
135134
++lineno;
136135
tokens.clear();
137136
tokens = vtr::split(input);
@@ -148,7 +147,7 @@ static void process_route(ifstream& fp, const char* filename, int& lineno) {
148147
tokens.clear();
149148
}
150149

151-
static void process_nets(ifstream& fp, ClusterNetId inet, string name, std::vector<std::string> input_tokens, const char* filename, int& lineno) {
150+
static void process_nets(std::ifstream& fp, ClusterNetId inet, std::string name, std::vector<std::string> input_tokens, const char* filename, int& lineno) {
152151
/* Check if the net is global or not, and process appropriately */
153152
auto& cluster_ctx = g_vpr_ctx.mutable_clustering();
154153

@@ -190,7 +189,7 @@ static void process_nets(ifstream& fp, ClusterNetId inet, string name, std::vect
190189
return;
191190
}
192191

193-
static void process_nodes(ifstream& fp, ClusterNetId inet, const char* filename, int& lineno) {
192+
static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* filename, int& lineno) {
194193
/* Not a global net. Goes through every node and add it into trace.head*/
195194

196195
auto& cluster_ctx = g_vpr_ctx.mutable_clustering();
@@ -201,14 +200,14 @@ static void process_nodes(ifstream& fp, ClusterNetId inet, const char* filename,
201200
t_trace* tptr = route_ctx.trace[inet].head;
202201

203202
/*remember the position of the last line in order to go back*/
204-
streampos oldpos = fp.tellg();
203+
std::streampos oldpos = fp.tellg();
205204
int inode, x, y, x2, y2, ptc, switch_id, offset;
206205
int node_count = 0;
207-
string input;
206+
std::string input;
208207
std::vector<std::string> tokens;
209208

210209
/*Walk through every line that begins with Node:*/
211-
while (getline(fp, input)) {
210+
while (std::getline(fp, input)) {
212211
++lineno;
213212

214213
tokens.clear();
@@ -292,7 +291,7 @@ static void process_nodes(ifstream& fp, ClusterNetId inet, const char* filename,
292291
t_pb_graph_pin* pb_pin = get_pb_graph_node_pin_from_block_pin(iblock, pin_num);
293292
t_pb_type* pb_type = pb_pin->parent_node->pb_type;
294293

295-
string pb_name, port_name;
294+
std::string pb_name, port_name;
296295
int pb_pin_num;
297296

298297
format_pin_info(pb_name, port_name, pb_pin_num, tokens[6 + offset]);
@@ -334,18 +333,18 @@ static void process_nodes(ifstream& fp, ClusterNetId inet, const char* filename,
334333

335334
/*This function goes through all the blocks in a global net and verify it with the
336335
* clustered netlist and the placement */
337-
static void process_global_blocks(ifstream& fp, ClusterNetId inet, const char* filename, int& lineno) {
336+
static void process_global_blocks(std::ifstream& fp, ClusterNetId inet, const char* filename, int& lineno) {
338337
auto& cluster_ctx = g_vpr_ctx.mutable_clustering();
339338
auto& place_ctx = g_vpr_ctx.placement();
340339

341-
string block, bnum_str;
340+
std::string block, bnum_str;
342341
int x, y;
343342
std::vector<std::string> tokens;
344343
int pin_counter = 0;
345344

346-
streampos oldpos = fp.tellg();
345+
std::streampos oldpos = fp.tellg();
347346
/*Walk through every block line*/
348-
while (getline(fp, block)) {
347+
while (std::getline(fp, block)) {
349348
++lineno;
350349
tokens.clear();
351350
tokens = vtr::split(block);
@@ -391,10 +390,10 @@ static void process_global_blocks(ifstream& fp, ClusterNetId inet, const char* f
391390
}
392391
}
393392

394-
static void format_coordinates(int& x, int& y, string coord, ClusterNetId net, const char* filename, const int lineno) {
393+
static void format_coordinates(int& x, int& y, std::string coord, ClusterNetId net, const char* filename, const int lineno) {
395394
/*Parse coordinates in the form of (x,y) into correct x and y values*/
396395
coord = format_name(coord);
397-
stringstream coord_stream(coord);
396+
std::stringstream coord_stream(coord);
398397
if (!(coord_stream >> x)) {
399398
vpr_throw(VPR_ERROR_ROUTE, filename, lineno,
400399
"Net %lu has coordinates that is not in the form (x,y)", size_t(net));
@@ -406,12 +405,12 @@ static void format_coordinates(int& x, int& y, string coord, ClusterNetId net, c
406405
}
407406
}
408407

409-
static void format_pin_info(string& pb_name, string& port_name, int& pb_pin_num, string input) {
408+
static void format_pin_info(std::string& pb_name, std::string& port_name, int& pb_pin_num, std::string input) {
410409
/*Parse the pin info in the form of pb_name.port_name[pb_pin_num]
411410
*into its appropriate variables*/
412-
stringstream pb_info(input);
413-
getline(pb_info, pb_name, '.');
414-
getline(pb_info, port_name, '[');
411+
std::stringstream pb_info(input);
412+
std::getline(pb_info, pb_name, '.');
413+
std::getline(pb_info, port_name, '[');
415414
pb_info >> pb_pin_num;
416415
if (!pb_info) {
417416
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
@@ -421,7 +420,7 @@ static void format_pin_info(string& pb_name, string& port_name, int& pb_pin_num,
421420
}
422421

423422
/*Return actual name by extracting it out of the form of (name)*/
424-
static string format_name(string name) {
423+
static std::string format_name(std::string name) {
425424
if (name.length() > 2) {
426425
name.erase(name.begin());
427426
name.erase(name.end() - 1);

vpr/src/base/stats.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <cstring>
33
#include <cmath>
44
#include <set>
5-
using namespace std;
65

76
#include "vtr_assert.h"
87
#include "vtr_log.h"
@@ -122,13 +121,13 @@ void length_and_bends_stats() {
122121
get_num_bends_and_length(net_id, &bends, &length, &segments);
123122

124123
total_bends += bends;
125-
max_bends = max(bends, max_bends);
124+
max_bends = std::max(bends, max_bends);
126125

127126
total_length += length;
128-
max_length = max(length, max_length);
127+
max_length = std::max(length, max_length);
129128

130129
total_segments += segments;
131-
max_segments = max(segments, max_segments);
130+
max_segments = std::max(segments, max_segments);
132131
} else if (cluster_ctx.clb_nlist.net_is_ignored(net_id)) {
133132
num_global_nets++;
134133
} else {
@@ -184,7 +183,7 @@ static void get_channel_occupancy_stats() {
184183
int max_occ = -1;
185184

186185
for (size_t i = 1; i < device_ctx.grid.width(); ++i) {
187-
max_occ = max(chanx_occ[i][j], max_occ);
186+
max_occ = std::max(chanx_occ[i][j], max_occ);
188187
ave_occ += chanx_occ[i][j];
189188
}
190189
ave_occ /= device_ctx.grid.width();
@@ -201,7 +200,7 @@ static void get_channel_occupancy_stats() {
201200
int max_occ = -1;
202201

203202
for (size_t j = 1; j < device_ctx.grid.height(); ++j) {
204-
max_occ = max(chany_occ[i][j], max_occ);
203+
max_occ = std::max(chany_occ[i][j], max_occ);
205204
ave_occ += chany_occ[i][j];
206205
}
207206
ave_occ /= device_ctx.grid.height();

vpr/src/base/vpr_api.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <chrono>
1414
#include <cmath>
1515
#include <sstream>
16-
using namespace std;
1716

1817
#include "vtr_assert.h"
1918
#include "vtr_math.h"
@@ -1043,7 +1042,7 @@ void vpr_setup_vpr(t_options* Options,
10431042
t_router_opts* RouterOpts,
10441043
t_analysis_opts* AnalysisOpts,
10451044
t_det_routing_arch* RoutingArch,
1046-
vector<t_lb_type_rr_node>** PackerRRGraph,
1045+
std::vector<t_lb_type_rr_node>** PackerRRGraph,
10471046
std::vector<t_segment_inf>& Segments,
10481047
t_timing_inf* Timing,
10491048
bool* ShowGraphics,

vpr/src/draw/buttons.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# include "ezgl/point.hpp"
1919
# include "ezgl/application.hpp"
2020
# include "ezgl/graphics.hpp"
21-
using namespace std;
2221

2322
//location of spin buttons, combo boxes, and labels on grid
2423
gint box_width = 1;
@@ -370,4 +369,4 @@ GtkWidget* find_button(const char* button_name) {
370369
return target_button;
371370
}
372371

373-
#endif /* NO_GRAPHICS */
372+
#endif /* NO_GRAPHICS */

vpr/src/draw/draw.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <algorithm>
2020
#include <sstream>
2121
#include <array>
22-
using namespace std;
2322

2423
#include "vtr_assert.h"
2524
#include "vtr_ndoffsetmatrix.h"
@@ -880,8 +879,8 @@ void init_draw_coords(float width_val) {
880879
for (const auto& type : device_ctx.physical_tile_types) {
881880
auto num_pins = type.num_pins;
882881
if (num_pins > 0) {
883-
draw_coords->pin_size = min(draw_coords->pin_size,
884-
(draw_coords->get_tile_width() / (4.0F * num_pins)));
882+
draw_coords->pin_size = std::min(draw_coords->pin_size,
883+
(draw_coords->get_tile_width() / (4.0F * num_pins)));
885884
}
886885
}
887886

0 commit comments

Comments
 (0)