Skip to content

Commit

Permalink
Update dependency management (cms-patatrack#71)
Browse files Browse the repository at this point in the history
* Update dependency management for boost and alpaka

* Add dependency section in README

* Add installation of boost in workflows

* Update package version
  • Loading branch information
sbaldu authored Jan 8, 2025
1 parent 389b73a commit d8e476d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 53 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bench_profile_serial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install matplotlib
sudo apt install -y libboost-dev
- name: Compile and run benchmark
working-directory: ${{ github.workspace }}/benchmark/dataset_size
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
python -m pip install scikit-learn
python -m pip install pandas
python -m pip install matplotlib
sudo apt install -y libboost-dev
- name: Compile CLUEstering modules
working-directory: ${{github.workspace}}
run: |
Expand Down
72 changes: 20 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,17 @@ set(PYBIND11_FINDPYTHON ON)
set(PYBIND11_PYTHON_VERSION ">=3.8")
add_subdirectory(extern/pybind11)

include(FetchContent)
find_package(Boost 1.75.0 REQUIRED)

find_package(alpaka)
if (NOT alpaka_FOUND)
FetchContent_Declare(
alpaka
GIT_REPOSITORY https://github.com/alpaka-group/alpaka.git
GIT_TAG develop
)

FetchContent_GetProperties(alpaka)
if(NOT alpaka_POPULATED)
FetchContent_Populate(alpaka)
endif()
set(alpaka_PATH ./build/_deps/alpaka-src/include)
else()
set(alpaka_PATH ${alpaka_INCLUDE_DIRS})
endif()
include(FetchContent)

find_package(Boost 1.75.0)
# if boost is not found, it's fetched from the official boost repository
if(NOT Boost_FOUND)
FetchContent_Declare(
boost
URL https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz
)

FetchContent_GetProperties(boost)
if(NOT boost_POPULATED)
FetchContent_Populate(boost)
endif()
set(Boost_PATH ./build/_deps/boost-src)
else()
set(Boost_PATH ${Boost_INCLUDE_DIRS})
endif()
FetchContent_Declare(
alpaka
GIT_REPOSITORY https://github.com/alpaka-group/alpaka.git
GIT_TAG develop
GIT_SHALLOW TRUE
FIND_PACKAGE_ARGS)
FetchContent_MakeAvailable(alpaka)

if(NOT DEFINED CPU_ONLY)
set(CPU_ONLY OFF)
Expand All @@ -70,10 +46,9 @@ execute_process(COMMAND mkdir -p ./CLUEstering/lib)
# Convolutional Kernels compile convolutional kernel module
pybind11_add_module(CLUE_Convolutional_Kernels SHARED
./CLUEstering/alpaka/BindingModules/binding_kernels.cc)
target_include_directories(CLUE_Convolutional_Kernels PRIVATE ${alpaka_PATH})
# link boost
target_link_libraries(CLUE_Convolutional_Kernels PRIVATE ${Boost_LIBRARIES})
target_include_directories(CLUE_Convolutional_Kernels PRIVATE ${Boost_PATH})
target_include_directories(
CLUE_Convolutional_Kernels PRIVATE ${alpaka_SOURCE_DIR}/include
${Boost_SOURCE_DIR})
# alpaka build flags
target_compile_options(
CLUE_Convolutional_Kernels
Expand All @@ -95,10 +70,8 @@ endforeach()
# CPU Serial compile cpu serial module
pybind11_add_module(CLUE_CPU_Serial SHARED
./CLUEstering/alpaka/BindingModules/binding_cpu.cc)
target_include_directories(CLUE_CPU_Serial PRIVATE ${alpaka_PATH})
# link boost
target_link_libraries(CLUE_CPU_Serial PRIVATE ${Boost_LIBRARIES})
target_include_directories(CLUE_CPU_Serial PRIVATE ${Boost_PATH})
target_include_directories(CLUE_CPU_Serial PRIVATE ${alpaka_SOURCE_DIR}/include
${Boost_SOURCE_DIR})
# alpaka build flags
target_compile_options(
CLUE_CPU_Serial
Expand All @@ -123,9 +96,8 @@ if(NOT ${SERIAL_ONLY})
# compile cpu tbb module
pybind11_add_module(CLUE_CPU_TBB SHARED
./CLUEstering/alpaka/BindingModules/binding_cpu_tbb.cc)
target_include_directories(CLUE_CPU_TBB PRIVATE ${alpaka_PATH})
target_link_libraries(CLUE_CPU_TBB PRIVATE ${Boost_LIBRARIES})
target_include_directories(CLUE_CPU_TBB PRIVATE ${Boost_PATH})
target_include_directories(CLUE_CPU_TBB PRIVATE ${alpaka_SOURCE_DIR}/include
${Boost_SOURCE_DIR})
target_compile_options(
CLUE_CPU_TBB
PRIVATE -ltbb -DALPAKA_ACC_CPU_B_TBB_T_SEQ_PRESENT
Expand Down Expand Up @@ -167,10 +139,8 @@ if((NOT ${CPU_ONLY}) AND (NOT ${SERIAL_ONLY}))
# compile gpu cuda module
pybind11_add_module(CLUE_GPU_CUDA SHARED
./CLUEstering/alpaka/BindingModules/binding_gpu_cuda.cc)
target_include_directories(CLUE_GPU_CUDA PRIVATE ${alpaka_PATH})
# link boost
target_link_libraries(CLUE_GPU_CUDA PRIVATE ${Boost_LIBRARIES})
target_include_directories(CLUE_GPU_CUDA PRIVATE ${Boost_PATH})
target_include_directories(
CLUE_GPU_CUDA PRIVATE ${alpaka_SOURCE_DIR}/include ${Boost_SOURCE_DIR})
# set the cuda architectures
set_target_properties(CLUE_GPU_CUDA PROPERTIES CUDA_ARCHITECTURES
"50;60;61;62;70")
Expand Down Expand Up @@ -210,10 +180,8 @@ if((NOT ${CPU_ONLY}) AND (NOT ${SERIAL_ONLY}))
# compile gpu hip module
pybind11_add_module(CLUE_GPU_HIP SHARED
./CLUEstering/alpaka/BindingModules/binding_gpu_hip.cc)
target_include_directories(CLUE_GPU_HIP PRIVATE ${alpaka_PATH})
# link boost
target_link_libraries(CLUE_GPU_HIP PRIVATE ${Boost_LIBRARIES})
target_include_directories(CLUE_GPU_HIP PRIVATE ${Boost_PATH})
target_include_directories(CLUE_GPU_HIP PRIVATE ${alpaka_SOURCE_DIR}/include
${Boost_SOURCE_DIR})
# alpaka build flags
target_compile_options(
CLUE_GPU_HIP
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ clust.cluster_plotter()
</p>

## Installation
### Dependencies
The main dependencies of CLUEstering are [Boost](https://www.boost.org/) (version 1.75.0+) and [Alpaka](https://github.com/alpaka-group/alpaka).
If alpaka is not found, it will be automatically fetched from the official repository, so it's not mandatory to install it manually.

### From source
To install the library, first clone the repository recursively:
```shell
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup
import subprocess

__version__ = "2.2.12"
__version__ = "2.3.0"

this_directory = Path(__file__).parent
long_description = (this_directory/'README.md').read_text()
Expand Down

0 comments on commit d8e476d

Please sign in to comment.