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] Fix library and include paths in CMakeLists.txt and setup.py #238

Merged
merged 6 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 0 additions & 8 deletions .gitmodules

This file was deleted.

79 changes: 57 additions & 22 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ include(FeatureSummary)
include(CheckIncludeFiles)
include(CheckLibraryExists)

###################################################################################################
# - third party dependencies-----------------------------------------------------------------------
# add third party dependencies using CMake FetchContent

add_subdirectory(cmake/thirdparty)

###################################################################################################
# - copy libcu++ ------------------------------------------------------------------------------------

file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/libcudacxx")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/libcxx/include")

file(INSTALL ${LIBCUDACXX_INCLUDE_DIR} DESTINATION ${CMAKE_BINARY_DIR}/include/libcudacxx/)
file(INSTALL ${LIBCXX_INCLUDE_DIR} DESTINATION ${CMAKE_BINARY_DIR}/include/libcxx/include/)

###################################################################################################
# - conda environment -----------------------------------------------------------------------------

Expand Down Expand Up @@ -183,22 +198,21 @@ endif (RMM_INCLUDE AND RMM_LIBRARY)
# - CUDF -------------------------------------------------------------------------------------------

find_path(CUDF_INCLUDE "cudf"
HINTS "$ENV{CUDF_ROOT}/cpp/include")
HINTS "$ENV{CUDF_ROOT}/include")
rlratzel marked this conversation as resolved.
Show resolved Hide resolved

find_library(CUDF_LIBRARY "cudf"
HINTS "$ENV{CUDF_ROOT}/lib")

SET(CUDF_SRC_INCLUDE "$ENV{CUDF_HOME}/cpp/src")
SET(CUB_INCLUDE "$ENV{CUDF_HOME}/cpp/thirdparty/cub")
SET(CUDACXX_INCLUDE "$ENV{CUDF_HOME}/cpp/thirdparty/libcudacxx/include")
SET(CUDF_TEST_INCLUDE "$ENV{CUDF_HOME}/cpp/")
set(CUDF_TEST_INCLUDE "$ENV{CUDF_HOME}/cpp")
kkraus14 marked this conversation as resolved.
Show resolved Hide resolved
set(CUDF_SRC_INCLUDE "$ENV{CUDF_HOME}/cpp/src")
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved

message(STATUS "CUDF: CUDF_HOME set to $ENV{CUDF_HOME}")
message(STATUS "CUDF: CUDF_LIBRARY set to ${CUDF_LIBRARY}")
message(STATUS "CUDF: CUDF_INCLUDE set to ${CUDF_INCLUDE}")
message(STATUS "CUDF SRC: CUDF_SRC_INCLUDE set to ${CUDF_SRC_INCLUDE}")
message(STATUS "CUDF: CUB_INCLUDE set to ${CUB_INCLUDE}")
message(STATUS "CUDF: CUDACXX_INCLUDE set to ${CUDACXX_INCLUDE}")
message(STATUS "CUDF: CUB_INCLUDE_DIR set to ${CUB_INCLUDE_DIR}")
message(STATUS "CUDF: THRUST_INCLUDE_DIR set to ${THRUST_INCLUDE_DIR}")
message(STATUS "CUDF: LIBCUDACXX_INCLUDE_DIR set to ${LIBCUDACXX_INCLUDE_DIR}")
message(STATUS "CUDF: CUDF_TEST_INCLUDE set to ${CUDF_TEST_INCLUDE}")

add_library(cudf SHARED IMPORTED ${CUDF_LIBRARY})
Expand All @@ -207,16 +221,28 @@ if (CUDF_INCLUDE AND CUDF_LIBRARY)
endif (CUDF_INCLUDE AND CUDF_LIBRARY)

###################################################################################################
# - find gdal -------------------------------------------------------------------------------------
# - gdal ------------------------------------------------------------------------------------------

find_path(GDAL_INCLUDE "gdal"
HINTS "$ENV{GDAL_ROOT}/include")

find_package(GDAL REQUIRED)
find_library(GDAL_LIBRARY "gdal"
HINTS "$ENV{GDAL_ROOT}/lib")

