Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
starrygl-DynamicHistory
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhlj
starrygl-DynamicHistory
Commits
27d6712a
Commit
27d6712a
authored
Jan 01, 2024
by
Wenjie Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add METIS to git submodule
parent
f9c80767
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
24 deletions
+61
-24
.gitignore
+0
-2
.gitmodules
+4
-0
CMakeLists.txt
+43
-12
cora.py
+6
-4
csrc/partition/metis.cpp
+0
-1
csrc/partition/mtmetis.cpp
+0
-1
starrygl/data/graph.py
+7
-4
third_party/METIS
+1
-0
No files found.
.gitignore
View file @
27d6712a
...
@@ -171,5 +171,3 @@ cython_debug/
...
@@ -171,5 +171,3 @@ cython_debug/
/dataset
/dataset
/test_*
/test_*
/*.ipynb
/*.ipynb
/third_party
!/third_party/ldg_partition
.gitmodules
View file @
27d6712a
[submodule "third_party/ldg_partition"]
[submodule "third_party/ldg_partition"]
path = third_party/ldg_partition
path = third_party/ldg_partition
url = https://gitee.com/onlynagesha/graph-partition-v4
url = https://gitee.com/onlynagesha/graph-partition-v4
[submodule "third_party/METIS"]
path = third_party/METIS
url = https://github.com/KarypisLab/METIS
branch = v5.1.1-DistDGL-v0.5
CMakeLists.txt
View file @
27d6712a
...
@@ -5,7 +5,7 @@ project(starrygl VERSION 0.1)
...
@@ -5,7 +5,7 @@ project(starrygl VERSION 0.1)
option
(
WITH_PYTHON
"Link to Python when building"
ON
)
option
(
WITH_PYTHON
"Link to Python when building"
ON
)
option
(
WITH_CUDA
"Link to CUDA when building"
ON
)
option
(
WITH_CUDA
"Link to CUDA when building"
ON
)
option
(
WITH_METIS
"Link to METIS when building"
ON
)
option
(
WITH_METIS
"Link to METIS when building"
ON
)
option
(
WITH_MTMETIS
"Link to multi-threaded METIS when building"
O
N
)
option
(
WITH_MTMETIS
"Link to multi-threaded METIS when building"
O
FF
)
option
(
WITH_LDG
"Link to (multi-threaded optionally) LDG when building"
ON
)
option
(
WITH_LDG
"Link to (multi-threaded optionally) LDG when building"
ON
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD 17
)
...
@@ -43,22 +43,53 @@ if(WITH_CUDA)
...
@@ -43,22 +43,53 @@ if(WITH_CUDA)
endif
()
endif
()
if
(
WITH_METIS
)
if
(
WITH_METIS
)
add_definitions
(
-DWITH_METIS
)
# add_definitions(-DWITH_METIS)
set
(
GKLIB_DIR
"
${
CMAKE_SOURCE_DIR
}
/third_party/GKlib"
)
# set(GKLIB_DIR "${CMAKE_SOURCE_DIR}/third_party/GKlib")
set
(
METIS_DIR
"
${
CMAKE_SOURCE_DIR
}
/third_party/METIS"
)
# set(METIS_DIR "${CMAKE_SOURCE_DIR}/third_party/METIS")
# set(GKLIB_INCLUDE_DIRS "${GKLIB_DIR}/include")
# file(GLOB_RECURSE GKLIB_LIBRARIES "${GKLIB_DIR}/lib/lib*.a")
# set(METIS_INCLUDE_DIRS "${METIS_DIR}/include")
# file(GLOB_RECURSE METIS_LIBRARIES "${METIS_DIR}/lib/lib*.a")
set
(
GKLIB_INCLUDE_DIRS
"
${
GKLIB_DIR
}
/include"
)
# include_directories(${METIS_INCLUDE_DIRS})
file
(
GLOB_RECURSE GKLIB_LIBRARIES
"
${
GKLIB_DIR
}
/lib/lib*.a"
)
set
(
METIS_INCLUDE_DIRS
"
${
METIS_DIR
}
/include"
)
# add_library(metis_partition SHARED "csrc/partition/metis.cpp")
file
(
GLOB_RECURSE METIS_LIBRARIES
"
${
METIS_DIR
}
/lib/lib*.a"
)
# target_link_libraries(metis_partition PRIVATE ${TORCH_LIBRARIES})
# target_link_libraries(metis_partition PRIVATE ${GKLIB_LIBRARIES})
# target_link_libraries(metis_partition PRIVATE ${METIS_LIBRARIES})
include_directories
(
${
METIS_INCLUDE_DIRS
}
)
add_definitions
(
-DWITH_METIS
)
set
(
METIS_DIR
"
${
CMAKE_SOURCE_DIR
}
/third_party/mts/METIS"
)
set
(
METIS_GKLIB_DIR
"
${
METIS_DIR
}
/GKlib"
)
file
(
GLOB METIS_SRCS
"
${
METIS_DIR
}
/libmetis/*.c"
)
file
(
GLOB METIS_GKLIB_SRCS
"
${
METIS_GKLIB_DIR
}
/*.c"
)
if
(
MSVC
)
file
(
GLOB METIS_GKLIB_WIN32_SRCS
"
${
METIS_GKLIB_DIR
}
/win32/*.c"
)
set
(
METIS_GKLIB_SRCS
${
METIS_GKLIB_SRCS
}
${
METIS_GKLIB_WIN32_SRCS
}
)
endif
()
add_library
(
metis_partition SHARED
"csrc/partition/metis.cpp"
${
METIS_SRCS
}
${
METIS_GKLIB_SRCS
}
)
target_include_directories
(
metis_partition PRIVATE
"
${
METIS_DIR
}
/include"
)
target_include_directories
(
metis_partition PRIVATE
"
${
METIS_GKLIB_DIR
}
"
)
if
(
MSVC
)
target_include_directories
(
metis_partition PRIVATE
"
${
METIS_GKLIB_DIR
}
/win32"
)
endif
()
target_compile_definitions
(
metis_partition PRIVATE -DIDXTYPEWIDTH=64
)
target_compile_definitions
(
metis_partition PRIVATE -DREALTYPEWIDTH=32
)
target_compile_options
(
metis_partition PRIVATE -O3
)
add_library
(
metis_partition SHARED
"csrc/partition/metis.cpp"
)
target_link_libraries
(
metis_partition PRIVATE
${
TORCH_LIBRARIES
}
)
target_link_libraries
(
metis_partition PRIVATE
${
TORCH_LIBRARIES
}
)
target_link_libraries
(
metis_partition PRIVATE
${
GKLIB_LIBRARIES
}
)
if
(
UNIX
)
target_link_libraries
(
metis_partition PRIVATE
${
METIS_LIBRARIES
}
)
target_link_libraries
(
metis_partition PRIVATE m
)
endif
()
endif
()
endif
()
if
(
WITH_MTMETIS
)
if
(
WITH_MTMETIS
)
...
...
cora.py
View file @
27d6712a
from
torch_geometric.datasets
import
Planetoid
from
torch_geometric.datasets
import
Planetoid
from
torch_geometric.utils
import
add_remaining_self_loops
,
to_undirected
from
torch_geometric.utils
import
add_remaining_self_loops
,
to_undirected
,
remove_self_loops
import
os.path
as
osp
import
os.path
as
osp
import
sys
import
sys
...
@@ -13,7 +13,8 @@ if __name__ == "__main__":
...
@@ -13,7 +13,8 @@ if __name__ == "__main__":
data
=
Planetoid
(
"/mnt/nfs/hwj/pyg_datasets/Planetoid/Cora"
,
"Cora"
)[
0
]
data
=
Planetoid
(
"/mnt/nfs/hwj/pyg_datasets/Planetoid/Cora"
,
"Cora"
)[
0
]
if
data
.
is_directed
():
if
data
.
is_directed
():
data
.
edge_index
,
_
=
to_undirected
(
data
.
edge_index
)
data
.
edge_index
,
_
=
to_undirected
(
data
.
edge_index
)
data
.
edge_index
,
_
=
add_remaining_self_loops
(
data
.
edge_index
)
# data.edge_index, _ = add_remaining_self_loops(data.edge_index)
data
.
edge_index
,
_
=
remove_self_loops
(
data
.
edge_index
)
print
(
f
"num_nodes: {data.num_nodes}"
)
print
(
f
"num_nodes: {data.num_nodes}"
)
print
(
f
"num_edges: {data.num_edges}"
)
print
(
f
"num_edges: {data.num_edges}"
)
...
@@ -22,11 +23,12 @@ if __name__ == "__main__":
...
@@ -22,11 +23,12 @@ if __name__ == "__main__":
data
=
GraphData
.
from_pyg_data
(
data
)
data
=
GraphData
.
from_pyg_data
(
data
)
num_parts_list
=
[
1
,
2
,
3
,
5
,
7
,
9
,
11
]
num_parts_list
=
[
1
,
2
,
3
,
5
,
7
,
9
,
11
]
algos
=
[
"metis"
,
'mt-metis'
,
"random"
]
# algos = ["metis", 'mt-metis', "random"]
algos
=
[
"metis"
,
"random"
]
root
=
osp
.
splitext
(
osp
.
abspath
(
__file__
))[
0
]
root
=
osp
.
splitext
(
osp
.
abspath
(
__file__
))[
0
]
print
(
f
"root: {root}"
)
print
(
f
"root: {root}"
)
for
num_parts
in
num_parts_list
:
for
num_parts
in
num_parts_list
:
for
algo
in
algos
:
for
algo
in
algos
:
print
(
f
"======== {num_parts} + {algo} ========"
)
print
(
f
"======== {num_parts} + {algo} ========"
)
data
.
save_partition
(
root
,
num_parts
,
algo
)
data
.
save_partition
(
root
,
num_parts
,
algo
rithm
=
algo
)
csrc/partition/metis.cpp
View file @
27d6712a
#include <torch/all.h>
#include <torch/all.h>
#include <metis.h>
#include <metis.h>
#include <mtmetis.h>
#include "utils.h"
#include "utils.h"
...
...
csrc/partition/mtmetis.cpp
View file @
27d6712a
#include <torch/all.h>
#include <torch/all.h>
#include <metis.h>
#include <mtmetis.h>
#include <mtmetis.h>
#include "utils.h"
#include "utils.h"
...
...
starrygl/data/graph.py
View file @
27d6712a
...
@@ -202,15 +202,18 @@ class GraphData:
...
@@ -202,15 +202,18 @@ class GraphData:
logging
.
info
(
f
"running partition aglorithm: {algorithm}"
)
logging
.
info
(
f
"running partition aglorithm: {algorithm}"
)
partition_kwargs
=
partition_kwargs
or
{}
partition_kwargs
=
partition_kwargs
or
{}
not_self_loop
=
(
edge_index
[
0
]
!=
edge_index
[
1
])
if
node_weight
is
not
None
:
if
node_weight
is
not
None
:
node_weight
=
self
.
node
()[
node_weight
]
node_weight
=
self
.
node
()[
node_weight
]
if
edge_weight
is
not
None
:
if
edge_weight
is
not
None
:
edge_weight
=
self
.
edge
()[
edge_weight
]
edge_weight
=
self
.
edge
()[
edge_weight
]
edge_weight
=
edge_weight
[
not_self_loop
]
if
algorithm
==
"metis"
:
if
algorithm
==
"metis"
:
node_parts
=
metis_partition
(
node_parts
=
metis_partition
(
edge_index
,
edge_index
[:,
not_self_loop
]
,
num_nodes
,
num_parts
,
num_nodes
,
num_parts
,
node_weight
=
node_weight
,
node_weight
=
node_weight
,
edge_weight
=
edge_weight
,
edge_weight
=
edge_weight
,
...
@@ -218,7 +221,7 @@ class GraphData:
...
@@ -218,7 +221,7 @@ class GraphData:
)
)
elif
algorithm
==
"mt-metis"
:
elif
algorithm
==
"mt-metis"
:
node_parts
=
mt_metis_partition
(
node_parts
=
mt_metis_partition
(
edge_index
,
edge_index
[:,
not_self_loop
]
,
num_nodes
,
num_parts
,
num_nodes
,
num_parts
,
node_weight
=
node_weight
,
node_weight
=
node_weight
,
edge_weight
=
edge_weight
,
edge_weight
=
edge_weight
,
...
@@ -226,7 +229,7 @@ class GraphData:
...
@@ -226,7 +229,7 @@ class GraphData:
)
)
elif
algorithm
==
"random"
:
elif
algorithm
==
"random"
:
node_parts
=
random_partition
(
node_parts
=
random_partition
(
edge_index
,
edge_index
[:,
not_self_loop
]
,
num_nodes
,
num_parts
,
num_nodes
,
num_parts
,
**
partition_kwargs
,
**
partition_kwargs
,
)
)
...
...
METIS
@
f5ae915a
Subproject commit f5ae915a84d3bbf1508b529af90292dd7085b9ec
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment