From b20c9fcccae0f6cf69b035c7cd505093111899f5 Mon Sep 17 00:00:00 2001 From: PaulaExposito Date: Tue, 14 Dec 2021 13:04:22 +0000 Subject: [PATCH 1/4] Linux App changed to new branch for PullRequest --- README.md | 2 + gen/template/java/RGBAImage.mako | 22 +- java/.gitignore | 1 + java/.idea/jarRepositories.xml | 5 + java/buildSrc/build.gradle | 3 + .../groovy/fancier.library-conventions.gradle | 10 +- .../ull/pcg/hpc/fancier/image/RGBAImage.java | 22 +- .../ull/pcg/hpc/fancier/image/RGBAImage.java | 22 +- native/Makefile | 4 +- native/core/include/fancier/exception.h | 5 + native/core/include/fancier/image.h | 9 + native/core/include/fancier/java.h | 1 - native/core/src/fancier.cpp | 30 +- native/core/src/image.c | 206 +- native/core/src/ocl.c | 10 +- test/copy_libs.sh | 18 +- test/linux/.gitignore | 216 + test/linux/images/fullhd.jpg | Bin 0 -> 1367680 bytes test/linux/images/hd1.jpg | Bin 0 -> 1095480 bytes test/linux/images/hd2.jpg | Bin 0 -> 830148 bytes test/linux/images/hdplus.jpg | Bin 0 -> 450258 bytes test/linux/images/qhd.jpg | Bin 0 -> 440073 bytes test/linux/images/test.png | Bin 0 -> 131 bytes test/linux/images/uhd.jpg | Bin 0 -> 2337434 bytes test/linux/images/vga.jpg | Bin 0 -> 50122 bytes test/linux/images/xga.jpg | Bin 0 -> 453443 bytes test/linux/java/.idea/.gitignore | 3 + test/linux/java/.idea/compiler.xml | 6 + test/linux/java/.idea/jarRepositories.xml | 25 + test/linux/java/.idea/misc.xml | 7 + test/linux/java/.idea/runConfigurations.xml | 10 + test/linux/java/.idea/vcs.xml | 6 + test/linux/java/build.gradle | 21 + .../gradle/wrapper/gradle-wrapper.properties | 5 + test/linux/java/gradlew | 185 + test/linux/java/gradlew.bat | 89 + test/linux/java/libs/commons-cli-1.5.0.jar | Bin 0 -> 58284 bytes test/linux/java/libs/rancid-1.1-sources.jar | Bin 0 -> 50882 bytes test/linux/java/libs/rancid-1.1.jar | Bin 0 -> 72404 bytes test/linux/java/run.sh | 18 + test/linux/java/settings.gradle | 2 + .../ull/pcg/hpc/fancier/linuxtest/Main.java | 227 + .../linuxtest/benchmark/BenchmarkTask.java | 412 + .../linuxtest/benchmark/DeviceDescriptor.java | 468 + .../linuxtest/benchmark/DeviceUtils.java | 56 + .../fancier/linuxtest/benchmark/Devices.java | 54 + .../benchmark/JreProgressListener.java | 14 + .../fancier/linuxtest/benchmark/OSUtils.java | 83 + .../benchmark/ReliableLinuxRunner.java | 216 + .../benchmark/RootFileContentsMeter.java | 60 + .../linuxtest/benchmark/ShellUtils.java | 73 + .../linuxtest/model/FancierTestRunner.java | 151 + .../fancier/linuxtest/model/FilterInfo.java | 29 + .../fancier/linuxtest/model/ImageFilter.java | 64 + .../linuxtest/model/ImageFilterBuilder.java | 13 + .../fancier/linuxtest/model/ImageFilters.java | 14 + .../linuxtest/model/JavaImageFilter.java | 2123 ++ .../linuxtest/model/NativeImageFilter.java | 102 + .../hpc/fancier/linuxtest/model/TestTask.java | 61 + .../hpc/fancier/linuxtest/test/ArrayTest.java | 118 + .../fancier/linuxtest/test/FilterTest.java | 77 + .../hpc/fancier/linuxtest/test/InitTest.java | 20 + .../hpc/fancier/linuxtest/test/MathTest.java | 49 + .../fancier/linuxtest/test/ReleaseTest.java | 17 + .../fancier/linuxtest/test/RuntimeTest.java | 9 + .../linuxtest/test/VectorArrayTest.java | 139 + .../fancier/linuxtest/test/VectorTest.java | 57 + .../FancierTest_IRIS_2021_11_24_15_18_25.xml | 2301 +++ test/linux/java/src/main/resources/ImageIds | 8 + .../linux/java/src/main/resources/ImageTitles | 8 + test/linux/java/src/main/resources/TestsNames | 36 + test/linux/java/src/main/resources/fullhd.jpg | Bin 0 -> 1367680 bytes test/linux/java/src/main/resources/hd1.jpg | Bin 0 -> 1095480 bytes test/linux/java/src/main/resources/hd2.jpg | Bin 0 -> 830148 bytes test/linux/java/src/main/resources/hdplus.jpg | Bin 0 -> 450258 bytes test/linux/java/src/main/resources/qhd.jpg | Bin 0 -> 440073 bytes test/linux/java/src/main/resources/test.png | Bin 0 -> 131 bytes test/linux/java/src/main/resources/uhd.jpg | Bin 0 -> 2337434 bytes test/linux/java/src/main/resources/vga.jpg | Bin 0 -> 50122 bytes test/linux/java/src/main/resources/xga.jpg | Bin 0 -> 453443 bytes test/linux/java/src/test/java/MainTest.java | 9 + test/linux/jni/CMakeLists.txt | 93 + test/linux/jni/include/thirdparty/CL/cl.h | 1929 ++ test/linux/jni/include/thirdparty/CL/cl_egl.h | 120 + test/linux/jni/include/thirdparty/CL/cl_ext.h | 907 + .../jni/include/thirdparty/CL/cl_ext_intel.h | 731 + test/linux/jni/include/thirdparty/CL/cl_gl.h | 159 + .../jni/include/thirdparty/CL/cl_gl_ext.h | 40 + .../linux/jni/include/thirdparty/CL/cl_half.h | 440 + test/linux/jni/include/thirdparty/CL/cl_icd.h | 1294 ++ .../jni/include/thirdparty/CL/cl_platform.h | 1384 ++ .../jni/include/thirdparty/CL/cl_version.h | 81 + test/linux/jni/include/thirdparty/CL/opencl.h | 33 + test/linux/jni/include/thirdparty/fancier.h | 81 + .../jni/include/thirdparty/fancier/array.h | 321 + .../jni/include/thirdparty/fancier/color.h | 79 + .../include/thirdparty/fancier/exception.h | 169 + .../jni/include/thirdparty/fancier/image.h | 90 + .../thirdparty/fancier/internal/snippets.inc | 39 + .../jni/include/thirdparty/fancier/java.h | 83 + .../jni/include/thirdparty/fancier/log.h | 119 + .../jni/include/thirdparty/fancier/math.h | 233 + .../jni/include/thirdparty/fancier/ocl.h | 84 + .../jni/include/thirdparty/fancier/platform.h | 57 + .../thirdparty/fancier/plugin/tiling.h | 169 + .../fancier/plugin/tiling/class_tiling_data.h | 67 + .../fancier/plugin/tiling/data_entry.h | 183 + .../fancier/plugin/tiling/data_entry_set.h | 183 + .../plugin/tiling/unique_ptr_content_comp.h | 36 + .../jni/include/thirdparty/fancier/utils.h | 140 + .../jni/include/thirdparty/fancier/vector.h | 17211 ++++++++++++++++ .../include/thirdparty/fancier/vector_array.h | 1107 + test/linux/jni/include/thirdparty/jni.h | 1960 ++ test/linux/jni/include/thirdparty/jni_md.h | 51 + test/linux/jni/src/filter/native_filter.c | 2348 +++ test/linux/jni/src/rancid/rancid.c | 154 + test/linux/jni/src/test/array_test.c | 207 + test/linux/jni/src/test/math_test.c | 58 + test/linux/jni/src/test/quick_test.c | 168 + test/linux/jni/src/test/vector_array_test.c | 244 + test/linux/jni/src/test/vector_test.c | 67 + test/linux/opencl/filters.cl | 348 + test/linux/opencl/math_lib.cl | 239 + 123 files changed, 41498 insertions(+), 39 deletions(-) create mode 100644 test/linux/.gitignore create mode 100644 test/linux/images/fullhd.jpg create mode 100644 test/linux/images/hd1.jpg create mode 100644 test/linux/images/hd2.jpg create mode 100644 test/linux/images/hdplus.jpg create mode 100644 test/linux/images/qhd.jpg create mode 100644 test/linux/images/test.png create mode 100644 test/linux/images/uhd.jpg create mode 100644 test/linux/images/vga.jpg create mode 100644 test/linux/images/xga.jpg create mode 100644 test/linux/java/.idea/.gitignore create mode 100644 test/linux/java/.idea/compiler.xml create mode 100644 test/linux/java/.idea/jarRepositories.xml create mode 100644 test/linux/java/.idea/misc.xml create mode 100644 test/linux/java/.idea/runConfigurations.xml create mode 100644 test/linux/java/.idea/vcs.xml create mode 100644 test/linux/java/build.gradle create mode 100644 test/linux/java/gradle/wrapper/gradle-wrapper.properties create mode 100755 test/linux/java/gradlew create mode 100644 test/linux/java/gradlew.bat create mode 100644 test/linux/java/libs/commons-cli-1.5.0.jar create mode 100644 test/linux/java/libs/rancid-1.1-sources.jar create mode 100644 test/linux/java/libs/rancid-1.1.jar create mode 100755 test/linux/java/run.sh create mode 100644 test/linux/java/settings.gradle create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/Main.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/BenchmarkTask.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/DeviceDescriptor.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/DeviceUtils.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/Devices.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/JreProgressListener.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/OSUtils.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/ReliableLinuxRunner.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/RootFileContentsMeter.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/benchmark/ShellUtils.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/FancierTestRunner.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/FilterInfo.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/ImageFilter.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/ImageFilterBuilder.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/ImageFilters.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/JavaImageFilter.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/NativeImageFilter.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/model/TestTask.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/ArrayTest.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/FilterTest.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/InitTest.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/MathTest.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/ReleaseTest.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/RuntimeTest.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/VectorArrayTest.java create mode 100644 test/linux/java/src/main/java/es/ull/pcg/hpc/fancier/linuxtest/test/VectorTest.java create mode 100644 test/linux/java/src/main/resources/BenchmarkResults/FancierTest_IRIS_2021_11_24_15_18_25.xml create mode 100644 test/linux/java/src/main/resources/ImageIds create mode 100644 test/linux/java/src/main/resources/ImageTitles create mode 100644 test/linux/java/src/main/resources/TestsNames create mode 100644 test/linux/java/src/main/resources/fullhd.jpg create mode 100644 test/linux/java/src/main/resources/hd1.jpg create mode 100644 test/linux/java/src/main/resources/hd2.jpg create mode 100644 test/linux/java/src/main/resources/hdplus.jpg create mode 100644 test/linux/java/src/main/resources/qhd.jpg create mode 100644 test/linux/java/src/main/resources/test.png create mode 100644 test/linux/java/src/main/resources/uhd.jpg create mode 100644 test/linux/java/src/main/resources/vga.jpg create mode 100644 test/linux/java/src/main/resources/xga.jpg create mode 100644 test/linux/java/src/test/java/MainTest.java create mode 100644 test/linux/jni/CMakeLists.txt create mode 100644 test/linux/jni/include/thirdparty/CL/cl.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_egl.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_ext.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_ext_intel.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_gl.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_gl_ext.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_half.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_icd.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_platform.h create mode 100644 test/linux/jni/include/thirdparty/CL/cl_version.h create mode 100644 test/linux/jni/include/thirdparty/CL/opencl.h create mode 100644 test/linux/jni/include/thirdparty/fancier.h create mode 100644 test/linux/jni/include/thirdparty/fancier/array.h create mode 100755 test/linux/jni/include/thirdparty/fancier/color.h create mode 100644 test/linux/jni/include/thirdparty/fancier/exception.h create mode 100755 test/linux/jni/include/thirdparty/fancier/image.h create mode 100755 test/linux/jni/include/thirdparty/fancier/internal/snippets.inc create mode 100755 test/linux/jni/include/thirdparty/fancier/java.h create mode 100644 test/linux/jni/include/thirdparty/fancier/log.h create mode 100755 test/linux/jni/include/thirdparty/fancier/math.h create mode 100755 test/linux/jni/include/thirdparty/fancier/ocl.h create mode 100755 test/linux/jni/include/thirdparty/fancier/platform.h create mode 100755 test/linux/jni/include/thirdparty/fancier/plugin/tiling.h create mode 100755 test/linux/jni/include/thirdparty/fancier/plugin/tiling/class_tiling_data.h create mode 100755 test/linux/jni/include/thirdparty/fancier/plugin/tiling/data_entry.h create mode 100644 test/linux/jni/include/thirdparty/fancier/plugin/tiling/data_entry_set.h create mode 100755 test/linux/jni/include/thirdparty/fancier/plugin/tiling/unique_ptr_content_comp.h create mode 100644 test/linux/jni/include/thirdparty/fancier/utils.h create mode 100755 test/linux/jni/include/thirdparty/fancier/vector.h create mode 100755 test/linux/jni/include/thirdparty/fancier/vector_array.h create mode 100644 test/linux/jni/include/thirdparty/jni.h create mode 100644 test/linux/jni/include/thirdparty/jni_md.h create mode 100644 test/linux/jni/src/filter/native_filter.c create mode 100644 test/linux/jni/src/rancid/rancid.c create mode 100644 test/linux/jni/src/test/array_test.c create mode 100644 test/linux/jni/src/test/math_test.c create mode 100644 test/linux/jni/src/test/quick_test.c create mode 100644 test/linux/jni/src/test/vector_array_test.c create mode 100644 test/linux/jni/src/test/vector_test.c create mode 100644 test/linux/opencl/filters.cl create mode 100644 test/linux/opencl/math_lib.cl diff --git a/README.md b/README.md index faaf2c1..fefaa74 100755 --- a/README.md +++ b/README.md @@ -130,6 +130,8 @@ the _Fancier_ API. The `copy_libs.sh` script copies the already-compiled `.jar` their build directories into the paths where these test applications expect them to be placed in order to be able to link and run their code. +For using the Linux test application it is necessary to have “at” installed and enabled. Moreover, the program must be executed as sudo. + ## License See [COPYING](COPYING.txt) and [COPYING.LESSER](COPYING.LESSER.txt). diff --git a/gen/template/java/RGBAImage.mako b/gen/template/java/RGBAImage.mako index 3424f0b..224d9db 100644 --- a/gen/template/java/RGBAImage.mako +++ b/gen/template/java/RGBAImage.mako @@ -19,6 +19,10 @@ package es.ull.pcg.hpc.fancier.image; import java.nio.ByteBuffer; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.DataBuffer; +import java.awt.image.Raster; import es.ull.pcg.hpc.fancier.vector.Byte4; import es.ull.pcg.hpc.fancier.vector.Int2; @@ -44,13 +48,17 @@ public class RGBAImage implements AutoCloseable { } public RGBAImage(int[] pixels, int width) { - initNative(pixels, width); + initNative(pixels, width, false); } public RGBAImage(RGBAImage image) { initNative(image); } + public RGBAImage(BufferedImage image) { + initNative(((DataBufferInt) image.getRaster().getDataBuffer()).getData(), image.getWidth(), true); + } + % if android: public RGBAImage(Bitmap bmp) { initNative(bmp); @@ -77,8 +85,8 @@ public class RGBAImage implements AutoCloseable { private native void initNative(long nativePtr); private native void initNative(int width, int height); - private native void initNative(int[] pixels, int width); private native void initNative(RGBAImage image); + private native void initNative(int[] pixels, int width, boolean changeFromBGRA); % if android: private native void initNative(Bitmap bmp); % endif @@ -109,6 +117,14 @@ public class RGBAImage implements AutoCloseable { Byte4Array.setBuffer(buffer, y * getWidth() + x, rgba); } + public void setPixels(BufferedImage image) { + setPixels(((DataBufferInt) image.getRaster().getDataBuffer()).getData(), image.getWidth(), true); + } + + public void updateImage(BufferedImage image) { + updateArray(((DataBufferInt) image.getRaster().getDataBuffer()).getData(), true); + } + public native Byte4 get(int x, int y); public native void set(int x, int y, Byte4 rgba); @@ -119,6 +135,8 @@ public class RGBAImage implements AutoCloseable { public native void setPixels(Bitmap bmp); public native void updateBitmap(Bitmap bmp); % endif + private native void setPixels(int[] pixels, int width, boolean changeFromBGRA); + private native void updateArray(int[] array, boolean changeFromBGRA); public native Int2 getDims(); public native int getWidth(); diff --git a/java/.gitignore b/java/.gitignore index 549ed76..217f027 100644 --- a/java/.gitignore +++ b/java/.gitignore @@ -1,2 +1,3 @@ .gradle **/build +local.properties diff --git a/java/.idea/jarRepositories.xml b/java/.idea/jarRepositories.xml index efa4625..b8b7f1c 100755 --- a/java/.idea/jarRepositories.xml +++ b/java/.idea/jarRepositories.xml @@ -16,5 +16,10 @@