Closed mikepapadim closed 1 month ago
@mikepapadim I do not use MemorySegments directly. I used them over the Float/Native arrays.
thanks, I am testing it on Linux
and macOS
and got this:
tornado-test -V uk.ac.manchester.tornado.unittests.api.TestMemorySegmentsAsType
WARNING: Using incubator modules: jdk.incubator.vector
WARNING: Code Bailout to Java sequential. Use --debug to see the reason
Test: class uk.ac.manchester.tornado.unittests.api.TestMemorySegmentsAsType
Running test: testMemorySegmentAsInput ................ [FAILED]
\_[REASON] Unable to build sketch for method: getMemorySegment(Cannot invoke "jdk.vm.ci.meta.ResolvedJavaType.getAnnotation(java.lang.Class)" because the return value of "org.graalvm.compiler.core.common.type.ObjectStamp.type()" is null)
Test ran: 1, Failed: 1, Unsupported: 0
thanks, I am testing it on
Linux
andmacOS
and got this:tornado-test -V uk.ac.manchester.tornado.unittests.api.TestMemorySegmentsAsType WARNING: Using incubator modules: jdk.incubator.vector WARNING: Code Bailout to Java sequential. Use --debug to see the reason Test: class uk.ac.manchester.tornado.unittests.api.TestMemorySegmentsAsType Running test: testMemorySegmentAsInput ................ [FAILED] \_[REASON] Unable to build sketch for method: getMemorySegment(Cannot invoke "jdk.vm.ci.meta.ResolvedJavaType.getAnnotation(java.lang.Class)" because the return value of "org.graalvm.compiler.core.common.type.ObjectStamp.type()" is null) Test ran: 1, Failed: 1, Unsupported: 0
Thats expected. Lets wait for @jjfumero to discuss at which level we should throw an appropriate exception if someone tries to use directly a MemorySegment
and not the wrapped types.
We can't use a segment directly due to the internal object header, which is custom for the GPU/FPGA. Also, with JDK22+, we can't invoke it directly. So the way to go is to throw an exception during the Task-Graph built, since we get all input/output objects to create the internal GPU buffers.
This is fixed now, it throws a TornadoRuntimeException
when user passes a MemorySegment as Task parameter
Description
Following the discussion in #491, currently there is no proper error and exception handling when the user tries to run TornadoVM with a
MemorySegment
directly without using any of theTornadoNativeTypes
.This PR adds a test to trigger this behaviour, so we can discuss at which level we should throw the appropriate exception to prevent end-users to try to use
MemorySegments
directly.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?