Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise JavaCPP bindings and core package #72

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

tpietzsch
Copy link
Contributor

@tpietzsch tpietzsch commented Oct 9, 2024

Streamline core API and reduce redundancies in JavaCPP wrapper.
The API for creating and writing ArrayJ looks like this now:

DeviceJ device = DeviceJ.getDefaultDevice();
ArrayJ arrayJ = device.createArray(DataType.UINT8, MemoryType.BUFFER, 4, 3);
// or, alternatively:
// ArrayJ arrayJ = new ArrayJ(4, 3, 1, 2, device, DataType.UINT8, MemoryType.BUFFER);

byte[] inValues = new byte[4 * 3];
arrayJ.writeFromArray(inValues);

byte[] outValues = new byte[4 * 3];
arrayJ.readToArray(outValues);

Changes in more detail:

  • cle::dType and cle::mType are represented as Java enums net.clesperanto.core.DataType and net.clesperanto.core.MemoryType

  • Reduce memory copying functions in cleasperantoj.hpp to only the primitive types. The distinction between signed and unsigned is unnecessary. Corresponding Java methods are in MemoryJ instances MemoryJ.BYTE, MemoryJ.SHORT, MemoryJ.INT, MemoryJ.FLOAT. The DataType enum has a memory() method that maps to the appropriate MemoryJ instance. For example, DataType.UINT8.memory() == MemoryJ.BYTE.

  • Move ArrayJ create/read/write methods into ArrayJ.

  • Revise ImgLib2Converters and ImageJConverters to not go through an additional ByteBuffer. Just copy from/to primitive arrays directly.

  • ArrayJ constructors can extract Device from underlying _ArrayJ directly. So we don't need the ArrayJ(_ArrayJ, DeviceJ) constructor anymore. However, this is left in for now, until we replace all the call sites in Tier1, Tier2, etc. (This should be done through gencle?)

  • There is a bit of confusion of how to handle width/height/depth/dimensions of an cle::Array consistently. I'll make a separate GitHub issue about that.

* cle::dType and cle::mType are represented as Java enums
  net.clesperanto.core.DataType and net.clesperanto.core.MemoryType

* Reduce memory copying functions in cleasperantoj.hpp to only the
  primitive types. The distinction between signed and unsigned is
  unnecessary. Corresponding Java methods are in MemoryJ instances
  MemoryJ.BYTE, MemoryJ.SHORT, MemoryJ.INT, MemoryJ.FLOAT.
  DataType enum has a memory() method that maps to the appropriate
  MemoryJ. For example, DataType.UINT8.memory() == MemoryJ.BYTE.

* Move ArrayJ create/read/write methods into ArrayJ.
  For example, arraJ.writeFromArray(data).

* Revise ImgLib2Converters and ImageJConverters to not go through an
  additional ByteBuffer. Just copy from/to primitive arrays directly.

* ArrayJ constructors can extract Device from underlying _ArrayJ driectly.
  So we don't need the ArrayJ(_ArrayJ, DeviceJ) constructor anymore.
  Howeverm this left in for now, until we replace all the call sites
  in Tier1, Tier2, etc. (This should be done through gencle?)

* There is a bit of confusion of how to handle
  width/height/depth/dimensions of an cle::Array consistently.
  I'll add a separate GitHub issue about that.
@StRigaud
Copy link
Member

StRigaud commented Oct 9, 2024

However, this is left in for now, until we replace all the call sites in Tier1, Tier2, etc. (This should be done through gencle?)

Yes, I will update gencle accordingly. I will merge this along the update of gencle

Thanks!

StRigaud added a commit to clEsperanto/gencle that referenced this pull request Oct 11, 2024
StRigaud added a commit to clEsperanto/clij3 that referenced this pull request Oct 11, 2024
@StRigaud StRigaud merged commit d504f26 into clEsperanto:main Oct 11, 2024
3 checks passed
@StRigaud StRigaud mentioned this pull request Oct 15, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants