Skip to content

Commit

Permalink
Merge pull request #1267 from aschaffer/enh_ext_compile_time_017
Browse files Browse the repository at this point in the history
[REVIEW] Enhance compile time
  • Loading branch information
BradReesWork committed Nov 23, 2020
2 parents cf94164 + e283aa2 commit 1952767
Show file tree
Hide file tree
Showing 21 changed files with 618 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

## Improvements
- PR #1227 Pin cmake policies to cmake 3.17 version
- PR #1267 Compile time improvements via Explicit Instantiation Declarations.
- PR #1269 Removed old db code that was not being used
- PR #1271 Add extra check to make SG Louvain deterministic
- PR #1273 Update Force Atlas 2 notebook, wrapper and coding style
Expand Down
19 changes: 16 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ARGS=$*
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

VALIDARGS="clean libcugraph cugraph docs -v -g -n --show_depr_warn -h --help"
VALIDARGS="clean libcugraph cugraph docs -v -g -n --allgpuarch --show_depr_warn -h --help"
HELP="$0 [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
Expand All @@ -29,10 +29,11 @@ HELP="$0 [<target> ...] [<flag> ...]
-v - verbose build mode
-g - build for debug
-n - no install step
--allgpuarch - build for all supported GPU architectures
--show_depr_warn - show cmake deprecation warnings
-h - print this text
default action (no args) is to build and install 'libcugraph' then 'cugraph' targets
default action (no args) is to build and install 'libcugraph' then 'cugraph' targets and then docs
"
LIBCUGRAPH_BUILD_DIR=${LIBCUGRAPH_BUILD_DIR:=${REPODIR}/cpp/build}
CUGRAPH_BUILD_DIR=${REPODIR}/python/build
Expand All @@ -44,6 +45,7 @@ VERBOSE=""
BUILD_TYPE=Release
INSTALL_TARGET=install
BUILD_DISABLE_DEPRECATION_WARNING=ON
BUILD_ALL_GPU_ARCH=0

# 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 Down Expand Up @@ -84,6 +86,9 @@ if hasArg -n; then
INSTALL_TARGET=""
ARG_COUNT=$((ARG_COUNT -1))
fi
if hasArg --allgpuarch; then
BUILD_ALL_GPU_ARCH=1
fi
if hasArg --show_depr_warn; then
BUILD_DISABLE_DEPRECATION_WARNING=OFF
ARG_COUNT=$((ARG_COUNT -1))
Expand All @@ -106,11 +111,19 @@ fi
################################################################################
# Configure, build, and install libcugraph
if (( ${ARG_COUNT} == 0 )) || hasArg libcugraph; then
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
GPU_ARCH=""
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} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
${GPU_ARCH} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..
make -j${PARALLEL_LEVEL} VERBOSE=${VERBOSE} ${INSTALL_TARGET}
fi
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/cugraph/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

# This assumes the script is executed from the root of the repo directory
./build.sh cugraph
./build.sh cugraph --allgpuarch
2 changes: 1 addition & 1 deletion conda/recipes/libcugraph/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

# This assumes the script is executed from the root of the repo directory
./build.sh libcugraph -v
./build.sh libcugraph -v --allgpuarch
47 changes: 20 additions & 27 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,45 +58,38 @@ set(GUNROCK_GENCODE_SM72 "OFF")
set(GUNROCK_GENCODE_SM75 "OFF")
set(GUNROCK_GENCODE_SM80 "OFF")

# Check for aarch64 vs workstation architectures
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
message(STATUS "CMAKE Detected aarch64 CPU architecture, selecting appropriate gencodes")
# This is being build for Linux4Tegra or SBSA ARM64 CUDA
set(GPU_ARCHS "62") # Default minimum CUDA GenCode - not supported by gunrock
if(CUDA_VERSION_MAJOR GREATER_EQUAL 9)
set(GPU_ARCHS "${GPU_ARCHS};72")
set(GUNROCK_GENCODE_SM72 "ON")
endif()
if(CUDA_VERSION_MAJOR GREATER_EQUAL 11)
# This is probably for SBSA CUDA, or a next gen Jetson
set(GPU_ARCHS "${GPU_ARCHS};75;80")
set(GUNROCK_GENCODE_SM75 "ON")
set(GUNROCK_GENCODE_SM80 "ON")
endif()
# ARCHS handling:
#
if("${GPU_ARCHS}" STREQUAL "")
include(cmake/EvalGpuArchs.cmake)
evaluate_gpu_archs(GPU_ARCHS)
endif()