message(STATUS "GDAL: GDAL_LIBRARIES set to ${GDAL_LIBRARIES}")
message(STATUS "GDAL: GDAL_INCLUDE_DIRS set to ${GDAL_INCLUDE_DIRS}")
if (GDAL_INCLUDE AND GDAL_LIBRARY)
add_library(gdal SHARED IMPORTED "${GDAL_LIBRARY}")
set_target_properties(gdal PROPERTIES IMPORTED_LOCATION "${GDAL_LIBRARY}")
else(GDAL_INCLUDE AND GDAL_LIBRARY)
find_package(GDAL REQUIRED)
if(NOT GDAL_FOUND)
message(FATAL_ERROR "GDAL not found, please check your settings.")
endif(NOT GDAL_FOUND)
set(GDAL_INCLUDE "${GDAL_INCLUDE_DIRS}")
set(GDAL_LIBRARY "${GDAL_LIBRARIES}")
endif (GDAL_INCLUDE AND GDAL_LIBRARY)

if(NOT GDAL_FOUND)
message(FATAL_ERROR "GDAL not found, please check your settings.")
endif(NOT GDAL_FOUND)
message(STATUS "GDAL: GDAL_INCLUDE set to ${GDAL_INCLUDE}")
message(STATUS "GDAL: GDAL_LIBRARY set to ${GDAL_LIBRARY}")
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved

###################################################################################################
# - add gtest -------------------------------------------------------------------------------------
Expand Down Expand Up @@ -261,14 +287,13 @@ endif(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
include_directories("${CMAKE_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/../thirdparty/cub"
"${CMAKE_SOURCE_DIR}/../thirdparty/libcudacxx/include"
"${GDAL_INCLUDE_DIRS}"
"${GDAL_INCLUDE}"
"${RMM_INCLUDE}"
"${CUDF_SRC_INCLUDE}"
"${CUDF_INCLUDE}"
"${CUB_INCLUDE}"
"${CUDACXX_INCLUDE}")
"${CUB_INCLUDE_DIR}"
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
"${THRUST_INCLUDE_DIR}"
"${LIBCUDACXX_INCLUDE_DIR}")

if(CONDA_INCLUDE_DIRS)
include_directories("${CONDA_INCLUDE_DIRS}")
Expand All @@ -280,7 +305,7 @@ endif(CONDA_INCLUDE_DIRS)
link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc
"${CMAKE_BINARY_DIR}/lib"
"${FLATBUFFERS_LIBRARY_DIR}"
"${GDAL_LIBRARIES}"
"${GDAL_LIBRARY}"
"${GTEST_LIBRARY_DIR}"
"${RMM_LIBRARY}"
"${CUDF_LIBRARY}")
Expand Down Expand Up @@ -333,7 +358,17 @@ target_link_libraries(cuspatial cudf rmm cudart cuda cusparse nvrtc gdal)
# - install targets -------------------------------------------------------------------------------

install(TARGETS cuspatial
DESTINATION lib)
DESTINATION lib
COMPONENT cuspatial)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/cuspatial
DESTINATION include)
DESTINATION include
COMPONENT cuspatial)

install(DIRECTORY ${CMAKE_BINARY_DIR}/include/libcxx
DESTINATION include/libcuspatial
COMPONENT cuspatial)

install(DIRECTORY ${CMAKE_BINARY_DIR}/include/libcudacxx
DESTINATION include/libcuspatial
COMPONENT cuspatial)
kkraus14 marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 5 additions & 6 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/../thirdparty/cub"
"${CMAKE_SOURCE_DIR}/../thirdparty/dlpack/include"
"${CMAKE_SOURCE_DIR}/../thirdparty/jitify"
"${CMAKE_SOURCE_DIR}/../thirdparty/libcudacxx/include"
"${GDAL_INCLUDE}"
"${GTEST_INCLUDE_DIR}"
"${GBENCH_INCLUDE_DIR}"
"${RMM_INCLUDE}"
"${CUDF_INCLUDE}"
"${CUDF_SRC_INCLUDE}"
"${CUDF_TEST_INCLUDE}"
"${CUB_INCLUDE}"
"${CUB_INCLUDE_DIR}"
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
"${THRUST_INCLUDE_DIR}"
"${LIBCUDACXX_INCLUDE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}")

###################################################################################################
Expand All @@ -62,7 +61,7 @@ include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}"
link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc
"${CMAKE_BINARY_DIR}/lib"
"${CMAKE_BINARY_DIR}"
"${GDAL_LIBRARIES}"
"${GDAL_LIBRARY}"
"${CONDA_LINK_DIRS}"
"${GTEST_LIBRARY_DIR}"
"${GBENCH_LIBRARY_DIR}"
Expand Down
64 changes: 64 additions & 0 deletions cpp/cmake/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
include(FetchContent)

###################################################################################################
# - cub -------------------------------------------------------------------------------------------

