Skip to content

Commit

Permalink
Merge pull request #99 from clEsperanto/test_new_backend_cuda_ocl
Browse files Browse the repository at this point in the history
update backend
  • Loading branch information
StRigaud authored Aug 27, 2023
2 parents 48237b4 + 96a0742 commit 761bcf9
Show file tree
Hide file tree
Showing 108 changed files with 13,093 additions and 7,233 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- name: Set up conda ${{ matrix.python-version }}
uses: conda-incubator/[email protected]
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: test
python-version: ${{ matrix.python-version }}
Expand All @@ -43,14 +44,18 @@ jobs:
shell: bash -l {0}
run: pip install scikit-build pytest pytest-cov pytest-benchmark

# - name: Install cuda
# shell: bash -l {0}
# run: conda install -y cudatoolkit

- name: Install pocl
shell: bash -l {0}
run: conda install -y pocl
run: conda install -y pocl

- name: Compile
shell: bash -l {0}
run: |
pip install . -vvv
pip install . -vvv --config-settings=cmake.define.CMAKE_PREFIX_PATH=$CONDA_PREFIX
- name: Tests
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v2x
with:
# Upload entire repository
path: './docs/build/html'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v3

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.3
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_MACOS: x86_64 arm64

Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
name: artifact
path: dist

- uses: pypa/[email protected].6
- uses: pypa/[email protected].8
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ __pycache__/
# C extensions
*.so

# Mac OS X
.DS_Store

# IDE
.vscode

Expand Down
85 changes: 40 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ cmake_minimum_required(VERSION 3.20)

# Set project name and version
# - package version is managed in file `version.py`
project(pyClesperanto)
project(
${SKBUILD_PROJECT_NAME}
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX)

# enforce release build type
# enforce release build type if possible
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_STANDARD 17)
# if(WIN32)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /d2FH4-")
# endif(WIN32)

string(TOLOWER ${PROJECT_NAME} PY_PACKAGE_NAME)
set(CY_PACKAGE_NAME _${PY_PACKAGE_NAME})
Expand All @@ -20,29 +27,23 @@ endif()
# find python dev library
# look for python in virtual env or conda first before checking the system.
set(Python_FIND_VIRTUALENV "FIRST")
find_package(Python3 COMPONENTS Interpreter Development.Embed Development.Module)
if(Python3_Development.Module_FOUND)
message(STATUS "Python Developement Module found")
endif()
if(Python3_Development.Embed_FOUND)
message(STATUS "Python Developement Embed found")
endif()

if(NOT DEFINED OpenCL_LIBRARY)
find_package(OpenCL REQUIRED)
endif()
message(STATUS "OpenCL_LIBRARY: ${OpenCL_LIBRARY}")
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)

