Do java 8 lambda expressions use GPU?

I recently got in touch with Java 8 and I'm trying to learn lambda expressions

IntStream.range(0,(screenSize.width * screenSize.height)).parallel().forEach(id -> { 
        int x = id % screenSize.width;
        int y = ((id-x) / screenSize.width);
        /*look up what color this pixel is.*/
    });

Now all these codes are for graphics. Everything is basic mathematics (addition, subtraction, multiplication, modulus), except bufferedimage Getrgb (x, y) and Java awt. Color operation, which can be completed separately for each pixel

The question now is: is it possible to run it on a GPU? Or is this even GPU based? (I remember seeing this somewhere, but I'm not sure)

Solution

As long as the result is correct, the Java VM implementation can freely implement Java bytecode interpretation It can run anything on the GPU at will However, I am not aware of any Java implementation currently performing this operation One project can add GPU acceleration to openjdk (project Sumatra). You guessed it right: it focuses on stream API because it is designed to write code that can be parallelized But it is far from ready for production, and no one seems to be studying it at present

If you want to run computing on GPU from Java programs today, you need a library that uses Java Native Interface to wrap GPU computing APIs such as OpenCL (jocl for OpenCL) Be ready to learn a new programming language, because each GPU computing API uses instructions in different languages, and they are very similar to Java

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>