Skip to content

Commit

Permalink
Fix whitespace errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleepingwell committed Nov 9, 2024
1 parent 9bcebd6 commit 05edb3a
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 67 deletions.
24 changes: 12 additions & 12 deletions src/accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ Accessibility::precomputeRangeQueries(float radius) {


vector<vector<pair<long, float>>>
Accessibility::Range(vector<long> srcnodes, float radius, int graphno,
Accessibility::Range(vector<long> srcnodes, float radius, int graphno,
vector<long> ext_ids) {

// Set up a mapping between the external node ids and internal ones
std::unordered_map<long, int> int_ids(ext_ids.size());
for (int i = 0; i < ext_ids.size(); i++) {
int_ids.insert(pair<long, int>(ext_ids[i], i));
}

// use cached results if available
vector<DistanceVec> dists(srcnodes.size());
if (dmsradius > 0 && radius <= dmsradius) {
Expand All @@ -107,7 +107,7 @@ Accessibility::Range(vector<long> srcnodes, float radius, int graphno,
omp_get_thread_num(), dists[i]);
}
}

// todo: check that results are returned from cache correctly
// todo: check that performing an aggregation creates cache

Expand All @@ -116,7 +116,7 @@ Accessibility::Range(vector<long> srcnodes, float radius, int graphno,
for (int i = 0; i < dists.size(); i++) {
output[i].resize(dists[i].size());
for (int j = 0; j < dists[i].size(); j++) {
output[i][j] = std::make_pair(ext_ids[dists[i][j].first],
output[i][j] = std::make_pair(ext_ids[dists[i][j].first],
dists[i][j].second);
}
}
Expand All @@ -140,7 +140,7 @@ Accessibility::Routes(vector<long> sources, vector<long> targets, int graphno) {
#pragma omp parallel
#pragma omp for schedule(guided)
for (int i = 0 ; i < n ; i++) {
vector<NodeID> ret = this->ga[graphno]->Route(sources[i], targets[i],
vector<NodeID> ret = this->ga[graphno]->Route(sources[i], targets[i],
omp_get_thread_num());
routes[i] = vector<int> (ret.begin(), ret.end());
}
Expand All @@ -155,17 +155,17 @@ Accessibility::Distance(int src, int tgt, int graphno) {


vector<double>
Accessibility::Distances(vector<long> sources, vector<long> targets, int graphno) {
Accessibility::Distances(vector<long> sources, vector<long> targets, int graphno) {

int n = std::min(sources.size(), targets.size()); // in case lists don't match
vector<double> distances(n);

#pragma omp parallel
#pragma omp for schedule(guided)
for (int i = 0 ; i < n ; i++) {
distances[i] = this->ga[graphno]->Distance(
sources[i],
targets[i],
sources[i],
targets[i],
omp_get_thread_num());
}
return distances;
Expand Down Expand Up @@ -216,11 +216,11 @@ Accessibility::findNearestPOIs(int srcnode, float maxradius, unsigned number,
maxradius, number, omp_get_thread_num());

vector<distance_node_pair> distance_node_pairs;
std::map<POIKeyType, accessibility_vars_t>::iterator cat_for_pois =
std::map<POIKeyType, accessibility_vars_t>::iterator cat_for_pois =
accessibilityVarsForPOIs.find(cat);
if(cat_for_pois == accessibilityVarsForPOIs.end())
return distance_node_pairs;

accessibility_vars_t &vars = cat_for_pois->second;

/* need to account for the possibility of having
Expand Down
8 changes: 4 additions & 4 deletions src/accessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ class Accessibility {
int graphno = 0);

// get nodes with a range for a specific list of source nodes
vector<vector<pair<long, float>>> Range(vector<long> srcnodes, float radius,
vector<vector<pair<long, float>>> Range(vector<long> srcnodes, float radius,
int graphno, vector<long> ext_ids);

// shortest path between two points
vector<int> Route(int src, int tgt, int graphno = 0);

// shortest path between list of origins and destinations
vector<vector<int>> Routes(vector<long> sources, vector<long> targets,
vector<vector<int>> Routes(vector<long> sources, vector<long> targets,
int graphno = 0);

// shortest path distance between two points
double Distance(int src, int tgt, int graphno = 0);

// shortest path distances between list of origins and destinations
vector<double> Distances(vector<long> sources, vector<long> targets,
vector<double> Distances(vector<long> sources, vector<long> targets,
int graphno = 0);

// precompute the range queries and reuse them
Expand Down
2 changes: 1 addition & 1 deletion src/contraction_hierarchies/src/BasicDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ static const int LATLON_MULTIPLIER = 1000000;
#define CHASSERT(x,y) do { if( !(x)) {ERR(y)} } while(0);


#endif // BASICDEFINITIONS_H_INCLUDED
#endif // BASICDEFINITIONS_H_INCLUDED
2 changes: 1 addition & 1 deletion src/contraction_hierarchies/src/Contractor/Contractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Contractor {
_ImportEdge edge;
edge.source = i->source();
edge.target = i->target();

edge.data.distance = std::max((int)i->weight(), 1 );
assert( edge.data.distance > 0 );
#ifdef DEBUG
Expand Down
26 changes: 13 additions & 13 deletions src/contraction_hierarchies/src/DataStructures/SimpleCHQuery.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
open source routing machine
Copyright (C) Dennis Luxen, others 2010
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Expand Down Expand Up @@ -109,19 +109,19 @@ class SimpleCHQuery {
void RangeQuery(const NodeID start, const unsigned int maxDistance, std::vector<std::pair<NodeID, unsigned> > & resultNodes) {
_rangeHeap->Clear();
_rangeHeap->Insert(start, 0, start);

while(_rangeHeap->Size() > 0) {
const NodeID node = _rangeHeap->DeleteMin(); //_forwardHeap->DeleteMin();
const unsigned distance = _rangeHeap->GetKey( node ); //_forwardHeap->GetKey( node );
resultNodes.push_back(std::make_pair(node, distance));

for ( typename GraphT::EdgeIterator edge = _range->BeginEdges( node ); edge < _range->EndEdges(node); edge++ ) {
const NodeID to = _range->GetTarget(edge);
const EdgeWeight edgeWeight = _range->GetEdgeData(edge).distance;

assert( edgeWeight > 0 );
const unsigned int toDistance = distance + edgeWeight;

if(toDistance <= maxDistance && _range->GetEdgeData(edge).forward) {
//New Node discovered -> Add to Heap + Node Info Storage
if ( !_rangeHeap->WasInserted( to ) ) {
Expand All @@ -137,25 +137,25 @@ class SimpleCHQuery {
}
}
}

//Don't use in production code. This is for verification purposes only
int SimpleDijkstraQuery(const NodeID start, const NodeID target) {
HeapT dijkstraHeap( _range->GetNumberOfNodes() );
dijkstraHeap.Insert(start, 0, start);
while(dijkstraHeap.Size() > 0) {
const NodeID node = dijkstraHeap.DeleteMin();
const NodeID node = dijkstraHeap.DeleteMin();
const unsigned distance = dijkstraHeap.GetKey( node );
if(node == target) {
return distance;
}

for ( typename GraphT::EdgeIterator edge = _range->BeginEdges( node ); edge < _range->EndEdges(node); edge++ ) {
const NodeID to = _range->GetTarget(edge);
const EdgeWeight edgeWeight = _range->GetEdgeData(edge).distance;

assert( edgeWeight > 0 );
const unsigned int toDistance = distance + edgeWeight;

if(_range->GetEdgeData(edge).forward) {
//New Node discovered -> Add to Heap + Node Info Storage
if ( !dijkstraHeap.WasInserted( to ) ) {
Expand Down Expand Up @@ -278,4 +278,4 @@ class SimpleCHQuery {

};

#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class StaticGraph {
_edges[i].target = graph[edge].target;
_edges[i].data = graph[edge].data;
if(0 >= _edges[i].data.distance)
INFO("i: " << i);
INFO("i: " << i);
assert(_edges[i].data.distance > 0);
edge++;
}
Expand Down
26 changes: 13 additions & 13 deletions src/contraction_hierarchies/src/Util/HyperThreading.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
open source routing machine
Copyright (C) Dennis Luxen, others 2010
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Expand All @@ -23,7 +23,7 @@
inline void cpuID(unsigned i, unsigned regs[4]) {
#ifdef _WIN32
//__cpuid((int *)regs, (int)i);

#else
asm volatile
("cpuid" : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
Expand All @@ -34,45 +34,45 @@ inline void cpuID(unsigned i, unsigned regs[4]) {

inline int getNumberOfRealCPUs () {
unsigned regs[4];

// Get vendor
char vendor[12];
cpuID(0, regs);
((unsigned *)vendor)[0] = regs[1]; // EBX
((unsigned *)vendor)[1] = regs[3]; // EDX
((unsigned *)vendor)[2] = regs[2]; // ECX
string cpuVendor = string(vendor, 12);

// Get CPU features
cpuID(1, regs);
unsigned cpuFeatures = regs[3]; // EDX
// Detect hyper-threads

// Detect hyper-threads
bool hyperThreads = false;
if (cpuVendor == "GenuineIntel" && cpuFeatures & (1 << 28)) { // HTT bit
// Logical core count per CPU
cpuID(1, regs);
unsigned logical = (regs[1] >> 16) & 0xff; // EBX[23:16]
cout << " logical cpus: " << logical << endl;
unsigned cores = logical;

if (cpuVendor == "GenuineIntel") {
// Get DCP cache info
cpuID(4, regs);
cores = ((regs[0] >> 26) & 0x3f) + 1; // EAX[31:26] + 1

} else if (cpuVendor == "AuthenticAMD") {
// Get NC: Number of CPU cores - 1
cpuID(0x80000008, regs);
cores = ((unsigned)(regs[2] & 0xff)) + 1; // ECX[7:0] + 1
}

cout << " cpu cores: " << cores << endl;

if (cores < logical) hyperThreads = true;
return cores;
}

cout << "hyper-threads: " << (hyperThreads ? "true" : "false") << endl;
return 1;
}
Expand Down
Loading

0 comments on commit 05edb3a

Please sign in to comment.