GPU上的Java:直接在GPU上用普通Java完成方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6460685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 06:08:45  来源:igfitidea点击:

Java on GPU: Complete Method directly on GPUin plain Java

javagpugpu-programming

提问by Andreas Hornig

Firstly: Is it possible to use Java and let it (partly) run on or use GPUs? And if it's possible, is it possible to use the normal Java syntax and not using special cuda or opencl syntax?

首先:是否可以使用 Java 并让它(部分)在 GPU 上运行或使用 GPU?如果可能,是否可以使用普通的 Java 语法而不使用特殊的 cuda 或 opencl 语法?

I want just take my coded java source and let it run with the smallest changes possible on GPUs.

我只想获取我编码的 Java 源代码,让它在 GPU 上以尽可能小的更改运行。

I would greatly appreciate code samples.

我将不胜感激代码示例。

回答by Jesper

There are several Java bindings to CUDA and OpenCL (jcuda.org, jocl.org, something else also called jocl) but these are all just ways to get CUDA or OpenCL code running on the GPU via Java and require you to write your code specifically for that. I don't think there is an easy way to run an arbitrary multi-threaded Java program on the GPU with just minor changes to the code.

有几种 Java 绑定到 CUDA 和 OpenCL(jcuda.orgjocl.org,也称为jocl),但这些都是通过 Java 在 GPU 上运行 CUDA 或 OpenCL 代码的方法,并且需要您专门编写代码为了那个原因。我不认为有一种简单的方法可以在 GPU 上运行任意多线程 Java 程序,而只需对代码进行少量更改。

What does your Java program do that you want to run on the GPU?

您希望在 GPU 上运行的 Java 程序是做什么的?

You have to take into account that the architecture of a GPU is quite different than that of a CPU; cores on a GPU are not general-purpose cores that can do anything and work independently, as in an Intel x86 CPU. To really take advantage of the specific SIMD architecture of a GPU, your code has to be written with that architecture in mind.

您必须考虑到 GPU 的架构与 CPU 的架构大不相同;GPU 上的内核不是可以做任何事情并独立工作的通用内核,就像在 Intel x86 CPU 中一样。要真正利用 GPU 的特定 SIMD 架构,编写代码时必须考虑到该架构。

回答by Ginnun

Have a look on http://code.google.com/p/java-gpu/.

看看http://code.google.com/p/java-gpu/

It compiles pure java code into kernels, with only using annotations.

它将纯 Java 代码编译为内核,仅使用注释。

回答by gfrost

Consider Aparapi http://aparapi.github.io/. It attempts to convert bytecode to OpenCL at runtime. So you can code for your GPU in pure Java.

考虑 Aparapi http://aparapi.github.io/。它尝试在运行时将字节码转换为 OpenCL。所以你可以用纯 Java 为你的 GPU 编码。

Full disclosure, I am the Aparapi lead developer.

完全公开,我是 Aparapi 的首席开发人员。

回答by pcpratts

The Rootbeer GPU Compiler supports running arbitrary Java code on the GPU. It is more full featured than Aparapi. Rootbeer supports arbirary object graphs of any type.

Rootbeer GPU 编译器支持在 GPU 上运行任意 Java 代码。它比 Aparapi 功能更全面。Rootbeer 支持任何类型的任意对象图。

It was just released open source on my github account: https://github.com/pcpratts/rootbeer1

它刚刚在我的 github 帐户上开源发布:https: //github.com/pcpratts/rootbeer1

回答by mikepapadim

TornadoVM is a plug-in to OpenJDK that allows programmers to automatically run Java programs on heterogeneous hardware. TornadoVM currently targets OpenCL-compatible devices and it runs on multi-core CPUs, GPUs (NVIDIA and AMD), Intel integrated GPUs, and Intel FPGAs. Take a look here: https://github.com/beehive-lab/TornadoVM

TornadoVM 是 OpenJDK 的一个插件,它允许程序员在异构硬件上自动运行 Java 程序。TornadoVM 目前针对兼容 OpenCL 的设备,它在多核 CPU、GPU(NVIDIA 和 AMD)、Intel 集成 GPU 和 Intel FPGA 上运行。看看这里:https: //github.com/beehive-lab/TornadoVM