Skip to content

Commit 21cfee2

Browse files
committed
Initial commit
0 parents  commit 21cfee2

22 files changed

+4315
-0
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.DS_Store
2+
demo_data/*
3+
results/*
4+
5+
*.swp
6+
7+
*.trace
8+
*.o
9+
*.out
10+
# Xcode
11+
#
12+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
13+
14+
## Build generated
15+
build/
16+
DerivedData/
17+
18+
## Various settings
19+
*.pbxuser
20+
!default.pbxuser
21+
*.mode1v3
22+
!default.mode1v3
23+
*.mode2v3
24+
!default.mode2v3
25+
*.perspectivev3
26+
!default.perspectivev3
27+
xcuserdata/
28+
29+
## Other
30+
*.moved-aside
31+
*.xccheckout
32+
*.xcscmblueprint

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/pngwriter"]
2+
path = lib/pngwriter
3+
url = https://github.com/pngwriter/pngwriter.git

LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

builds/linux/Makefile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
CC:=gcc
2+
3+
# Directories
4+
L_SRC_DIR := ../../lib
5+
SRC_DIR := ../../src
6+
OBJ_DIR := obj
7+
8+
# C/C++ compiler flags
9+
COMMON_FLAGS:=-O3
10+
CFLAGS :=$(COMMON_FLAGS) -D NO_FREETYPE
11+
CXXFLAGS :=$(COMMON_FLAGS) -std=c++11 #-g
12+
NVCCFLAGS:=#-G
13+
14+
# C preprocessor flags
15+
CPPFLAGS :=-D NO_FREETYPE
16+
ifeq ($(CUDA_SUPPORT), 1)
17+
CPPFLAGS:=$(CPPFLAGS) -D __CUDA__ -isystem /usr/local/cuda/include/
18+
endif
19+
ifeq ($(DEBUG_PRINTING), 1)
20+
CPPFLAGS:=$(CPPFLAGS) -D DEBUGPRINT
21+
endif
22+
23+
# Linker flags
24+
LDFLAGS :=-lc -lm -lstdc++ -fopenmp -lpng
25+
ifeq ($(CUDA_SUPPORT), 1)
26+
LDFLAGS:=$(LDFLAGS) -L/usr/local/cuda/lib64 -lcudart
27+
endif
28+
29+
# src./obj. files
30+
31+
32+
GRAPH_VIEWER_SRCS := $(wildcard $(SRC_DIR)/*.cpp)
33+
GRAPH_VIEWER_OBJS := $(GRAPH_VIEWER_SRCS:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
34+
35+
PNGWRITER_SRCS := $(L_SRC_DIR)/pngwriter/src/pngwriter.cc
36+
PNGWRITER_OBJS := $(PNGWRITER_SRCS:$(L_SRC_DIR)/%.cc=$(OBJ_DIR)/%.o)
37+
38+
CUDA_SRCS := $(wildcard $(SRC_DIR)/*.cu)
39+
CUDA_OBJS := $(CUDA_SRCS:$(SRC_DIR)/%.cu=$(OBJ_DIR)/%.o)
40+
CUDA_DEPS := $(wildcard $(SRC_DIR)/*.cuh)
41+
42+
# Don't compile with CUDA support by default
43+
CUDA_SUPPORT ?= 0
44+
45+
CPP_SRC := $(GRAPH_VIEWER_SRCS) $(PNGWRITER_SRCS)
46+
CUDA_SRC := $(CUDA_SRCS)
47+
SOURCES := $(C_SRC) $(CPP_SRC)
48+
OBJECTS := $(GRAPH_VIEWER_OBJS) $(PNGWRITER_OBJS)
49+
50+
ifeq ($(CUDA_SUPPORT), 1)
51+
OBJECTS := $(OBJECTS) $(CUDA_OBJS)
52+
SOURCES := $(SOURCES) $(CUDA_SRCS)
53+
endif
54+
55+
# Generate dependency (.h, .hpp)
56+
# ala http://stackoverflow.com/questions/2394609/makefile-header-dependencies
57+
depend: .depend
58+
.depend: $(SRCS)
59+
rm -f ./.depend
60+
$(CC) $(CXXFLAGS) $(CPPFLAGS) -MM $(CPP_SRC) >> ./.depend
61+
62+
include ./.depend
63+
64+
graph_viewer: $(OBJECTS)
65+
$(CC) $(OBJECTS) $(LDFLAGS) -o graph_viewer
66+
67+
$(GRAPH_VIEWER_OBJS): $(GRAPH_VIEWER_SRCS)
68+
mkdir -p $(@D)
69+
$(CC) -c $(CPPFLAGS) $(CXXFLAGS) --std=c++11 -o $@ $(@:$(OBJ_DIR)/%.o=$(SRC_DIR)/%.cpp)
70+
71+
$(CUDA_OBJS): $(CUDA_SRCS) $(CUDA_DEPS)
72+
mkdir -p $(@D)
73+
nvcc -c $(CXXFLAGS) $(NVCCFLAGS) $(CPPFLAGS) -o $@ $(@:$(OBJ_DIR)/%.o=$(SRC_DIR)/%.cu)
74+
75+
$(PNGWRITER_OBJS): $(PNGWRITER_SRCS)
76+
mkdir -p $(@D)
77+
$(CC) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $(@:$(OBJ_DIR)/%.o=$(L_SRC_DIR)/%.cc)
78+
79+
clear: clean
80+
81+
clean:
82+
rm -r graph_viewer $(OBJ_DIR)/* ./.depend
83+
84+
.PHONY: all clear clean depend

lib/pngwriter

Submodule pngwriter added at 2e2da78

readme.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
`graph_viewer` | GPU accelerated graph layout
2+
=============================================
3+
4+
This repository contains experimental code for large scale graph layout using the GPU. Currently we only implement the basics of ForceAtlas2, a graph layout algorithm designed for social network visualization in Gephi<sup>[1](#jacomy14),[2](#bastian09)</sup>. Our implementation of ForceAtlas2 is based on [the open source implementation](https://github.com/gephi/gephi/tree/6efb108718fa67d1055160f3a18b63edb4ca7be2/modules/LayoutPlugin/src/main/java/org/gephi/layout/plugin/forceAtlas2) used in Gephi itself. For force approximation, we use a CUDA implementation of the Barnes-Hut approximation algorithm<sup>[3](#barnes86)</sup> by Martin Burtscher and Keshav Pingali<sup>[4](#burtscher11)</sup>. This implementation is available as part of [Galois](http://iss.ices.utexas.edu/?p=projects/galois). The average speedup, compared to a *de facto* CPU implementation of ForceAtlas2, is over 40x. This makes it feasible to compute layouts for networks with millions of nodes and edges. More details and results can be found in:
5+
6+
* G.G. Brinkmann, K.F.D. Rietveld and F.W. Takes, Exploiting GPUs for fast force-directed visualization of large-scale networks, in Proceedings of the 46th International Conference on Parallel Processing (ICPP), pp. 382-391, 2017. doi: https://dx.doi.org/10.1109/ICPP.2017.47
7+
8+
9+
#### System Requirements
10+
11+
A CUDA capable GPU. Currently only Linux is supported.
12+
13+
#### Obtaining all code
14+
This repository contains a submodule (`lib/pngwriter`). Be sure to run
15+
```
16+
git submodule init && git submodule update
17+
```
18+
from the root of this Git repository before compiling. The code also depends on the `libpng` library (including its development headers). It should be possible to obtain this using the package manager for your Linux distribution.
19+
20+
#### Compiling
21+
A `Makefile` is located in `builds/linux`. Running
22+
```
23+
make graph_viewer CUDA_SUPPORT=1
24+
```
25+
from this directory compiles `graph_viewer` with CUDA support.
26+
27+
#### Usage
28+
`graph_viewer cuda|seq max_iterations num_snaps sg|wg scale gravity exact|approximate edgelist_path out_path test|image`
29+
30+
`cuda|seq` : choose between a CUDA parallel implementation or a sequential implementation.
31+
32+
`max_iterations` : how many iterations of the layout algorithm to run
33+
34+
`num_snaps` : choose how many times during the layout process a visualization should be rendered
35+
36+
`wg|sg` : choose between weak gravity (inversely proportional to distance) or
37+
strong gravity
38+
39+
`scale` : scale repulsive force
40+
41+
`gravity` : scale gravitational force
42+
43+
`exact|approximate` : choose between the exact/pairwise O(|V|^2) repulsive force calculation or the O(|V|lg(|V|))
44+
approximation using Barnes-Hut (CUDA implementation only supports Barnes-Hut)
45+
46+
`edgelist_path` : ASCII file containing node IDs for each edge on a separate line (whitespace separated)
47+
48+
`out_path` : path to write rendered .png files to
49+
50+
`test|image` : measure runningtimes or produce image of layout
51+
52+
#### References
53+
<a name="jacomy14"><sup>1</sup></a> M. Jacomy, T. Venturini, S. Heymann, and M. Bastian, ["Forceatlas2, a continuous graph layout algorithm for handy network visualization designed for the Gephi software"](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0098679), PLoS ONE, vol. 9, no. 6, pp. 1–12, 2014.
54+
55+
<a name="bastian09"><sup>2</sup></a> M. Bastian, S. Heymann, and M. Jacomy, ["Gephi: an open source software for exploring and manipulating networks."](https://aaai.org/ocs/index.php/ICWSM/09/paper/view/154) in Proceedings of International Conference on Web and Social Media (ICWSM), 2009, pp. 361–362.
56+
57+
<a name="barnes86"><sup>3</sup></a>J. Barnes and P. Hut, ["A hierarchical O(N log N) force-calculation algorithm"](https://www.nature.com/nature/journal/v324/n6096/abs/324446a0.html), Nature, vol. 324, pp. 446–449, 1986.
58+
59+
<a name="burtscher11"><sup>4</sup></a> M. Burtscher and K. Pingali, "An efficient CUDA implementation of the tree-based Barnes Hut n-body algorithm", in GPU Computing Gems Emerald Edition, W. mei W. Hwu, Ed., 2011, ch. 6, pp. 75–92.
60+
61+
#### Disclaimer
62+
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.

0 commit comments

Comments
 (0)