message("Fetching CUB")

FetchContent_Declare(
cub
GIT_REPOSITORY https://github.com/thrust/cub.git
GIT_TAG 1.9.10
GIT_SHALLOW true
# TODO(rongou): remove this after upgrading to new CUB release.
PATCH_COMMAND
COMMAND sed -i "494 a histogram_sweep_config.template Init<typename Policy110::HistogramSweepPolicy>()$<SEMICOLON>" cub/device/dispatch/dispatch_histogram.cuh
)

FetchContent_GetProperties(cub)
if(NOT cub_POPULATED)
FetchContent_Populate(cub)
# We are not using the cub CMake targets, so no need to call `add_subdirectory()`.
endif()
set(CUB_INCLUDE_DIR "${cub_SOURCE_DIR}" PARENT_SCOPE)

###################################################################################################
# - thrust ----------------------------------------------------------------------------------------

message("Fetching Thrust")

FetchContent_Declare(
thrust
GIT_REPOSITORY https://github.com/thrust/thrust.git
GIT_TAG 1.9.10
GIT_SHALLOW true
)

FetchContent_GetProperties(thrust)
if(NOT thrust_POPULATED)
FetchContent_Populate(thrust)
# We are not using the thrust CMake targets, so no need to call `add_subdirectory()`.
endif()
set(THRUST_INCLUDE_DIR "${thrust_SOURCE_DIR}" PARENT_SCOPE)

###################################################################################################
# - libcudacxx ------------------------------------------------------------------------------------

message("Fetching libcudacxx")

FetchContent_Declare(
libcudacxx
GIT_REPOSITORY https://github.com/rapidsai/thirdparty-freestanding.git
GIT_TAG cudf
GIT_SHALLOW true
)

FetchContent_GetProperties(libcudacxx)
if(NOT libcudacxx_POPULATED)
FetchContent_Populate(libcudacxx)
# libcudacxx has no CMake targets, so no need to call `add_subdirectory()`.
endif()
set(LIBCUDACXX_DIR "${libcudacxx_SOURCE_DIR}" PARENT_SCOPE)
set(LIBCUDACXX_INCLUDE_DIR "${libcudacxx_SOURCE_DIR}/include/" PARENT_SCOPE)
set(LIBCXX_DIR "${libcudacxx_SOURCE_DIR}/libcxx/" PARENT_SCOPE)
set(LIBCXX_INCLUDE_DIR "${libcudacxx_SOURCE_DIR}/libcxx/include/" PARENT_SCOPE)
14 changes: 7 additions & 7 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,29 @@ include_directories("${CMAKE_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/../thirdparty/cub"
"${CMAKE_SOURCE_DIR}/../thirdparty/libcudacxx/include"
"${CMAKE_SOURCE_DIR}/thirdparty/dlpack/include"
"${GDAL_INCLUDE}"
"${GTEST_INCLUDE_DIR}"
"${RMM_INCLUDE}"
"${CUDF_INCLUDE}"
"${CUDF_SRC_INCLUDE}"
"${CUDF_TEST_INCLUDE}"
"${CUB_INCLUDE}"
"${CUB_INCLUDE_DIR}"
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
"${THRUST_INCLUDE_DIR}"
"${LIBCUDACXX_INCLUDE_DIR}"
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
)

###################################################################################################
# - library paths ---------------------------------------------------------------------------------

link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc
"${CMAKE_BINARY_DIR}/lib"
"${GDAL_LIBRARIES}"
"${GDAL_LIBRARY}"
"${CONDA_LINK_DIRS}"
"${GTEST_LIBRARY_DIR}"
"${RMM_LIBRARY}"
"${CUDF_LIBRARY}"
"${CUSPATIAL_LIBRARY}"
)
"${CUSPATIAL_LIBRARY}")

