"git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "59ec1dfd550652a493cb99d5704dcddae832a204"
Unverified Commit 40506ecc authored by Da Zheng's avatar Da Zheng Committed by GitHub
Browse files

use openmp to accelerate nid mapping (#242)

* use openmp.

* update cmake.
parent 378c2645
...@@ -77,6 +77,10 @@ else(MSVC) ...@@ -77,6 +77,10 @@ else(MSVC)
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_C_FLAGS "-fopenmp ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fopenmp ${CMAKE_CXX_FLAGS}")
endif()
endif(MSVC) endif(MSVC)
# add source group # add source group
......
...@@ -116,6 +116,7 @@ IdArray GraphOp::MapParentIdToSubgraphId(IdArray parent_vids, IdArray query) { ...@@ -116,6 +116,7 @@ IdArray GraphOp::MapParentIdToSubgraphId(IdArray parent_vids, IdArray query) {
const bool is_sorted = std::is_sorted(parent_data, parent_data + parent_len); const bool is_sorted = std::is_sorted(parent_data, parent_data + parent_len);
if (is_sorted) { if (is_sorted) {
#pragma omp parallel for
for (int64_t i = 0; i < query_len; i++) { for (int64_t i = 0; i < query_len; i++) {
const dgl_id_t id = query_data[i]; const dgl_id_t id = query_data[i];
const auto it = std::find(parent_data, parent_data + parent_len, id); const auto it = std::find(parent_data, parent_data + parent_len, id);
...@@ -132,6 +133,7 @@ IdArray GraphOp::MapParentIdToSubgraphId(IdArray parent_vids, IdArray query) { ...@@ -132,6 +133,7 @@ IdArray GraphOp::MapParentIdToSubgraphId(IdArray parent_vids, IdArray query) {
const dgl_id_t id = parent_data[i]; const dgl_id_t id = parent_data[i];
parent_map[id] = i; parent_map[id] = i;
} }
#pragma omp parallel for
for (int64_t i = 0; i < query_len; i++) { for (int64_t i = 0; i < query_len; i++) {
const dgl_id_t id = query_data[i]; const dgl_id_t id = query_data[i];
auto it = parent_map.find(id); auto it = parent_map.find(id);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment