From 26d6b9184de828d420686462870704ea513a4c03 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 3 Jul 2023 15:14:42 +0200 Subject: [PATCH 01/38] test: link to new backend --- native/clesperantoj/CMakeLists.txt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/native/clesperantoj/CMakeLists.txt b/native/clesperantoj/CMakeLists.txt index e649874..d2634ee 100644 --- a/native/clesperantoj/CMakeLists.txt +++ b/native/clesperantoj/CMakeLists.txt @@ -18,15 +18,26 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Require (at least) it set(CMAKE_CXX_EXTENSIONS OFF) # Don't use e.g. GNU extension (like -std=gnu++11) for portability set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Export all symbols for shared library windows +# include(FetchContent) +# option(BUILD_TESTING OFF) +# option(BUILD_BENCHMARK OFF) +# FetchContent_Declare( +# clic_lib +# GIT_REPOSITORY https://github.com/clEsperanto/CLIc_prototype.git +# GIT_TAG master # 0.6.3 +# ) +# FetchContent_MakeAvailable(clic_lib) + +## fetch CLIc using CMake FetchContent include(FetchContent) option(BUILD_TESTING OFF) option(BUILD_BENCHMARK OFF) FetchContent_Declare( - clic_lib - GIT_REPOSITORY https://github.com/clEsperanto/CLIc_prototype.git - GIT_TAG master # 0.6.3 + CLIc_lib + GIT_REPOSITORY https://github.com/clEsperanto/MultiBackends.git + GIT_TAG fit-arch-to-clic ) -FetchContent_MakeAvailable(clic_lib) +FetchContent_MakeAvailable(CLIc_lib) file(GLOB_RECURSE WRAPPER_SOURCES_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) file(GLOB_RECURSE WRAPPER_HEADERS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) From 1ab9589a4491507a35a881ec9d3dbd4bc19e8ec9 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 3 Jul 2023 15:14:55 +0200 Subject: [PATCH 02/38] update managment class --- native/clesperantoj/include/clesperantoj.hpp | 73 ++++++---- native/clesperantoj/src/clesperantoj.cpp | 139 ++++++++++--------- 2 files changed, 119 insertions(+), 93 deletions(-) diff --git a/native/clesperantoj/include/clesperantoj.hpp b/native/clesperantoj/include/clesperantoj.hpp index b73bae5..92fb774 100644 --- a/native/clesperantoj/include/clesperantoj.hpp +++ b/native/clesperantoj/include/clesperantoj.hpp @@ -5,44 +5,58 @@ #include #include -#include "cleImage.hpp" -#include "cleProcessor.hpp" +#include "array.hpp" +#include "backend.hpp" +#include "device.hpp" +#include "utils.hpp" -class ProcessorJ +// #include "cleImage.hpp" +// #include "cleProcessor.hpp" + +class BackendJ { - friend class BufferJ; - friend class MemoryJ; +public: + static void setBackend(const std::string &backendName); +}; + +class DeviceJ +{ + friend class BackendJ; private: - cle::Processor proc; - ProcessorJ(const cle::Processor &proc); + std::shared_ptr device_; public: - ProcessorJ(); - ProcessorJ(const std::string &name); - std::vector getAvailableDevices(); - void setDevice(const std::string &name); - std::string getDevice(); + DeviceJ(); - cle::Processor get() const; - std::shared_ptr getShared() const; -}; + static std::vector getAvailableDevices(const std::string &deviceType = "all"); + + void setDevice(const std::string &deviceName = "", const std::string &deviceType = "all"); + std::string getName(); + std::string getInfo(); -class BufferJ + std::shared_ptr get() const; +}; +class ArrayJ { - friend class MemoryJ; private: - cle::Image buffer; - BufferJ(const cle::Image &buffer); + std::shared_ptr array_; + ArrayJ(const std::shared_ptr &array); + + friend class MemoryJ; + +protected: + static ArrayJ create(const size_t &width, const size_t &height, const size_t &depth, const cle::dType &data_type, const cle::mType &memory_type, const DeviceJ &device); + void write(void *data) const; + void read(void *data) const; public: - BufferJ(); + ArrayJ() = default; size_t getWidth(); size_t getHeight(); size_t getDepth(); - void getShape(size_t *shape); unsigned int getDimension(); std::string getDataType(); @@ -50,23 +64,22 @@ class BufferJ std::string getDevice(); void fillMemory(float value); - void copyDataTo(BufferJ &dst); + void copyDataTo(ArrayJ &dst); - cle::Image get() const; - std::shared_ptr getShared() const; + std::shared_ptr get() const; }; class MemoryJ { public: - static BufferJ makeFloatBuffer(const ProcessorJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type); - static BufferJ makeIntBuffer(const ProcessorJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type); + static ArrayJ makeFloatBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type); + static ArrayJ makeIntBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type); - static void writeFloatBuffer(const BufferJ &buffer, float *data, const size_t &size); - static void writeIntBuffer(const BufferJ &buffer, int *data, const size_t &size); + static void writeFloatBuffer(const ArrayJ &array, float *data, const size_t &size); + static void writeIntBuffer(const ArrayJ &array, int *data, const size_t &size); - static void readFloatBuffer(const BufferJ &buffer, float *data, const size_t &size); - static void readIntBuffer(const BufferJ &buffer, int *data, const size_t &size); + static void readFloatBuffer(const ArrayJ &array, float *data, const size_t &size); + static void readIntBuffer(const ArrayJ &array, int *data, const size_t &size); }; #endif // __INCLUDE_CLESPERANTOJ_HPP diff --git a/native/clesperantoj/src/clesperantoj.cpp b/native/clesperantoj/src/clesperantoj.cpp index e7d6d60..868089e 100644 --- a/native/clesperantoj/src/clesperantoj.cpp +++ b/native/clesperantoj/src/clesperantoj.cpp @@ -1,159 +1,172 @@ #include "clesperantoj.hpp" -#include "cleMemory.hpp" -#include "cleTypes.hpp" +#include -ProcessorJ::ProcessorJ() : proc(cle::Processor("")) +void BackendJ::setBackend(const std::string &backendName) { + if (backendName.find("cuda") != std::string::npos) + { + cle::BackendManager::getInstance().setBackend(true); + std::cout << "Using CUDA backend" << std::endl; + } + else + { + cle::BackendManager::getInstance().setBackend(false); + std::cout << "Using OpenCL backend" << std::endl; + } } -ProcessorJ::ProcessorJ(const std::string &name) : proc(cle::Processor(name)) +DeviceJ::DeviceJ() { + this->device_ = cle::BackendManager::getInstance().getBackend().getDevice("", "all"); } -ProcessorJ::ProcessorJ(const cle::Processor &proc) : proc(proc) +std::vector DeviceJ::getAvailableDevices(const std::string &deviceType) { + return cle::BackendManager::getInstance().getBackend().getDevicesList(deviceType); } -std::vector ProcessorJ::getAvailableDevices() +void DeviceJ::setDevice(const std::string &deviceName, const std::string &deviceType) { - return cle::Processor::ListAvailableDevices(); + this->device_ = cle::BackendManager::getInstance().getBackend().getDevice(deviceName, deviceType); } -void ProcessorJ::setDevice(const std::string &name) +std::string DeviceJ::getName() { - this->proc.SelectDevice(name); + return this->device_->getName(); } -std::string ProcessorJ::getDevice() +std::string DeviceJ::getInfo() { - return this->proc.GetDeviceName(); + return this->device_->getInfo(); } -cle::Processor ProcessorJ::get() const +std::shared_ptr DeviceJ::get() const { - return this->proc; + return this->device_; } -std::shared_ptr ProcessorJ::getShared() const +ArrayJ::ArrayJ(const std::shared_ptr &array) : array_(array) { - return std::make_shared(this->proc); } -BufferJ::BufferJ() : buffer(cle::Image()) +ArrayJ ArrayJ::create(const size_t &width, const size_t &height, const size_t &depth, const cle::dType &data_type, const cle::mType &memory_type, const DeviceJ &device) { + auto data = cle::Array::create(width, height, depth, cle::dType::FLOAT, cle::mType::BUFFER, device.get()); + return ArrayJ{data}; } -BufferJ::BufferJ(const cle::Image &buffer) : buffer(buffer) +void ArrayJ::read(void *data) const { + this->array_->read(data); } -size_t BufferJ::getWidth() +void ArrayJ::write(void *data) const { - return this->buffer.Shape()[0]; + this->array_->write(data); } -size_t BufferJ::getHeight() +size_t ArrayJ::getWidth() { - return this->buffer.Shape()[1]; + return this->array_->width(); } -size_t BufferJ::getDepth() +size_t ArrayJ::getHeight() { - return this->buffer.Shape()[2]; + return this->array_->height(); } -void BufferJ::getShape(size_t *shape) +size_t ArrayJ::getDepth() { - shape[0] = this->buffer.Shape()[0]; - shape[1] = this->buffer.Shape()[1]; - shape[2] = this->buffer.Shape()[2]; + return this->array_->depth(); } -unsigned int BufferJ::getDimension() +unsigned int ArrayJ::getDimension() { - return this->buffer.Ndim(); + return this->array_->dim(); } -std::string BufferJ::getDataType() +std::string ArrayJ::getDataType() { - return DataTypeToString(this->buffer.GetDataType()); + std::ostringstream oss; + oss << this->array_->dtype(); + return oss.str(); } -std::string BufferJ::getMemoryType() +std::string ArrayJ::getMemoryType() { - return MemoryTypeToString(this->buffer.GetMemoryType()); + std::ostringstream oss; + oss << this->array_->mtype(); + return oss.str(); } -std::string BufferJ::getDevice() +std::string ArrayJ::getDevice() { - return this->buffer.GetDevice()->GetDeviceName(); + return this->array_->device()->getName(); } -void BufferJ::fillMemory(float value) +std::shared_ptr ArrayJ::get() const { - this->buffer.Fill(value); + return this->array_; } -void BufferJ::copyDataTo(BufferJ &dst) +void ArrayJ::fillMemory(float value) { - this->buffer.CopyDataTo(dst.get()); + this->array_->fill(value); } -cle::Image BufferJ::get() const +void ArrayJ::copyDataTo(ArrayJ &dst) { - return this->buffer; + this->array_->copy(dst.get()); } -std::shared_ptr BufferJ::getShared() const -{ - return std::make_shared(this->buffer); -} +// void Array::getShape(size_t *shape) +// { +// shape[0] = this->array_.width(); +// shape[1] = this->array_.height(); +// shape[2] = this->array_.width(); +// } -BufferJ MemoryJ::makeFloatBuffer(const ProcessorJ &proc, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type) +ArrayJ MemoryJ::makeFloatBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type) { if (memory_type == "image") { - cle::Image image = cle::Memory::AllocateImageMemory(proc.getShared(), {width, height, depth}, cle::DataType::FLOAT32); - return BufferJ{image}; + return ArrayJ::create(width, height, depth, cle::dType::FLOAT, cle::mType::IMAGE, device); } else { - cle::Image image = cle::Memory::AllocateBufferMemory(proc.getShared(), {width, height, depth}, cle::DataType::FLOAT32); - return BufferJ{image}; + return ArrayJ::create(width, height, depth, cle::dType::FLOAT, cle::mType::BUFFER, device); } } -BufferJ MemoryJ::makeIntBuffer(const ProcessorJ &proc, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type) +ArrayJ MemoryJ::makeIntBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type) { if (memory_type == "image") { - cle::Image image = cle::Memory::AllocateImageMemory(proc.getShared(), {width, height, depth}, cle::DataType::FLOAT32); - return BufferJ{image}; + return ArrayJ::create(width, height, depth, cle::dType::INT32, cle::mType::IMAGE, device); } else { - cle::Image image = cle::Memory::AllocateBufferMemory(proc.getShared(), {width, height, depth}, cle::DataType::FLOAT32); - return BufferJ{image}; + return ArrayJ::create(width, height, depth, cle::dType::INT32, cle::mType::BUFFER, device); } } -void MemoryJ::writeFloatBuffer(const BufferJ &buffer, float *data, const size_t &size) +void MemoryJ::writeFloatBuffer(const ArrayJ &array, float *data, const size_t &size) { - cle::Memory::WriteObject(buffer.get(), data, size); + array.write(static_cast(data)); } -void MemoryJ::writeIntBuffer(const BufferJ &buffer, int *data, const size_t &size) +void MemoryJ::writeIntBuffer(const ArrayJ &array, int *data, const size_t &size) { - cle::Memory::WriteObject(buffer.get(), data, size); + array.write(static_cast(data)); } -void MemoryJ::readFloatBuffer(const BufferJ &buffer, float *data, const size_t &size) +void MemoryJ::readFloatBuffer(const ArrayJ &array, float *data, const size_t &size) { - cle::Memory::ReadObject(buffer.get(), data, size); + array.read(static_cast(data)); } -void MemoryJ::readIntBuffer(const BufferJ &buffer, int *data, const size_t &size) +void MemoryJ::readIntBuffer(const ArrayJ &array, int *data, const size_t &size) { - cle::Memory::ReadObject(buffer.get(), data, size); + array.read(static_cast(data)); } From 44428f741c43f0e69308e4644ea0e7ca26770131 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 3 Jul 2023 15:15:02 +0200 Subject: [PATCH 03/38] add some kernels --- native/clesperantoj/include/kernelj.hpp | 3 ++- native/clesperantoj/src/kernelj.cpp | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/native/clesperantoj/include/kernelj.hpp b/native/clesperantoj/include/kernelj.hpp index 63a3133..9d92019 100644 --- a/native/clesperantoj/include/kernelj.hpp +++ b/native/clesperantoj/include/kernelj.hpp @@ -6,7 +6,8 @@ class Tier1 { public: - static void addImageAndScalar(const ProcessorJ &proc, const BufferJ &src, const BufferJ &dst, const float &scalar); + static void absolute(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst); + static void gaussianBlur(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst, const float &sigmaX, const float &sigmaY, const float &sigmaZ); }; #endif // __INCLUDE_KERNELJ_HPP diff --git a/native/clesperantoj/src/kernelj.cpp b/native/clesperantoj/src/kernelj.cpp index 7e1c71b..5785295 100644 --- a/native/clesperantoj/src/kernelj.cpp +++ b/native/clesperantoj/src/kernelj.cpp @@ -1,8 +1,12 @@ #include "kernelj.hpp" +#include "tier1.hpp" -#include "cleAddImageAndScalarKernel.hpp" +void Tier1::absolute(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst) +{ + cle::tier1::absolute_func(dev.get(), src.get(), dst.get()); +} -void Tier1::addImageAndScalar(const ProcessorJ &proc, const BufferJ &src, const BufferJ &dst, const float &scalar) +void Tier1::gaussianBlur(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst, const float &sigmaX, const float &sigmaY, const float &sigmaZ) { - cle::AddImageAndScalarKernel_Call(proc.getShared(), src.get(), dst.get(), scalar); -} \ No newline at end of file + cle::tier1::gaussian_blur_func(dev.get(), src.get(), dst.get(), sigmaX, sigmaY, sigmaZ); +} From feffad9bc47fab0fe16f346001763c2611cd1d3a Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 3 Jul 2023 15:15:27 +0200 Subject: [PATCH 04/38] update presets JCPP --- .../net/clesperanto/presets/clesperantoj.java | 4 ++-- .../java/net/clesperanto/presets/kernelj.java | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index f86af3c..b1b3427 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -11,7 +11,7 @@ @Properties(inherit = javacpp.class, value = { @Platform(compiler = { "cpp17" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { - "clesperantoj.hpp" }, link = { "JCLIc", "OpenCL" }) + "clesperantoj.hpp" }, link = { "JCLIc", "OpenCL", "cuda" }) }, target = "net.clesperanto.wrapper.clesperantoj") public class clesperantoj implements InfoMapper { @@ -27,6 +27,6 @@ public void map(InfoMap infoMap) { .pointerTypes("@Cast({\"char*\", \"std::string*\"}) BytePointer")) .put(new Info("std::vector").pointerTypes("StringVector").define()); - infoMap.put(new Info("cle::Image", "cle::Processor").skip()); + 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 21c7fa1..752e7db 100644 --- a/src/main/java/net/clesperanto/presets/kernelj.java +++ b/src/main/java/net/clesperanto/presets/kernelj.java @@ -1,4 +1,3 @@ - package net.clesperanto.presets; import org.bytedeco.javacpp.Loader; @@ -9,16 +8,16 @@ import org.bytedeco.javacpp.tools.InfoMapper; @Properties(inherit = clesperantoj.class, value = { - @Platform(compiler = { "cpp17" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { - "kernelj.hpp" }, link = { "JCLIc" }) + @Platform(compiler = { "cpp17" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { + "kernelj.hpp" }, link = { "JCLIc" }) }, target = "net.clesperanto.wrapper.kernelj") public class kernelj implements InfoMapper { - static { - Loader.load(); - } + static { + Loader.load(); + } - public void map(InfoMap infoMap) { + public void map(InfoMap infoMap) { - } + } } \ No newline at end of file From 026b474632bed5686f35190c4e39d7271a4924d8 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 3 Jul 2023 15:15:33 +0200 Subject: [PATCH 05/38] test new code --- .../java/net/clesperanto/ClesperantoJ.java | 76 ++++++------------- 1 file changed, 25 insertions(+), 51 deletions(-) diff --git a/src/main/java/net/clesperanto/ClesperantoJ.java b/src/main/java/net/clesperanto/ClesperantoJ.java index db06eea..f85c23b 100644 --- a/src/main/java/net/clesperanto/ClesperantoJ.java +++ b/src/main/java/net/clesperanto/ClesperantoJ.java @@ -4,85 +4,59 @@ import java.util.Arrays; +import org.bytedeco.javacpp.FloatPointer; import org.bytedeco.javacpp.LongPointer; +import org.bytedeco.javacpp.Pointer; -import net.clesperanto.wrapper.clesperantoj.ProcessorJ; -import net.clesperanto.wrapper.kernelj.Tier1; -import net.clesperanto.wrapper.clesperantoj.BufferJ; +import net.clesperanto.wrapper.clesperantoj.DeviceJ; import net.clesperanto.wrapper.clesperantoj.MemoryJ; +import net.clesperanto.wrapper.clesperantoj.BackendJ; +import net.clesperanto.wrapper.clesperantoj.ArrayJ; + +import net.clesperanto.wrapper.kernelj.Tier1; public class ClesperantoJ { public static void main(String[] args) { System.out.println("Hello World! Native Java"); - try (ProcessorJ proc = new ProcessorJ()) { - StringVector deviceList = proc.getAvailableDevices(); - for (int i = 0; i < deviceList.size(); i++) { - System.out.println(deviceList.get(i) + " is available"); - } - System.out.println("device currently used is : " + proc.getDevice()); + BackendJ.setBackend("opencl"); + BackendJ.setBackend("cuda"); - proc.setDevice("Intel"); - System.out.println("device currently used is : " + proc.getDevice()); + StringVector deviceList = DeviceJ.getAvailableDevices(); + for (int i = 0; i < deviceList.size(); i++) { + System.out.println(deviceList.get(i) + " is available"); } - try (BufferJ buffer = new BufferJ()) { - System.out.println("Buffer created"); + try (DeviceJ currentDevice = new DeviceJ()) { + System.out.println("Device created"); + currentDevice.setDevice("TX", "all"); + System.out.println("device currently used is : " + currentDevice.getName()); + System.out.println(currentDevice.getInfo()); } - ProcessorJ proc = new ProcessorJ("TX"); - - try (BufferJ buffer = MemoryJ.makeFloatBuffer(proc, 3, 3, 2, "buffer")) { - - System.out.println("Buffer created"); - System.out.println("Buffer shape is (" + buffer.getWidth() + ", " + buffer.getHeight() + ", " - + buffer.getDepth() + ")"); - System.out.println("Buffer data type is " + buffer.getDataType()); - System.out.println("Buffer mem type is " + buffer.getMemoryType()); - System.out.println("Buffer device is " + buffer.getDevice()); - - float data[] = new float[3 * 3 * 2]; - float out[] = new float[3 * 3 * 2]; - Arrays.fill(data, 5); - Arrays.fill(out, 1); + DeviceJ currentDevice = new DeviceJ(); + currentDevice.setDevice("TX", "all"); - for (int i = 0; i < out.length; i++) { - System.out.println("before out[" + i + "] = " + out[i]); - } - - MemoryJ.writeFloatBuffer(buffer, data, (long) data.length); - MemoryJ.readFloatBuffer(buffer, out, (long) out.length); - - for (int i = 0; i < out.length; i++) { - System.out.println("after out[" + i + "] = " + out[i]); - } - - buffer.fillMemory(10.0f); - MemoryJ.readFloatBuffer(buffer, out, (long) out.length); - for (int i = 0; i < out.length; i++) { - System.out.println("out[" + i + "] = " + out[i]); - } - } - - BufferJ input = MemoryJ.makeFloatBuffer(proc, 3, 3, 2, "buffer"); - BufferJ output = MemoryJ.makeFloatBuffer(proc, 3, 3, 2, "buffer"); + ArrayJ input = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, "buffer"); + ArrayJ output = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, "buffer"); float data[] = new float[3 * 3 * 2]; float out[] = new float[3 * 3 * 2]; - Arrays.fill(data, 5); - Arrays.fill(out, 1); + Arrays.fill(data, -5); + Arrays.fill(out, -1); MemoryJ.writeFloatBuffer(input, data, (long) data.length); MemoryJ.writeFloatBuffer(output, out, (long) out.length); - Tier1.addImageAndScalar(proc, input, output, 10.0f); + Tier1.absolute(currentDevice, input, output); MemoryJ.readFloatBuffer(output, out, (long) out.length); for (int i = 0; i < out.length; i++) { System.out.println("out[" + i + "] = " + out[i]); } + } } From ff244a6b03e08730cc71bb8154758c654d4c8ed2 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 3 Jul 2023 15:15:41 +0200 Subject: [PATCH 06/38] auto gen files ... --- .../net/clesperanto/wrapper/clesperantoj.java | 116 +++++++++++------- .../java/net/clesperanto/wrapper/kernelj.java | 3 +- 2 files changed, 73 insertions(+), 46 deletions(-) diff --git a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java index 2a5f31a..f17ffab 100644 --- a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java +++ b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java @@ -108,56 +108,82 @@ public StringVector put(BytePointer ... array) { // #include // #include +// #include "array.hpp" +// #include "backend.hpp" +// #include "device.hpp" +// #include "utils.hpp" + // #include "cleImage.hpp" // #include "cleProcessor.hpp" -public static class ProcessorJ extends Pointer { +public static class BackendJ extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public BackendJ() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BackendJ(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BackendJ(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public BackendJ position(long position) { + return (BackendJ)super.position(position); + } + @Override public BackendJ getPointer(long i) { + return new BackendJ((Pointer)this).offsetAddress(i); + } + + public static native void setBackend(@StdString String backendName); + public static native void setBackend(@StdString BytePointer backendName); +} + +public static class DeviceJ extends Pointer { static { Loader.load(); } /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public ProcessorJ(Pointer p) { super(p); } + public DeviceJ(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public ProcessorJ(long size) { super((Pointer)null); allocateArray(size); } + public DeviceJ(long size) { super((Pointer)null); allocateArray(size); } private native void allocateArray(long size); - @Override public ProcessorJ position(long position) { - return (ProcessorJ)super.position(position); + @Override public DeviceJ position(long position) { + return (DeviceJ)super.position(position); } - @Override public ProcessorJ getPointer(long i) { - return new ProcessorJ((Pointer)this).offsetAddress(i); + @Override public DeviceJ getPointer(long i) { + return new DeviceJ((Pointer)this).offsetAddress(i); } - public ProcessorJ() { super((Pointer)null); allocate(); } + public DeviceJ() { super((Pointer)null); allocate(); } private native void allocate(); - public ProcessorJ(@StdString String name) { super((Pointer)null); allocate(name); } - private native void allocate(@StdString String name); - public ProcessorJ(@StdString BytePointer name) { super((Pointer)null); allocate(name); } - private native void allocate(@StdString BytePointer name); - public native @ByVal StringVector getAvailableDevices(); - public native void setDevice(@StdString String name); - public native void setDevice(@StdString BytePointer name); - public native @StdString String getDevice(); -} -public static class BufferJ extends Pointer { + public static native @ByVal StringVector getAvailableDevices(@StdString String deviceType/*="all"*/); + public static native @ByVal StringVector getAvailableDevices(); + public static native @ByVal StringVector getAvailableDevices(@StdString BytePointer deviceType/*="all"*/); + + public native void setDevice(@StdString String deviceName/*=""*/, @StdString String deviceType/*="all"*/); + public native void setDevice(); + public native void setDevice(@StdString BytePointer deviceName/*=""*/, @StdString BytePointer deviceType/*="all"*/); + public native @StdString String getName(); + public native @StdString String getInfo(); +} +public static class ArrayJ extends Pointer { static { Loader.load(); } /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public BufferJ(Pointer p) { super(p); } + public ArrayJ(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public BufferJ(long size) { super((Pointer)null); allocateArray(size); } + public ArrayJ(long size) { super((Pointer)null); allocateArray(size); } private native void allocateArray(long size); - @Override public BufferJ position(long position) { - return (BufferJ)super.position(position); + @Override public ArrayJ position(long position) { + return (ArrayJ)super.position(position); } - @Override public BufferJ getPointer(long i) { - return new BufferJ((Pointer)this).offsetAddress(i); + @Override public ArrayJ getPointer(long i) { + return new ArrayJ((Pointer)this).offsetAddress(i); } - public BufferJ() { super((Pointer)null); allocate(); } + public ArrayJ() { super((Pointer)null); allocate(); } private native void allocate(); public native @Cast("size_t") long getWidth(); public native @Cast("size_t") long getHeight(); public native @Cast("size_t") long getDepth(); - public native void getShape(@Cast("size_t*") SizeTPointer shape); public native @Cast("unsigned int") int getDimension(); public native @StdString String getDataType(); @@ -165,7 +191,7 @@ public static class BufferJ extends Pointer { public native @StdString String getDevice(); public native void fillMemory(float value); - public native void copyDataTo(@ByRef BufferJ dst); + public native void copyDataTo(@ByRef ArrayJ dst); } public static class MemoryJ extends Pointer { @@ -185,24 +211,24 @@ public static class MemoryJ extends Pointer { return new MemoryJ((Pointer)this).offsetAddress(i); } - public static native @ByVal BufferJ makeFloatBuffer(@Const @ByRef ProcessorJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString String memory_type); - public static native @ByVal BufferJ makeFloatBuffer(@Const @ByRef ProcessorJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString BytePointer memory_type); - public static native @ByVal BufferJ makeIntBuffer(@Const @ByRef ProcessorJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString String memory_type); - public static native @ByVal BufferJ makeIntBuffer(@Const @ByRef ProcessorJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString BytePointer memory_type); - - public static native void writeFloatBuffer(@Const @ByRef BufferJ buffer, FloatPointer data, @Cast("const size_t") long size); - public static native void writeFloatBuffer(@Const @ByRef BufferJ buffer, FloatBuffer data, @Cast("const size_t") long size); - public static native void writeFloatBuffer(@Const @ByRef BufferJ buffer, float[] data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef BufferJ buffer, IntPointer data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef BufferJ buffer, IntBuffer data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef BufferJ buffer, int[] data, @Cast("const size_t") long size); - - public static native void readFloatBuffer(@Const @ByRef BufferJ buffer, FloatPointer data, @Cast("const size_t") long size); - public static native void readFloatBuffer(@Const @ByRef BufferJ buffer, FloatBuffer data, @Cast("const size_t") long size); - public static native void readFloatBuffer(@Const @ByRef BufferJ buffer, float[] data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef BufferJ buffer, IntPointer data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef BufferJ buffer, IntBuffer data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef BufferJ buffer, int[] data, @Cast("const size_t") long size); + public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString String memory_type); + public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString BytePointer memory_type); + public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString String memory_type); + public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString BytePointer memory_type); + + public static native void writeFloatBuffer(@Const @ByRef ArrayJ buffer, FloatPointer data, @Cast("const size_t") long size); + public static native void writeFloatBuffer(@Const @ByRef ArrayJ buffer, FloatBuffer data, @Cast("const size_t") long size); + public static native void writeFloatBuffer(@Const @ByRef ArrayJ buffer, float[] data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ buffer, IntPointer data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ buffer, IntBuffer data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ buffer, int[] data, @Cast("const size_t") long size); + + public static native void readFloatBuffer(@Const @ByRef ArrayJ buffer, FloatPointer data, @Cast("const size_t") long size); + public static native void readFloatBuffer(@Const @ByRef ArrayJ buffer, FloatBuffer data, @Cast("const size_t") long size); + public static native void readFloatBuffer(@Const @ByRef ArrayJ buffer, float[] data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ buffer, IntPointer data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ buffer, IntBuffer data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ buffer, int[] data, @Cast("const size_t") long size); } // #endif // __INCLUDE_CLESPERANTOJ_HPP diff --git a/src/gen/java/net/clesperanto/wrapper/kernelj.java b/src/gen/java/net/clesperanto/wrapper/kernelj.java index aa552b9..6beaf21 100644 --- a/src/gen/java/net/clesperanto/wrapper/kernelj.java +++ b/src/gen/java/net/clesperanto/wrapper/kernelj.java @@ -36,7 +36,8 @@ public static class Tier1 extends Pointer { return new Tier1((Pointer)this).offsetAddress(i); } - public static native void addImageAndScalar(@Const @ByRef ProcessorJ proc, @Const @ByRef BufferJ src, @Const @ByRef BufferJ dst, float scalar); + public static native void absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst); + public static native void gaussianBlur(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst, float sigmaX, float sigmaY, float sigmaZ); } // #endif // __INCLUDE_KERNELJ_HPP From c3c6f3c510434d86098bd18c9f609918408e8259 Mon Sep 17 00:00:00 2001 From: StRigaud Date: Tue, 4 Jul 2023 22:51:41 +0200 Subject: [PATCH 07/38] update setbackend func --- native/clesperantoj/src/clesperantoj.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/clesperantoj/src/clesperantoj.cpp b/native/clesperantoj/src/clesperantoj.cpp index 868089e..7ae25ab 100644 --- a/native/clesperantoj/src/clesperantoj.cpp +++ b/native/clesperantoj/src/clesperantoj.cpp @@ -6,12 +6,12 @@ void BackendJ::setBackend(const std::string &backendName) { if (backendName.find("cuda") != std::string::npos) { - cle::BackendManager::getInstance().setBackend(true); + cle::BackendManager::getInstance().setBackend("cuda"); std::cout << "Using CUDA backend" << std::endl; } else { - cle::BackendManager::getInstance().setBackend(false); + cle::BackendManager::getInstance().setBackend("opencl"); std::cout << "Using OpenCL backend" << std::endl; } } From 1e321ff2ea5a855a75aac1a5a92f3be67dea8c23 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 30 Oct 2023 13:30:24 +0100 Subject: [PATCH 08/38] update repo with clic master branch --- native/clesperantoj/CMakeLists.txt | 29 +++++-------------- native/clesperantoj/clic/CMakeLists.txt | 13 +++++++++ native/clesperantoj/include/clesperantoj.hpp | 3 -- .../net/clesperanto/wrapper/clesperantoj.java | 29 +++++++++---------- .../java/net/clesperanto/ClesperantoJ.java | 2 ++ .../net/clesperanto/presets/clesperantoj.java | 3 +- .../java/net/clesperanto/presets/kernelj.java | 1 - 7 files changed, 37 insertions(+), 43 deletions(-) create mode 100644 native/clesperantoj/clic/CMakeLists.txt diff --git a/native/clesperantoj/CMakeLists.txt b/native/clesperantoj/CMakeLists.txt index d2634ee..2354b79 100644 --- a/native/clesperantoj/CMakeLists.txt +++ b/native/clesperantoj/CMakeLists.txt @@ -18,35 +18,20 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Require (at least) it set(CMAKE_CXX_EXTENSIONS OFF) # Don't use e.g. GNU extension (like -std=gnu++11) for portability set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Export all symbols for shared library windows -# include(FetchContent) -# option(BUILD_TESTING OFF) -# option(BUILD_BENCHMARK OFF) -# FetchContent_Declare( -# clic_lib -# GIT_REPOSITORY https://github.com/clEsperanto/CLIc_prototype.git -# GIT_TAG master # 0.6.3 -# ) -# FetchContent_MakeAvailable(clic_lib) - -## fetch CLIc using CMake FetchContent -include(FetchContent) -option(BUILD_TESTING OFF) -option(BUILD_BENCHMARK OFF) -FetchContent_Declare( - CLIc_lib - GIT_REPOSITORY https://github.com/clEsperanto/MultiBackends.git - GIT_TAG fit-arch-to-clic -) -FetchContent_MakeAvailable(CLIc_lib) +## CLIc dependency +option(BUILD_TESTING OFF) +option(BUILD_BENCHMARK OFF) +option(BUILD_SHARED_LIBS OFF) +set(CLIC_REPO_TAG master) # branch name for dev +set(CLIC_REPO_URL https://github.com/clEsperanto/CLIc_prototype.git) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/clic) file(GLOB_RECURSE WRAPPER_SOURCES_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) file(GLOB_RECURSE WRAPPER_HEADERS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) set(WRAPPER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) add_library(${LIB_PACKAGE_NAME} SHARED ${WRAPPER_SOURCES_FILES}) - target_link_libraries(${LIB_PACKAGE_NAME} PUBLIC CLIc::CLIc) - target_include_directories(${LIB_PACKAGE_NAME} PUBLIC "$") install(TARGETS ${LIB_PACKAGE_NAME} DESTINATION .) diff --git a/native/clesperantoj/clic/CMakeLists.txt b/native/clesperantoj/clic/CMakeLists.txt new file mode 100644 index 0000000..2a57751 --- /dev/null +++ b/native/clesperantoj/clic/CMakeLists.txt @@ -0,0 +1,13 @@ +## fetch CLIc from repo release +include(FetchContent) + +option(BUILD_SHARED_LIBS OFF) +option(BUILD_TESTING OFF) +option(BUILD_BENCHMARK OFF) + +FetchContent_Declare( + CLIc + GIT_REPOSITORY ${CLIC_REPO_URL} + GIT_TAG ${CLIC_REPO_TAG} +) +FetchContent_MakeAvailable(CLIc) diff --git a/native/clesperantoj/include/clesperantoj.hpp b/native/clesperantoj/include/clesperantoj.hpp index 92fb774..e61dd6b 100644 --- a/native/clesperantoj/include/clesperantoj.hpp +++ b/native/clesperantoj/include/clesperantoj.hpp @@ -10,9 +10,6 @@ #include "device.hpp" #include "utils.hpp" -// #include "cleImage.hpp" -// #include "cleProcessor.hpp" - class BackendJ { public: diff --git a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java index f17ffab..2e651bd 100644 --- a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java +++ b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java @@ -113,9 +113,6 @@ public StringVector put(BytePointer ... array) { // #include "device.hpp" // #include "utils.hpp" -// #include "cleImage.hpp" -// #include "cleProcessor.hpp" - public static class BackendJ extends Pointer { static { Loader.load(); } /** Default native constructor. */ @@ -216,19 +213,19 @@ public static class MemoryJ extends Pointer { public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString String memory_type); public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString BytePointer memory_type); - public static native void writeFloatBuffer(@Const @ByRef ArrayJ buffer, FloatPointer data, @Cast("const size_t") long size); - public static native void writeFloatBuffer(@Const @ByRef ArrayJ buffer, FloatBuffer data, @Cast("const size_t") long size); - public static native void writeFloatBuffer(@Const @ByRef ArrayJ buffer, float[] data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef ArrayJ buffer, IntPointer data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef ArrayJ buffer, IntBuffer data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef ArrayJ buffer, int[] data, @Cast("const size_t") long size); - - public static native void readFloatBuffer(@Const @ByRef ArrayJ buffer, FloatPointer data, @Cast("const size_t") long size); - public static native void readFloatBuffer(@Const @ByRef ArrayJ buffer, FloatBuffer data, @Cast("const size_t") long size); - public static native void readFloatBuffer(@Const @ByRef ArrayJ buffer, float[] data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef ArrayJ buffer, IntPointer data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef ArrayJ buffer, IntBuffer data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef ArrayJ buffer, int[] data, @Cast("const size_t") long size); + public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatPointer data, @Cast("const size_t") long size); + public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatBuffer data, @Cast("const size_t") long size); + public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, float[] data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ array, IntPointer data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ array, IntBuffer data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ array, int[] data, @Cast("const size_t") long size); + + public static native void readFloatBuffer(@Const @ByRef ArrayJ array, FloatPointer data, @Cast("const size_t") long size); + public static native void readFloatBuffer(@Const @ByRef ArrayJ array, FloatBuffer data, @Cast("const size_t") long size); + public static native void readFloatBuffer(@Const @ByRef ArrayJ array, float[] data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ array, IntPointer data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ array, IntBuffer data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ array, int[] data, @Cast("const size_t") long size); } // #endif // __INCLUDE_CLESPERANTOJ_HPP diff --git a/src/main/java/net/clesperanto/ClesperantoJ.java b/src/main/java/net/clesperanto/ClesperantoJ.java index f85c23b..026431a 100644 --- a/src/main/java/net/clesperanto/ClesperantoJ.java +++ b/src/main/java/net/clesperanto/ClesperantoJ.java @@ -20,6 +20,8 @@ public class ClesperantoJ { public static void main(String[] args) { System.out.println("Hello World! Native Java"); + System.out.println(System.getProperty("java.library.path")); + BackendJ.setBackend("opencl"); BackendJ.setBackend("cuda"); diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index b1b3427..19962ad 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -11,7 +11,8 @@ @Properties(inherit = javacpp.class, value = { @Platform(compiler = { "cpp17" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { - "clesperantoj.hpp" }, link = { "JCLIc", "OpenCL", "cuda" }) + "clesperantoj.hpp" }, link = { "JCLIc", "OpenCL", "cuda" }, linkpath = { // only for windows? + "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.2\\lib\\x64" }) }, target = "net.clesperanto.wrapper.clesperantoj") public class clesperantoj implements InfoMapper { diff --git a/src/main/java/net/clesperanto/presets/kernelj.java b/src/main/java/net/clesperanto/presets/kernelj.java index 752e7db..8d42987 100644 --- a/src/main/java/net/clesperanto/presets/kernelj.java +++ b/src/main/java/net/clesperanto/presets/kernelj.java @@ -3,7 +3,6 @@ import org.bytedeco.javacpp.Loader; import org.bytedeco.javacpp.annotation.Platform; import org.bytedeco.javacpp.annotation.Properties; -import org.bytedeco.javacpp.tools.Info; import org.bytedeco.javacpp.tools.InfoMap; import org.bytedeco.javacpp.tools.InfoMapper; From df0b6f923fe52ff073a570138d0bd634076d074b Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 5 Apr 2024 15:37:20 +0200 Subject: [PATCH 09/38] update for 0.9.0 --- native/clesperantoj/CMakeLists.txt | 2 +- native/clesperantoj/include/clesperantoj.hpp | 6 ++-- native/clesperantoj/src/clesperantoj.cpp | 30 ++++++++++---------- pom.xml | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/native/clesperantoj/CMakeLists.txt b/native/clesperantoj/CMakeLists.txt index 2354b79..7ec2ca6 100644 --- a/native/clesperantoj/CMakeLists.txt +++ b/native/clesperantoj/CMakeLists.txt @@ -22,7 +22,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Export all symbols for shared library option(BUILD_TESTING OFF) option(BUILD_BENCHMARK OFF) option(BUILD_SHARED_LIBS OFF) -set(CLIC_REPO_TAG master) # branch name for dev +set(CLIC_REPO_TAG 0.9.0) # branch name for dev set(CLIC_REPO_URL https://github.com/clEsperanto/CLIc_prototype.git) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/clic) diff --git a/native/clesperantoj/include/clesperantoj.hpp b/native/clesperantoj/include/clesperantoj.hpp index e61dd6b..dbe3405 100644 --- a/native/clesperantoj/include/clesperantoj.hpp +++ b/native/clesperantoj/include/clesperantoj.hpp @@ -44,7 +44,7 @@ class ArrayJ friend class MemoryJ; protected: - static ArrayJ create(const size_t &width, const size_t &height, const size_t &depth, const cle::dType &data_type, const cle::mType &memory_type, const DeviceJ &device); + static ArrayJ create(size_t width, size_t height, size_t depth, size_t dimension, const cle::dType &data_type, const cle::mType &memory_type, const DeviceJ &device); void write(void *data) const; void read(void *data) const; @@ -69,8 +69,8 @@ class ArrayJ class MemoryJ { public: - static ArrayJ makeFloatBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type); - static ArrayJ makeIntBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type); + static ArrayJ makeFloatBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const size_t &dimension, const std::string &memory_type); + static ArrayJ makeIntBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const size_t &dimension, const std::string &memory_type); static void writeFloatBuffer(const ArrayJ &array, float *data, const size_t &size); static void writeIntBuffer(const ArrayJ &array, int *data, const size_t &size); diff --git a/native/clesperantoj/src/clesperantoj.cpp b/native/clesperantoj/src/clesperantoj.cpp index 7ae25ab..3ef3a0f 100644 --- a/native/clesperantoj/src/clesperantoj.cpp +++ b/native/clesperantoj/src/clesperantoj.cpp @@ -50,9 +50,9 @@ ArrayJ::ArrayJ(const std::shared_ptr &array) : array_(array) { } -ArrayJ ArrayJ::create(const size_t &width, const size_t &height, const size_t &depth, const cle::dType &data_type, const cle::mType &memory_type, const DeviceJ &device) +ArrayJ ArrayJ::create(size_t width, size_t height, size_t depth, size_t dimension, const cle::dType &data_type, const cle::mType &memory_type, const DeviceJ &device) { - auto data = cle::Array::create(width, height, depth, cle::dType::FLOAT, cle::mType::BUFFER, device.get()); + auto data = cle::Array::create(width, height, depth, dimension, cle::dType::FLOAT, cle::mType::BUFFER, device.get()); return ArrayJ{data}; } @@ -83,7 +83,7 @@ size_t ArrayJ::getDepth() unsigned int ArrayJ::getDimension() { - return this->array_->dim(); + return this->array_->dimension(); } std::string ArrayJ::getDataType() @@ -120,34 +120,34 @@ void ArrayJ::copyDataTo(ArrayJ &dst) this->array_->copy(dst.get()); } -// void Array::getShape(size_t *shape) -// { -// shape[0] = this->array_.width(); -// shape[1] = this->array_.height(); -// shape[2] = this->array_.width(); -// } +// // void Array::getShape(size_t *shape) +// // { +// // shape[0] = this->array_.width(); +// // shape[1] = this->array_.height(); +// // shape[2] = this->array_.width(); +// // } -ArrayJ MemoryJ::makeFloatBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type) +ArrayJ MemoryJ::makeFloatBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const size_t &dimension, const std::string &memory_type) { if (memory_type == "image") { - return ArrayJ::create(width, height, depth, cle::dType::FLOAT, cle::mType::IMAGE, device); + return ArrayJ::create(width, height, depth, dimension, cle::dType::FLOAT, cle::mType::IMAGE, device); } else { - return ArrayJ::create(width, height, depth, cle::dType::FLOAT, cle::mType::BUFFER, device); + return ArrayJ::create(width, height, depth, dimension, cle::dType::FLOAT, cle::mType::BUFFER, device); } } -ArrayJ MemoryJ::makeIntBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const std::string &memory_type) +ArrayJ MemoryJ::makeIntBuffer(const DeviceJ &device, const size_t &width, const size_t &height, const size_t &depth, const size_t &dimension, const std::string &memory_type) { if (memory_type == "image") { - return ArrayJ::create(width, height, depth, cle::dType::INT32, cle::mType::IMAGE, device); + return ArrayJ::create(width, height, depth, dimension, cle::dType::INT32, cle::mType::IMAGE, device); } else { - return ArrayJ::create(width, height, depth, cle::dType::INT32, cle::mType::BUFFER, device); + return ArrayJ::create(width, height, depth, dimension, cle::dType::INT32, cle::mType::BUFFER, device); } } diff --git a/pom.xml b/pom.xml index be9afb8..8c068f3 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ bsd_3 Robert Haase, MPI CBG - /home/stephane/Documents/Fiji.app/ + /home/stephane/Libraries/Fiji.app/ 11.2 From 2291a69b14692e896bd71e1a994c8ce3a13f074b Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 5 Apr 2024 15:37:41 +0200 Subject: [PATCH 10/38] link to libraries --- src/main/java/net/clesperanto/presets/clesperantoj.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index e868e24..8bbbdba 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -11,8 +11,9 @@ @Properties(inherit = javacpp.class, value = { @Platform(compiler = { "cpp17" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { - "clesperantoj.hpp" }, linkpath = {"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.2\\lib\\x64"}, - link = { "JCLIc", "OpenCL", "cuda" }) + "clesperantoj.hpp" }, includepath = { + "/usr/local/cuda-12.3/targets/x86_64-linux/include" }, linkpath = { + "/usr/local/cuda-12.3/targets/x86_64-linux/lib" }, link = { "JCLIc", "OpenCL" }) }, target = "net.clesperanto.wrapper.clesperantoj") public class clesperantoj implements InfoMapper { From a4cf73951cadfd93a49cbd6381c3175c6379390f Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 5 Apr 2024 15:37:51 +0200 Subject: [PATCH 11/38] update low code --- src/main/java/net/clesperanto/ClesperantoJ.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/clesperanto/ClesperantoJ.java b/src/main/java/net/clesperanto/ClesperantoJ.java index 026431a..1cb1e6a 100644 --- a/src/main/java/net/clesperanto/ClesperantoJ.java +++ b/src/main/java/net/clesperanto/ClesperantoJ.java @@ -23,7 +23,7 @@ public static void main(String[] args) { System.out.println(System.getProperty("java.library.path")); BackendJ.setBackend("opencl"); - BackendJ.setBackend("cuda"); + // BackendJ.setBackend("cuda"); StringVector deviceList = DeviceJ.getAvailableDevices(); for (int i = 0; i < deviceList.size(); i++) { @@ -40,8 +40,8 @@ public static void main(String[] args) { DeviceJ currentDevice = new DeviceJ(); currentDevice.setDevice("TX", "all"); - ArrayJ input = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, "buffer"); - ArrayJ output = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, "buffer"); + ArrayJ input = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, 3, "buffer"); + ArrayJ output = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, 3, "buffer"); float data[] = new float[3 * 3 * 2]; float out[] = new float[3 * 3 * 2]; From c0c2f3a3563d7d6875d2d7ee466523a2bbef2783 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 5 Apr 2024 15:37:58 +0200 Subject: [PATCH 12/38] auto gen code --- src/gen/java/net/clesperanto/wrapper/clesperantoj.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java index 2e651bd..2b2a94e 100644 --- a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java +++ b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java @@ -208,10 +208,10 @@ public static class MemoryJ extends Pointer { return new MemoryJ((Pointer)this).offsetAddress(i); } - public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString String memory_type); - public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString BytePointer memory_type); - public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString String memory_type); - public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @StdString BytePointer memory_type); + public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString String memory_type); + public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString BytePointer memory_type); + public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString String memory_type); + public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString BytePointer memory_type); public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatPointer data, @Cast("const size_t") long size); public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatBuffer data, @Cast("const size_t") long size); From a7b1d528b48c8c8e52a42520558517e4ebc5a71a Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 5 Apr 2024 15:47:13 +0200 Subject: [PATCH 13/38] Update CMakeLists.txt --- native/clesperantoj/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/clesperantoj/CMakeLists.txt b/native/clesperantoj/CMakeLists.txt index 7ec2ca6..79b9f41 100644 --- a/native/clesperantoj/CMakeLists.txt +++ b/native/clesperantoj/CMakeLists.txt @@ -22,7 +22,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Export all symbols for shared library option(BUILD_TESTING OFF) option(BUILD_BENCHMARK OFF) option(BUILD_SHARED_LIBS OFF) -set(CLIC_REPO_TAG 0.9.0) # branch name for dev +set(CLIC_REPO_TAG 0.9.1) # branch name for dev set(CLIC_REPO_URL https://github.com/clEsperanto/CLIc_prototype.git) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/clic) From c3e00e5f1ed3c1cdd6af8f0a1fcd381b460d9339 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 5 Apr 2024 17:55:49 +0200 Subject: [PATCH 14/38] test: overload to enable output auto-generation --- native/clesperantoj/include/clesperantoj.hpp | 2 +- native/clesperantoj/include/kernelj.hpp | 3 ++- native/clesperantoj/src/kernelj.cpp | 13 ++++++++++--- src/main/java/net/clesperanto/ClesperantoJ.java | 6 +++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/native/clesperantoj/include/clesperantoj.hpp b/native/clesperantoj/include/clesperantoj.hpp index dbe3405..9d3ca9c 100644 --- a/native/clesperantoj/include/clesperantoj.hpp +++ b/native/clesperantoj/include/clesperantoj.hpp @@ -39,7 +39,6 @@ class ArrayJ private: std::shared_ptr array_; - ArrayJ(const std::shared_ptr &array); friend class MemoryJ; @@ -50,6 +49,7 @@ class ArrayJ public: ArrayJ() = default; + ArrayJ(const std::shared_ptr &array); size_t getWidth(); size_t getHeight(); diff --git a/native/clesperantoj/include/kernelj.hpp b/native/clesperantoj/include/kernelj.hpp index 25d6c8f..2c7d9eb 100644 --- a/native/clesperantoj/include/kernelj.hpp +++ b/native/clesperantoj/include/kernelj.hpp @@ -6,7 +6,8 @@ class Tier1 { public: - static void absolute(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst); + static ArrayJ absolute(const DeviceJ &dev, const ArrayJ &src, ArrayJ &dst); + static ArrayJ absolute(const DeviceJ &dev, const ArrayJ &src); static void gaussianBlur(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst, const float &sigmaX, const float &sigmaY, const float &sigmaZ); static void addImageAndScalar(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst, const float &scalar); }; diff --git a/native/clesperantoj/src/kernelj.cpp b/native/clesperantoj/src/kernelj.cpp index b7cf3c3..516bb13 100644 --- a/native/clesperantoj/src/kernelj.cpp +++ b/native/clesperantoj/src/kernelj.cpp @@ -1,9 +1,17 @@ #include "kernelj.hpp" #include "tier1.hpp" -void Tier1::absolute(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst) +ArrayJ Tier1::absolute(const DeviceJ &dev, const ArrayJ &src, ArrayJ &dst) { - cle::tier1::absolute_func(dev.get(), src.get(), dst.get()); + auto out = cle::tier1::absolute_func(dev.get(), src.get(), dst.get()); + dst = ArrayJ{out}; + return dst; +} + +ArrayJ Tier1::absolute(const DeviceJ &dev, const ArrayJ &src) +{ + auto out = cle::tier1::absolute_func(dev.get(), src.get(), nullptr); + return ArrayJ{out}; } void Tier1::gaussianBlur(const DeviceJ &dev, const ArrayJ &src, const ArrayJ &dst, const float &sigmaX, const float &sigmaY, const float &sigmaZ) @@ -15,4 +23,3 @@ void Tier1::addImageAndScalar(const DeviceJ &dev, const ArrayJ &src, const Array { cle::tier1::add_image_and_scalar_func(dev.get(), src.get(), dst.get(), scalar); } - diff --git a/src/main/java/net/clesperanto/ClesperantoJ.java b/src/main/java/net/clesperanto/ClesperantoJ.java index 1cb1e6a..7e1a77b 100644 --- a/src/main/java/net/clesperanto/ClesperantoJ.java +++ b/src/main/java/net/clesperanto/ClesperantoJ.java @@ -41,7 +41,7 @@ public static void main(String[] args) { currentDevice.setDevice("TX", "all"); ArrayJ input = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, 3, "buffer"); - ArrayJ output = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, 3, "buffer"); + // ArrayJ output = MemoryJ.makeFloatBuffer(currentDevice, 3, 3, 2, 3, "buffer"); float data[] = new float[3 * 3 * 2]; float out[] = new float[3 * 3 * 2]; @@ -49,9 +49,9 @@ public static void main(String[] args) { Arrays.fill(out, -1); MemoryJ.writeFloatBuffer(input, data, (long) data.length); - MemoryJ.writeFloatBuffer(output, out, (long) out.length); + // MemoryJ.writeFloatBuffer(output, out, (long) out.length); - Tier1.absolute(currentDevice, input, output); + ArrayJ output = Tier1.absolute(currentDevice, input); MemoryJ.readFloatBuffer(output, out, (long) out.length); From 8af948944b0d39f966830874e0840e0003fc2a09 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Mon, 22 Apr 2024 23:36:03 +0200 Subject: [PATCH 15/38] make it compile on osx --- native/clesperantoj/CMakeLists.txt | 2 +- native/clesperantoj/cppbuild.sh | 2 +- pom.xml | 3 +++ .../java/net/clesperanto/wrapper/kernelj.java | 3 ++- .../net/clesperanto/presets/clesperantoj.java | 16 ++++++++++++---- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/native/clesperantoj/CMakeLists.txt b/native/clesperantoj/CMakeLists.txt index 79b9f41..d9f7b0c 100644 --- a/native/clesperantoj/CMakeLists.txt +++ b/native/clesperantoj/CMakeLists.txt @@ -22,7 +22,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Export all symbols for shared library option(BUILD_TESTING OFF) option(BUILD_BENCHMARK OFF) option(BUILD_SHARED_LIBS OFF) -set(CLIC_REPO_TAG 0.9.1) # branch name for dev +set(CLIC_REPO_TAG 0.10.1) # branch name for dev set(CLIC_REPO_URL https://github.com/clEsperanto/CLIc_prototype.git) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/clic) diff --git a/native/clesperantoj/cppbuild.sh b/native/clesperantoj/cppbuild.sh index 1c529a4..1fbd894 100644 --- a/native/clesperantoj/cppbuild.sh +++ b/native/clesperantoj/cppbuild.sh @@ -23,7 +23,7 @@ case $PLATFORM in ;; 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=/Applications/CMake.app/Contents/bin/cmake $CMAKE -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="../../../lib/macosx/" .. diff --git a/pom.xml b/pom.xml index 8c068f3..190e9a6 100644 --- a/pom.xml +++ b/pom.xml @@ -157,6 +157,8 @@ ${basedir}/lib/linux64/include/CLIc ${basedir}/lib/win64/include/CLIc ${basedir}/lib/macosx/include/CLIc + + /usr/local/cuda-12.3/targets/x86_64-linux/include ${basedir}/lib/win64/ @@ -169,6 +171,7 @@ C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v{cuda.version}/lib/x64/ + /usr/local/cuda-12.3/targets/x86_64-linux/lib true diff --git a/src/gen/java/net/clesperanto/wrapper/kernelj.java b/src/gen/java/net/clesperanto/wrapper/kernelj.java index 93ca096..0491c5d 100644 --- a/src/gen/java/net/clesperanto/wrapper/kernelj.java +++ b/src/gen/java/net/clesperanto/wrapper/kernelj.java @@ -36,7 +36,8 @@ public static class Tier1 extends Pointer { return new Tier1((Pointer)this).offsetAddress(i); } - public static native void absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst); + public static native @ByVal ArrayJ absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @ByRef ArrayJ dst); + public static native @ByVal ArrayJ absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src); public static native void gaussianBlur(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst, float sigmaX, float sigmaY, float sigmaZ); public static native void addImageAndScalar(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst, float scalar); } diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index 8bbbdba..156871b 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -9,11 +9,19 @@ import org.bytedeco.javacpp.tools.InfoMap; import org.bytedeco.javacpp.tools.InfoMapper; +// // compile on ubuntu +// @Properties(inherit = javacpp.class, value = { +// @Platform(compiler = { "cpp17", "-framework OpenCL" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { +// "clesperantoj.hpp" }, includepath = { +// "/usr/local/cuda-12.3/targets/x86_64-linux/include" }, linkpath = { +// "/usr/local/cuda-12.3/targets/x86_64-linux/lib" }, link = { "JCLIc", "OpenCL" }) +// }, target = "net.clesperanto.wrapper.clesperantoj") + +// compile on mac @Properties(inherit = javacpp.class, value = { - @Platform(compiler = { "cpp17" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { - "clesperantoj.hpp" }, includepath = { - "/usr/local/cuda-12.3/targets/x86_64-linux/include" }, linkpath = { - "/usr/local/cuda-12.3/targets/x86_64-linux/lib" }, link = { "JCLIc", "OpenCL" }) + @Platform(compiler = { "cpp17", "-framework OpenCL" }, define = { + "SHARED_PTR_NAMESPACE std" }, include = { + "clesperantoj.hpp" }, link = { "JCLIc" }) }, target = "net.clesperanto.wrapper.clesperantoj") public class clesperantoj implements InfoMapper { From c7301de24ecd1aebe8a6385afa8ef1c70c8997b4 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 3 May 2024 13:52:23 +0200 Subject: [PATCH 16/38] update to 0.10.2 plus clean up --- native/clesperantoj/CMakeLists.txt | 4 +-- pom.xml | 33 +++++++++++++------ .../net/clesperanto/presets/clesperantoj.java | 7 ++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/native/clesperantoj/CMakeLists.txt b/native/clesperantoj/CMakeLists.txt index d9f7b0c..3b529cd 100644 --- a/native/clesperantoj/CMakeLists.txt +++ b/native/clesperantoj/CMakeLists.txt @@ -21,8 +21,8 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Export all symbols for shared library ## CLIc dependency option(BUILD_TESTING OFF) option(BUILD_BENCHMARK OFF) -option(BUILD_SHARED_LIBS OFF) -set(CLIC_REPO_TAG 0.10.1) # branch name for dev +option(BUILD_SHARED_LIBS ON) +set(CLIC_REPO_TAG 0.10.2) # branch name for dev set(CLIC_REPO_URL https://github.com/clEsperanto/CLIc_prototype.git) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/clic) diff --git a/pom.xml b/pom.xml index 190e9a6..d4ff7a1 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ - + net.imagej @@ -111,9 +111,9 @@ ${project.basedir}/native - + - + org.codehaus.mojo build-helper-maven-plugin @@ -150,6 +150,11 @@ javacpp 1.5.8 + + -std=c++17 + + + ${project.build.outputDirectory} ${project.build.sourceDirectory} @@ -157,8 +162,14 @@ ${basedir}/lib/linux64/include/CLIc ${basedir}/lib/win64/include/CLIc ${basedir}/lib/macosx/include/CLIc - + + + /usr/local/cuda-12.3/targets/x86_64-linux/include + + ${basedir}/lib/win64/ @@ -168,11 +179,13 @@ ${basedir}/lib/linux64/lib ${basedir}/lib/macosx/lib - - - C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v{cuda.version}/lib/x64/ - /usr/local/cuda-12.3/targets/x86_64-linux/lib + + + true @@ -195,7 +208,7 @@ - + process-classes process-classes @@ -208,7 +221,7 @@ net.clesperanto.wrapper.kernelj - + diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index 156871b..48cd13a 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -9,7 +9,7 @@ import org.bytedeco.javacpp.tools.InfoMap; import org.bytedeco.javacpp.tools.InfoMapper; -// // compile on ubuntu +// // @Properties(inherit = javacpp.class, value = { // @Platform(compiler = { "cpp17", "-framework OpenCL" }, define = { "SHARED_PTR_NAMESPACE std" }, include = { // "clesperantoj.hpp" }, includepath = { @@ -17,11 +17,8 @@ // "/usr/local/cuda-12.3/targets/x86_64-linux/lib" }, link = { "JCLIc", "OpenCL" }) // }, target = "net.clesperanto.wrapper.clesperantoj") -// compile on mac @Properties(inherit = javacpp.class, value = { - @Platform(compiler = { "cpp17", "-framework OpenCL" }, define = { - "SHARED_PTR_NAMESPACE std" }, include = { - "clesperantoj.hpp" }, link = { "JCLIc" }) + @Platform(include = { "clesperantoj.hpp" }, link = { "JCLIc"}) }, target = "net.clesperanto.wrapper.clesperantoj") public class clesperantoj implements InfoMapper { From adaa4d472a5c68e80deafb590da3fc398daf7601 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Tue, 7 May 2024 16:41:28 +0200 Subject: [PATCH 17/38] change the phase of parsing to a later one --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d4ff7a1..c5bf8f8 100644 --- a/pom.xml +++ b/pom.xml @@ -195,7 +195,7 @@ generate-sources - generate-sources + compile parse From 005868f74f7634e8bf46cd85afa6efcb3aeef1de Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 7 May 2024 16:46:03 +0200 Subject: [PATCH 18/38] REorder indentation and spaces in pom --- pom.xml | 268 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 132 insertions(+), 136 deletions(-) diff --git a/pom.xml b/pom.xml index c5bf8f8..8006531 100644 --- a/pom.xml +++ b/pom.xml @@ -89,144 +89,140 @@ - - - - - exec-maven-plugin - 1.6.0 - org.codehaus.mojo - - - cppbuild - generate-sources - - exec - - - bash - ${project.basedir}/native/cppbuild.sh - ${project.basedir}/native - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.3.0 - - - add-source - generate-sources - - add-source - - - - ${project.basedir}/src/gen/java - - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.4.1 - - -Xmx2G - - - - - org.bytedeco - javacpp - 1.5.8 - - - -std=c++17 - - - - ${project.build.outputDirectory} - - ${project.build.sourceDirectory} - ${basedir}/native/clesperantoj/include - ${basedir}/lib/linux64/include/CLIc - ${basedir}/lib/win64/include/CLIc - ${basedir}/lib/macosx/include/CLIc - - - - /usr/local/cuda-12.3/targets/x86_64-linux/include - - - - - ${basedir}/lib/win64/ - ${basedir}/lib/linux64/ - ${basedir}/lib/macosx/ - ${basedir}/lib/win64/lib - ${basedir}/lib/linux64/lib - ${basedir}/lib/macosx/lib - - - - - - - true - - - - - - - generate-sources - compile - - parse - - - ${project.basedir}/src/gen/java - - net.clesperanto.presets.clesperantoj - net.clesperanto.presets.kernelj - - - - - - - process-classes - process-classes - - build - - - - net.clesperanto.wrapper.clesperantoj - net.clesperanto.wrapper.kernelj - - - - - - - - + + + exec-maven-plugin + 1.6.0 + org.codehaus.mojo + + + cppbuild + generate-sources + + exec + + + bash + ${project.basedir}/native/cppbuild.sh + ${project.basedir}/native + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.3.0 + + + add-source + generate-sources + + add-source + + + + ${project.basedir}/src/gen/java + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.4.1 + + -Xmx2G + + + + + org.bytedeco + javacpp + 1.5.8 + + + -std=c++17 + + + + ${project.build.outputDirectory} + + ${project.build.sourceDirectory} + ${basedir}/native/clesperantoj/include + ${basedir}/lib/linux64/include/CLIc + ${basedir}/lib/win64/include/CLIc + ${basedir}/lib/macosx/include/CLIc + + + + /usr/local/cuda-12.3/targets/x86_64-linux/include + + + + + ${basedir}/lib/win64/ + ${basedir}/lib/linux64/ + ${basedir}/lib/macosx/ + ${basedir}/lib/win64/lib + ${basedir}/lib/linux64/lib + ${basedir}/lib/macosx/lib + + + + + + + true + + + + + + + generate-sources + compile + + parse + + + ${project.basedir}/src/gen/java + + net.clesperanto.presets.clesperantoj + net.clesperanto.presets.kernelj + + + + + + + process-classes + process-classes + + build + + + + net.clesperanto.wrapper.clesperantoj + net.clesperanto.wrapper.kernelj + + + + + + + + From 567e82ec355228b282b40bdc8d6ddc0d0b4aeaa2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 7 May 2024 18:19:09 +0200 Subject: [PATCH 19/38] Add compile during generate-sources part, and also during compilation --- pom.xml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8006531..ded4bc8 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,35 @@ + + + + maven-compiler-plugin + 3.12.1 + + 1.7 + 1.7 + + + + default-compile + + + compile-b4-javacpp-parser + generate-sources + + compile + + + + net/clesperanto/presets/*.java + + + + + + + @@ -190,8 +219,8 @@ - generate-sources - compile + javacpp-parser + generate-sources parse From dfcaa6844c070b848da110fc6cf24b47194b8ec8 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 7 May 2024 18:30:38 +0200 Subject: [PATCH 20/38] reorder plugins, as their order specifies execution order --- pom.xml | 66 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/pom.xml b/pom.xml index ded4bc8..3380a84 100644 --- a/pom.xml +++ b/pom.xml @@ -91,31 +91,6 @@ - - maven-compiler-plugin - 3.12.1 - - 1.7 - 1.7 - - - - default-compile - - - compile-b4-javacpp-parser - generate-sources - - compile - - - - net/clesperanto/presets/*.java - - - - - @@ -161,13 +136,30 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 2.4.1 - - -Xmx2G - + + maven-compiler-plugin + 3.12.1 + + 1.7 + 1.7 + + + + default-compile + + + compile-b4-javacpp-parser + generate-sources + + compile + + + + net/clesperanto/presets/*.java + + + + @@ -250,6 +242,16 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.4.1 + + -Xmx2G + + From 4ed0661a1c98c6f4de5cee69a4ae5215187fb876 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Tue, 7 May 2024 18:59:49 +0200 Subject: [PATCH 21/38] Delete src/gen/java/net/clesperanto/wrapper/clesperantoj.java --- .../net/clesperanto/wrapper/clesperantoj.java | 234 ------------------ 1 file changed, 234 deletions(-) delete mode 100644 src/gen/java/net/clesperanto/wrapper/clesperantoj.java diff --git a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java deleted file mode 100644 index 2b2a94e..0000000 --- a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java +++ /dev/null @@ -1,234 +0,0 @@ -// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE - -package net.clesperanto.wrapper; - -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; - -public class clesperantoj extends net.clesperanto.presets.clesperantoj { - static { Loader.load(); } - -@Name("std::vector") public static class StringVector extends Pointer { - static { Loader.load(); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public StringVector(Pointer p) { super(p); } - public StringVector(String value) { this(1); put(0, value); } - public StringVector(String ... array) { this(array.length); put(array); } - public StringVector(BytePointer value) { this(1); put(0, value); } - public StringVector(BytePointer ... array) { this(array.length); put(array); } - public StringVector() { allocate(); } - public StringVector(long n) { allocate(n); } - private native void allocate(); - private native void allocate(@Cast("size_t") long n); - public native @Name("operator =") @ByRef StringVector put(@ByRef StringVector x); - - public boolean empty() { return size() == 0; } - public native long size(); - public void clear() { resize(0); } - public native void resize(@Cast("size_t") long n); - - @Index(function = "at") public native @StdString String get(@Cast("size_t") long i); - public native StringVector put(@Cast("size_t") long i, String value); - @ValueSetter @Index(function = "at") public native StringVector put(@Cast("size_t") long i, @StdString BytePointer value); - - public native @ByVal Iterator insert(@ByVal Iterator pos, @StdString String value); - public native @ByVal Iterator erase(@ByVal Iterator pos); - public native @ByVal Iterator begin(); - public native @ByVal Iterator end(); - @NoOffset @Name("iterator") public static class Iterator extends Pointer { - public Iterator(Pointer p) { super(p); } - public Iterator() { } - - public native @Name("operator ++") @ByRef Iterator increment(); - public native @Name("operator ==") boolean equals(@ByRef Iterator it); - public native @Name("operator *") @StdString String get(); - } - - public String[] get() { - String[] array = new String[size() < Integer.MAX_VALUE ? (int)size() : Integer.MAX_VALUE]; - for (int i = 0; i < array.length; i++) { - array[i] = get(i); - } - return array; - } - @Override public String toString() { - return java.util.Arrays.toString(get()); - } - - public String pop_back() { - long size = size(); - String value = get(size - 1); - resize(size - 1); - return value; - } - public StringVector push_back(String value) { - long size = size(); - resize(size + 1); - return put(size, value); - } - public StringVector put(String value) { - if (size() != 1) { resize(1); } - return put(0, value); - } - public StringVector put(String ... array) { - if (size() != array.length) { resize(array.length); } - for (int i = 0; i < array.length; i++) { - put(i, array[i]); - } - return this; - } - - public StringVector push_back(BytePointer value) { - long size = size(); - resize(size + 1); - return put(size, value); - } - public StringVector put(BytePointer value) { - if (size() != 1) { resize(1); } - return put(0, value); - } - public StringVector put(BytePointer ... array) { - if (size() != array.length) { resize(array.length); } - for (int i = 0; i < array.length; i++) { - put(i, array[i]); - } - return this; - } -} - -// Parsed from clesperantoj.hpp - -// #ifndef __INCLUDE_CLESPERANTOJ_HPP -// #define __INCLUDE_CLESPERANTOJ_HPP - -// #include -// #include -// #include - -// #include "array.hpp" -// #include "backend.hpp" -// #include "device.hpp" -// #include "utils.hpp" - -public static class BackendJ extends Pointer { - static { Loader.load(); } - /** Default native constructor. */ - public BackendJ() { super((Pointer)null); allocate(); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public BackendJ(long size) { super((Pointer)null); allocateArray(size); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public BackendJ(Pointer p) { super(p); } - private native void allocate(); - private native void allocateArray(long size); - @Override public BackendJ position(long position) { - return (BackendJ)super.position(position); - } - @Override public BackendJ getPointer(long i) { - return new BackendJ((Pointer)this).offsetAddress(i); - } - - public static native void setBackend(@StdString String backendName); - public static native void setBackend(@StdString BytePointer backendName); -} - -public static class DeviceJ extends Pointer { - static { Loader.load(); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public DeviceJ(Pointer p) { super(p); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public DeviceJ(long size) { super((Pointer)null); allocateArray(size); } - private native void allocateArray(long size); - @Override public DeviceJ position(long position) { - return (DeviceJ)super.position(position); - } - @Override public DeviceJ getPointer(long i) { - return new DeviceJ((Pointer)this).offsetAddress(i); - } - - public DeviceJ() { super((Pointer)null); allocate(); } - private native void allocate(); - - public static native @ByVal StringVector getAvailableDevices(@StdString String deviceType/*="all"*/); - public static native @ByVal StringVector getAvailableDevices(); - public static native @ByVal StringVector getAvailableDevices(@StdString BytePointer deviceType/*="all"*/); - - public native void setDevice(@StdString String deviceName/*=""*/, @StdString String deviceType/*="all"*/); - public native void setDevice(); - public native void setDevice(@StdString BytePointer deviceName/*=""*/, @StdString BytePointer deviceType/*="all"*/); - public native @StdString String getName(); - public native @StdString String getInfo(); -} -public static class ArrayJ extends Pointer { - static { Loader.load(); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public ArrayJ(Pointer p) { super(p); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public ArrayJ(long size) { super((Pointer)null); allocateArray(size); } - private native void allocateArray(long size); - @Override public ArrayJ position(long position) { - return (ArrayJ)super.position(position); - } - @Override public ArrayJ getPointer(long i) { - return new ArrayJ((Pointer)this).offsetAddress(i); - } - - public ArrayJ() { super((Pointer)null); allocate(); } - private native void allocate(); - - public native @Cast("size_t") long getWidth(); - public native @Cast("size_t") long getHeight(); - public native @Cast("size_t") long getDepth(); - public native @Cast("unsigned int") int getDimension(); - - public native @StdString String getDataType(); - public native @StdString String getMemoryType(); - public native @StdString String getDevice(); - - public native void fillMemory(float value); - public native void copyDataTo(@ByRef ArrayJ dst); -} - -public static class MemoryJ extends Pointer { - static { Loader.load(); } - /** Default native constructor. */ - public MemoryJ() { super((Pointer)null); allocate(); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public MemoryJ(long size) { super((Pointer)null); allocateArray(size); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public MemoryJ(Pointer p) { super(p); } - private native void allocate(); - private native void allocateArray(long size); - @Override public MemoryJ position(long position) { - return (MemoryJ)super.position(position); - } - @Override public MemoryJ getPointer(long i) { - return new MemoryJ((Pointer)this).offsetAddress(i); - } - - public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString String memory_type); - public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString BytePointer memory_type); - public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString String memory_type); - public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString BytePointer memory_type); - - public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatPointer data, @Cast("const size_t") long size); - public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatBuffer data, @Cast("const size_t") long size); - public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, float[] data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef ArrayJ array, IntPointer data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef ArrayJ array, IntBuffer data, @Cast("const size_t") long size); - public static native void writeIntBuffer(@Const @ByRef ArrayJ array, int[] data, @Cast("const size_t") long size); - - public static native void readFloatBuffer(@Const @ByRef ArrayJ array, FloatPointer data, @Cast("const size_t") long size); - public static native void readFloatBuffer(@Const @ByRef ArrayJ array, FloatBuffer data, @Cast("const size_t") long size); - public static native void readFloatBuffer(@Const @ByRef ArrayJ array, float[] data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef ArrayJ array, IntPointer data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef ArrayJ array, IntBuffer data, @Cast("const size_t") long size); - public static native void readIntBuffer(@Const @ByRef ArrayJ array, int[] data, @Cast("const size_t") long size); -} - -// #endif // __INCLUDE_CLESPERANTOJ_HPP - - -} From d103d59d1ee71f98429cee597cb86ec2a16ad8b1 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Tue, 7 May 2024 19:00:02 +0200 Subject: [PATCH 22/38] Delete src/gen/java/net/clesperanto/wrapper/kernelj.java --- .../java/net/clesperanto/wrapper/kernelj.java | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 src/gen/java/net/clesperanto/wrapper/kernelj.java diff --git a/src/gen/java/net/clesperanto/wrapper/kernelj.java b/src/gen/java/net/clesperanto/wrapper/kernelj.java deleted file mode 100644 index 0491c5d..0000000 --- a/src/gen/java/net/clesperanto/wrapper/kernelj.java +++ /dev/null @@ -1,48 +0,0 @@ -// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE - -package net.clesperanto.wrapper; - -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; -import static net.clesperanto.wrapper.clesperantoj.*; - -public class kernelj extends net.clesperanto.presets.kernelj { - static { Loader.load(); } - -// Parsed from kernelj.hpp - -// #ifndef __INCLUDE_KERNELJ_HPP -// #define __INCLUDE_KERNELJ_HPP - -// #include "clesperantoj.hpp" - -public static class Tier1 extends Pointer { - static { Loader.load(); } - /** Default native constructor. */ - public Tier1() { super((Pointer)null); allocate(); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public Tier1(long size) { super((Pointer)null); allocateArray(size); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public Tier1(Pointer p) { super(p); } - private native void allocate(); - private native void allocateArray(long size); - @Override public Tier1 position(long position) { - return (Tier1)super.position(position); - } - @Override public Tier1 getPointer(long i) { - return new Tier1((Pointer)this).offsetAddress(i); - } - - public static native @ByVal ArrayJ absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @ByRef ArrayJ dst); - public static native @ByVal ArrayJ absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src); - public static native void gaussianBlur(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst, float sigmaX, float sigmaY, float sigmaZ); - public static native void addImageAndScalar(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst, float scalar); -} - -// #endif // __INCLUDE_KERNELJ_HPP - - -} From f1668c041a092dd9df23d6a1680eaa67acc591d2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 7 May 2024 19:02:57 +0200 Subject: [PATCH 23/38] add back to avoid conflicts with the compiled code --- .../net/clesperanto/wrapper/clesperantoj.java | 234 ++++++++++++++++++ .../java/net/clesperanto/wrapper/kernelj.java | 48 ++++ 2 files changed, 282 insertions(+) create mode 100644 src/gen/java/net/clesperanto/wrapper/clesperantoj.java create mode 100644 src/gen/java/net/clesperanto/wrapper/kernelj.java diff --git a/src/gen/java/net/clesperanto/wrapper/clesperantoj.java b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java new file mode 100644 index 0000000..2b2a94e --- /dev/null +++ b/src/gen/java/net/clesperanto/wrapper/clesperantoj.java @@ -0,0 +1,234 @@ +// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE + +package net.clesperanto.wrapper; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +public class clesperantoj extends net.clesperanto.presets.clesperantoj { + static { Loader.load(); } + +@Name("std::vector") public static class StringVector extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public StringVector(Pointer p) { super(p); } + public StringVector(String value) { this(1); put(0, value); } + public StringVector(String ... array) { this(array.length); put(array); } + public StringVector(BytePointer value) { this(1); put(0, value); } + public StringVector(BytePointer ... array) { this(array.length); put(array); } + public StringVector() { allocate(); } + public StringVector(long n) { allocate(n); } + private native void allocate(); + private native void allocate(@Cast("size_t") long n); + public native @Name("operator =") @ByRef StringVector put(@ByRef StringVector x); + + public boolean empty() { return size() == 0; } + public native long size(); + public void clear() { resize(0); } + public native void resize(@Cast("size_t") long n); + + @Index(function = "at") public native @StdString String get(@Cast("size_t") long i); + public native StringVector put(@Cast("size_t") long i, String value); + @ValueSetter @Index(function = "at") public native StringVector put(@Cast("size_t") long i, @StdString BytePointer value); + + public native @ByVal Iterator insert(@ByVal Iterator pos, @StdString String value); + public native @ByVal Iterator erase(@ByVal Iterator pos); + public native @ByVal Iterator begin(); + public native @ByVal Iterator end(); + @NoOffset @Name("iterator") public static class Iterator extends Pointer { + public Iterator(Pointer p) { super(p); } + public Iterator() { } + + public native @Name("operator ++") @ByRef Iterator increment(); + public native @Name("operator ==") boolean equals(@ByRef Iterator it); + public native @Name("operator *") @StdString String get(); + } + + public String[] get() { + String[] array = new String[size() < Integer.MAX_VALUE ? (int)size() : Integer.MAX_VALUE]; + for (int i = 0; i < array.length; i++) { + array[i] = get(i); + } + return array; + } + @Override public String toString() { + return java.util.Arrays.toString(get()); + } + + public String pop_back() { + long size = size(); + String value = get(size - 1); + resize(size - 1); + return value; + } + public StringVector push_back(String value) { + long size = size(); + resize(size + 1); + return put(size, value); + } + public StringVector put(String value) { + if (size() != 1) { resize(1); } + return put(0, value); + } + public StringVector put(String ... array) { + if (size() != array.length) { resize(array.length); } + for (int i = 0; i < array.length; i++) { + put(i, array[i]); + } + return this; + } + + public StringVector push_back(BytePointer value) { + long size = size(); + resize(size + 1); + return put(size, value); + } + public StringVector put(BytePointer value) { + if (size() != 1) { resize(1); } + return put(0, value); + } + public StringVector put(BytePointer ... array) { + if (size() != array.length) { resize(array.length); } + for (int i = 0; i < array.length; i++) { + put(i, array[i]); + } + return this; + } +} + +// Parsed from clesperantoj.hpp + +// #ifndef __INCLUDE_CLESPERANTOJ_HPP +// #define __INCLUDE_CLESPERANTOJ_HPP + +// #include +// #include +// #include + +// #include "array.hpp" +// #include "backend.hpp" +// #include "device.hpp" +// #include "utils.hpp" + +public static class BackendJ extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public BackendJ() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BackendJ(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BackendJ(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public BackendJ position(long position) { + return (BackendJ)super.position(position); + } + @Override public BackendJ getPointer(long i) { + return new BackendJ((Pointer)this).offsetAddress(i); + } + + public static native void setBackend(@StdString String backendName); + public static native void setBackend(@StdString BytePointer backendName); +} + +public static class DeviceJ extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public DeviceJ(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public DeviceJ(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public DeviceJ position(long position) { + return (DeviceJ)super.position(position); + } + @Override public DeviceJ getPointer(long i) { + return new DeviceJ((Pointer)this).offsetAddress(i); + } + + public DeviceJ() { super((Pointer)null); allocate(); } + private native void allocate(); + + public static native @ByVal StringVector getAvailableDevices(@StdString String deviceType/*="all"*/); + public static native @ByVal StringVector getAvailableDevices(); + public static native @ByVal StringVector getAvailableDevices(@StdString BytePointer deviceType/*="all"*/); + + public native void setDevice(@StdString String deviceName/*=""*/, @StdString String deviceType/*="all"*/); + public native void setDevice(); + public native void setDevice(@StdString BytePointer deviceName/*=""*/, @StdString BytePointer deviceType/*="all"*/); + public native @StdString String getName(); + public native @StdString String getInfo(); +} +public static class ArrayJ extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public ArrayJ(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public ArrayJ(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public ArrayJ position(long position) { + return (ArrayJ)super.position(position); + } + @Override public ArrayJ getPointer(long i) { + return new ArrayJ((Pointer)this).offsetAddress(i); + } + + public ArrayJ() { super((Pointer)null); allocate(); } + private native void allocate(); + + public native @Cast("size_t") long getWidth(); + public native @Cast("size_t") long getHeight(); + public native @Cast("size_t") long getDepth(); + public native @Cast("unsigned int") int getDimension(); + + public native @StdString String getDataType(); + public native @StdString String getMemoryType(); + public native @StdString String getDevice(); + + public native void fillMemory(float value); + public native void copyDataTo(@ByRef ArrayJ dst); +} + +public static class MemoryJ extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public MemoryJ() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public MemoryJ(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public MemoryJ(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public MemoryJ position(long position) { + return (MemoryJ)super.position(position); + } + @Override public MemoryJ getPointer(long i) { + return new MemoryJ((Pointer)this).offsetAddress(i); + } + + public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString String memory_type); + public static native @ByVal ArrayJ makeFloatBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString BytePointer memory_type); + public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString String memory_type); + public static native @ByVal ArrayJ makeIntBuffer(@Const @ByRef DeviceJ device, @Cast("const size_t") long width, @Cast("const size_t") long height, @Cast("const size_t") long depth, @Cast("const size_t") long dimension, @StdString BytePointer memory_type); + + public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatPointer data, @Cast("const size_t") long size); + public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, FloatBuffer data, @Cast("const size_t") long size); + public static native void writeFloatBuffer(@Const @ByRef ArrayJ array, float[] data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ array, IntPointer data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ array, IntBuffer data, @Cast("const size_t") long size); + public static native void writeIntBuffer(@Const @ByRef ArrayJ array, int[] data, @Cast("const size_t") long size); + + public static native void readFloatBuffer(@Const @ByRef ArrayJ array, FloatPointer data, @Cast("const size_t") long size); + public static native void readFloatBuffer(@Const @ByRef ArrayJ array, FloatBuffer data, @Cast("const size_t") long size); + public static native void readFloatBuffer(@Const @ByRef ArrayJ array, float[] data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ array, IntPointer data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ array, IntBuffer data, @Cast("const size_t") long size); + public static native void readIntBuffer(@Const @ByRef ArrayJ array, int[] data, @Cast("const size_t") long size); +} + +// #endif // __INCLUDE_CLESPERANTOJ_HPP + + +} diff --git a/src/gen/java/net/clesperanto/wrapper/kernelj.java b/src/gen/java/net/clesperanto/wrapper/kernelj.java new file mode 100644 index 0000000..0491c5d --- /dev/null +++ b/src/gen/java/net/clesperanto/wrapper/kernelj.java @@ -0,0 +1,48 @@ +// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE + +package net.clesperanto.wrapper; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; +import static net.clesperanto.wrapper.clesperantoj.*; + +public class kernelj extends net.clesperanto.presets.kernelj { + static { Loader.load(); } + +// Parsed from kernelj.hpp + +// #ifndef __INCLUDE_KERNELJ_HPP +// #define __INCLUDE_KERNELJ_HPP + +// #include "clesperantoj.hpp" + +public static class Tier1 extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public Tier1() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public Tier1(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Tier1(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public Tier1 position(long position) { + return (Tier1)super.position(position); + } + @Override public Tier1 getPointer(long i) { + return new Tier1((Pointer)this).offsetAddress(i); + } + + public static native @ByVal ArrayJ absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @ByRef ArrayJ dst); + public static native @ByVal ArrayJ absolute(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src); + public static native void gaussianBlur(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst, float sigmaX, float sigmaY, float sigmaZ); + public static native void addImageAndScalar(@Const @ByRef DeviceJ dev, @Const @ByRef ArrayJ src, @Const @ByRef ArrayJ dst, float scalar); +} + +// #endif // __INCLUDE_KERNELJ_HPP + + +} From 3e81b6907d6609206f3ed31d9bf0ef258f5da723 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Wed, 8 May 2024 13:33:10 +0200 Subject: [PATCH 24/38] Create build-and-run-yaml to test the build --- ,github/workflows/build-and-run-yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ,github/workflows/build-and-run-yaml diff --git a/,github/workflows/build-and-run-yaml b/,github/workflows/build-and-run-yaml new file mode 100644 index 0000000..1dca8ab --- /dev/null +++ b/,github/workflows/build-and-run-yaml @@ -0,0 +1,26 @@ +name: Build and Run + +on: + push: + branches: [ use-new-backend-gpu ] + pull_request: + branches: [ use-new-backend-gpu ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + + - name: Build with Maven + run: mvn clean install + + - name: Run Java class + run: java -cp target/classes com.example.YourMainClass From d7ff8694da91896906d85f97508972edc8621392 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 8 May 2024 13:36:20 +0200 Subject: [PATCH 25/38] correct name of the folder --- {,github => .github}/workflows/build-and-run-yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {,github => .github}/workflows/build-and-run-yaml (100%) diff --git a/,github/workflows/build-and-run-yaml b/.github/workflows/build-and-run-yaml similarity index 100% rename from ,github/workflows/build-and-run-yaml rename to .github/workflows/build-and-run-yaml From 9fc2cf98fa486b67ff3b70be068b8ef62f00dc0e Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 8 May 2024 13:38:41 +0200 Subject: [PATCH 26/38] correct bad naming again --- .github/workflows/{build-and-run-yaml => build-and-run.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{build-and-run-yaml => build-and-run.yaml} (100%) diff --git a/.github/workflows/build-and-run-yaml b/.github/workflows/build-and-run.yaml similarity index 100% rename from .github/workflows/build-and-run-yaml rename to .github/workflows/build-and-run.yaml From 078fcb9734d3cb37c40939123b60e98f152e9e9b Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Wed, 8 May 2024 13:41:22 +0200 Subject: [PATCH 27/38] trigger run --- .github/workflows/build-and-run.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-run.yaml b/.github/workflows/build-and-run.yaml index 1dca8ab..30db16a 100644 --- a/.github/workflows/build-and-run.yaml +++ b/.github/workflows/build-and-run.yaml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: '11' distribution: 'adopt' From 9b96613ea770b8662bbfac6c1aa0de95b5618931 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Wed, 8 May 2024 13:42:55 +0200 Subject: [PATCH 28/38] see if with v2 and changing the settings of repo also works --- .github/workflows/build-and-run.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-run.yaml b/.github/workflows/build-and-run.yaml index 30db16a..1dca8ab 100644 --- a/.github/workflows/build-and-run.yaml +++ b/.github/workflows/build-and-run.yaml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v2 with: java-version: '11' distribution: 'adopt' From eae19aa26e78ae42ec13faa3c987931206430c06 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Wed, 8 May 2024 17:39:14 +0200 Subject: [PATCH 29/38] Find which GPUs are being used --- .github/workflows/build-and-run.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-run.yaml b/.github/workflows/build-and-run.yaml index 1dca8ab..3657422 100644 --- a/.github/workflows/build-and-run.yaml +++ b/.github/workflows/build-and-run.yaml @@ -18,7 +18,8 @@ jobs: with: java-version: '11' distribution: 'adopt' - + - name: Find available GPUs + run: lspci | grep -i vga - name: Build with Maven run: mvn clean install From 053566c31fa54f036f68a5c203d23b2539ae9f65 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Wed, 8 May 2024 18:37:59 +0200 Subject: [PATCH 30/38] Install openCl on the environment --- .github/workflows/build-and-run.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-run.yaml b/.github/workflows/build-and-run.yaml index 3657422..b5a1e9b 100644 --- a/.github/workflows/build-and-run.yaml +++ b/.github/workflows/build-and-run.yaml @@ -20,6 +20,8 @@ jobs: distribution: 'adopt' - name: Find available GPUs run: lspci | grep -i vga + - name: Install openCL + run: sudo apt install intel-opencl-icd - name: Build with Maven run: mvn clean install From 22d4d9fed421553d19a43f9fd2e5b792cdfd5443 Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Wed, 8 May 2024 18:42:00 +0200 Subject: [PATCH 31/38] correct the way to install opencl --- .github/workflows/build-and-run.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-run.yaml b/.github/workflows/build-and-run.yaml index b5a1e9b..adf6059 100644 --- a/.github/workflows/build-and-run.yaml +++ b/.github/workflows/build-and-run.yaml @@ -21,7 +21,7 @@ jobs: - name: Find available GPUs run: lspci | grep -i vga - name: Install openCL - run: sudo apt install intel-opencl-icd + run: sudo apt install ocl-icd-opencl-dev - name: Build with Maven run: mvn clean install From 6139e4e7388a17cd9fded2b276f1d82d00e290ce Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 14 May 2024 01:35:53 +0200 Subject: [PATCH 32/38] CHANGES FOR WINDOWS --- native/clesperantoj/cppbuild.sh | 5 +++-- pom.xml | 10 ++++++---- .../java/net/clesperanto/presets/clesperantoj.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/native/clesperantoj/cppbuild.sh b/native/clesperantoj/cppbuild.sh index 1fbd894..0934b4a 100644 --- a/native/clesperantoj/cppbuild.sh +++ b/native/clesperantoj/cppbuild.sh @@ -36,8 +36,9 @@ case $PLATFORM in windows-x86_64) $CMAKE -G"NMake Makefiles" \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="../../../lib/win64/" .. - # -DOPENCL_INCLUDE_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/include/" \ + -DCMAKE_INSTALL_PREFIX="../../../lib/win64/" \ + -DOpenCL_INCLUDE_DIR="C:/Program Files (x86)/OCL_SDK_Light/include" \ + -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/" .. diff --git a/pom.xml b/pom.xml index 3380a84..bc11d5f 100644 --- a/pom.xml +++ b/pom.xml @@ -168,7 +168,7 @@ 1.5.8 - -std=c++17 + /std:c++17 @@ -184,7 +184,7 @@ - /usr/local/cuda-12.3/targets/x86_64-linux/include + C:/Program Files (x86)/OCL_SDK_Light/include @@ -201,9 +201,11 @@ This provide the library path for javacpp to link to. It (should) avoid the need to add the linkpath in the presets. NB: not needed in MacOS, nor in Ubuntu --> - - + C:/Program Files (x86)/OCL_SDK_Light/lib/x86_64 + C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64 + + true diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index 48cd13a..af130cb 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -18,7 +18,7 @@ // }, target = "net.clesperanto.wrapper.clesperantoj") @Properties(inherit = javacpp.class, value = { - @Platform(include = { "clesperantoj.hpp" }, link = { "JCLIc"}) + @Platform(include = { "clesperantoj.hpp" }, link = { "JCLIc", "Shell32"}) }, target = "net.clesperanto.wrapper.clesperantoj") public class clesperantoj implements InfoMapper { From 024a8f49b1d08537c7f91e69d45217685b7ab372 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Mon, 27 May 2024 17:56:09 +0200 Subject: [PATCH 33/38] adapt to unix and win --- pom.xml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc11d5f..fc12f0a 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,30 @@ 11.2 + + + os-windows + + + Windows + + + + /std:c++17 + + + + non-windows + + + !Windows + + + + -std=c++17 + + + @@ -168,7 +192,7 @@ 1.5.8 - /std:c++17 + ${compiler.option} From 71a4ffb1742237c99cf278c896299e7685eabbd6 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Mon, 27 May 2024 19:35:18 +0200 Subject: [PATCH 34/38] remove unnecessary paths for win --- pom.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index fc12f0a..b73bc67 100644 --- a/pom.xml +++ b/pom.xml @@ -208,7 +208,8 @@ - C:/Program Files (x86)/OCL_SDK_Light/include + @@ -225,8 +226,10 @@ This provide the library path for javacpp to link to. It (should) avoid the need to add the linkpath in the presets. NB: not needed in MacOS, nor in Ubuntu --> - C:/Program Files (x86)/OCL_SDK_Light/lib/x86_64 - C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64 + + From a6385f1cde0c455f44b5bdbc0d075205cc67165c Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Mon, 27 May 2024 19:40:05 +0200 Subject: [PATCH 35/38] find way to link shell32 on win only --- .../java/net/clesperanto/presets/clesperantoj.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/clesperanto/presets/clesperantoj.java b/src/main/java/net/clesperanto/presets/clesperantoj.java index af130cb..3a3664f 100644 --- a/src/main/java/net/clesperanto/presets/clesperantoj.java +++ b/src/main/java/net/clesperanto/presets/clesperantoj.java @@ -18,8 +18,18 @@ // }, target = "net.clesperanto.wrapper.clesperantoj") @Properties(inherit = javacpp.class, value = { - @Platform(include = { "clesperantoj.hpp" }, link = { "JCLIc", "Shell32"}) -}, target = "net.clesperanto.wrapper.clesperantoj") + @Platform( + value = "windows", + include = "clesperantoj.hpp", + link = {"JCLIc", "Shell32"} + ), + @Platform( + value = {"linux", "macosx"}, + include = "clesperantoj.hpp", + link = "JCLIc" + )}, + target = "net.clesperanto.wrapper.clesperantoj" + ) public class clesperantoj implements InfoMapper { static { From 5d7d6da93dcaa804dea3145b81cac32c2705339c Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Mon, 27 May 2024 20:24:41 +0200 Subject: [PATCH 36/38] remove specific paths from cppbuild.sh win --- native/clesperantoj/cppbuild.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/clesperantoj/cppbuild.sh b/native/clesperantoj/cppbuild.sh index 0934b4a..66af9bd 100644 --- a/native/clesperantoj/cppbuild.sh +++ b/native/clesperantoj/cppbuild.sh @@ -36,9 +36,9 @@ case $PLATFORM in windows-x86_64) $CMAKE -G"NMake Makefiles" \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="../../../lib/win64/" \ - -DOpenCL_INCLUDE_DIR="C:/Program Files (x86)/OCL_SDK_Light/include" \ - -DOpenCL_LIBRARY="C:/Program Files (x86)/OCL_SDK_Light/lib/x86_64/opencl.lib" .. + -DCMAKE_INSTALL_PREFIX="../../../lib/win64/" .. + # -DOpenCL_INCLUDE_DIR="C:/Program Files (x86)/OCL_SDK_Light/include" \ + # -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/" .. From 1f270fb5d86e0ed592548902dd968f1e23c22d17 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 28 May 2024 17:08:01 +0200 Subject: [PATCH 37/38] reduce the repetition of paths depending on the OS --- pom.xml | 64 +++++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index b73bc67..7964712 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,7 @@ - os-windows + win Windows @@ -69,17 +69,32 @@ /std:c++17 + win64 - non-windows + mac - !Windows + mac -std=c++17 + macosx + + + + linux + + + unix + Linux + + + + -std=c++17 + linux64 @@ -153,8 +168,6 @@ ${project.basedir}/src/gen/java - - @@ -164,8 +177,8 @@ maven-compiler-plugin 3.12.1 - 1.7 - 1.7 + 1.8 + 1.8 @@ -193,46 +206,25 @@ ${compiler.option} - - ${project.build.outputDirectory} + ${project.build.sourceDirectory} ${basedir}/native/clesperantoj/include - ${basedir}/lib/linux64/include/CLIc - ${basedir}/lib/win64/include/CLIc - ${basedir}/lib/macosx/include/CLIc - - - - - - + ${basedir}/lib/${folder.name}/include/CLIc - ${basedir}/lib/win64/ - ${basedir}/lib/linux64/ - ${basedir}/lib/macosx/ - ${basedir}/lib/win64/lib - ${basedir}/lib/linux64/lib - ${basedir}/lib/macosx/lib - - + ${basedir}/lib/${folder.name}/ + ${basedir}/lib/${folder.name}/lib - - + NB: Only needed on Windows unless the LIB env var contains the + path to OpenCL lib and teh path to Windows Kit--> - - true From 03b1f47d9bea4e513065a2ef7bda8a6e76b7fe7c Mon Sep 17 00:00:00 2001 From: carlosuc3m <49989524+carlosuc3m@users.noreply.github.com> Date: Tue, 28 May 2024 17:26:27 +0200 Subject: [PATCH 38/38] add command to check installation --- .github/workflows/build-and-run.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-run.yaml b/.github/workflows/build-and-run.yaml index adf6059..0aa2432 100644 --- a/.github/workflows/build-and-run.yaml +++ b/.github/workflows/build-and-run.yaml @@ -22,6 +22,8 @@ jobs: run: lspci | grep -i vga - name: Install openCL run: sudo apt install ocl-icd-opencl-dev + - name: Check installation + run: dpkg -L ocl-icd-opencl-dev - name: Build with Maven run: mvn clean install