set(CUBIC_SPLINE_TEST_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/interpolate/cubic_spline_test.cpp")
ConfigureTest(CUBIC_SPLINE_TEST "${CUBIC_SPLINE_TEST_SRC}")
Expand Down
2 changes: 1 addition & 1 deletion python/cuspatial/cuspatial/_lib/cpp/point_in_polygon.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from cudf._lib.column cimport column, column_view
from cudf._lib.move cimport unique_ptr

cdef extern from "point_in_polygon.hpp" namespace "cuspatial" nogil:
cdef extern from "cuspatial/point_in_polygon.hpp" namespace "cuspatial" nogil:
cdef unique_ptr[column] point_in_polygon(
const column_view & test_points_x,
const column_view & test_points_y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ from cudf._lib.cpp.column.column_view cimport column_view
from cudf._lib.cpp.table.table cimport table
from libcpp.memory cimport unique_ptr

cdef extern from "polygon_bounding_box.hpp" namespace "cuspatial" nogil:
cdef extern from "cuspatial/polygon_bounding_box.hpp" \
namespace "cuspatial" nogil:
cdef unique_ptr[table] polygon_bounding_boxes(
const column_view & poly_offsets,
const column_view & ring_offsets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ from cudf._lib.cpp.column.column_view cimport column_view
from cudf._lib.cpp.table.table cimport table
from libcpp.memory cimport unique_ptr

cdef extern from "polyline_bounding_box.hpp" namespace "cuspatial" nogil:
cdef extern from "cuspatial/polyline_bounding_box.hpp" \
namespace "cuspatial" nogil:
cdef unique_ptr[table] polyline_bounding_boxes(
const column_view & poly_offsets,
const column_view & x,
Expand Down
2 changes: 1 addition & 1 deletion python/cuspatial/cuspatial/_lib/cpp/shapefile_reader.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ from libcpp.string cimport string
from libcpp.vector cimport vector
from cudf._lib.cpp.column.column cimport column

cdef extern from "shapefile_reader.hpp" namespace "cuspatial" nogil:
cdef extern from "cuspatial/shapefile_reader.hpp" namespace "cuspatial" nogil:
cdef vector[unique_ptr[column]] \
read_polygon_shapefile(const string filename) except +
2 changes: 1 addition & 1 deletion python/cuspatial/cuspatial/_lib/cpp/spatial.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from libcpp.memory cimport unique_ptr
from cudf._lib.column cimport column, column_view

cdef extern from "haversine.hpp" namespace "cuspatial" nogil:
cdef extern from "cuspatial/haversine.hpp" namespace "cuspatial" nogil:
cdef unique_ptr[column] haversine_distance(
const column_view& a_lon,
const column_view& a_lat,
Expand Down
2 changes: 1 addition & 1 deletion python/cuspatial/cuspatial/_lib/cpp/spatial_window.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from cudf._lib.column cimport column, column_view
from cudf._lib.table cimport table, table_view
from cudf._lib.move cimport move, unique_ptr

cdef extern from "spatial_window.hpp" namespace "cuspatial" nogil:
cdef extern from "cuspatial/spatial_window.hpp" namespace "cuspatial" nogil:
cdef unique_ptr[table] points_in_spatial_window \
"cuspatial::points_in_spatial_window" (
double window_min_x,
Expand Down
2 changes: 1 addition & 1 deletion python/cuspatial/cuspatial/_lib/interpolate.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from cudf._lib.column cimport column, column_view
from cudf._lib.table cimport table, table_view
from cudf._lib.move cimport move, unique_ptr

cdef extern from "cubic_spline.hpp" namespace "cuspatial" nogil:
cdef extern from "cuspatial/cubic_spline.hpp" namespace "cuspatial" nogil:
cdef unique_ptr[table] cpp_cubicspline_coefficients \
"cuspatial::cubicspline_coefficients" (
const column_view & t,
Expand Down
11 changes: 8 additions & 3 deletions python/cuspatial/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

cuda_include_dir = os.path.join(CUDA_HOME, "include")

CUSPATIAL_ROOT = os.environ.get("CUSPATIAL_ROOT", "../../cpp/build/")
rlratzel marked this conversation as resolved.
Show resolved Hide resolved

try:
nthreads = int(os.environ.get("PARALLEL_LEVEL", "0") or "0")
except Exception:
Expand All @@ -41,10 +43,13 @@
"*",
sources=cython_files,
include_dirs=[
"../../cpp/include/cuspatial",
"../../cpp/include",
"../../thirdparty/cub",
"../../thirdparty/libcudacxx/include",
os.path.join(CUSPATIAL_ROOT, "include"),
os.path.join(CUSPATIAL_ROOT, "_deps/libcudacxx-src/include"),
os.path.join(
os.path.dirname(sysconfig.get_path("include")),
"libcuspatial/libcudacxx",
),
os.path.dirname(sysconfig.get_path("include")),
np.get_include(),
cuda_include_dir,
Expand Down
1 change: 0 additions & 1 deletion thirdparty/cub
Submodule cub deleted from b165e1
1 change: 0 additions & 1 deletion thirdparty/libcudacxx
Submodule libcudacxx deleted from cdcda4