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

Add support to TornadoNativeArray data types to get Memory Segments without header offset #350

Closed mikepapadim closed 5 months ago

mikepapadim commented 5 months ago

Description

This PR adds support to obtain a MemorySegment from TornadoNativeArray types with and without the header bytes.

By having distinct funtion in the above auxiliry methods we can have interoperoability when using Segments for GPU execution through the Taskgraph API and Vector API when using any of the TornadoNative types.

Also, refactor internally methods that operate on memory segments to be named explictly as getSegmentWithHeader.

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=openc
make tests 

jjfumero commented 5 months ago

I am confused. The withHeader version, does it always return +24 bytes, or it returns the bytes specified in TornadoNativeArray.ARRAY_HEADER?

mikepapadim commented 5 months ago

I am confused. The withHeader version, does it always return +24 bytes, or it returns the bytes specified in TornadoNativeArray.ARRAY_HEADER?

withHeader returns always number of bytes including the TornadoNativeArray.ARRAY_HEADER

jjfumero commented 5 months ago

I am confused. The withHeader version, does it always return +24 bytes, or it returns the bytes specified in TornadoNativeArray.ARRAY_HEADER?

withHeader returns always number of bytes including the TornadoNativeArray.ARRAY_HEADER

So please, update the PR description with this.

mikepapadim commented 5 months ago

I am confused. The withHeader version, does it always return +24 bytes, or it returns the bytes specified in TornadoNativeArray.ARRAY_HEADER?

withHeader returns always number of bytes including the TornadoNativeArray.ARRAY_HEADER

So please, update the PR description with this.

done

jjfumero commented 5 months ago

Unittests are passing on OSx 14.4

mikepapadim commented 5 months ago

@jjfumero done

jjfumero commented 5 months ago

ok, thanks. the PR looks good to me.