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

Unsupported type error for int and uint types #605

Open
selcuksert opened this issue Dec 22, 2024 · 1 comment
Open

Unsupported type error for int and uint types #605

selcuksert opened this issue Dec 22, 2024 · 1 comment
Assignees
Labels
bug Something isn't working compiler

Comments

@selcuksert
Copy link

selcuksert commented Dec 22, 2024

Description

Running TornadoVM powered applications on a PC with Turkish locale yields to following error:

Unable to compile task graph.double - computeDouble
The internal error is: [Error during the Task Compilation]: Unsupported type: ınt
Stacktrace: [
[email protected]/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.compileTask(OCLTornadoDevice.java:306)
[email protected]/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.compileJavaToAccelerator(OCLTornadoDevice.java:342)
[email protected]/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.installCode(OCLTornadoDevice.java:469)
[email protected]/uk.ac.manchester.tornado.runtime.interpreter.TornadoVMInterpreter.compileTaskFromBytecodeToBinary(TornadoVMInterpreter.java:670)
[email protected]/uk.ac.manchester.tornado.runtime.interpreter.TornadoVMInterpreter.execute(TornadoVMInterpreter.java:333)
[email protected]/uk.ac.manchester.tornado.runtime.interpreter.TornadoVMInterpreter.execute(TornadoVMInterpreter.java:909)
java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
[email protected]/uk.ac.manchester.tornado.runtime.TornadoVM.executeInterpreterSingleThreaded(TornadoVM.java:127)
[email protected]/uk.ac.manchester.tornado.runtime.TornadoVM.execute(TornadoVM.java:114)
[email protected]/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskGraph.scheduleInner(TornadoTaskGraph.java:892)
[email protected]/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskGraph.execute(TornadoTaskGraph.java:1470)
[email protected]/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskGraph.execute(TornadoTaskGraph.java:1499)
[email protected]/uk.ac.manchester.tornado.api.TaskGraph.execute(TaskGraph.java:759)
[email protected]/uk.ac.manchester.tornado.api.ImmutableTaskGraph.execute(ImmutableTaskGraph.java:50)
[email protected]/uk.ac.manchester.tornado.api.TornadoExecutor.lambda$execute$0(TornadoExecutor.java:47)
java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
[email protected]/uk.ac.manchester.tornado.api.TornadoExecutor.execute(TornadoExecutor.java:47)
[email protected]/uk.ac.manchester.tornado.api.TornadoExecutionPlan.execute(TornadoExecutionPlan.java:163)
com.corp.compute.TornadoCompute.buildAndRun(TornadoCompute.java:33)
com.corp.Main.main(Main.java:30)
]

To overcome the issue following JVM parameters should be added as a workaround:

-Duser.country=US -Duser.language=en
Dec 22, 2024 6:24:03 PM uk.ac.manchester.tornado.runtime.common.TornadoLogger debug
INFO: 	OpenCL compilation status = CL_BUILD_SUCCESS

TornadoVM test reports similar errors. To eliminate the errors, test should be run as follows:

tornado-test -V --jvm="-Duser.country=US -Duser.language=en"

How To Reproduce

Ensure system locale is set as tr-TR and use OpenCL backend:

% defaults read .GlobalPreferences AppleLanguages                              
(
    "tr-TR"
)

Use following computation execution:

package com.corp.compute;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uk.ac.manchester.tornado.api.TaskGraph;
import uk.ac.manchester.tornado.api.TornadoExecutionPlan;
import uk.ac.manchester.tornado.api.TornadoExecutionResult;
import uk.ac.manchester.tornado.api.annotations.Parallel;
import uk.ac.manchester.tornado.api.enums.DataTransferMode;
import uk.ac.manchester.tornado.api.exceptions.TornadoExecutionPlanException;
import uk.ac.manchester.tornado.api.math.TornadoMath;
import uk.ac.manchester.tornado.api.types.arrays.FloatArray;

public class TornadoCompute {
    private static final Logger logger = LoggerFactory.getLogger(TornadoCompute.class.getName());

    private TornadoCompute() {
        throw new IllegalStateException("%s is a utility class and cannot be instantiated!".formatted(this.getClass().getName()));
    }

    public static void buildAndRun(FloatArray array) {
        //@formatter:off
        TaskGraph taskGraph = new TaskGraph("graph")
                .transferToDevice(DataTransferMode.EVERY_EXECUTION, array)
                .task("double", TornadoCompute::computeDouble, array)
                .task("sqrt", TornadoCompute::computeSqrt, array)
                .transferToHost(DataTransferMode.EVERY_EXECUTION, array);
        //@formatter:on

        try (TornadoExecutionPlan tornadoExecutionPlan = new TornadoExecutionPlan(taskGraph.snapshot())) {
            logger.info("Pre-execution result: {}", array.get(1));
            TornadoExecutionResult result = tornadoExecutionPlan.execute();
            logger.info("Execution time: {}", result.getProfilerResult().getTotalTime());
            logger.info("Post-execution result: {}", array.get(1));
        } catch (TornadoExecutionPlanException e) {
            logger.error("Tornado execution error:", e);
        }
    }

    private static void computeDouble(FloatArray array) {
        for (@Parallel int i = 0; i < array.getSize(); i++) {
            float value = array.get(i);
            array.set(i, value * 2);
        }
    }

    private static void computeSqrt(FloatArray array) {
        for (@Parallel int i = 0; i < array.getSize(); i++) {
            float value = array.get(i);
            array.set(i, TornadoMath.sqrt(value));
        }
    }

}

Invoke TornadoVM computation:

package com.corp;

import java.util.Random;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.corp.compute.TornadoCompute;

import uk.ac.manchester.tornado.api.types.arrays.FloatArray;

public class Main {
    private static final Logger logger = LoggerFactory.getLogger(Main.class.getName());

    public static void main(String[] args) {
        Random rand = new Random();
        int noOfElements = 10000;
        FloatArray floatArray = new FloatArray(noOfElements);

        for (int i = 0; i < noOfElements; i++) {
            float randFloat = rand.nextFloat(noOfElements);
            floatArray.set(i, randFloat);
        }

        logger.info("Starting computation");
        TornadoCompute.buildAndRun(floatArray);
        logger.info("Finished computation");
    }
}

Expected behavior

Execution should result in success.

Computing system setup (please complete the following information):

  • OS: MacOS 15.2
  • OpenCL and Driver versions
      Tornado device=0:1
            OPENCL --  [Apple] -- AMD Radeon Pro 5500M Compute Engine
                    Global Memory Size: 4,0 GB
                    Local Memory Size: 64,0 KB
                    Workgroup Dimensions: 3
                    Total Number of Block Threads: [256]
                    Max WorkGroup Configuration: [256, 256, 256]
                    Device OpenCL C version: OpenCL C 1.2
    

Additional context

From stack trace it seems following invocation turns out to be letter ı in Turkish for Integer type name instead of i:

@jjfumero
Copy link
Member

Hi @selcuksert . Thank you for the report. Now I wonder if these options:

-Duser.country=US -Duser.language=en

should be enabled by default. TornadoVM needs the type descriptor names that are passed to the JIT compiler. Let me see if we can find an alternative using JVMCI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler
Projects
Status: No status
Development

No branches or pull requests

3 participants