# CUDA 11 onwards cub ships with CTK
if((CUDA_VERSION_MAJOR EQUAL 11) OR (CUDA_VERSION_MAJOR GREATER 11))
set(CUB_IS_PART_OF_CTK ON)
else()
message(STATUS "CMAKE selecting appropriate gencodes for x86 or ppc64 CPU architectures")
# System architecture was not aarch64,
# this is datacenter or workstation class hardware
set(GPU_ARCHS "60") # Default minimum supported CUDA gencode
set(GUNROCK_GENCODE_SM60 "ON")
if(CUDA_VERSION_MAJOR GREATER_EQUAL 9)
set(CUB_IS_PART_OF_CTK OFF)
endif()

if("${GPU_ARCHS}" STREQUAL "ALL")
set(GPU_ARCHS "60")
if((CUDA_VERSION_MAJOR EQUAL 9) OR (CUDA_VERSION_MAJOR GREATER 9))
set(GPU_ARCHS "${GPU_ARCHS};70")
set(GUNROCK_GENCODE_SM70 "ON")
endif()
if(CUDA_VERSION_MAJOR GREATER_EQUAL 10)
if((CUDA_VERSION_MAJOR EQUAL 10) OR (CUDA_VERSION_MAJOR GREATER 10))
set(GPU_ARCHS "${GPU_ARCHS};75")
set(GUNROCK_GENCODE_SM75 "ON")
endif()
if(CUDA_VERSION_MAJOR GREATER_EQUAL 11)
if((CUDA_VERSION_MAJOR EQUAL 11) OR (CUDA_VERSION_MAJOR GREATER 11))
set(GPU_ARCHS "${GPU_ARCHS};80")
set(GUNROCK_GENCODE_SM80 "ON")
endif()
endif()

message("-- Building for GPU_ARCHS = ${GPU_ARCHS}")
foreach(arch ${GPU_ARCHS})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode arch=compute_${arch},code=sm_${arch}")
set(GUNROCK_GENCODE_SM${arch} "ON")
endforeach()

list(GET GPU_ARCHS -1 ptx)
Expand Down Expand Up @@ -212,7 +205,7 @@ message("Fetching cuco")
FetchContent_Declare(
cuco
GIT_REPOSITORY https://github.com/NVIDIA/cuCollections.git
GIT_TAG 5f94cdd3b3df0e5f79c47fb772497d6e42455414
GIT_TAG d965ed8dea8f56da8e260a6130dddf3ca351c45f
)

FetchContent_GetProperties(cuco)
Expand Down
68 changes: 68 additions & 0 deletions cpp/cmake/EvalGpuArchs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

