Skip to content

Commit

Permalink
Fixed par for code generation and added closeness centrality
Browse files Browse the repository at this point in the history
  • Loading branch information
tugsbayasgalan committed May 19, 2020
1 parent b423546 commit 0ead07d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 73 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ add_library(graphitlib ${HEADER_FILES} ${LIB_SOURCE_FILES})
include_directories(./test/gtest/)
add_subdirectory(test)
set(GTEST_SOURCE ./test/gtest/gtest-all.cc)
set(GTEST_HEADER ./test/gtest/gtest.h test/input/extern_add_one.cpp src/runtime_lib/infra_gapbs/minimum_spanning_tree.h include/graphit/midend/par_for_lower.h src/runtime_lib/infra_gapbs/memory_alloc.h)
set(GTEST_HEADER ./test/gtest/gtest.h test/input/extern_add_one.cpp src/runtime_lib/infra_gapbs/minimum_spanning_tree.h include/graphit/midend/par_for_lower.h)
add_library(gtest ${GTEST_HEADER} ${GTEST_SOURCE})


Expand Down
Empty file removed apps/closeness_unweighted.gt
Empty file.
64 changes: 64 additions & 0 deletions apps/closeness_unweighted_par_for.gt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
element Vertex end
element Edge end

const edges : edgeset{Edge}(Vertex, Vertex) = load (argv[1]);
const vertices : vertexset{Vertex} = edges.getVertices();
const checked : vector{Vertex}(int) = -1;
const scores: vector{Vertex}(double) = 0;

func updateEdge[checked_local: vector{Vertex}(int)](src : Vertex, dst : Vertex)
checked_local[dst] = checked_local[src] + 1;
end

func toFilter[checked_local: vector{Vertex}(int)](v : Vertex) -> output : bool
output = checked_local[v] == -1;
end

func main()
startTimer();

#l1# par_for i in 0:64

var checked_local : vector{Vertex}(int) = -1;

var start_vertex : int = atoi(argv[2]);
checked_local[start_vertex] = 0;

var frontier : vertexset{Vertex} = new vertexset{Vertex}(0);

frontier.addVertex(start_vertex);

while (frontier.getVertexSetSize() != 0)

#s1# var output : vertexset{Vertex} = edges.from(frontier).to(toFilter[checked_local]).applyModified(updateEdge[checked_local], checked_local);
delete frontier;
frontier = output;

end
delete frontier;


var notConnected : vertexset{Vertex} = vertices.filter(toFilter[checked_local]);
var amountNotConnected : int = notConnected.getVertexSetSize();
var sum: int = checked_local.sum();
sum = sum + amountNotConnected;

scores[start_vertex] = 1/sum;

delete checked_local;
end

var elapsed_time : float = stopTimer();
print "elapsed time: ";
print elapsed_time;
end

schedule:
program->configParForGrainSize("l1", 16)
->configParForScheduleType("l1", "static")
->configParForNumThreads("l1", 4);

program->configApplyDirection("l1:s1", "SparsePush-DensePull")
->configApplyParallelization("l1:s1", "dynamic-vertex-parallel")
->configApplyDenseVertexSet("l1:s1","bitvector", "src-vertexset", "DensePull");

4 changes: 3 additions & 1 deletion src/backend/codegen_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ namespace graphit {
printIndent();
auto for_domain = par_for_stmt->domain;
auto loop_var = par_for_stmt->loopVar;
oss << "#pragma omp parallel ";
oss << "#pragma omp parallel for";

if (par_for_stmt->grain_size != 0){

oss << " ";

if (par_for_stmt->type == ParForSchedule::ParForType::STATIC) {
oss << "schedule(static, " << par_for_stmt->grain_size << ")";

Expand Down
71 changes: 0 additions & 71 deletions src/runtime_lib/infra_gapbs/memory_alloc.h

This file was deleted.

7 changes: 7 additions & 0 deletions test/c++/backend_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,3 +1207,10 @@ TEST_F(BackendTest, ParForNested) {
EXPECT_EQ (0, basicTest(is));
}

//TEST_F(BackendTest, LocalVectorFixedSize) {
// istringstream is("func main()\n"
// " var array: vector[5](int) = {5, 6, 7, 8, 9};\n"
// " print array.sum();\n"
// "end\n");
// EXPECT_EQ (0, basicTest(is));
//}

0 comments on commit 0ead07d

Please sign in to comment.