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

exceptions when using @Parallel with Double3 #345

Open
gaoyang-li opened this issue Mar 4, 2024 · 3 comments
Open

exceptions when using @Parallel with Double3 #345

gaoyang-li opened this issue Mar 4, 2024 · 3 comments
Assignees
Labels
API question Further information is requested

Comments

@gaoyang-li
Copy link

Describe the bug

Exception in thread "main" uk.ac.manchester.tornado.api.exceptions.TornadoInternalError: org.graalvm.compiler.debug.GraalError: should not reach here: node is not LIRLowerable: 16|VectorStoreElementProxy
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLNodeLIRBuilder.doBlock(OCLNodeLIRBuilder.java:238)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLLIRGenerationPhase.emitBlock(OCLLIRGenerationPhase.java:51)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLLIRGenerationPhase.run(OCLLIRGenerationPhase.java:65)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLLIRGenerationPhase.run(OCLLIRGenerationPhase.java:41)
at jdk.internal.vm.compiler/org.graalvm.compiler.lir.phases.LIRPhase.apply(LIRPhase.java:121)
at jdk.internal.vm.compiler/org.graalvm.compiler.lir.phases.LIRPhase.apply(LIRPhase.java:110)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLCompiler.emitLIR0(OCLCompiler.java:261)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLCompiler.emitLIR(OCLCompiler.java:216)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLCompiler.emitBackEnd(OCLCompiler.java:201)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLCompiler.compile(OCLCompiler.java:138)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLCompiler$Request.execute(OCLCompiler.java:509)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.graal.compiler.OCLCompiler.compileSketchForDevice(OCLCompiler.java:386)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.compileTask(OCLTornadoDevice.java:261)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.compileJavaToAccelerator(OCLTornadoDevice.java:335)
at tornado.drivers.opencl@1.0.2/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.installCode(OCLTornadoDevice.java:462)

How To Reproduce

public static void parallel1(Double3 d, int x){
    for (@Parallel int i = 0; i < x; i++){
        d.setX(1.1);
    }
}
public static void parallel2(Double3 d, int x){
    for (@Parallel int i = 0; i < x; i++){
        d.setX(d.getX() + 1.1);
    }
}

public static void main (String[] args){
    Double3 d = new Double3();
    Double2 dd = new Double2();
    VectorDouble ddd = new VectorDouble(1);
    d.setX(1.1);
    dd.setX(1.1);
    ddd.set(0, 1.1);
    int x = 10;

    TaskGraph taskGraph1 = new TaskGraph("s1")
            .transferToDevice(DataTransferMode.EVERY_EXECUTION, d, x)
            .task("t1", Double3Test::parallel1, d, x)
            .transferToHost(DataTransferMode.EVERY_EXECUTION, d);
    ImmutableTaskGraph immutableTaskGraph1 = taskGraph1.snapshot();
    TornadoExecutionPlan executor1 = new TornadoExecutionPlan(immutableTaskGraph1);
    executor1.execute();

    TaskGraph taskGraph2 = new TaskGraph("s2")
            .transferToDevice(DataTransferMode.EVERY_EXECUTION, d, x)
            .task("t2", Double3Test::parallel2, d, x)
            .transferToHost(DataTransferMode.EVERY_EXECUTION, d);
    ImmutableTaskGraph immutableTaskGraph2 = taskGraph2.snapshot();
    TornadoExecutionPlan executor2 = new TornadoExecutionPlan(immutableTaskGraph2);
    executor2.execute();
}

Expected behavior

Modify a value of a 'Double3' variable inside the parallelised loop.

Computing system setup (please complete the following information):

  • OS: Ubuntu 22.04.3 LTS
  • OpenCL and Driver versions: NVIDIA CUDA: OpenCL 3.0 CUDA 12.2.148 Intel OpenCL: OpenCL 3.0
  • If applicable, PTX and CUDA Driver versions: CUDA Compilation Tools Version: 12.2 CUDA Release Version: V12.2.140
  • If applicable, Level Zero & SPIR-V Versions
  • TornadoVM commit id: 188e3a4

@jjfumero
Copy link
Member

jjfumero commented Mar 5, 2024

Thank you for the report. This is currently not supported. Double3 is just a single element (item) composed of three values. What you might want to use instead is the VectorDouble3 collection, which contains a vector of N elements, each of them composed of three values.

See an example here:

public void privateVectorDouble4() {
int size = 16;
VectorDouble4 sequentialOutput = new VectorDouble4(size);
VectorDouble4 tornadoOutput = new VectorDouble4(size);
TaskGraph taskGraph = new TaskGraph("s0");
taskGraph.task("t0", TestDoubles::testPrivateVectorDouble4, tornadoOutput);
taskGraph.transferToHost(DataTransferMode.EVERY_EXECUTION, tornadoOutput);
ImmutableTaskGraph immutableTaskGraph = taskGraph.snapshot();
TornadoExecutionPlan executionPlan = new TornadoExecutionPlan(immutableTaskGraph);
executionPlan.execute();
testPrivateVectorDouble4(sequentialOutput);
for (int i = 0; i < size; i++) {
assertEquals(sequentialOutput.get(i).getX(), tornadoOutput.get(i).getX(), DELTA);
assertEquals(sequentialOutput.get(i).getY(), tornadoOutput.get(i).getY(), DELTA);
assertEquals(sequentialOutput.get(i).getZ(), tornadoOutput.get(i).getZ(), DELTA);
assertEquals(sequentialOutput.get(i).getW(), tornadoOutput.get(i).getW(), DELTA);
}
}

@jjfumero jjfumero self-assigned this Mar 5, 2024
@jjfumero jjfumero added question Further information is requested API labels Mar 5, 2024
@gaoyang-li
Copy link
Author

Thank you for the report. This is currently not supported. Double3 is just a single element (item) composed of three values. What you might want to use instead is the VectorDouble3 collection, which contains a vector of N elements, each of them composed of three values.

See an example here:

public void privateVectorDouble4() {
int size = 16;
VectorDouble4 sequentialOutput = new VectorDouble4(size);
VectorDouble4 tornadoOutput = new VectorDouble4(size);
TaskGraph taskGraph = new TaskGraph("s0");
taskGraph.task("t0", TestDoubles::testPrivateVectorDouble4, tornadoOutput);
taskGraph.transferToHost(DataTransferMode.EVERY_EXECUTION, tornadoOutput);
ImmutableTaskGraph immutableTaskGraph = taskGraph.snapshot();
TornadoExecutionPlan executionPlan = new TornadoExecutionPlan(immutableTaskGraph);
executionPlan.execute();
testPrivateVectorDouble4(sequentialOutput);
for (int i = 0; i < size; i++) {
assertEquals(sequentialOutput.get(i).getX(), tornadoOutput.get(i).getX(), DELTA);
assertEquals(sequentialOutput.get(i).getY(), tornadoOutput.get(i).getY(), DELTA);
assertEquals(sequentialOutput.get(i).getZ(), tornadoOutput.get(i).getZ(), DELTA);
assertEquals(sequentialOutput.get(i).getW(), tornadoOutput.get(i).getW(), DELTA);
}
}

Thank you :-)

@jjfumero
Copy link
Member

jjfumero commented Mar 5, 2024

No problem. What I think we should do in TornadoVM is to raise the appropriate exception with a meaningful message. I will pass this to our team.

@jjfumero jjfumero reopened this Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants