Skip to content

Commit f4b17f0

Browse files
prime_factors uses std::vecotr & commenting style
1 parent b199b7f commit f4b17f0

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,16 +2294,16 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
22942294
std::vector<bool> perturb_opins(segment_inf.size(), false);
22952295

22962296
if (segment_inf.size() > 1) {
2297-
/* Segments of one length are grouped together in the channel. *
2298-
* In the future we can determine if any of these segments will *
2299-
* encounter the pathological step size case, and determine if *
2300-
* we need to perturb based on the segment's frequency (if *
2301-
* frequency is small we should not perturb - testing has found *
2302-
* that perturbing a channel when unnecessary increases needed *
2303-
* W to achieve the same delay); but for now we just return. */
2297+
// Segments of one length are grouped together in the channel.
2298+
// In the future we can determine if any of these segments will
2299+
// encounter the pathological step size case, and determine if
2300+
// we need to perturb based on the segment's frequency (if
2301+
// frequency is small we should not perturb - testing has found
2302+
// that perturbing a channel when unnecessary increases needed
2303+
// W to achieve the same delay); but for now we just return.
23042304
return perturb_opins;
23052305
} else {
2306-
/* There are as many wire start points as the value of L */
2306+
// There are as many wire start points as the value of L
23072307
num_wire_types = segment_inf[0].length;
23082308
}
23092309

@@ -2315,25 +2315,22 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
23152315
Fc_max = Fc_out[i][0];
23162316
}
23172317
}
2318-
/* Nothing to perturb if Fc=0; no need to perturb if Fc = 1 */
2318+
2319+
// Nothing to perturb if Fc=0; no need to perturb if Fc = 1
23192320
if (Fc_max == 0 || Fc_max == max_chan_width) {
23202321
return perturb_opins;
23212322
}
23222323

2323-
/* Pathological cases occur when the step size, W/Fc, is a multiple of *
2324-
* the number of wire starting points, L. Specifically, when the step *
2325-
* size is a multiple of a prime factor of L, the connection pattern *
2326-
* will always skip some wires. Thus, we perturb pins if we detect this *
2327-
* case. */
2324+
// Pathological cases occur when the step size, W/Fc, is a multiple of
2325+
// the number of wire starting points, L. Specifically, when the step
2326+
// size is a multiple of a prime factor of L, the connection pattern
2327+
// will always skip some wires. Thus, we perturb pins if we detect this case.
23282328

23292329
// get an upper bound on the number of prime factors of num_wire_types
23302330
int max_primes = (int)floor(log((float)num_wire_types) / log(2.0));
2331-
max_primes = std::max(max_primes, 1); //Minimum of 1 to ensure we allocate space for at least one prime_factor
2331+
max_primes = std::max(max_primes, 1); // Minimum of 1 to ensure we allocate space for at least one prime_factor
23322332

2333-
int* prime_factors = new int[max_primes];
2334-
for (int i = 0; i < max_primes; i++) {
2335-
prime_factors[i] = 0;
2336-
}
2333+
std::vector<int> prime_factors(max_primes, 0);
23372334

23382335
// Find the prime factors of num_wire_types
23392336
int num = num_wire_types;
@@ -2351,11 +2348,11 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
23512348
}
23522349
}
23532350
if (num_factors == 0) {
2354-
prime_factors[num_factors++] = num_wire_types; /* covers cases when num_wire_types is prime */
2351+
prime_factors[num_factors++] = num_wire_types; // covers cases when num_wire_types is prime
23552352
}
23562353

2357-
/* Now see if step size is an approximate multiple of one of the factors. A *
2358-
* threshold is used because step size may not be an integer. */
2354+
// Now see if step size is an approximate multiple of one of the factors.
2355+
// A threshold is used because step size may not be an integer.
23592356
step_size = (float)max_chan_width / Fc_max;
23602357
for (int i = 0; i < num_factors; i++) {
23612358
if (vtr::nint(step_size) < prime_factors[i]) {
@@ -2364,15 +2361,14 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
23642361
}
23652362

23662363
n = step_size / prime_factors[i];
2367-
n = n - (float)vtr::nint(n); /* fractional part */
2364+
n = n - (float)vtr::nint(n); // fractional part
23682365
if (fabs(n) < threshold) {
23692366
perturb_opins[0] = true;
23702367
break;
23712368
} else {
23722369
perturb_opins[0] = false;
23732370
}
23742371
}
2375-
delete[] prime_factors;
23762372

23772373
return perturb_opins;
23782374
}

0 commit comments

Comments
 (0)