Skip to content

Commit 11b50ac

Browse files
committed
Merge pull request #31 from erikzenker/dev
Fix issue #30
2 parents 0f34144 + ca802c8 commit 11b50ac

File tree

10 files changed

+280
-250
lines changed

10 files changed

+280
-250
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/utils/cmake/modules/" ${CMAKE
1010
###############################################################################
1111
# METIS
1212
###############################################################################
13-
find_package(METIS 5.1.0 REQUIRED)
13+
find_package(METIS 5.1.0)
1414
include_directories(SYSTEM ${METIS_INCLUDE_DIRS})
1515
set(LIBS ${LIBS} ${METIS_LIBRARIES})
1616

@@ -37,7 +37,7 @@ endif(MPI_CXX_FOUND)
3737
# Compiler Flags
3838
###############################################################################
3939
string(FIND ${CMAKE_CXX_COMPILER} "clang++" CXX_COMPILER_IS_CLANG++)
40-
string(FIND ${CMAKE_CXX_COMPILER} "clang++" CXX_COMPILER_IS_G++)
40+
string(FIND ${CMAKE_CXX_COMPILER} "g++" CXX_COMPILER_IS_G++)
4141

4242
if(${CXX_COMPILER_IS_G++})
4343
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

include/BMPI.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace graybat {
7171
Context& operator=(const Context& otherContext){
7272
id = otherContext.getID();
7373
isValid = otherContext.valid();
74+
comm = otherContext.comm;
7475
return *this;
7576

7677
}
@@ -91,7 +92,7 @@ namespace graybat {
9192
return isValid;
9293
}
9394

94-
const mpi::communicator comm;
95+
mpi::communicator comm;
9596

9697
private:
9798
ContextID id;
@@ -563,8 +564,7 @@ namespace graybat {
563564
allGather(newContext, uri, otherUris);
564565

565566
std::copy(otherUris.begin(), otherUris.end(), uriMap[newContext.getID()].begin());
566-
567-
567+
568568
return newContext;
569569

570570
}

include/Cave.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ namespace graybat {
156156
assert(oldContext.valid());
157157

158158
// Create new context for peers which host vertices
159-
std::vector<unsigned> hasVertices(1, vertices.size());
159+
std::vector<unsigned> nVertices(1, vertices.size());
160160
std::vector<unsigned> recvHasVertices(oldContext.size(), 0);
161-
cal.allGather(oldContext, hasVertices, recvHasVertices);
161+
cal.allGather(oldContext, nVertices, recvHasVertices);
162162

163163
std::vector<VAddr> vAddrsWithVertices;
164164

@@ -170,18 +170,16 @@ namespace graybat {
170170

171171
Context newContext = cal.createContext(vAddrsWithVertices, oldContext);
172172
graphMap[graph.id] = newContext;
173-
// std::cout << "context size: " << newContext.size() << std::endl;
174173

175174
// Each peer announces the vertices it hosts
176175
if(newContext.valid()){
177-
178176
// Bound graph to new context
179177

180178

181179
// Retrieve maximum number of vertices per peer
182-
std::vector<unsigned> myVerticesCount(1,vertices.size());
180+
std::vector<unsigned> nVertices(1,vertices.size());
183181
std::vector<unsigned> maxVerticesCount(1, 0);
184-
cal.allReduce(newContext, op::maximum<unsigned>(), myVerticesCount, maxVerticesCount);
182+
cal.allReduce(newContext, op::maximum<unsigned>(), nVertices, maxVerticesCount);
185183

186184
// Gather maxVerticesCount times vertex ids
187185
std::vector<std::vector<Vertex> > newVertexMaps (newContext.size(), std::vector<Vertex>());

include/graybat.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//#include <MPI.hpp> /* graybat::communicationPolicy::MPI */
1111
#include <BMPI.hpp> /* graybat::communicationPolicy::BMPI */
1212
#include <Cave.hpp> /* graybat::Cave */
13-
#include <mapping.hpp> /* graybat::Consecutive etc. */
14-
#include <pattern.hpp> /* graybat::GridDiagonal */
13+
#include <pattern.hpp> /* graybat::pattern::GridDiagonal */
1514

1615

include/mapping.hpp

Lines changed: 0 additions & 233 deletions
This file was deleted.

include/mapping/Consecutive.hpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#pragma once
2+
3+
#include <algorithm> /* std::min */
4+
#include <vector> /* std::vector */
5+
#include <assert.h> /* assert */
6+
7+
namespace graybat {
8+
9+
namespace mapping {
10+
11+
struct Consecutive {
12+
13+
template<typename T_Graph>
14+
std::vector<typename T_Graph::Vertex> operator()(const unsigned processID, const unsigned processCount, T_Graph &graph){
15+
16+
typedef typename T_Graph::Vertex Vertex;
17+
18+
unsigned vertexCount = graph.getVertices().size();
19+
unsigned vertexPerProcess = ceil((float)vertexCount / processCount);
20+
21+
// More processes than vertices
22+
if(processID > vertexCount - 1){
23+
return std::vector<Vertex>(0);
24+
}
25+
26+
unsigned minVertex = processID * vertexPerProcess;
27+
unsigned maxVertex = minVertex + vertexPerProcess;
28+
29+
// Slice maxVertex of last process
30+
if(minVertex > vertexCount){
31+
return std::vector<Vertex>(0);
32+
}
33+
34+
maxVertex = std::min(maxVertex, vertexCount);
35+
36+
assert(minVertex <= maxVertex);
37+
38+
std::vector<Vertex> vertices = graph.getVertices();
39+
std::vector<Vertex> myVertices(vertices.begin() + minVertex, vertices.begin() + maxVertex);
40+
return myVertices;
41+
42+
}
43+
44+
};
45+
46+
} /* mapping */
47+
48+
} /* graybat */

0 commit comments

Comments
 (0)