Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] FEA SciPy sparse matrix input support for WCC, SCC, SSSP, and BFS #1277

Merged
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- PR #1265 Implement Hungarian Algorithm
- PR #1274 Add generic from_edgelist() and from_adjlist() APIs
- PR #1279 Add self loop check variable in graph
- PR #1277 SciPy sparse matrix input support for WCC, SCC, SSSP, and BFS

## Improvements
- PR #1227 Pin cmake policies to cmake 3.17 version
Expand Down
71 changes: 35 additions & 36 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (c) 2019, NVIDIA CORPORATION.
# Copyright (c) 2019-2020, NVIDIA CORPORATION.

# cugraph build script

Expand All @@ -17,6 +17,7 @@ ARGS=$*
# NOTE: ensure all dir changes are relative to the location of this
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)
LIBCUGRAPH_BUILD_DIR=${LIBCUGRAPH_BUILD_DIR:=${REPODIR}/cpp/build}

VALIDARGS="clean libcugraph cugraph docs -v -g -n --allgpuarch --show_depr_warn -h --help"
HELP="$0 [<target> ...] [<flag> ...]
Expand All @@ -33,19 +34,21 @@ HELP="$0 [<target> ...] [<flag> ...]
--show_depr_warn - show cmake deprecation warnings
-h - print this text

default action (no args) is to build and install 'libcugraph' then 'cugraph' targets and then docs
default action (no args) is to build and install 'libcugraph' then 'cugraph' then 'docs' targets

libcugraph build dir is: ${LIBCUGRAPH_BUILD_DIR}

Set env var LIBCUGRAPH_BUILD_DIR to override libcugraph build dir.
"
LIBCUGRAPH_BUILD_DIR=${LIBCUGRAPH_BUILD_DIR:=${REPODIR}/cpp/build}
CUGRAPH_BUILD_DIR=${REPODIR}/python/build
BUILD_DIRS="${LIBCUGRAPH_BUILD_DIR} ${CUGRAPH_BUILD_DIR}"

# Set defaults for vars modified by flags to this script
ARG_COUNT=${NUMARGS}
VERBOSE=""
BUILD_TYPE=Release
INSTALL_TARGET=install
BUILD_DISABLE_DEPRECATION_WARNING=ON
BUILD_ALL_GPU_ARCH=0
GPU_ARCH=""

# Set defaults for vars that may not have been defined externally
# FIXME: if PREFIX is not set, check CONDA_PREFIX, but there is no fallback
Expand All @@ -58,6 +61,10 @@ function hasArg {
(( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
}

function buildAll {
(( ${NUMARGS} == 0 )) || !(echo " ${ARGS} " | grep -q " [^-]\+ ")
}

if hasArg -h || hasArg --help; then
echo "${HELP}"
exit 0
Expand All @@ -76,30 +83,31 @@ fi
# Process flags
if hasArg -v; then
VERBOSE=1
ARG_COUNT=$((ARG_COUNT -1))
fi
if hasArg -g; then
BUILD_TYPE=Debug
ARG_COUNT=$((ARG_COUNT -1))
fi
if hasArg -n; then
INSTALL_TARGET=""
ARG_COUNT=$((ARG_COUNT -1))
fi
if hasArg --allgpuarch; then
BUILD_ALL_GPU_ARCH=1
GPU_ARCH="-DGPU_ARCHS=ALL"
fi
if hasArg --show_depr_warn; then
BUILD_DISABLE_DEPRECATION_WARNING=OFF
ARG_COUNT=$((ARG_COUNT -1))
fi

# If clean given, run it prior to any other steps
if hasArg clean; then
# If the dirs to clean are mounted dirs in a container, the
# contents should be removed but the mounted dirs will remain.
# The find removes all contents but leaves the dirs, the rmdir
# attempts to remove the dirs but can fail safely.
# FIXME: ideally the "setup.py clean" command below would also be run to
# remove all the "inplace" python build artifacts, but currently, running
# any setup.py command has side effects (eg. cloning repos).
#(cd ${REPODIR}/python && python setup.py clean)

# If the dirs to clean are mounted dirs in a container, the contents should
# be removed but the mounted dirs will remain. The find removes all
# contents but leaves the dirs, the rmdir attempts to remove the dirs but
# can fail safely.
for bd in ${BUILD_DIRS}; do
if [ -d ${bd} ]; then
find ${bd} -mindepth 1 -delete
Expand All @@ -110,53 +118,44 @@ fi

################################################################################
# Configure, build, and install libcugraph
if (( ${ARG_COUNT} == 0 )) || hasArg libcugraph; then
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
GPU_ARCH=""
if buildAll || hasArg libcugraph; then
if [[ ${GPU_ARCH} == "" ]]; then
echo "Building for the architecture of the GPU in the system..."
else
GPU_ARCH="-DGPU_ARCHS=ALL"
echo "Building for *ALL* supported GPU architectures..."
fi

mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${GPU_ARCH} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..
${GPU_ARCH} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${REPODIR}/cpp
make -j${PARALLEL_LEVEL} VERBOSE=${VERBOSE} ${INSTALL_TARGET}
fi

# Build and install the cugraph Python package
if (( ${ARG_COUNT} == 0 )) || hasArg cugraph; then

if buildAll || hasArg cugraph; then
cd ${REPODIR}/python
# setup.py references an env var CUGRAPH_BUILD_PATH to find the libcugraph
# build. If not set by the user, set it to LIBCUGRAPH_BUILD_DIR
CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH:=${LIBCUGRAPH_BUILD_DIR}}
env CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH} python setup.py build_ext --inplace --library-dir=${LIBCUGRAPH_BUILD_DIR}
if [[ ${INSTALL_TARGET} != "" ]]; then
python setup.py build_ext --inplace --library-dir=${LIBCUGRAPH_BUILD_DIR}
python setup.py install
else
python setup.py build_ext --inplace --library-dir=${LIBCUGRAPH_BUILD_DIR}
env CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH} python setup.py install
fi
fi

################################################################################
# Build the docs
if (( ${ARG_COUNT} == 0 )) || hasArg docs; then

if buildAll || hasArg docs; then
if [ ! -d ${LIBCUGRAPH_BUILD_DIR} ]; then
mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${REPODIR}/cpp
fi

cd ${LIBCUGRAPH_BUILD_DIR}

make -j${PARALLEL_LEVEL} VERBOSE=${VERBOSE} docs_cugraph

cd ${REPODIR}/docs
make html

fi
1 change: 1 addition & 0 deletions python/cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from cugraph.cores import core_number, k_core

from cugraph.components import (
connected_components,
weakly_connected_components,
strongly_connected_components,
)
Expand Down
1 change: 1 addition & 0 deletions python/cugraph/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from cugraph.components.connectivity import connected_components
from cugraph.components.connectivity import weakly_connected_components
from cugraph.components.connectivity import strongly_connected_components
Loading