Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
branches: [ master, sc_release ]
workflow_dispatch:


env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -25,14 +24,6 @@ jobs:

- name: prep
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
&& sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
&& rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
&& sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" \
&& sudo apt-get update
DEBIAN_FRONTEND=noninteractive \
sudo apt-get -y install \
intel-oneapi-tbb-devel
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
DEBIAN_FRONTEND=noninteractive \
sudo apt-get -y install \
Expand All @@ -47,8 +38,7 @@ jobs:
cd NWgr
mkdir build
cd build
export TBBROOT=/opt/intel/oneapi/tbb/latest
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=g++-11 -DNW_GRAPH_BUILD_DOCS=OFF -DNW_GRAPH_BUILD_TESTS=ON
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=g++-11 -DNWGRAPH_BUILD_DOCS=OFF -DNWGRAPH_BUILD_TESTS=ON -DNWGRAPH_BUILD_BENCH=ON -DNWGRAPH_BUILD_EXAMPLES=ON -DNWGRAPH_BUILD_APBS=ON -DNWGRAPH_FETCH_TBB=ON

- name: make
run: |
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/build_cmake_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
branches: [ master, sc_release ]
workflow_dispatch:

# pull_request:
# branches:
# - '*'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -30,15 +26,13 @@ jobs:
- name: prep
run: |
brew update
brew install tbb

- name: cmake
run: |
cd NWgr
mkdir build
cd build
export TBBROOT=/opt/intel/oneapi/tbb/latest
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=g++-11 -DNW_GRAPH_BUILD_DOCS=OFF -DNW_GRAPH_BUILD_TESTS=ON
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=g++-11 -DNWGRAPH_BUILD_DOCS=OFF -DNWGRAPH_BUILD_TESTS=ON -DNWGRAPH_BUILD_BENCH=ON -DNWGRAPH_BUILD_EXAMPLES=ON -DNWGRAPH_BUILD_APBS=ON -DNWGRAPH_FETCH_TBB=ON