function(evaluate_gpu_archs gpu_archs)
set(eval_file ${PROJECT_BINARY_DIR}/eval_gpu_archs.cu)
set(eval_exe ${PROJECT_BINARY_DIR}/eval_gpu_archs)
file(WRITE ${eval_file}
"
#include <cstdio>
#include <set>
#include <string>
using namespace std;
int main(int argc, char** argv) {
set<string> archs;
int nDevices;
if((cudaGetDeviceCount(&nDevices) == cudaSuccess) && (nDevices > 0)) {
for(int dev=0;dev<nDevices;++dev) {
char buff[32];
cudaDeviceProp prop;
if(cudaGetDeviceProperties(&prop, dev) != cudaSuccess) continue;
sprintf(buff, \"%d%d\", prop.major, prop.minor);
archs.insert(buff);
}
}
if(archs.empty()) {
printf(\"ALL\");
} else {
bool first = true;
for(set<string>::const_iterator itr=archs.begin();itr!=archs.end();++itr) {
printf(first? \"%s\" : \";%s\", itr->c_str());
first = false;
}
}
printf(\"\\n\");
return 0;
}
")
execute_process(
COMMAND ${CUDA_NVCC_EXECUTABLE}
-o ${eval_exe}
--run
${eval_file}
OUTPUT_VARIABLE __gpu_archs
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(__gpu_archs_filtered "${__gpu_archs}")
foreach(arch ${__gpu_archs})
if (arch VERSION_LESS 60)
list(REMOVE_ITEM __gpu_archs_filtered ${arch})
endif()
endforeach()
if (NOT __gpu_archs_filtered)
message(FATAL_ERROR "No supported GPU arch found on this system")
endif()
message("Auto detection of gpu-archs: ${__gpu_archs_filtered}")
set(${gpu_archs} ${__gpu_archs_filtered} PARENT_SCOPE)
endfunction(evaluate_gpu_archs)
91 changes: 91 additions & 0 deletions cpp/include/eidecl_graph.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

namespace cugraph {
extern template class GraphViewBase<int32_t, int32_t, float>;
extern template class GraphViewBase<int32_t, int32_t, double>;
extern template class GraphViewBase<int32_t, int64_t, float>;
extern template class GraphViewBase<int32_t, int64_t, double>;
extern template class GraphViewBase<int64_t, int32_t, float>;
extern template class GraphViewBase<int64_t, int32_t, double>;
extern template class GraphViewBase<int64_t, int64_t, float>;
extern template class GraphViewBase<int64_t, int64_t, double>;
extern template class GraphCompressedSparseBaseView<int32_t, int32_t, float>;
extern template class GraphCompressedSparseBaseView<int32_t, int32_t, double>;
extern template class GraphCompressedSparseBaseView<int32_t, int64_t, float>;
extern template class GraphCompressedSparseBaseView<int32_t, int64_t, double>;
extern template class GraphCompressedSparseBaseView<int64_t, int32_t, float>;
extern template class GraphCompressedSparseBaseView<int64_t, int32_t, double>;
extern template class GraphCompressedSparseBaseView<int64_t, int64_t, float>;
extern template class GraphCompressedSparseBaseView<int64_t, int64_t, double>;
extern template class GraphCompressedSparseBase<int32_t, int32_t, float>;
extern template class GraphCompressedSparseBase<int32_t, int32_t, double>;
extern template class GraphCompressedSparseBase<int32_t, int64_t, float>;
extern template class GraphCompressedSparseBase<int32_t, int64_t, double>;
extern template class GraphCompressedSparseBase<int64_t, int32_t, float>;
extern template class GraphCompressedSparseBase<int64_t, int32_t, double>;
extern template class GraphCompressedSparseBase<int64_t, int64_t, float>;
extern template class GraphCompressedSparseBase<int64_t, int64_t, double>;
extern template class GraphCOOView<int32_t, int32_t, float>;
extern template class GraphCOOView<int32_t, int32_t, double>;
extern template class GraphCOOView<int32_t, int64_t, float>;
extern template class GraphCOOView<int32_t, int64_t, double>;
extern template class GraphCOOView<int64_t, int32_t, float>;
extern template class GraphCOOView<int64_t, int32_t, double>;
extern template class GraphCOOView<int64_t, int64_t, float>;
extern template class GraphCOOView<int64_t, int64_t, double>;
extern template class GraphCSRView<int32_t, int32_t, float>;
extern template class GraphCSRView<int32_t, int32_t, double>;
extern template class GraphCSRView<int32_t, int64_t, float>;
extern template class GraphCSRView<int32_t, int64_t, double>;
extern template class GraphCSRView<int64_t, int32_t, float>;
extern template class GraphCSRView<int64_t, int32_t, double>;
extern template class GraphCSRView<int64_t, int64_t, float>;
extern template class GraphCSRView<int64_t, int64_t, double>;
extern template class GraphCSCView<int32_t, int32_t, float>;
extern template class GraphCSCView<int32_t, int32_t, double>;
extern template class GraphCSCView<int32_t, int64_t, float>;
extern template class GraphCSCView<int32_t, int64_t, double>;
extern template class GraphCSCView<int64_t, int32_t, float>;
extern template class GraphCSCView<int64_t, int32_t, double>;
extern template class GraphCSCView<int64_t, int64_t, float>;
extern template class GraphCSCView<int64_t, int64_t, double>;
extern template class GraphCOO<int32_t, int32_t, float>;
extern template class GraphCOO<int32_t, int32_t, double>;
extern template class GraphCOO<int32_t, int64_t, float>;
extern template class GraphCOO<int32_t, int64_t, double>;
extern template class GraphCOO<int64_t, int32_t, float>;
extern template class GraphCOO<int64_t, int32_t, double>;
extern template class GraphCOO<int64_t, int64_t, float>;
extern template class GraphCOO<int64_t, int64_t, double>;
extern template class GraphCSR<int32_t, int32_t, float>;
extern template class GraphCSR<int32_t, int32_t, double>;
extern template class GraphCSR<int32_t, int64_t, float>;
extern template class GraphCSR<int32_t, int64_t, double>;
extern template class GraphCSR<int64_t, int32_t, float>;
extern template class GraphCSR<int64_t, int32_t, double>;
extern template class GraphCSR<int64_t, int64_t, float>;
extern template class GraphCSR<int64_t, int64_t, double>;
extern template class GraphCSC<int32_t, int32_t, float>;
extern template class GraphCSC<int32_t, int32_t, double>;
extern template class GraphCSC<int32_t, int64_t, float>;
extern template class GraphCSC<int32_t, int64_t, double>;
extern template class GraphCSC<int64_t, int32_t, float>;
extern template class GraphCSC<int64_t, int32_t, double>;
extern template class GraphCSC<int64_t, int64_t, float>;
extern template class GraphCSC<int64_t, int64_t, double>;
} // namespace cugraph
73 changes: 73 additions & 0 deletions cpp/include/eidir_graph.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

namespace cugraph {
template class GraphViewBase<int32_t, int32_t, float>;
template class GraphViewBase<int32_t, int32_t, double>;
template class GraphViewBase<int32_t, int64_t, float>;
template class GraphViewBase<int32_t, int64_t, double>;
template class GraphViewBase<int64_t, int64_t, float>;
template class GraphViewBase<int64_t, int64_t, double>;
template class GraphCompressedSparseBaseView<int32_t, int32_t, float>;
template class GraphCompressedSparseBaseView<int32_t, int32_t, double>;
template class GraphCompressedSparseBaseView<int32_t, int64_t, float>;
template class GraphCompressedSparseBaseView<int32_t, int64_t, double>;
template class GraphCompressedSparseBaseView<int64_t, int64_t, float>;
template class GraphCompressedSparseBaseView<int64_t, int64_t, double>;
template class GraphCompressedSparseBase<int32_t, int32_t, float>;
template class GraphCompressedSparseBase<int32_t, int32_t, double>;
template class GraphCompressedSparseBase<int32_t, int64_t, float>;
template class GraphCompressedSparseBase<int32_t, int64_t, double>;
template class GraphCompressedSparseBase<int64_t, int64_t, float>;
template class GraphCompressedSparseBase<int64_t, int64_t, double>;
template class GraphCOOView<int32_t, int32_t, float>;
template class GraphCOOView<int32_t, int32_t, double>;
template class GraphCOOView<int32_t, int64_t, float>;
template class GraphCOOView<int32_t, int64_t, double>;
template class GraphCOOView<int64_t, int64_t, float>;
template class GraphCOOView<int64_t, int64_t, double>;
template class GraphCSRView<int32_t, int32_t, float>;
template class GraphCSRView<int32_t, int32_t, double>;
template class GraphCSRView<int32_t, int64_t, float>;
template class GraphCSRView<int32_t, int64_t, double>;
template class GraphCSRView<int64_t, int64_t, float>;
template class GraphCSRView<int64_t, int64_t, double>;
template class GraphCSCView<int32_t, int32_t, float>;
template class GraphCSCView<int32_t, int32_t, double>;
template class GraphCSCView<int32_t, int64_t, float>;
template class GraphCSCView<int32_t, int64_t, double>;
template class GraphCSCView<int64_t, int64_t, float>;
template class GraphCSCView<int64_t, int64_t, double>;
template class GraphCOO<int32_t, int32_t, float>;
template class GraphCOO<int32_t, int32_t, double>;
template class GraphCOO<int32_t, int64_t, float>;
template class GraphCOO<int32_t, int64_t, double>;
template class GraphCOO<int64_t, int64_t, float>;
template class GraphCOO<int64_t, int64_t, double>;
template class GraphCSR<int32_t, int32_t, float>;
template class GraphCSR<int32_t, int32_t, double>;
template class GraphCSR<int32_t, int64_t, float>;
template class GraphCSR<int32_t, int64_t, double>;
template class GraphCSR<int64_t, int64_t, float>;
template class GraphCSR<int64_t, int64_t, double>;
template class GraphCSC<int32_t, int32_t, float>;
template class GraphCSC<int32_t, int32_t, double>;
template class GraphCSC<int32_t, int64_t, float>;
template class GraphCSC<int32_t, int64_t, double>;
template class GraphCSC<int64_t, int64_t, float>;
template class GraphCSC<int64_t, int64_t, double>;
} // namespace cugraph
Loading

0 comments on commit 1952767

Please sign in to comment.