Skip to content
Snippets Groups Projects
Commit 05a136d2 authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

Merge branch 'feat/release_pip' into 'dev'

feat : release_pip

See merge request !19
parents f5968e18 007c7470
No related branches found
No related tags found
2 merge requests!38version 0.3.0,!19feat : release_pip
Pipeline #54977 passed
Showing
with 448 additions and 509 deletions
# common
.cache
# C++ Build # C++ Build
build*/ build*/
install*/ install*/
...@@ -10,6 +13,9 @@ install*/ ...@@ -10,6 +13,9 @@ install*/
__pycache__ __pycache__
*.pyc *.pyc
*.egg-info *.egg-info
dist*/
wheelhouse/*
_version.py
# Mermaid # Mermaid
*.mmd *.mmd
...@@ -18,4 +24,4 @@ __pycache__ ...@@ -18,4 +24,4 @@ __pycache__
xml*/ xml*/
# ONNX # ONNX
*.onnx *.onnx
\ No newline at end of file
################################################################################ ###############################################################################
# Pre-configured CI/CD for your Aidge module. # Aidge Continuous Integration and Deployment #
# # #
# Three stages are already pre-configured to run on Eclipse Aidge CI: ###############################################################################
# - build: ubuntu_cpp, ubuntu_python and windows_cpp;
# - test: ubuntu_cpp, ubuntu_python and windows_cpp;
# - coverage: ubuntu_cpp and ubuntu_python.
#
# If your project is pure C++ or pure Python, you can remove the "_python" or
# "_cpp" jobs respectively.
# "ubuntu" jobs require an Ubuntu runner with a docker executor with tag
# "docker".
# "windows" jobs require a Windows runner with a docker-windows executor with
# tag "windows".
#
# You can change the docker images in the YML scripts directly. The default
# images are:
# - nvidia/cuda:12.2.0-devel-ubuntu22.04 for Ubuntu jobs;
# - buildtools for Windows jobs, built on top of
# mcr.microsoft.com/windows/servercore:ltsc2022 with Microsoft Visual Studio
# 2022 BuildTools installed.
#
# See Aidge project wiki for more details on how to setup your own docker images
# and Gitlab runners.
################################################################################
stages: stages:
# Build - static_analysis
- build - build
# Unit test stage
- test - test
# Code coverage
- coverage - coverage
- release
- deploy
include: include:
- local: '/.gitlab/ci/_global.gitlab-ci.yml' - project: 'eclipse/aidge/gitlab_shared_files'
- local: '/.gitlab/ci/build.gitlab-ci.yml' ref: 'main'
- local: '/.gitlab/ci/test.gitlab-ci.yml' file:
- local: '/.gitlab/ci/coverage.gitlab-ci.yml' # choose which jobs to run by including the corresponding files.
- '.gitlab/ci/ubuntu_cpp.gitlab-ci.yml'
- '.gitlab/ci/ubuntu_python.gitlab-ci.yml'
- '.gitlab/ci/release/cibuildwheel_ubuntu.gitlab-ci.yml'
# - '.gitlab/ci/windows_cpp.gitlab-ci.yml'
# - '.gitlab/ci/windows_python.gitlab-ci.yml'
# - '.gitlab/ci/release/cibuildwheel_windows.gitlab-ci.yml'
release:pip:ubuntu:
tags:
- release:cuda
variables:
DOCKER_HOST: unix:///var/run/docker.sock
CIBW_ENVIRONMENT: >-
BUILD_WITH_CUDA=1
AIDGE_DEPENDENCIES='aidge_core aidge_backend_cpu'
AIDGE_INSTALL='/AIDGE_INSTALL_CIBUILDWHEEL'
CUDA_TOOLKIT_VERSION='11-8'
DOCKER_HOST='unix:///var/run/docker.sock'
ARCH='x86_64'
CUDNN_VERSION='9'
CUDA_MAJOR_VERSION='11'
CUDA_MINOR_VERSION='8'
SEARCH_PATH='/home/ubuntu/builds/$CI_RUNNER_SHORT_TOKEN/$CI_CONCURRENT_ID'
parallel:
matrix:
- CIBW_BUILD: "cp38-manylinux_x86_64"
- CIBW_BUILD: "cp39-manylinux_x86_64"
- CIBW_BUILD: "cp310-manylinux_x86_64"
before_script:
# retrieve aidge dependencies
- DEPENDENCY_JOB="build:ubuntu_python"
- !reference [.ubuntu:download:repositories, before_script] # located in common.gitlab-ci.yml
script:
- /home/ubuntu/.local/bin/cibuildwheel --output-dir wheelhouse
after_script:
# Ensure all files are owned by the correct user at the end of the job
- sudo chown -R $(whoami):$(whoami) .
################################################################################
# Centralized definitions of common job parameter values. #
# Parameters with many optional configurations may be in separate files. #
# #
################################################################################
variables:
GIT_SUBMODULE_STRATEGY: recursive
OMP_NUM_THREADS: 4
GIT_SSL_NO_VERIFY: 1
DEBIAN_FRONTEND: noninteractive
# See https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
default:
image: nvidia/cuda:12.2.0-devel-ubuntu22.04
before_script:
- apt update
- apt install -y cmake cppcheck python-is-python3 pip git gcovr unzip curl
- apt install -y libcudnn8-dev
include:
- project: 'eclipse/aidge/gitlab_shared_files'
ref: 'main'
file:
- '.gitlab/ci/shared_script.gitlab-ci.yml'
build:ubuntu_cpp:
stage: build
needs: []
tags:
- docker
script:
# Download dependencies
- DEPENDENCY_JOB="$CI_JOB_NAME"
# aidge_core
- DEPENDENCY_NAME="aidge_core"
- !reference [.download_dependency, script]
# aidge_backend_cpu
- DEPENDENCY_NAME="aidge_backend_cpu"
- !reference [.download_dependency, script]
# Build current module
- export CMAKE_PREFIX_PATH=../install_cpp
- mkdir -p build_cpp
- cd build_cpp
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON ..
- make -j4 all install
artifacts:
expire_in: 1 week
paths:
- build_cpp/
- install_cpp/
build:ubuntu_cpp_g++10:
stage: build
needs: []
tags:
- docker
script:
# Download dependencies
- DEPENDENCY_JOB="build:ubuntu_cpp_g++:\ [10]"
# aidge_core
- DEPENDENCY_NAME="aidge_core"
- !reference [.download_dependency, script]
# aidge_backend_cpu
- DEPENDENCY_NAME="aidge_backend_cpu"
- !reference [.download_dependency, script]
# Build current module
- export CMAKE_PREFIX_PATH=../install_cpp
- apt install -y g++-10
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/g++-10
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=OFF ..
- make -j4 all install
build:ubuntu_cpp_g++12:
stage: build
needs: []
tags:
- docker
script:
# Download dependencies
- DEPENDENCY_JOB="build:ubuntu_cpp:g++:\ [12]"
# aidge_core
- DEPENDENCY_NAME="aidge_core"
- !reference [.download_dependency, script]
# aidge_backend_cpu
- DEPENDENCY_NAME="aidge_backend_cpu"
- !reference [.download_dependency, script]
# Build current module
- export CMAKE_PREFIX_PATH=../install_cpp
- apt install -y g++-12
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/g++-12
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=OFF -DPYBIND=0 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
- make -j4 all install
build:ubuntu_cpp_clang12:
stage: build
needs: []
tags:
- docker
script:
# Download dependencies
- DEPENDENCY_JOB="build:ubuntu_cpp:clang:\ [12]"
# aidge_core
- DEPENDENCY_NAME="aidge_core"
- !reference [.download_dependency, script]
# aidge_backend_cpu
- DEPENDENCY_NAME="aidge_backend_cpu"
- !reference [.download_dependency, script]
# Build current module
- export CMAKE_PREFIX_PATH=../install_cpp
- apt install -y clang-12
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/clang++-12
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=OFF ..
- make -j4 all install
build:ubuntu_cpp_clang15:
stage: build
needs: []
tags:
- docker
script:
# Download dependencies
- DEPENDENCY_JOB="build:ubuntu_cpp:clang:\ [15]"
# aidge_core
- DEPENDENCY_NAME="aidge_core"
- !reference [.download_dependency, script]
# aidge_backend_cpu
- DEPENDENCY_NAME="aidge_backend_cpu"
- !reference [.download_dependency, script]
# Build current module
- export CMAKE_PREFIX_PATH=../install_cpp
- apt install -y clang-15
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/clang++-15
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=OFF ..
- make -j4 all install
build:ubuntu_python:
stage: build
needs: []
tags:
- docker
script:
# Download dependencies
- DEPENDENCY_JOB="build:ubuntu_python"
# aidge_core (python)
- DEPENDENCY_NAME="aidge_core"
- !reference [.download_dependency, script]
# aidge_backend_cpu (python)
- DEPENDENCY_NAME="aidge_backend_cpu"
- !reference [.download_dependency, script]
- python3 -m pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- python3 -m pip install -r requirements.txt
- python3 -m pip install .
artifacts:
expire_in: 1 week
paths:
- venv/
# build:windows_cpp:
# stage: build
# needs: []
# tags:
# - windows
# image: buildtools
# before_script:
# # Install Chocolatey
# - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# # Install dependencies
# - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
# - choco install git -Y
# - choco install python -Y
# - choco install cuda -Y
# # Update PATH
# - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# script:
# # Download dependencies
# # aidge_core
# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:windows_cpp" -o build_artifacts.zip'
# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force
# - Remove-Item .\build_cpp\ -Recurse
# # aidge_backend_cpu
# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5140/jobs/artifacts/main/download?job=build:windows_cpp" -o build_artifacts.zip'
# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force
# - Remove-Item .\build_cpp\ -Recurse
# - $env:CMAKE_PREFIX_PATH = '../install_cpp'
# - mkdir -p build_cpp
# - cd build_cpp
# - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug ..
# - cmake --build . -j2
# - cmake --install . --config Debug
# artifacts:
# expire_in: 1 week
# paths:
# - build_cpp/
# - install_cpp/
# build:windows_python:
# stage: build
# needs: []
# tags:
# - windows
# image: buildtools
# before_script:
# # Install Chocolatey
# - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# # Install dependencies
# - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
# - choco install git -Y
# - choco install python -Y
# - choco install cuda -Y
# # Update PATH
# - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# script:
# # Download dependencies
# # aidge_core (Python)
# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:windows_python" -o build_artifacts.zip'
# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force
# # aidge_backend_cpu (Python)
# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5140/jobs/artifacts/main/download?job=build:windows_python" -o build_artifacts.zip'
# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force
# - python -m pip install virtualenv
# - virtualenv venv
# - venv\Scripts\Activate.ps1
# - python -m pip install -r requirements.txt
# - python -m pip install .
# artifacts:
# expire_in: 1 week
# paths:
# - venv/
$ErrorActionPreference = "Stop"
# Retrieve and clean the dependencies string from the environment variable
$AIDGE_DEPENDENCIES = $env:AIDGE_DEPENDENCIES -split ' '
Write-Host "Aidge dependencies : $AIDGE_DEPENDENCIES"
if ( $($AIDGE_DEPENDENCIES.Length) -eq 0) {
Write-Host "- No dependencies provided for current repsitory"
New-Item -ItemType Directory -Force -Path ".\build" | Out-Null
Remove-Item -Path ".\build\*" -Recurse -Force
} else {
Write-Host "Retrieving given dependencies to build current package : $AIDGE_DEPENDENCIES"
foreach ($dep in $($AIDGE_DEPENDENCIES -split " ")) {
Write-Host "Retrieving : $dep"
$curr_loc=$(Get-Location)
Set-Location ../$dep
Get-Location
Get-ChildItem .
New-Item -Path ".\build" -ItemType Directory -Force | Out-Null
Get-ChildItem -Path ".\build" -File | Remove-Item -Force
python -m pip install . -v
Set-Location $curr_loc
}
}
#!/bin/bash
set -e
if [[ "$1" == "" ]]; then
echo "build aidge deps in cibuildwheel container before building wheel."
echo "search path defines where the dependencies will be searched."
echo "Hint : In wheel containers, files are mounted on /host by default."
echo "\nusage : ./cibuildwheel_build_deps_before_build_wheel.sh $search_path"
fi
set -x
if [[ $AIDGE_DEPENDENCIES == "" ]]; then # case for aidge_ core
mkdir -p build # creating build if its not already there to hold the build of cpp files
rm -rf build/* # build from scratch
else
for repo in $AIDGE_DEPENDENCIES ; do # case for other projects
search_path=$1
REPO_PATH=$(find $search_path ! -writable -prune -o -type d \
-name "$repo" \
-not -path "*/install/*" \
-not -path "*/.git/*" \
-not -path "*/miniconda/*" \
-not -path "*/conda/*" \
-not -path "*/.local/*" \
-not -path "*/lib/*" \
-not -path "*/$repo/$repo/*" \
-not -path "*/proc/*" \
-print -quit)
if [[ -z "$REPO_PATH" ]]; then
echo "ERROR : dependency $repo not found in search_path \"$search_path\". ABORTING."
exit -1
fi
cd $REPO_PATH
mkdir -p build # creating build if its not already there to hold the build of cpp files
rm -rf build/* # build from scratch
pip install . -v
cd -
done
fi
set +x
set +e
coverage:ubuntu_cpp:
stage: coverage
needs: ["build:ubuntu_cpp"]
tags:
- docker
script:
- cd build_cpp
- ctest --output-on-failure
# HTML report for visualization
- gcovr --html-details --exclude-unreachable-branches -o coverage.html --root ${CI_PROJECT_DIR} --filter '\.\./include/' --filter '\.\./src/'
# Coberta XML report for Gitlab integration
- gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml --root ${CI_PROJECT_DIR} --filter '\.\./include/' --filter '\.\./src/'
coverage: /^\s*lines:\s*\d+.\d+\%/
artifacts:
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
expire_in: 2 days
reports:
coverage_report:
coverage_format: cobertura
path: build_cpp/coverage.xml
coverage:ubuntu_python:
stage: coverage
needs: ["build:ubuntu_python"]
tags:
- docker
script:
- source venv/bin/activate
- python3 -m pip install numpy coverage
- cd ${CI_PROJECT_NAME}
# Retrieve the installation path of the module, since it is installed with pip.
- export MODULE_LOCATION=`python -c "import ${CI_PROJECT_NAME} as _; print(_.__path__[0])"`
- python3 -m coverage run --source=$MODULE_LOCATION -m unittest discover -s unit_tests/ -v -b
- python3 -m coverage report
- python3 -m coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: ${CI_PROJECT_NAME}/coverage.xml
test:ubuntu_cpp:
stage: test
needs: ["build:ubuntu_cpp"]
tags:
- docker
script:
- cd build_cpp
- ctest --output-junit ctest-results.xml --output-on-failure
artifacts:
reports:
junit: build_cpp/ctest-results.xml
test:ubuntu_python:
stage: test
needs: ["build:ubuntu_python"]
tags:
- docker
script:
- source venv/bin/activate
- cd ${CI_PROJECT_NAME}
- python3 -m pip install numpy unittest-xml-reporting
- python3 -m pip list
# Run on discovery all tests located in core/unit_tests/python
- python3 -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml
artifacts:
reports:
junit: ${CI_PROJECT_NAME}/xmlrunner-results.xml
# test:windows_cpp:
# stage: test
# needs: ["build:windows_cpp"]
# tags:
# - windows
# image: buildtools
# before_script:
# # Install Chocolatey
# - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# # Install dependencies
# - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
# - choco install python -Y
# # Update PATH
# - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# script:
# - cd build_cpp
# - ctest --output-junit ctest-results.xml --output-on-failure
# artifacts:
# reports:
# junit: build_cpp/ctest-results.xml
# CMake >= 3.18 is required for good support of FindCUDAToolkit # CMake >= 3.18 is required for good support of FindCUDAToolkit
cmake_minimum_required(VERSION 3.18) cmake_minimum_required(VERSION 3.18)
set(CXX_STANDARD 14)
file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" version) project(aidge_backend_cuda
add_definitions(-DPROJECT_VERSION="${version}") VERSION ${version}
file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project) DESCRIPTION "CUDA implementations of the operators of aidge framework."
LANGUAGES CXX)
message(STATUS "Project name: ${project}") message(STATUS "Project name: ${CMAKE_PROJECT_NAME}")
message(STATUS "Project version: ${version}") message(STATUS "Project version: ${version}")
execute_process( execute_process(
...@@ -13,23 +17,18 @@ execute_process( ...@@ -13,23 +17,18 @@ execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
) )
message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}") message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}")
# Define a preprocessor macro with the Git commit version # Define a preprocessor macro with the Git commit version
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}") add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
# Note : project name is ${CMAKE_PROJECT_NAME} and python module name is also ${CMAKE_PROJECT_NAME}
# Note : project name is {project} and python module name is also {project} set(module_name _${CMAKE_PROJECT_NAME}) # target name
set(module_name _${project}) # target name
project(${project})
set(CXX_STANDARD 14)
############################################## ##############################################
# Define options # Define options
option(PYBIND "python binding" ON) option(PYBIND "python binding" OFF)
option(WERROR "Warning as error" OFF) option(WERROR "Warning as error" OFF)
option(TEST "Enable tests" ON) option(TEST "Enable tests" ON)
option(COVERAGE "Enable coverage" OFF) option(COVERAGE "Enable coverage" OFF)
...@@ -38,34 +37,76 @@ option(ENABLE_ASAN "Enable ASan (AddressSanitizer) for runtime analysis of memor ...@@ -38,34 +37,76 @@ option(ENABLE_ASAN "Enable ASan (AddressSanitizer) for runtime analysis of memor
############################################## ##############################################
# Import utils CMakeLists # Import utils CMakeLists
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(PybindModuleCreation)
if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE) if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE)
Include(CodeCoverage) Include(CodeCoverage)
endif() endif()
enable_language(CUDA) ##############################################
# Find system dependencies
##############################################
# FIND AIDGE Dependencies
if(NOT $ENV{AIDGE_INSTALL} STREQUAL "")
set(CMAKE_INSTALL_PREFIX $ENV{AIDGE_INSTALL})
list(APPEND CMAKE_PREFIX_PATH $ENV{AIDGE_INSTALL})
message(WARNING "Env var AIDGE_INSTALL detected : $ENV{AIDGE_INSTALL}. Set CMAKE_INSTALL_PREFIX to AIDGE_INSTALL & added to CMAKE_PREFIX_PATH"
"\n\tCMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}"
"\n\tCMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
endif()
find_package(aidge_core REQUIRED)
if(TEST)
find_package(aidge_backend_cpu REQUIRED)
endif()
##########
# CUDA
if(NOT $ENV{AIDGE_INSTALL} STREQUAL "")
message(WARNING "Env var CIBUILDWHEEL detected : currently building for a release job."
"\nSetting manually CUDACXX, PATH & LD_LIBRARY_PATH Variables")
list(APPEND ENV{LD_LIBRARY_PATH} /usr/local/cuda/lib64)
list(APPEND ENV{PATH} /usr/local/cuda/bin)
set(ENV{CUDACXX} /usr/local/cuda/bin/nvcc)
endif()
find_package(CUDAToolkit REQUIRED)
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
if(NOT DEFINED CMAKE_CUDA_ARCHITECURE)
set(CMAKE_CUDA_ARCHITECTURE native)
endif()
message(STATUS "Cuda compiler version = ${CMAKE_CUDA_COMPILER_VERSION}") message(STATUS "Cuda compiler version = ${CMAKE_CUDA_COMPILER_VERSION}")
# Define a preprocessor macro with the Cuda compiler version # Define a preprocessor macro with the Cuda compiler version
add_definitions(-DCUDA_COMPILER_VERSION="${CMAKE_CUDA_COMPILER_VERSION}") add_definitions(-DCUDA_COMPILER_VERSION="${CMAKE_CUDA_COMPILER_VERSION}")
message(STATUS "CUDA STANDARD : ${CMAKE_CUDA_STANDARD}")
message(STATUS "CUDA ARCHITECTURE : ${CMAKE_CUDA_ARCHITECTURES}")
############################################## enable_language(CUDA)
# Find system dependencies
find_package(CUDAToolkit REQUIRED)
find_package(aidge_core REQUIRED)
if(TEST)
find_package(aidge_backend_cpu REQUIRED)
endif()
############################################## ##############################################
# Create target and set properties # Create target and set properties
file(GLOB_RECURSE src_files "src/*.cpp" "src/*.cu") file(GLOB_RECURSE src_files "src/*.cpp" "src/*.cu")
file(GLOB_RECURSE inc_files "include/*.hpp") file(GLOB_RECURSE inc_files "include/*.hpp")
add_library(${module_name} ${src_files} ${inc_files}) add_library(${module_name} ${src_files} ${inc_files})
# PYTHON BINDING
if (PYBIND)
# Handles Python + pybind11 headers dependencies
include(PybindModuleCreation)
# creates a target of the same name as CMAKE_PROJECT_NAME
generate_python_binding(${CMAKE_PROJECT_NAME} ${module_name}) # the python bindings module has the same name as the project.
target_link_libraries(${module_name}
PUBLIC
pybind11::pybind11
PRIVATE
Python::Module
)
endif()
target_link_libraries(${module_name} target_link_libraries(${module_name}
PUBLIC PUBLIC
_aidge_core # _ is added because we link the target not the project _aidge_core # _ is added because we link the target not the project
...@@ -103,27 +144,9 @@ target_include_directories(${module_name} ...@@ -103,27 +144,9 @@ target_include_directories(${module_name}
${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src
) )
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
set_property(TARGET ${module_name} PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET ${module_name} PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties(${module_name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(${module_name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# PYTHON BINDING
if (PYBIND)
generate_python_binding(${project} ${module_name})
# Handles Python + pybind11 headers dependencies
target_link_libraries(${module_name}
PUBLIC
pybind11::pybind11
PRIVATE
Python::Python
)
endif()
target_compile_features(${module_name} PRIVATE cxx_std_14) target_compile_features(${module_name} PRIVATE cxx_std_14)
target_compile_options(${module_name} PRIVATE target_compile_options(${module_name} PRIVATE
...@@ -142,11 +165,10 @@ endif() ...@@ -142,11 +165,10 @@ endif()
############################################## ##############################################
# Installation instructions # Installation instructions
include(GNUInstallDirs) include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${project}) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
install(TARGETS ${module_name} EXPORT ${project}-targets install(TARGETS ${module_name} EXPORT ${CMAKE_PROJECT_NAME}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
...@@ -157,8 +179,8 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ...@@ -157,8 +179,8 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#Export the targets to a script #Export the targets to a script
install(EXPORT ${project}-targets install(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${project}-targets.cmake" FILE "${CMAKE_PROJECT_NAME}-targets.cmake"
DESTINATION ${INSTALL_CONFIGDIR} DESTINATION ${INSTALL_CONFIGDIR}
# COMPONENT ${module_name} # COMPONENT ${module_name}
) )
...@@ -167,32 +189,34 @@ install(EXPORT ${project}-targets ...@@ -167,32 +189,34 @@ install(EXPORT ${project}-targets
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake"
VERSION ${version} VERSION ${version}
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
configure_package_config_file("${project}-config.cmake.in" configure_package_config_file("${CMAKE_PROJECT_NAME}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIGDIR} INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
) )
#Install the config, configversion and custom find modules #Install the config, configversion and custom find modules
install(FILES install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake"
DESTINATION ${INSTALL_CONFIGDIR} DESTINATION ${INSTALL_CONFIGDIR}
) )
############################################## ##############################################
## Exporting from the build tree ## Exporting from the build tree
export(EXPORT ${project}-targets export(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${project}-targets.cmake") FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-targets.cmake")
############################################## ##############################################
## Add test ## Add test
if(TEST) if(TEST)
if(PYBIND)
message(FATAL_ERROR "PYBIND and TEST are both enabled. But cannot compile with catch_2.\nChoose between pybind and Catch2 for compilation.")
endif()
enable_testing() enable_testing()
add_subdirectory(unit_tests) add_subdirectory(unit_tests)
endif() endif()
include README.md LICENCE
recursive-include aidge_backend_cuda *.py
recursive-exclude aidge_backend_cuda/unit_tests *.py
recursive-include include *.hpp
recursive-include src *.cpp
recursive-include python_binding *.cpp
include CMakeLists.txt
...@@ -3,15 +3,28 @@ ...@@ -3,15 +3,28 @@
# Aidge CUDA library # Aidge CUDA library
You can find in this folder the library that implements the CUDA operators. You can find in this folder the library that implements the CUDA operators.
[TOC]
## Pip installation ## Installation
You will need to install first the aidge_core library before installing aidge_backend_cuda. ### Dependencies
Also, make sure that the install path was set before installing aidge_core library. - `GCC`
Then run in your python environnement : - `Make`/`Ninja`
- `CMake`
- `Python` (optional, if you have no intend to use this library in python with pybind)
#### Aidge dependencies
- `aidge_core`
- `aidge_backend_cpu`
### Pip installation
``` bash ``` bash
pip install . -v pip install . -v
``` ```
> **TIPS:** Use environment variables to change compilation options:
> - `AIDGE_INSTALL`: to set the installation folder. Defaults to /usr/local/lib. :warning: This path must be identical to aidge_core install path.
> - `AIDGE_PYTHON_BUILD_TYPE`: to set the compilation mode to **Debug** or **Release**
> - `AIDGE_BUILD_GEN`: to set the build backend with
## Standard C++ Compilation ## Standard C++ Compilation
......
from aidge_backend_cuda.aidge_backend_cuda import * # import so generated by PyBind from aidge_backend_cuda.aidge_backend_cuda import * # import so generated by PyBind
from ._version import *
...@@ -6,15 +6,17 @@ import numpy as np ...@@ -6,15 +6,17 @@ import numpy as np
class test_tensor(unittest.TestCase): class test_tensor(unittest.TestCase):
"""Test tensor binding """Test tensor binding"""
"""
def setUp(self): def setUp(self):
pass pass
def tearDown(self): def tearDown(self):
pass pass
def test_getavailable_backends(self): def test_getavailable_backends(self):
self.assertTrue("cuda" in aidge_core.Tensor.get_available_backends()) self.assertTrue("cuda" in aidge_core.Tensor.get_available_backends())
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main() unittest.main()
function(generate_python_binding name target_to_bind) function(generate_python_binding pybind_module_name target_to_bind)
add_definitions(-DPYBIND) add_definitions(-DPYBIND)
Include(FetchContent) Include(FetchContent)
set(PYBIND_VERSION v2.10.4)
set(PYBIND11_FINDPYTHON ON)
message(STATUS "Retrieving pybind ${PYBIND_VERSION} from git")
FetchContent_Declare( FetchContent_Declare(
PyBind11 PyBind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.10.4 # or a later release GIT_TAG ${PYBIND_VERSION} # or a later release
) )
# Use the New FindPython mode, recommanded. Requires CMake 3.15+ # Use the New FindPython mode, recommanded. Requires CMake 3.15+
find_package(Python COMPONENTS Interpreter Development) find_package(Python COMPONENTS Interpreter Development.Module)
FetchContent_MakeAvailable(PyBind11) FetchContent_MakeAvailable(PyBind11)
message(STATUS "Creating binding for module ${name}") message(STATUS "Creating binding for module ${pybind_module_name}")
file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp") file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp")
pybind11_add_module(${name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install pybind11_add_module(${pybind_module_name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install
target_include_directories(${name} PUBLIC "python_binding") target_include_directories(${pybind_module_name} PUBLIC "python_binding")
target_link_libraries(${name} PUBLIC ${target_to_bind}) target_link_libraries(${pybind_module_name} PUBLIC ${target_to_bind})
endfunction() endfunction()
aidge_backend_cuda
\ No newline at end of file
[project]
name = "aidge_backend_cuda"
description="CUDA implementations of the operators of aidge framework"
dependencies = [
"numpy",
]
requires-python = ">= 3.7"
readme = "README.md"
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Programming Language :: Python :: 3"
]
dynamic = ["version"]
#####################################################
# SETUPTOOLS
[tool.setuptools]
[tool.setuptools.packages.find]
where = ["."] # list of folders that contain the packages (["."] by default)
include = ["aidge_backend_cuda*"] # package names should match these glob patterns (["*"] by default)
exclude = ["aidge_backend_cuda.unit_tests*"] # exclude packages matching these glob patterns (empty by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
# SETUPTOOLS_SCM
[tool.setuptools_scm]
write_to = "aidge_backend_cuda/_version.py"
[build-system]
requires = [
"setuptools>=68",
"setuptools-scm",
"cmake>=3.18.0",
"toml"
]
build-backend = "setuptools.build_meta"
#####################################################
# CIBUILDWHEEL
[tool.cibuildwheel]
build-frontend = "build"
test-requires = "pytest"
test-command = "pytest {project}/aidge_backend_cuda/unit_tests"
# uncomment to run cibuildwheel locally on selected distros
# build=[
# "cp38-manylinux_x86_64",
# "cp39-manylinux_x86_64",
# "cp310-manylinux_x86_64"
# ]
[tool.cibuildwheel.container-engine]
# pass command line options to 'docker run'
name = "docker"
create-args = [
"--runtime=nvidia",
"--gpus", "all",
"--privileged",
"-v","/cache",
"-v","/var/run/docker.sock:/var/run/docker.sock",
]
### AIDGE DEPENDENCIES DECLARATION
[tool.cibuildwheel.environment]
# These variables are here for debug purpose but their values when called from CI are set in .gitlab-ci.yml
BUILD_WITH_CUDA=1
AIDGE_DEPENDENCIES = "aidge_core aidge_backend_cpu" # format => "dep_1 dep_2 ... dep_n"
AIDGE_INSTALL="/AIDGE_INSTALL_CIBUILDWHEEL"
ARCH="x86_64"
CUDNN_VERSION="9"
CUDA_MAJOR_VERSION="11"
CUDA_MINOR_VERSION="8"
DOCKER_HOST="unix:///var/run/docker.sock"
SEARCH_PATH="/home/ubuntu/aidge/aidge" # debug path
# these two following variables are set within CMakeLists.txt when calling cibuildwheel from CI
LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
PATH="/usr/local/cuda/bin:$PATH"
[tool.cibuildwheel.linux]
before-build = [
"export CUDA_TOOLKIT_VERSION=$CUDA_MAJOR_VERSION-$CUDA_MINOR_VERSION",
"echo '\n\n\n\n yum -y install cuda-toolkit-$CUDA_TOOLKIT_VERSION.$ARCH'",
"yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/$ARCH/cuda-rhel7.repo",
"yum clean all",
"yum -y install cuda-toolkit-$CUDA_TOOLKIT_VERSION.$ARCH",
"yum list available | grep cudnn",
"yum -y install libcudnn$CUDNN_VERSION-cuda-$CUDA_MAJOR_VERSION.$ARCH",
"yum -y install libcudnn$CUDNN_VERSION-devel-cuda-$CUDA_MAJOR_VERSION.$ARCH",
"export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH",
"export PATH=/usr/local/cuda/bin:$PATH",
"which nvcc",
"nvcc --version",
"echo '\n\n\n\nInstalling required dependencies for aidge_backend_cuda.\n\n'",
"bash .gitlab/ci/cibuildwheel_build_deps_before_build_wheel.sh /host/$SEARCH_PATH"
]
before-test= [
"export CUDA_TOOLKIT_VERSION=$CUDA_MAJOR_VERSION-$CUDA_MINOR_VERSION",
"echo '\n\n\n\n yum -y install cuda-toolkit-$CUDA_TOOLKIT_VERSION.$ARCH'",
"yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/$ARCH/cuda-rhel7.repo",
"yum clean all",
"yum -y install cuda-toolkit-$CUDA_TOOLKIT_VERSION.$ARCH",
"yum list available | grep cudnn",
"yum -y install libcudnn$CUDNN_VERSION-cuda-$CUDA_MAJOR_VERSION.$ARCH",
"yum -y install libcudnn$CUDNN_VERSION-devel-cuda-$CUDA_MAJOR_VERSION.$ARCH",
"export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH",
"export PATH=/usr/local/cuda/bin:$PATH",
"nvcc --version",
"echo '\n\n\n\nInstalling required dependencies for aidge_backend_cuda.\n\n'",
"bash .gitlab/ci/cibuildwheel_build_deps_before_build_wheel.sh /host/$SEARCH_PATH"
]
[tool.cibuildwheel.windows]
before-build = [
"powershell -File .\\.gitlab\\ci\\cibuildwheel_build_deps_before_build_wheel.ps1"
]
before-test = [
"powershell -File .\\.gitlab\\ci\\cibuildwheel_build_deps_before_build_wheel.ps1"
]
#!/usr/bin/env python3 #!/usr/bin/env python3
""" Aidge
#TODO To change
POC of the next framework named Aidge
"""
DOCLINES = (__doc__ or '').split("\n")
import sys import sys
import os import os
# Python supported version checks
if sys.version_info[:2] < (3, 7):
raise RuntimeError("Python version >= 3.7 required.")
CLASSIFIERS = """\
Development Status :: 2 - Pre-Alpha
"""
import shutil import shutil
import pathlib import pathlib
import subprocess
import multiprocessing import multiprocessing
from math import ceil from math import ceil
import toml
from setuptools import setup, Extension from setuptools import setup, Extension
from setuptools import find_packages from setuptools import find_packages
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
def get_project_name() -> str: def get_project_name() -> str:
return open(pathlib.Path().absolute() / "project_name.txt", "r").read() with open(pathlib.Path().absolute() / "pyproject.toml", "r") as file:
project_toml = toml.load(file)
return project_toml["project"]["name"]
def get_project_version() -> str: def get_project_version() -> str:
aidge_root = pathlib.Path().absolute() aidge_root = pathlib.Path().absolute()
...@@ -43,8 +31,8 @@ class CMakeExtension(Extension): ...@@ -43,8 +31,8 @@ class CMakeExtension(Extension):
def __init__(self, name): def __init__(self, name):
super().__init__(name, sources=[]) super().__init__(name, sources=[])
class CMakeBuild(build_ext):
class CMakeBuild(build_ext):
def run(self): def run(self):
# This lists the number of processors available on the machine # This lists the number of processors available on the machine
# The compilation will use half of them # The compilation will use half of them
...@@ -62,17 +50,45 @@ class CMakeBuild(build_ext): ...@@ -62,17 +50,45 @@ class CMakeBuild(build_ext):
os.chdir(str(build_temp)) os.chdir(str(build_temp))
# Impose to use the executable of the python compile_type = (
# used to launch setup.py to setup PythonInterp "Release"
param_py = "-DPYTHON_EXECUTABLE=" + sys.executable if "AIDGE_PYTHON_BUILD_TYPE" not in os.environ
else os.environ["AIDGE_PYTHON_BUILD_TYPE"]
)
install_path = (
os.path.join(sys.prefix, "lib", "libAidge")
if "AIDGE_INSTALL" not in os.environ
else os.environ["AIDGE_INSTALL"]
)
# using ninja as default build system to build faster and with the same compiler as on windows
build_gen = (
["-G", os.environ["AIDGE_BUILD_GEN"]]
if "AIDGE_BUILD_GEN" in os.environ
else []
)
self.spawn(
[
"cmake",
*build_gen,
str(cwd),
"-DTEST=OFF",
f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
f"-DCMAKE_BUILD_TYPE={compile_type}",
"-DPYBIND=ON",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DCOVERAGE=OFF",
"-DCMAKE_CUDA_ARCHITECTURES=native",
]
)
compile_type = 'Debug'
install_path = os.path.join(sys.prefix, "lib", "libAidge") if "AIDGE_INSTALL" not in os.environ else os.environ["AIDGE_INSTALL"]
self.spawn(['cmake', str(cwd), param_py, '-DTEST=OFF', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}', f'-DCMAKE_BUILD_TYPE={compile_type}'])
if not self.dry_run: if not self.dry_run:
self.spawn(['cmake', '--build', '.', '--config', compile_type, '-j', max_jobs]) self.spawn(
self.spawn(['cmake', '--install', '.', '--config', compile_type]) ["cmake", "--build", ".", "--config", compile_type, "-j", max_jobs]
)
self.spawn(["cmake", "--install", ".", "--config", compile_type])
os.chdir(str(cwd)) os.chdir(str(cwd))
aidge_package = build_lib / (get_project_name()) aidge_package = build_lib / (get_project_name())
...@@ -83,8 +99,10 @@ class CMakeBuild(build_ext): ...@@ -83,8 +99,10 @@ class CMakeBuild(build_ext):
# Copy all shared object files from build_temp/lib to aidge_package # Copy all shared object files from build_temp/lib to aidge_package
for root, _, files in os.walk(build_temp.absolute()): for root, _, files in os.walk(build_temp.absolute()):
for file in files: for file in files:
if (file.endswith('.so') or file.endswith('.pyd')) and (root != str(aidge_package.absolute())): if (file.endswith(".so") or file.endswith(".pyd")) and (
currentFile=os.path.join(root, file) root != str(aidge_package.absolute())
):
currentFile = os.path.join(root, file)
shutil.copy(currentFile, str(aidge_package.absolute())) shutil.copy(currentFile, str(aidge_package.absolute()))
# Copy version.txt in aidge_package # Copy version.txt in aidge_package
...@@ -92,23 +110,12 @@ class CMakeBuild(build_ext): ...@@ -92,23 +110,12 @@ class CMakeBuild(build_ext):
shutil.copy("version.txt", str(aidge_package.absolute())) shutil.copy("version.txt", str(aidge_package.absolute()))
if __name__ == '__main__': if __name__ == "__main__":
setup( setup(
name=get_project_name(),
version=get_project_version(),
python_requires='>=3.7',
description=DOCLINES[0],
long_description_content_type="text/markdown",
long_description="\n".join(DOCLINES[2:]),
classifiers=[c for c in CLASSIFIERS.split('\n') if c],
packages=find_packages(where="."),
include_package_data=True, include_package_data=True,
ext_modules=[CMakeExtension(get_project_name())], ext_modules=[CMakeExtension(get_project_name())],
cmdclass={ cmdclass={
'build_ext': CMakeBuild, "build_ext": CMakeBuild,
}, },
install_requires=['aidge_core'],
zip_safe=False, zip_safe=False,
) )
...@@ -98,3 +98,34 @@ bool Aidge::TensorImpl_cuda<T>::operator==(const TensorImpl &otherImpl) const { ...@@ -98,3 +98,34 @@ bool Aidge::TensorImpl_cuda<T>::operator==(const TensorImpl &otherImpl) const {
thrust::device_ptr<T> thrustOtherData(otherImplCuda.mData.data()); thrust::device_ptr<T> thrustOtherData(otherImplCuda.mData.data());
return thrust::equal(thrustData, thrustData + mNbElts, thrustOtherData); return thrust::equal(thrustData, thrustData + mNbElts, thrustOtherData);
} }
template void Aidge::thrust_copy<double, double>(double const*, double*, unsigned long);
template void Aidge::thrust_copy<double, float>(double const*, float*, unsigned long);
template void Aidge::thrust_copy<double, int>(double const*, int*, unsigned long);
template void Aidge::thrust_copy<float, double>(float const*, double*, unsigned long);
template void Aidge::thrust_copy<float, float>(float const*, float*, unsigned long);
template void Aidge::thrust_copy<float, int>(float const*, int*, unsigned long);
template void Aidge::thrust_copy<int, double>(int const*, double*, unsigned long);
template void Aidge::thrust_copy<int, float>(int const*, float*, unsigned long);
template void Aidge::thrust_copy<int, int>(int const*, int*, unsigned long);
template void Aidge::thrust_copy<long, double>(long const*, double*, unsigned long);
template void Aidge::thrust_copy<long, float>(long const*, float*, unsigned long);
template void Aidge::thrust_copy<long, int>(long const*, int*, unsigned long);
template void Aidge::thrust_copy<short, double>(short const*, double*, unsigned long);
template void Aidge::thrust_copy<short, float>(short const*, float*, unsigned long);
template void Aidge::thrust_copy<short, int>(short const*, int*, unsigned long);
template void Aidge::thrust_copy<signed char, double>(signed char const*, double*, unsigned long);
template void Aidge::thrust_copy<signed char, float>(signed char const*, float*, unsigned long);
template void Aidge::thrust_copy<signed char, int>(signed char const*, int*, unsigned long);
template void Aidge::thrust_copy<unsigned char, double>(unsigned char const*, double*, unsigned long);
template void Aidge::thrust_copy<unsigned char, float>(unsigned char const*, float*, unsigned long);
template void Aidge::thrust_copy<unsigned char, int>(unsigned char const*, int*, unsigned long);
template void Aidge::thrust_copy<unsigned int, double>(unsigned int const*, double*, unsigned long);
template void Aidge::thrust_copy<unsigned int, float>(unsigned int const*, float*, unsigned long);
template void Aidge::thrust_copy<unsigned int, int>(unsigned int const*, int*, unsigned long);
template void Aidge::thrust_copy<unsigned long, double>(unsigned long const*, double*, unsigned long);
template void Aidge::thrust_copy<unsigned long, float>(unsigned long const*, float*, unsigned long);
template void Aidge::thrust_copy<unsigned long, int>(unsigned long const*, int*, unsigned long);
template void Aidge::thrust_copy<unsigned short, double>(unsigned short const*, double*, unsigned long);
template void Aidge::thrust_copy<unsigned short, float>(unsigned short const*, float*, unsigned long);
template void Aidge::thrust_copy<unsigned short, int>(unsigned short const*, int*, unsigned long);
...@@ -20,7 +20,7 @@ __device__ T div(T a, T b) { ...@@ -20,7 +20,7 @@ __device__ T div(T a, T b) {
template <> template <>
__device__ half div<half>(half a, half b) { __device__ half div<half>(half a, half b) {
#if __CUDA_ARCH__ >= 530 && defined(CUDART_VERSION) && CUDART_VERSION >= 8000 #if __CUDA_ARCH__ >= 530 && defined(CUDART_VERSION) && CUDART_VERSION >= 8000
return __hdiv(a, b) return __hdiv(a, b);
#else #else
return __float2half(__half2float(a) / __half2float(b)); return __float2half(__half2float(a) / __half2float(b));
#endif #endif
...@@ -97,4 +97,4 @@ template void Aidge::divForward<float>(const float* input1, float* output, const ...@@ -97,4 +97,4 @@ template void Aidge::divForward<float>(const float* input1, float* output, const
template void Aidge::divForward<half>(const half* input1, half* output, const half* input2, template void Aidge::divForward<half>(const half* input1, half* output, const half* input2,
const std::vector<int>& input1Dims,const std::vector<int>& input2Dims, const std::vector<int>& outputDims, const std::vector<int>& input1Dims,const std::vector<int>& input2Dims, const std::vector<int>& outputDims,
const std::vector<int>& input1Strides, const std::vector<int>& input2Strides,const std::vector<int>& outputStrides, const std::vector<int>& input1Strides, const std::vector<int>& input2Strides,const std::vector<int>& outputStrides,
int outSize); int outSize);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment