diff --git a/.gitignore b/.gitignore index a802e58..d10a0c2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,20 +14,20 @@ CLIJ*.txt *~* *.swp -# Maven +# Maven target/ -# Eclipse +# Eclipse .classpath .project .settings/ /.metadata /.recommenders -# vscode +# vscode .vscode/ -# binaries +# binaries *.class *.exp *.obj @@ -36,7 +36,7 @@ target/ # java cpp cppbuild -# CMake +# CMake CMakeCache.txt CMakeFiles CMakeScripts @@ -56,4 +56,3 @@ __pycache__/ *.egg-info python/dist python/lib - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..22c380a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - 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 diff --git a/README.md b/README.md index 9efa947..cb04ba9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The current build instructions are for early adapters to test and give us feedba ## pre-requisites ### Install a c++ compiler -For windows look at the [CLIc_prototype windows build guide](https://github.com/clEsperanto/CLIc_prototype/blob/master/docs/how_to_build/windows_build/windows_build.md) and install Microsoft Build tools (or Visual Studio Community edition) as explained [here](https://biapol.github.io/blog/robert_haase/ms_build_tools/readme.html). +For windows look at the [CLIc_prototype windows build guide](https://github.com/clEsperanto/CLIc_prototype/blob/master/docs/how_to_build/windows_build/windows_build.md) and install Microsoft Build tools (or Visual Studio Community edition) as explained [here](https://biapol.github.io/blog/robert_haase/ms_build_tools/readme.html). Hint: during installation, activate Windows C++ development. ### Install OpenCL @@ -26,7 +26,7 @@ Add the folder where "cl.exe" lives to the PATH, e.g. this one: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64 ``` -Follow the instructions to build [CLIc](https://github.com/clEsperanto/CLIc_prototype/blob/master/docs/how_to_build/windows_build/windows_build.md). +Follow the instructions to build [CLIc](https://github.com/clEsperanto/CLIc_prototype/blob/master/docs/how_to_build/windows_build/windows_build.md). Make sure when setting up CMAKE, that it is built into this directory as explained [here](https://github.com/clEsperanto/CLIc_prototype/blob/master/docs/how_to_build/windows_build/windows_build.md). ``` @@ -64,8 +64,8 @@ Download and install [cmake](https://cmake.org/download/). Get [CLIc_prototype](https://github.com/clEsperanto/CLIc_prototype) and put code in the same directory as ```clesperantoj_prototype```. -Build and install using ```CLIc_prototype/build``` as the folder to place the build files generated by cmake -and ```CLIc_prototype/bin``` as the installation folder where the binaries will be placed. +Build and install using ```CLIc_prototype/build``` as the folder to place the build files generated by cmake +and ```CLIc_prototype/bin``` as the installation folder where the binaries will be placed. It is important to use this code and installation folder as ```clesperantoj_protyotype``` uses them as include and link paths. If using the cmake windows GUI and Visual Studio GUI @@ -97,7 +97,7 @@ mvn ## Running the prototype -After the build succeeded, you can run the main functions in [this package](https://github.com/clEsperanto/clesperantoj_prototype/tree/main/src/main/java/net/clesperanto/test) and play with clesperantoj. +After the build succeeded, you can run the main functions in [this package](https://github.com/clEsperanto/clesperantoj_prototype/tree/main/src/main/java/net/clesperanto/test) and play with clesperantoj. This is recommended to do from an IDE such as IntellIJ by clicking on the green triangle next to the main function: ![img.png](developer_docs/intellij_screenshot.png) @@ -108,7 +108,7 @@ This is recommended to do from an IDE such as IntellIJ by clicking on the green * Sometimes we had to make a trivial change to [clesperantoj][https://github.com/clEsperanto/clesperantoj_prototype/blob/javacpp/src/main/java/net/clesperanto/clicwrapper/clesperantoj.java], like adding a space, to activate the parser that generated the java wrapper.) -* In some cases, the build fails when executed the first time. +* In some cases, the build fails when executed the first time. You find a potential workaround explained [here](https://github.com/clEsperanto/clesperantoj_prototype/issues/4#issuecomment-1184768674). * You may need to add the src/gen/java path to the java build path in your IDE. diff --git a/guideline.md b/guideline.md index 7b9a5f8..9daf9c8 100644 --- a/guideline.md +++ b/guideline.md @@ -17,7 +17,7 @@ We will need the following tools installed and available in the path: Most of those software will propose to be added to the path during installation. If not, you will need to add them manually. -#### **_For windows:_** +#### **_For windows:_** To do so, open the "System" control panel, then "Advanced system settings", then "Environment Variables". In the "System variables" section, edit the "Path" variable and add the path to the executables. E.g. for maven, you will need to add `C:\Program Files\apache-maven-3.6.0\bin` to the path. @@ -55,7 +55,7 @@ The project is structured as follow: * Sometimes we had to make a trivial change to [clesperantoj](https://github.com/clEsperanto/clesperantoj_prototype/blob/javacpp/src/main/java/net/clesperanto/clicwrapper/clesperantoj.java), like adding a space, to activate the parser that generated the java wrapper.) -* In some cases, the build fails when executed the first time. +* In some cases, the build fails when executed the first time. You find a potential workaround explained [here](https://github.com/clEsperanto/clesperantoj_prototype/issues/4#issuecomment-1184768674). * You may need to add the src/gen/java path to the java build path in your IDE. @@ -65,4 +65,4 @@ You find a potential workaround explained [here](https://github.com/clEsperanto/ 1. Go to Project -> Properties -> Java Build Path -> Source (tab). Then add src/main as a source folder. 2. Right-clicking your project, then click Properties. 3. In the left pane, click Java Build Path . In the right pane, select the Source tab. - 4. Here you can add/edit/remove source folders. \ No newline at end of file + 4. Here you can add/edit/remove source folders. diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 8e91435..b8b5ec9 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -6,4 +6,3 @@ message(STATUS "ClesperantoJ and TEST") add_subdirectory(clesperantoj) add_subdirectory(clesperantoj_test) - diff --git a/native/clesperantoj/clic/CMakeLists.txt b/native/clesperantoj/clic/CMakeLists.txt index 2a57751..03c3c93 100644 --- a/native/clesperantoj/clic/CMakeLists.txt +++ b/native/clesperantoj/clic/CMakeLists.txt @@ -1,6 +1,13 @@ ## fetch CLIc from repo release include(FetchContent) +FetchContent_Declare( + ocl_headers + GIT_REPOSITORY https://github.com/KhronosGroup/OpenCL-Headers.git + GIT_TAG v2024.05.08 +) +FetchContent_MakeAvailable(ocl_headers) + option(BUILD_SHARED_LIBS OFF) option(BUILD_TESTING OFF) option(BUILD_BENCHMARK OFF) diff --git a/native/clesperantoj/cppbuild.sh b/native/clesperantoj/cppbuild.sh index 66af9bd..7ea94d0 100644 --- a/native/clesperantoj/cppbuild.sh +++ b/native/clesperantoj/cppbuild.sh @@ -17,14 +17,14 @@ case $PLATFORM in # -DCMAKE_CXX_COMPILER="/usr/bin/g++" \ # -DCMAKE_CUDA_HOST_COMPILER="/usr/bin/g++" \ # -DOPENCL_INCLUDE_DIR="/usr/local/cuda/include/" \ - # -DCLFFT_LIBRARY_DIR="/opt/OpenCL/clFFT-2.12.2-Linux-x64/lib64/" .. - make -j + # -DCLFFT_LIBRARY_DIR="/opt/OpenCL/clFFT-2.12.2-Linux-x64/lib64/" .. + make -j make install ;; macosx-*) # the following line might not be necessary if make would be properly installed in the path # CMAKE=/Applications/CMake.app/Contents/bin/cmake - + $CMAKE -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="../../../lib/macosx/" .. # -DCMAKE_CXX_COMPILER="g++" \ @@ -41,7 +41,7 @@ case $PLATFORM in # -DOpenCL_LIBRARY="C:/Program Files (x86)/OCL_SDK_Light/lib/x86_64/opencl.lib" .. # -DCLIC_INCLUDE_DIR="../../../CLIc_prototype/clic/include/core" \ # -DOCLCL_INCLUDE_DIR="../../../CLIc_prototype/thirdparty/opencl/ocl-clhpp/include" \ - # -DCLFFT_LIBRARY_DIR="C:/OpenCL/clFFT-2.12.2-Windows-x64/lib64/import/" .. + # -DCLFFT_LIBRARY_DIR="C:/OpenCL/clFFT-2.12.2-Windows-x64/lib64/import/" .. nmake nmake install ;; @@ -49,5 +49,3 @@ case $PLATFORM in echo "Error: Platform \"$PLATFORM\" is not supported" ;; esac - - diff --git a/native/clesperantoj_test/CMakeLists.txt b/native/clesperantoj_test/CMakeLists.txt index 7af9dfd..b20b104 100644 --- a/native/clesperantoj_test/CMakeLists.txt +++ b/native/clesperantoj_test/CMakeLists.txt @@ -6,4 +6,4 @@ message(STATUS "TEST") add_executable(clesperantoj_test clictest.cpp) -target_link_libraries(clesperantoj_test PUBLIC clesperantoj::clesperantoj) \ No newline at end of file +target_link_libraries(clesperantoj_test PUBLIC clesperantoj::clesperantoj) diff --git a/native/clesperantoj_test/clictest.cpp b/native/clesperantoj_test/clictest.cpp index 1e73ff9..7e420c7 100644 --- a/native/clesperantoj_test/clictest.cpp +++ b/native/clesperantoj_test/clictest.cpp @@ -15,4 +15,4 @@ int main() clesperanto.getDeviceInfo(); return 0; -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index 7964712..a5bf6be 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ - + net.imagej @@ -152,7 +152,7 @@ ${project.basedir}/native - + org.codehaus.mojo @@ -215,6 +215,7 @@ ${project.build.sourceDirectory} ${basedir}/native/clesperantoj/include ${basedir}/lib/${folder.name}/include/CLIc + ${basedir}/lib/${folder.name}/include ${basedir}/lib/${folder.name}/ @@ -222,14 +223,14 @@ true - + - + javacpp-parser @@ -245,7 +246,7 @@ - + process-classes @@ -259,11 +260,11 @@ net.clesperanto.wrapper.kernelj - - + + - + org.apache.maven.plugins @@ -273,7 +274,7 @@ -Xmx2G - + diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index 3a3664f..5801623 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -46,4 +46,4 @@ public void map(InfoMap infoMap) { infoMap.put(new Info("cle::Array", "cle::Device", "cle::BackendManager", "cle::Backend").skip()); } -} \ No newline at end of file +} diff --git a/src/main/java/net/clesperanto/presets/kernelj.java b/src/main/java/net/clesperanto/presets/kernelj.java index 8d42987..7a318fd 100644 --- a/src/main/java/net/clesperanto/presets/kernelj.java +++ b/src/main/java/net/clesperanto/presets/kernelj.java @@ -19,4 +19,4 @@ public class kernelj implements InfoMapper { public void map(InfoMap infoMap) { } -} \ No newline at end of file +}