-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc46995
commit 9d88802
Showing
21 changed files
with
3,272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# SPDX-License-Identifier: MIT | ||
# Copyright (c) 2023. University of Texas at Austin. All rights reserved. | ||
|
||
### Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. ### | ||
|
||
cmake_minimum_required(VERSION 3.21 FATAL_ERROR) | ||
|
||
project( | ||
pando-wf2 | ||
VERSION 1.0.0 | ||
DESCRIPTION "Exact Matching Galois implementation for PANDO" | ||
LANGUAGES CXX | ||
) | ||
|
||
if(PROJECT_IS_TOP_LEVEL) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(LINKER_SCRIPT ${CMAKE_BINARY_DIR}/linker.ld) | ||
set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage -fprofile-info-section -DENABLE_GCOV=1") | ||
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "--coverage -T ${LINKER_SCRIPT}") | ||
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "--coverage -T ${LINKER_SCRIPT}") | ||
set(CMAKE_MODULE_LINKER_FLAGS_COVERAGE "--coverage -T ${LINKER_SCRIPT}") | ||
endif() | ||
|
||
# helper functions | ||
include(${pando-lib-galois_SOURCE_DIR}/cmake/PANDOCompilerOptions.cmake) | ||
|
||
# disable in-source builds to avoid source tree corruption | ||
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") | ||
message(FATAL_ERROR | ||
"In-source builds are not supported. Please create a directory for build files and delete CMakeCache.txt and \ | ||
the CMakefiles directory." | ||
) | ||
endif() | ||
|
||
# default build type | ||
set(DEFAULT_BUILD_TYPE "Release") | ||
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to default '${DEFAULT_BUILD_TYPE}' as none was specified.") | ||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) | ||
# possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") | ||
endif () | ||
|
||
# target | ||
pando_add_library(pando-wf2-galois) | ||
|
||
# headers | ||
include(GenerateExportHeader) | ||
generate_export_header(pando-wf2-galois EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/pando-wf2-galois/export.h) | ||
|
||
target_include_directories(pando-wf2-galois | ||
PUBLIC | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/pando-wf2-galois>" | ||
"$<INSTALL_INTERFACE:include>" | ||
PRIVATE | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src" | ||
) | ||
|
||
# library properties | ||
set_target_properties(pando-wf2-galois | ||
PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON | ||
CXX_EXTENSIONS OFF | ||
CXX_VISIBILITY_PRESET hidden | ||
VISIBILITY_INLINES_HIDDEN ON | ||
POSITION_INDEPENDENT_CODE ON | ||
VERSION "${PROJECT_VERSION}" | ||
SOVERSION "${PROJECT_VERSION_MAJOR}" | ||
EXPORT_NAME pando-wf2-galois | ||
OUTPUT_NAME pando-wf2-galois | ||
PUBLIC_HEADER "${PUBLIC_HEADERS}" | ||
# enable RPATH during both build and installation; use relative RPATH as well | ||
SKIP_BUILD_RPATH FALSE | ||
BUILD_WITH_INSTALL_RPATH FALSE | ||
INSTALL_RPATH_USE_LINK_PATH TRUE | ||
BUILD_RPATH "\$ORIGIN" | ||
INSTALL_RPATH "\$ORIGIN" | ||
# organize lib / bin in the build directory | ||
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib | ||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib | ||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin | ||
) | ||
|
||
# sources | ||
add_subdirectory(src) | ||
|
||
# tests | ||
option(BUILD_TESTING "Build tests." ON) | ||
if (BUILD_TESTING AND ENABLE_PANDORT_TESTS) | ||
add_subdirectory(test) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-License-Identifier: MIT | ||
# Copyright (c) 2023. University of Texas at Austin. All rights reserved. | ||
|
||
# Stop searching for additional config files. | ||
set noparent | ||
|
||
# Use 'PANDO_WF2_GALOIS_' as the cpp header guard prefix | ||
root=.. | ||
|
||
# Limit line length. | ||
linelength=100 | ||
|
||
# We ignore the below rules | ||
|
||
# do not want to indent public/private/protected by +1 space inside class | ||
filter=-whitespace/indent | ||
# ok without two spaces between code and comments | ||
filter=-whitespace/comments | ||
filter=-legal/copyright | ||
# do not include the directory when naming header files | ||
filter=-build/include_subdir | ||
filter=-build/c++11 | ||
#filter=-build/include_order | ||
# We want to pass non-const references as function arguments | ||
filter=-runtime/references | ||
# cpplint throws false positives for some constexpr expressions that are used for array dims | ||
filter=-runtime/arrays | ||
|
||
# Ignore code that may be submodules in future. | ||
# exclude_files=third_party or external |
160 changes: 160 additions & 0 deletions
160
workflows/matching/include/pando-wf2-galois/approx_match.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) 2023. University of Texas at Austin. All rights reserved. | ||
#ifndef PANDO_WF2_GALOIS_APPROX_MATCH_H_ | ||
#define PANDO_WF2_GALOIS_APPROX_MATCH_H_ | ||
|
||
#include "export.h" | ||
|
||
#include "pando-rt/export.h" | ||
#include "pando-rt/pando-rt.hpp" | ||
#include "pando-wf2-galois/graph_ds.h" | ||
#include <pando-lib-galois/graphs/dist_local_csr.hpp> | ||
|
||
namespace wf2 { | ||
namespace approx { | ||
|
||
using Vertex = wf::WMDVertex; | ||
using Edge = wf::WMDEdge; | ||
using Graph = galois::DistLocalCSR<Vertex, Edge>; | ||
|
||
struct node_sim { | ||
std::uint64_t lid; | ||
double similarity; | ||
std::uint64_t token; | ||
node_sim(std::uint64_t lid_, double similarity_, std::uint64_t token_) | ||
: lid(lid_), similarity(similarity_), token(token_) {} | ||
node_sim() = default; | ||
}; | ||
|
||
struct GraphState { | ||
Graph graph; | ||
pando::Vector<std::uint64_t> person_sale_person_bomb_bath; | ||
pando::Vector<std::uint64_t> person_sale_person_pressure_cooker; | ||
pando::Vector<std::uint64_t> person_sale_person_ammunition; | ||
pando::Vector<std::uint64_t> person_sale_person_electronics; | ||
pando::Vector<std::uint64_t> person_purchase_person_bomb_bath; | ||
pando::Vector<std::uint64_t> person_purchase_person_pressure_cooker; | ||
pando::Vector<std::uint64_t> person_purchase_person_ammunition; | ||
pando::Vector<std::uint64_t> person_purchase_person_electronics; | ||
pando::Vector<std::uint64_t> person_author_forumevent; | ||
pando::Vector<std::uint64_t> person_author_publication; | ||
pando::Vector<std::uint64_t> forum_includes_forumevent; | ||
pando::Vector<std::uint64_t> forum_hastopic_topic_nyc; | ||
pando::Vector<std::uint64_t> forumevent_hastopic_topic_bomb; | ||
pando::Vector<std::uint64_t> forumevent_hastopic_topic_explosion; | ||
pando::Vector<std::uint64_t> forumevent_hastopic_topic_williamsburg; | ||
pando::Vector<std::uint64_t> forumevent_hastopic_topic_outdoors; | ||
pando::Vector<std::uint64_t> forumevent_hastopic_topic_prospect_park; | ||
pando::Vector<std::uint64_t> forumevent_hastopic_topic_jihad; | ||
pando::Vector<std::uint64_t> publication_hasorg_topic_near_nyc; | ||
pando::Vector<std::uint64_t> publication_hastopic_topic_electrical_eng; | ||
|
||
pando::Vector<pando::Vector<node_sim>> similarity; | ||
pando::Vector<bool> new_matched; | ||
pando::Vector<bool> matched; | ||
pando::Vector<node_sim> match; | ||
|
||
explicit GraphState(Graph g_) : graph(g_) {} | ||
GraphState() = default; | ||
|
||
void initialize(std::uint64_t other_size) { | ||
std::uint64_t size = graph.size(); | ||
PANDO_CHECK(person_sale_person_bomb_bath.initialize(size)); | ||
PANDO_CHECK(person_sale_person_pressure_cooker.initialize(size)); | ||
PANDO_CHECK(person_sale_person_ammunition.initialize(size)); | ||
PANDO_CHECK(person_sale_person_electronics.initialize(size)); | ||
PANDO_CHECK(person_purchase_person_bomb_bath.initialize(size)); | ||
PANDO_CHECK(person_purchase_person_pressure_cooker.initialize(size)); | ||
PANDO_CHECK(person_purchase_person_ammunition.initialize(size)); | ||
PANDO_CHECK(person_purchase_person_electronics.initialize(size)); | ||
PANDO_CHECK(person_author_forumevent.initialize(size)); | ||
PANDO_CHECK(person_author_publication.initialize(size)); | ||
PANDO_CHECK(forum_includes_forumevent.initialize(size)); | ||
PANDO_CHECK(forum_hastopic_topic_nyc.initialize(size)); | ||
PANDO_CHECK(forumevent_hastopic_topic_bomb.initialize(size)); | ||
PANDO_CHECK(forumevent_hastopic_topic_explosion.initialize(size)); | ||
PANDO_CHECK(forumevent_hastopic_topic_williamsburg.initialize(size)); | ||
PANDO_CHECK(forumevent_hastopic_topic_outdoors.initialize(size)); | ||
PANDO_CHECK(forumevent_hastopic_topic_prospect_park.initialize(size)); | ||
PANDO_CHECK(forumevent_hastopic_topic_jihad.initialize(size)); | ||
PANDO_CHECK(publication_hasorg_topic_near_nyc.initialize(size)); | ||
PANDO_CHECK(publication_hastopic_topic_electrical_eng.initialize(size)); | ||
|
||
PANDO_CHECK(similarity.initialize(size)); | ||
for (pando::GlobalRef<pando::Vector<node_sim>> s : similarity) { | ||
pando::Vector<node_sim> empty_s; | ||
PANDO_CHECK(empty_s.initialize(other_size)); | ||
s = empty_s; | ||
} | ||
PANDO_CHECK(new_matched.initialize(size)); | ||
PANDO_CHECK(matched.initialize(size)); | ||
PANDO_CHECK(match.initialize(size)); | ||
} | ||
|
||
void deinitialize() { | ||
person_sale_person_bomb_bath.deinitialize(); | ||
person_sale_person_pressure_cooker.deinitialize(); | ||
person_sale_person_ammunition.deinitialize(); | ||
person_sale_person_electronics.deinitialize(); | ||
person_purchase_person_bomb_bath.deinitialize(); | ||
person_purchase_person_pressure_cooker.deinitialize(); | ||
person_purchase_person_ammunition.deinitialize(); | ||
person_purchase_person_electronics.deinitialize(); | ||
person_author_forumevent.deinitialize(); | ||
person_author_publication.deinitialize(); | ||
forum_includes_forumevent.deinitialize(); | ||
forum_hastopic_topic_nyc.deinitialize(); | ||
forumevent_hastopic_topic_bomb.deinitialize(); | ||
forumevent_hastopic_topic_explosion.deinitialize(); | ||
forumevent_hastopic_topic_williamsburg.deinitialize(); | ||
forumevent_hastopic_topic_outdoors.deinitialize(); | ||
forumevent_hastopic_topic_prospect_park.deinitialize(); | ||
forumevent_hastopic_topic_jihad.deinitialize(); | ||
publication_hasorg_topic_near_nyc.deinitialize(); | ||
publication_hastopic_topic_electrical_eng.deinitialize(); | ||
for (pando::Vector<node_sim> s : similarity) { | ||
s.deinitialize(); | ||
} | ||
similarity.deinitialize(); | ||
match.deinitialize(); | ||
matched.deinitialize(); | ||
new_matched.deinitialize(); | ||
} | ||
}; | ||
|
||
struct State { | ||
GraphState state_lhs; | ||
GraphState state_rhs; | ||
pando::GlobalPtr<std::uint64_t> match_count_ptr; | ||
|
||
public: | ||
State() = default; | ||
State(Graph g_lhs, Graph g_rhs) : state_lhs(g_lhs), state_rhs(g_rhs) {} | ||
|
||
void initialize() { | ||
state_lhs.initialize(state_rhs.graph.size()); | ||
state_rhs.initialize(state_lhs.graph.size()); | ||
match_count_ptr = static_cast<decltype(match_count_ptr)>( | ||
pando::getDefaultMainMemoryResource()->allocate(sizeof(std::uint64_t))); | ||
} | ||
|
||
void deinitialize() { | ||
state_lhs.deinitialize(); | ||
state_rhs.deinitialize(); | ||
} | ||
}; | ||
|
||
void match(pando::GlobalPtr<Graph>, pando::GlobalPtr<Graph>, int k); | ||
|
||
void matchTriples(GraphState, Graph::VertexTopologyID); | ||
void matchTriplesPerson(GraphState, Graph::VertexTopologyID); | ||
void matchTriplesForum(GraphState, Graph::VertexTopologyID); | ||
void matchTriplesForumEvent(GraphState, Graph::VertexTopologyID); | ||
void matchTriplesPub(GraphState, Graph::VertexTopologyID); | ||
void calculateSimilarity(State&); | ||
void calculateMatch(State); | ||
|
||
} // namespace approx | ||
} // namespace wf2 | ||
|
||
#endif // PANDO_WF2_GALOIS_APPROX_MATCH_H_ |
Oops, something went wrong.