Skip to content

Commit

Permalink
Merge pull request #297 from clEsperanto/ADD-PRE-COMMIT
Browse files Browse the repository at this point in the history
add pre-commit config for auto formating
  • Loading branch information
StRigaud committed May 16, 2024
2 parents 49e9762 + e6e1c4a commit 2bb872b
Show file tree
Hide file tree
Showing 60 changed files with 183 additions and 180 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
cmake-build-flag: ""

steps:

- name: Setup Python
uses: actions/setup-python@v5.1.0
with:
Expand All @@ -61,8 +61,8 @@ jobs:
cd ..
git clone --branch ${{ env.opencl-icd-loader-git-tag }} https://github.com/KhronosGroup/OpenCL-ICD-Loader
git clone --branch ${{ env.opencl-headers-git-tag }} https://github.com/KhronosGroup/OpenCL-Headers
# cmake -D CMAKE_INSTALL_PREFIX="./OpenCL-Headers/install" -S "./OpenCL-Headers" -B "./OpenCL-Headers/build"
cmake -S "./OpenCL-Headers" -B "./OpenCL-Headers/build"
# cmake -D CMAKE_INSTALL_PREFIX="./OpenCL-Headers/install" -S "./OpenCL-Headers" -B "./OpenCL-Headers/build"
cmake -S "./OpenCL-Headers" -B "./OpenCL-Headers/build"
cmake --build "./OpenCL-Headers/build" --parallel 6 --target install
cmake -D CMAKE_PREFIX_PATH="./OpenCL-Headers" -D OPENCL_ICD_LOADER_HEADERS_DIR="./OpenCL-Headers/" -S "./OpenCL-ICD-Loader" -B "./OpenCL-ICD-Loader/build" -A x64
cmake --build "./OpenCL-ICD-Loader/build" --parallel 6 --target install --config Release
Expand All @@ -81,7 +81,7 @@ jobs:
cd ..
git clone --branch ${{ env.opencl-icd-loader-git-tag }} https://github.com/KhronosGroup/OpenCL-ICD-Loader
git clone --branch ${{ env.opencl-headers-git-tag }} https://github.com/KhronosGroup/OpenCL-Headers
cmake -S "./OpenCL-Headers" -B "./OpenCL-Headers/build"
cmake -S "./OpenCL-Headers" -B "./OpenCL-Headers/build"
sudo cmake --build "./OpenCL-Headers/build" --parallel 6 --target install
cmake -D CMAKE_PREFIX_PATH="./OpenCL-Headers/" -D OPENCL_ICD_LOADER_HEADERS_DIR="./OpenCL-Headers/" -S "./OpenCL-ICD-Loader" -B "./OpenCL-ICD-Loader/build"
sudo cmake --build "./OpenCL-ICD-Loader/build" --parallel 6 --target install --config Release
Expand All @@ -97,7 +97,7 @@ jobs:
# sudo cp /var/cuda-repo-ubuntu2204-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/
# sudo apt-get update
# sudo apt-get -y install cuda

- uses: actions/checkout@v4
with:
submodules: true
Expand All @@ -107,7 +107,7 @@ jobs:
run : |
cmake -S "${{ github.workspace }}" -B "${{ runner.workspace }}/build" -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DBUILD_DOCUMENTATION=OFF -DBUILD_BENCHMARK=OFF -DOpenCL_LIBRARIES:FILEPATH="/usr/local/lib/libOpenCL.so" -DOpenCL_INCLUDE_DIRS:PATH="/usr/local/include/"
cmake --build "${{ runner.workspace }}/build" --parallel 10 --config Release
shell: bash -l {0}
shell: bash -l {0}

- name: compile CLIc - windows
if: matrix.os == 'windows-latest'
Expand All @@ -122,10 +122,3 @@ jobs:
cmake -S "${{ github.workspace }}" -B "${{ runner.workspace }}/build" -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DBUILD_DOCUMENTATION=OFF -DBUILD_BENCHMARK=OFF
cmake --build "${{ runner.workspace }}/build" --parallel 10 --config Release
shell: bash -l {0}







6 changes: 3 additions & 3 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
python-version: 3.11

- name: Get specific version of CMake, Ninja
uses: lukka/get-cmake@v3.29.0
uses: lukka/get-cmake@v3.29.0

- name: Install doxygen
run: |
Expand All @@ -49,13 +49,13 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install ninja breathe==4.35.0 sphinx==7.2.6 sphinx_rtd_theme==2.0.0
shell: bash -l {0}
shell: bash -l {0}

- name: generat build folder
run: |
cmake -S ./docs -B ./build -G Ninja
cmake --build ./build --target documentation
shell: bash -l {0}
shell: bash -l {0}

- name: Setup Pages
uses: actions/configure-pages@v5
Expand Down
21 changes: 17 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.1.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: clang-format
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: mixed-line-ending


- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
types_or: [c++, c]
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"configurePresets": [],
"buildPresets": [],
"testPresets": []
}
}
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CLIc

[![Build & test](https://github.com/clEsperanto/CLIc/actions/workflows/build-test.yml/badge.svg)](https://github.com/clEsperanto/CLIc/actions/workflows/build-test.yml)
[![CI-Tests](https://github.com/clEsperanto/CLIc/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/clEsperanto/CLIc/actions/workflows/tests_and_coverage.yml)
[![CI-Tests](https://github.com/clEsperanto/CLIc/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/clEsperanto/CLIc/actions/workflows/tests_and_coverage.yml)
[![Codecov](https://codecov.io/gh/clEsperanto/CLIc/branch/master/graph/badge.svg?token=QRSZHYDFIF)](https://codecov.io/gh/clEsperanto/CLIc)
[![License](https://img.shields.io/badge/license-BSD-informational)](https://github.com/clEsperanto/CLIc/blob/master/LICENSE)
[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/clesperanto/CLIc?color=white&include_prereleases)](https://github.com/clEsperanto/CLIc/releases/latest)
Expand All @@ -28,19 +28,19 @@ int main( int argc, char** argv)
auto device = cle::BackendManager::getInstance().getBackend().getDevice("", "all");

// host vector to hold input and output
std::vector<float> input (width * height * depth);
std::vector<float> output (input.size());
std::vector<float> input (width * height * depth);
std::vector<float> output (input.size());

/*
* ... fill input with data to process
* ... fill input with data to process
*/

// push data from host to device
auto gpu_src = cle::Push<float>(input.data(), width, height, depth, device);
// apply filter with parameters
auto gpu_dst = cle::tier1::AddImageAndScalar(device, gpu_src, nullptr, 10);
// pull output from device to host
cle::Pull<float>(gpu_dst, output.data());
cle::Pull<float>(gpu_dst, output.data());

return EXIT_SUCCESS;
}
Expand All @@ -51,8 +51,8 @@ See more complete example on usage by looking at the kernels [tests](./tests/).
## Requirements
CLIc rely on OpenCL language for parallelisation and CMake for configuration and build.
Follow the [compilation guideline](https://clesperanto.github.io/CLIc/compilation.html) for helps on building the library.
CLIc rely on OpenCL language for parallelisation and CMake for configuration and build.
Follow the [compilation guideline](https://clesperanto.github.io/CLIc/compilation.html) for helps on building the library.
## Quick install
Expand Down Expand Up @@ -80,12 +80,12 @@ cmake --build ./build --target uninstall
CLIc filters rely on the clEsperanto branch of [CLIj OpenCL kernels](https://github.com/clEsperanto/clij-opencl-kernels). They are managed as a submodule of this repository.
# __Contributing__
Contributions are very welcome. Before spending effort on coding and filing a pull-request, please get in touch with us, [file an issue](https://github.com/clEsperanto/CLIc/issues), and let's discuss your potential contribution.
Contributions are very welcome. Before spending effort on coding and filing a pull-request, please get in touch with us, [file an issue](https://github.com/clEsperanto/CLIc/issues), and let's discuss your potential contribution.
More information on how to add new kernels to the library can be found in the [documentation](https://clesperanto.github.io/CLIc/contribute.html).
# __Feedback welcome!__
clEsperanto is developed in the open because we believe in the [open source community](https://clij.github.io/clij2-docs/community_guidelines).
Feel free to drop feedback as [github issue](https://github.com/clEsperanto/CLIc/issues) or via [image.sc](https://image.sc).
clEsperanto is developed in the open because we believe in the [open source community](https://clij.github.io/clij2-docs/community_guidelines).
Feel free to drop feedback as [github issue](https://github.com/clEsperanto/CLIc/issues) or via [image.sc](https://image.sc).
And if you liked our work, star the repository, share it with your friends, and use it to make cool stuff!
## Acknowledgements
Expand Down
4 changes: 2 additions & 2 deletions clic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if(${CUDAToolkit_FOUND})
set_target_properties(${LIBRARY_NAME} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${LIBRARY_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(${LIBRARY_NAME} PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
target_link_libraries(${LIBRARY_NAME} PUBLIC CUDA::cudart CUDA::cuda_driver CUDA::nvrtc CUDA::OpenCL)
target_link_libraries(${LIBRARY_NAME} PUBLIC CUDA::cudart CUDA::cuda_driver CUDA::nvrtc CUDA::OpenCL)
endif()

# # Set RPATH configuration
Expand All @@ -60,4 +60,4 @@ endif()
# endif()

# library install instructions
include(${PROJECT_SOURCE_DIR}/cmake/Install.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/Install.cmake)
2 changes: 1 addition & 1 deletion clic/src/openclbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,4 +1192,4 @@ OpenCLBackend::getPreamble() const -> std::string
return kernel::preamble_cl;
}

} // namespace cle
} // namespace cle
2 changes: 1 addition & 1 deletion clic/src/tier0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ create_zx(const Array::Pointer & src, Array::Pointer & dst, dType type) -> void
}


} // namespace cle::tier0
} // namespace cle::tier0
2 changes: 1 addition & 1 deletion clic/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ add_custom_command(
)
# Define the target that depends on the output of the custom command
add_custom_target(
generate_kernels
generate_kernels
DEPENDS ${KERNELS_HEADER_DIR}
)

Expand Down
4 changes: 2 additions & 2 deletions clic/thirdparty/kernel_to_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import glob

def stringify(input_file: str, output_path: str, prefix: str):
def stringify(input_file: str, output_path: str, prefix: str):
kernel_template = """// This file is auto generated at build time. Do not edit manually.
#ifndef {prefix}_{kernel_upcase}_H
Expand Down Expand Up @@ -55,7 +55,7 @@ def main():
output_folder = sys.argv[2]
if not os.path.exists(output_folder):
os.makedirs(output_folder)

file_list = glob.glob( os.path.join(input_folder,'**/*.cl'), recursive=True)
file_list += glob.glob( os.path.join(input_folder,'**/*.cu'), recursive=True)
for file in file_list:
Expand Down
2 changes: 1 addition & 1 deletion cmake/CMakeBackends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ if (CLE_OPENCL)
endif()
if (CLE_CUDA)
message(STATUS "Building for CUDA Backend")
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/CMakeRegistery.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ endfunction ()
# CMake Register (install directory)
if(CMAKE_REGISTRY_FOLDER STREQUAL "INSTALL_FOLDER")
register_package(${CONFIG_INSTALL_DIR})
endif ()
endif ()
2 changes: 1 addition & 1 deletion cmake/presets/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@
}
}
]
}
}
2 changes: 1 addition & 1 deletion cmake/presets/linux/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion cmake/presets/macos/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion cmake/presets/windows/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@
]
}
]
}
}
2 changes: 0 additions & 2 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@ add_custom_target(
DEPENDS doxygen
BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/build
)


2 changes: 1 addition & 1 deletion docs/source/_static/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ $(function () {
$("[data-toggle='rst-debug-badge']").on("click", function () {
$("[data-toggle='rst-versions']").toggleClass("rst-badge");
});
})
})
2 changes: 1 addition & 1 deletion docs/source/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
</div>
</div>
{%- endif %}
{%- endblock %}
{%- endblock %}
2 changes: 1 addition & 1 deletion docs/source/array.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Array
=====

The ``Array`` class is the primary data structure class of the library.
The ``Array`` class is the primary data structure class of the library.
It stores the pointer to the memory space in the ``Device``, along with the necessary information to access and manipulate it.
The class is intended to be used through smart pointers defined as ``Array::Pointer`` and should not be accessed directly.
Hence, the creation of an ``Array`` object is done through ``Array::create()`` function.
Expand Down
26 changes: 13 additions & 13 deletions docs/source/backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Backends
Backend Manager
---------------

The Backend Manager is a singleton class that manages backend selection and initialization.
The Backend Manager is a singleton class that manages backend selection and initialization.
It is designed to allow only one backend to be active at a time. Users can select
backends at runtime, during the initialization phase.
By default, the library will try to initialize the OpenCL backend.
If initialization fails, it will attempt to initialize the CUDA backend.
backends at runtime, during the initialization phase.
By default, the library will try to initialize the OpenCL backend.
If initialization fails, it will attempt to initialize the CUDA backend.
If both fail, the library will throw an exception.

.. warning::
.. warning::

Switching between backends during runtime is not supported and may lead to undefined behavior.

Expand All @@ -22,30 +22,30 @@ If both fail, the library will throw an exception.
Backend Class
-------------

The `Backend` class is an abstract class defining the interface for the different hardware backends supported by CLIc.
Inherited classes implement the necessary low-level functions to operate the hardware.
This abstraction enforces a design pattern allowing switching between different hardware backends without changing the high-level code.
The `Backend` class is an abstract class defining the interface for the different hardware backends supported by CLIc.
Inherited classes implement the necessary low-level functions to operate the hardware.
This abstraction enforces a design pattern allowing switching between different hardware backends without changing the high-level code.
Currently, the library supports OpenCL and CUDA backends, with the possibility of adding more in the future.

.. note::
.. note::

This class operates closest to the hardware, and casual developers should not need to interact with it.

.. warning::
.. warning::

The `CUDABackend` class is operational but not yet fully released.

.. doxygenclass:: cle::Backend
:members:
:members:

OpenCL Backend
~~~~~~~~~~~~~~~

.. doxygenclass:: cle::OpenCLBackend
:members:
:members:

CUDA Backend
~~~~~~~~~~~~

.. doxygenclass:: cle::CUDABackend
:members:
:members:

0 comments on commit 2bb872b

Please sign in to comment.