- name: make
run: |
Expand Down
29 changes: 19 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ option(NWGRAPH_BUILD_BENCH "Determines whether to build performance benchmarks."
option(NWGRAPH_BUILD_EXAMPLES "Determines whether to build examples." OFF)
option(NWGRAPH_BUILD_TESTS "Determines whether to build tests." ON)
option(NWGRAPH_USE_TBBMALLOC "Link to tbbmalloc" OFF)
option(NWGRAPH_FETCH_TBB "Fetch TBB during build process" ON)
option(NWGRAPH_USE_SUBMODULE "Use TBB submodule for build" OFF)


# -----------------------------------------------------------------------------
Expand All @@ -102,15 +104,18 @@ option(NWGRAPH_USE_TBBMALLOC "Link to tbbmalloc" OFF)
set(THREADS_PREFER_PTHREAD_FLAG ON)

option(TBB_TEST "" OFF)

option(BUILD_SHARED_LIBS "Enable building TBB shared library" ON)

message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
if (DEFINED BUILD_SHARED_LIBS)
message(STATUS "defined")
if (NWGRAPH_USE_TBBMALLOC AND APPLE AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "arm64")
message(WARNING "TBB malloc will probably not work on Apple arm64.
You should probably disable it with -DNWGRAPH_USE_TBBMALLOC=OFF")
endif()

if (NOT NWGRAPH_USE_TBBMALLOC)
option(TBBMALLOC_BUILD "Enable tbbmalloc build" OFF)
else()
option(TBBMALLOC_BUILD "Enable tbbmalloc build" OFF)
endif()

if(NWGRAPH_FETCH_TBB)

Expand All @@ -127,21 +132,25 @@ message(STATUS "Fetching TBB")

FetchContent_MakeAvailable(oneTBB)

else()
elseif(NWGRAPH_USE_SUBMODULE)

# add_subdirectory(external/oneTBB)
find_package(TBB REQUIRED)
# Use submodule
add_subdirectory(external/oneTBB)

endif()
else()

# find_package(TBB REQUIRED)
# Use locall installed version
find_package(TBB REQUIRED)

# find_package(TBB)
# if (not TBB_Found)
# FetchContent(
# TBB_STUFF)
# endif()

endif()


find_package(Threads REQUIRED)

add_library(nwgraph_tbb INTERFACE)
Expand Down Expand Up @@ -172,7 +181,7 @@ if (NWGRAPH_BUILD_EXAMPLES)
add_subdirectory(examples/imdb)
endif()

#Artifacts
# Artifacts
option(NWGRAPH_BUILD_HPEC "Determines whether to build HPEC artifact." OFF)
if (NWGRAPH_BUILD_HPEC)
add_subdirectory(${CMAKE_SOURCE_DIR}/../Artifacts/hpec hpec)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ $ cmake .. -DCMAKE_BUILD_TYPE=Release (or Debug)
```
To enable test cases and examples under build/test directory:
```bash
$ cmake .. -DNW_GRAPH_BUILD_TESTS=ON (or OFF)
$ cmake .. -DNWGRAPH_BUILD_TESTS=ON (or OFF)
```
To generate applications under build/bench/ directory:
```bash
$ cmake .. -DNW_GRAPH_BUILD_BENCH=ON (or OFF)
$ cmake .. -DNWGRAPH_BUILD_BENCH=ON (or OFF)
```
To generate abstraction penalty under build/abp/ directory:
```bash
$ cmake .. -DNW_GRAPH_BUILD_APBS=OFF (or ON)
$ cmake .. -DNWGRAPH_BUILD_APBS=OFF (or ON)
```
To generate tools under build/example/ directory:
```bash
$ cmake .. -DNW_GRAPH_BUILD_EXAMPLES=OFF (or ON)
$ cmake .. -DNWGRAPH_BUILD_EXAMPLES=OFF (or ON)
```

If cmake is not able to find TBB in its expected places, you may get an error during the cmake step. In this case, you need to set the `TBBROOT` environment variable to the location where oneTBB was installed. For example:
Expand Down
2 changes: 2 additions & 0 deletions include/nwgraph/build.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef NW_GRAPH_BUILD_HPP
#define NW_GRAPH_BUILD_HPP

#include "nwgraph/util/print_types.hpp"
#include "nwgraph/util/proxysort.hpp"

#include "nwgraph/graph_base.hpp"
Expand Down Expand Up @@ -104,6 +105,7 @@ void push_back_fill(const EdgeList& edge_list, Adjacency& adj, bool directed, si

for (auto&& e : edge_list) {
if (0 == idx) {
// std::apply([&](auto... properties) { adj[source(edge_list, e)].emplace_back(target(edge_list, e), properties...); }, props(e));
std::apply([&](auto... properties) { adj[std::get<0>(e)].emplace_back(std::get<1>(e), properties...); }, props(e));
if (!directed) {
std::apply([&](auto... properties) { adj[std::get<1>(e)].emplace_back(std::get<0>(e), properties...); }, props(e));
Expand Down
6 changes: 4 additions & 2 deletions include/nwgraph/edge_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,14 @@ auto tag_invoke(const num_vertices_tag, const index_edge_list<vertex_id, graph_b
}

template <std::unsigned_integral vertex_id, typename graph_base_t, directedness direct = directedness::undirected, typename... Attributes>
auto& tag_invoke(const source_tag, const index_edge_list<vertex_id, graph_base_t, direct, Attributes...>&, const typename index_edge_list<vertex_id, graph_base_t, direct, Attributes...>::reference e) {
auto& tag_invoke(const source_tag, const index_edge_list<vertex_id, graph_base_t, direct, Attributes...>&,
const typename index_edge_list<vertex_id, graph_base_t, direct, Attributes...>::reference e) {
return std::get<0>(e);
}

template <std::unsigned_integral vertex_id, typename graph_base_t, directedness direct = directedness::undirected, typename... Attributes>
auto& tag_invoke(const target_tag, const index_edge_list<vertex_id, graph_base_t, direct, Attributes...>&, const typename index_edge_list<vertex_id, graph_base_t, direct, Attributes...>::reference e) {
auto& tag_invoke(const target_tag, const index_edge_list<vertex_id, graph_base_t, direct, Attributes...>&,
const typename index_edge_list<vertex_id, graph_base_t, direct, Attributes...>::reference e) {
return std::get<1>(e);
}

Expand Down
120 changes: 74 additions & 46 deletions include/nwgraph/graph_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class has_push_back {
return true;
}


template <class W>
requires(requires(W v, typename W::value_type t) { v.push_back(t); } == false) static constexpr bool test() {
return false;
Expand Down Expand Up @@ -55,9 +54,15 @@ bool has_push_back_v = has::has_push_back<V>::value;
template <template <class> class V, class T>
bool has_push_front_v = has::has_push_front<V, T>::value;

template <class>
class graph_adaptor;


// clang-format off
template <class T>
requires(min_idx_adjacency_list<T> || idx_adjacency_list<T>) class graph_adaptor : public unipartite_graph_base, public T {
requires (min_idx_adjacency_list<T> || idx_adjacency_list<T>)
class graph_adaptor<T> : public unipartite_graph_base, public T {
// clang-format on

using base = T;
using graph_base = unipartite_graph_base;
Expand Down Expand Up @@ -95,69 +100,92 @@ requires(min_idx_adjacency_list<T> || idx_adjacency_list<T>) class graph_adaptor
base::operator[](i).emplace_back(attrs...);
}

auto size() const {
return base::size();
}
auto num_vertices() const {
return base::size();
}
auto num_edgees() const {
return num_edges_;
}

private:
auto size() const {
return base::size();
}
};


template <typename... Ts>
auto graph_edge(std::tuple<Ts...> t) {
return nth_cdr<1>(t);
}
// clang-format off
template <class T>
requires (!min_idx_adjacency_list<T> && !idx_adjacency_list<T>)
class graph_adaptor<T> : public unipartite_graph_base, public T {
// clang-format on

/**
* Fill a plain graph from edge list
*/
template <class EdgeList, class Adjacency>
void push_back_plain_fill(const EdgeList& edge_list, Adjacency& adj, bool directed, size_t idx) {
const size_t jdx = (idx + 1) % 2;
using base = T;
using graph_base = unipartite_graph_base;

for (auto&& e : edge_list) {
size_t num_vertices_{0};

if (idx == 0) {
std::apply([&](size_t u, size_t v) { adj[u].emplace_back(v); }, e);
if (!directed) {
std::apply([&](size_t u, size_t v) { adj[v].emplace_back(u); }, e);
}
} else {
std::apply([&](size_t u, size_t v) { adj[v].emplace_back(u); }, e);
if (!directed) {
std::apply([&](size_t u, size_t v) { adj[u].emplace_back(v); }, e);
}
}
public:
using vertex_id_type = vertex_id_t<T>;

explicit graph_adaptor(size_t N = 0) : base(N) {
}
}

/**
* Fill a non-plain graph from edge list
*/
template <class EdgeList, class Adjacency>
void push_back_fill(const EdgeList& edge_list, Adjacency& adj, bool directed, size_t idx) {
const size_t jdx = (idx + 1) % 2;
void open_for_push_back() {
graph_base::is_open = true;
}
void close_for_push_back() {
graph_base::is_open = false;
}

for (auto&& e : edge_list) {
template <class... Attributes>
void push_back(vertex_id_type i, vertex_id_type j, Attributes... attrs) {
base::emplace_back(attrs...);
}

if (idx == 0) {
std::apply([&](size_t u, size_t v, auto... props) { adj[u].emplace_back(v, props...); }, e);
if (!directed) {
std::apply([&](size_t u, size_t v, auto... props) { adj[v].emplace_back(u, props...); }, e);
}
} else {
std::apply([&](size_t u, size_t v, auto... props) { adj[v].emplace_back(u, props...); }, e);
if (!directed) {
std::apply([&](size_t u, size_t v, auto... props) { adj[u].emplace_back(v, props...); }, e);
}
}
template <class... Attributes>
void push_front(vertex_id_type i, vertex_id_type j, Attributes... attrs) {
base::emplace_front(attrs...);
}

auto num_vertices() const {
return num_vertices_;
}
auto num_edges() const {
return base::size();
}

private:
auto size() const {
return base::size();
}
};


template <class V>
auto tag_invoke(const num_edges_tag, const graph_adaptor<V>& graph) {
return graph.num_edges();
}

template <class V>
auto tag_invoke(const num_vertices_tag, const graph_adaptor<V>& graph) {
return graph.num_vertices();
}

template <class V>
auto& tag_invoke(const source_tag, graph_adaptor<V>& v, typename V::value_type e) {
return source(V(), e);
}

template <class V>
auto& tag_invoke(const target_tag, graph_adaptor<V>& v, typename V::value_type e) {
return target(V(), e);
}

template <typename... Ts>
auto graph_edge(std::tuple<Ts...> t) {
return nth_cdr<1>(t);
}

/**
* Make an edge list with properties copied from original data, e.g., vector<tuple<size_t, size_t, props...>>
Expand Down
Loading