## fetch CLIc using CMake FetchContent
include(FetchContent)
option(BUILD_TESTING OFF)
option(BUILD_BENCHMARK OFF)
option(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(
CLIc_lib
CLIc
GIT_REPOSITORY https://github.com/clEsperanto/CLIc_prototype.git
GIT_TAG ${CLIC_VERSION}
GIT_TAG add-cuda-backend
)
FetchContent_MakeAvailable(CLIc_lib)
FetchContent_MakeAvailable(CLIc)

set(PACKAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${PY_PACKAGE_NAME})
set(WRAPPER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wrapper)
file(GLOB_RECURSE WRAPPER_SOURCES_FILES ${WRAPPER_DIR}/*.cpp)

if(SKBUILD)
# Scikit-Build does not add your site-packages to the search path
Expand All @@ -53,36 +54,30 @@ if(SKBUILD)
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
endif()

set(PACKAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${PY_PACKAGE_NAME})
set(WRAPPER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wrapper)
file(GLOB_RECURSE WRAPPER_SOURCES_FILES ${WRAPPER_DIR}/*.cpp)

find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(${CY_PACKAGE_NAME} MODULE ${WRAPPER_SOURCES_FILES})
find_package(pybind11 CONFIG REQUIRED)
python_add_library(${CY_PACKAGE_NAME} MODULE ${WRAPPER_SOURCES_FILES} WITH_SOABI)

target_link_libraries(${CY_PACKAGE_NAME} PRIVATE CLIc::CLIc ${OpenCL_LIBRARY})
add_dependencies(${CY_PACKAGE_NAME} CLIc)
target_include_directories(${CY_PACKAGE_NAME} PUBLIC "$<BUILD_INTERFACE:${WRAPPER_DIR}>")
target_compile_features(${CY_PACKAGE_NAME} PRIVATE cxx_std_17)
target_link_libraries(${CY_PACKAGE_NAME} PRIVATE CLIc::CLIc pybind11::headers)
add_dependencies(${CY_PACKAGE_NAME} CLIc)
target_include_directories(${CY_PACKAGE_NAME} PUBLIC "$<BUILD_INTERFACE:${WRAPPER_DIR}>")
target_compile_definitions(${CY_PACKAGE_NAME} PRIVATE VERSION_INFO=${PROJECT_VERSION})

# Installing the extension module to the root of the package
install(TARGETS ${CY_PACKAGE_NAME} DESTINATION .)
# Install the target to the appropriate location
install(TARGETS ${CY_PACKAGE_NAME} DESTINATION ${PY_PACKAGE_NAME})

# if(APPLE)
# set_target_properties(
# ${CY_PACKAGE_NAME} PROPERTIES INSTALL_RPATH "@loader_path/${CMAKE_INSTALL_LIBDIR}")
# else()
# set_target_properties(${CY_PACKAGE_NAME} PROPERTIES INSTALL_RPATH
# "$ORIGIN/${CMAKE_INSTALL_LIBDIR}")
# endif()
# Configure the RPATH based on the platform
if(APPLE)
set(CY_PACKAGE_RPATH "@loader_path;@loader_path/${CMAKE_INSTALL_LIBDIR};@loader_path/${CMAKE_INSTALL_BINDIR}")
elseif(WIN32)
set(CY_PACKAGE_RPATH ".;@ORIGIN/${CMAKE_INSTALL_LIBDIR};@ORIGIN/${CMAKE_INSTALL_BINDIR}")
else()
set(CY_PACKAGE_RPATH "$ORIGIN;$ORIGIN/${CMAKE_INSTALL_LIBDIR};$ORIGIN/${CMAKE_INSTALL_BINDIR}")
endif()

if(APPLE)
set_target_properties(
${CY_PACKAGE_NAME} PROPERTIES INSTALL_RPATH "@loader_path/${CMAKE_INSTALL_LIBDIR};${CMAKE_PREFIX_PATH}/lib" INSTALL_RPATH_USE_LINK_PATH TRUE)
else()
set_target_properties(${CY_PACKAGE_NAME} PROPERTIES INSTALL_RPATH
"$ORIGIN/${CMAKE_INSTALL_LIBDIR}:$ORIGIN/../lib:${CMAKE_PREFIX_PATH}/lib"
INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
set_target_properties(${CY_PACKAGE_NAME} PROPERTIES
INSTALL_RPATH "${CY_PACKAGE_RPATH}"
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE
)
endif()
79 changes: 79 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
include .github/dependabot.yml
include .github/workflows/build_and_test.yml
include .github/workflows/pages.yml
include .github/workflows/wheels.yml
include .gitignore
include CMakeLists.txt
include LICENSE
include MANIFEST.in
include README.md
include benchmarking/benchmark_basic_operations.ipynb
include benchmarking/benchmark_gaussian.ipynb
include benchmarking/benchmark_histogram.ipynb
include benchmarking/benchmark_mini_pipeline.ipynb
include benchmarking/benchmark_otsu.ipynb
include benchmarking/benchmarking_tribolium_workflow.ipynb
include demos/add_image_and_scalar.cl
include demos/cell_segmentation.ipynb
include demos/explore_API.ipynb
include demos/find_local_maxima.ipynb
include demos/image_API.ipynb
include demos/image_filtering.ipynb
include demos/images/cell_segmentation.png
include demos/images/explore_API.png
include demos/images/find_local_maxima.png
include demos/images/image_filtering.png
include demos/images/labeled_blobs.png
include demos/images/multi-gpu.png
include demos/images/tribolium3d_segmentation.png
include demos/multi_gpu_demo.ipynb
include demos/process_blobs.ipynb
include demos/process_tribolium.ipynb
include demos/run_custom_kernel.ipynb
include developer_docs/API_demo.ipynb
include docs/Makefile
include docs/README.rst
include docs/make.bat
include docs/source/api.rst
include docs/source/conf.py
include docs/source/index.rst
include docs/source/install.rst
include docs/source/usage.rst
include pyclesperanto/__init__.py
include pyclesperanto/_array.py
include pyclesperanto/_core.py
include pyclesperanto/_decorators.py
include pyclesperanto/_functionalities.py
include pyclesperanto/_memory.py
include pyclesperanto/_operators.py
include pyclesperanto/_tier1.py
include pyclesperanto/_tier2.py
include pyclesperanto/_tier3.py
include pyclesperanto/_tier4.py
include pyclesperanto/_tier5.py
include pyclesperanto/_version.py
include pyproject.toml
include scripts/build-opencl-linux.sh
include scripts/build-opencl-macos.sh
include scripts/build-opencl-windows.sh
include scripts/pyclesperanto_autogen_tier_script.ipynb
include setup.py
include tests/test_core.py
include tests/test_import.py
include tests/test_tier1.py
include tests/test_tier2.py
include tests/test_tier3.py
include tests/test_tier4.py
include tests/test_tier5.py
include tests/test_tier6.py
include wrapper/array_.cpp
include wrapper/core_.cpp
include wrapper/pycle_wrapper.cpp
include wrapper/pycle_wrapper.hpp
include wrapper/tier1_.cpp
include wrapper/tier2_.cpp
include wrapper/tier3_.cpp
include wrapper/tier4_.cpp
include wrapper/tier5_.cpp
include wrapper/types_.cpp
exclude MANIFEST.in
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# py-clesperanto
[![Build & Deploy](https://github.com/clEsperanto/pyclesperanto/actions/workflows/wheels.yml/badge.svg)](https://github.com/clEsperanto/pyclesperanto/actions/workflows/wheels.yml)
[![Tests](https://github.com/clEsperanto/pyclesperanto/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/clEsperanto/pyclesperanto/actions/workflows/build_and_test.yml)
[![codecov](https://codecov.io/gh/clesperanto/pyclesperanto/branch/main/graph/badge.svg)](https://codecov.io/gh/clesperanto/pyclesperanto)
[![License](https://img.shields.io/pypi/l/pyclesperanto.svg?color=green)](https://github.com/clEsperanto/pyclesperanto/raw/main/LICENSE)
[![Tests](https://github.com/clEsperanto/pyclesperanto/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/clEsperanto/pyclesperanto/actions/workflows/build_and_test.yml) <!-- [![codecov](https://codecov.io/gh/clesperanto/pyclesperanto/branch/main/graph/badge.svg)](https://codecov.io/gh/clesperanto/pyclesperanto) --> [![License](https://img.shields.io/pypi/l/pyclesperanto.svg?color=green)](https://github.com/clEsperanto/pyclesperanto/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/pyclesperanto.svg?color=green)](https://pypi.org/project/pyclesperanto)
[![Python Version](https://img.shields.io/pypi/pyversions/pyclesperanto.svg?color=green)](https://python.org)
[![Development Status](https://img.shields.io/pypi/status/pyclesperanto.svg)](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)
Expand All @@ -26,7 +24,6 @@ conda activate my_env
```
~~Install pyclesperanto package using __conda__:~~ __(WIP, please use pip instead)__
```
conda install -c conda-forge pyclesperanto
```
OR using __pip__:
```
Expand All @@ -45,7 +42,7 @@ from skimage.io import imread, imsave
device = cle.select_device()
print("Used GPU: ", device)

image = imread("https://imagej.nih.gov/ij/images/blobs.gif")
image = imread("https://samples.fiji.sc/blobs.png")

# push image to device memory
input_image = cle.push(image)
Expand Down
25 changes: 25 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Demos

This is a collection of notebooks and scripts that demonstrate how to use 'pyclesperanto' for image processing and analysis. They are here to show various use cases and to help you get started.

These are note exaustives and we are happy to add more. Please get in touch if you have a demo that you would like to share.

### pre-requisites

To run these demos, you need to have 'pyclesperanto' installed. If you don't have it yet, please follow the instructions [here](../README.md) or read the documentation [here](https://clesperanto.github.io/pyclesperanto_prototype/).

Most of the demos also require [scikit-image](https://scikit-image.org/) and [jupyter](https://jupyter.org/), which you can install via pip:

```bash
pip install scikit-image jupyterlab
```

or conda:

```bash
conda install scikit-image jupyterlab
```

# Warning

These demos are not meant to be used for benchmarking. They are meant to be easy to understand and to get you started. Several costly operations are done on purpose to make the code easier to understand. If you want to use pyclesperanto in production, please read the documentation and don't hesitate to get in touch with us to get help with optimizing your code.
14 changes: 0 additions & 14 deletions demos/add_image_and_scalar.cl

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 761bcf9

Please sign in to comment.