beehive-lab / TornadoVM

TornadoVM: A practical and efficient heterogeneous programming framework for managed languages
https://www.tornadovm.org
Apache License 2.0
1.17k stars 110 forks source link

Implement Multi-Array Concatenation using Memory Segment Copy #370

Closed mikepapadim closed 4 months ago

mikepapadim commented 4 months ago

Description

This pull request introduces a new method concat to multiple instances of TornadoNativeArray types into a single array. This aims at providing a straightforward and efficient way to merge several arrays by using Memory Segment copies and without the overhead of manual array copying.

Example usage:

  IntArray a = new IntArray(numElements);
  IntArray b = new IntArray(numElements);
  IntArray e = new IntArray(numElements);

  a.init(100);
  b.init(5);
  e.init(12);

  IntArray c = IntArray.concat(a, b, e);

Example size output;

Array a size: 256
Array b size: 256
Array e size: 256
---------------------------------
Concat Array c size: 768
---------------------------------

Backend/s tested

Mark the backends affected by this PR.

OS tested

Mark the OS where this PR is tested.

Did you check on FPGAs?

If it is applicable, check your changes on FPGAs.

How to test the new patch?

make jdk21 backend=opencl
tornado-test -V --fast uk.ac.manchester.tornado.unittests.api.TestConcat

mikepapadim commented 4 months ago

Nice to have this method.

Nice to have this method.

Thanks. Are there any specific comments to fix?