0

我正在学习使用 Rootbeer,所以我做了以下事情:

[1] 下载Rootbeer-1.2.3.jar

[2] 从http://www.nvidia.com/content/cuda/cuda-downloads.html安装 CUDA Toolkit 和 CUDA Driver

[3] 编译了以下示例程序。

[4] 从 NetBeans 8.0.2 运行 ArrayMultApp

import java.util.List;
import java.util.ArrayList;
import org.trifort.rootbeer.runtime.Kernel;
import org.trifort.rootbeer.runtime.Rootbeer;

public class ArrayMultApp
{
  public void multArray(int[] array)
  {
    List<Kernel> jobs=new ArrayList();
    for (int i=0;i<array.length;++i) jobs.add(new ArrayMult(array,i));
    Rootbeer rootbeer=new Rootbeer();
    rootbeer.run(jobs);
  }

  public static void main(String[] args)
  {
    ArrayMultApp app=new ArrayMultApp();
    int[] array=new int[10];
    for (int i=0;i<array.length;++i) array[i]=i;
    for (int i=0;i<array.length;++i) System.out.println("start array["+i+"]: "+array[i]);
    app.multArray(array);
    for (int i=0;i<array.length;++i) System.out.println("final array["+i+"]: "+array[i]);
  }
}

class ArrayMult implements Kernel
{
  private int[] m_source;
  private int m_index;

  public ArrayMult(int[] source,int index)
  {
    m_source=source;
    m_index=index;
  }

  public void gpuMethod()
  {
    m_source[m_index]*=11;
  }
}

但我收到以下错误消息:

start array[0]: 0
start array[1]: 1
start array[2]: 2
start array[3]: 3
start array[4]: 4
start array[5]: 5
start array[6]: 6
start array[7]: 7
start array[8]: 8
start array[9]: 9
Exception in thread "main" java.lang.ClassCastException: ArrayMult cannot be cast to org.trifort.rootbeer.runtime.CompiledKernel
    at org.trifort.rootbeer.runtime.CUDAContext.setKernel(CUDAContext.java:119)Java Result: 1

我在 Win 7 64 位上安装了 Intel Core i7 x 980、NVIDA GeForce GTX 780 和 Java 8。

我从 Rootbeer 网站复制了示例应用程序,为什么会收到错误消息,以及如何解决?

编辑:我忘了提一件事,在安装过程中,它说我没有Microsoft Visual Studio,类似的东西并说没有安装某些部分,我以为我是Java开发人员,我没有需要 Visual Studio,我不介意没有这些部分,这可能是问题吗?这是否意味着我必须先购买并安装 Microsoft Visual Studio 才能使用 Rootbeer 进行 Java 开发?

我按照说明进入 [ C:\ProgramData\NVIDIA Corporation\CUDA Samples\v6.5\bin\win64\Release> ] 并进行了大量测试,它们都工作正常,我可以看到正在小窗口中处理的图像正确。

当我尝试 jar 时,出现以下错误:

C:\Dir_Rootbeer_Samples\dist>java -jar lib/Rootbeer-1.2.3.jar Rootbeer_Samples.jar Rootbeer_Samples-GPU.jar
warning: sm_12 and sm_11 not supported with recursion. use -norecursion to enable.
warning: sm_12 and sm_11 not supported with doubles. use -nodoubles to enable.
caching package names for: C:\Dir_Rootbeer_Samples\dist\Rootbeer_Samples.jar
cpool == null
java.lang.NullPointerException
        at soot.rbclassload.RootbeerClassLoader.loadHierarchySootClasses(RootbeerClassLoader.java:963)
        at soot.rbclassload.RootbeerClassLoader.loadNecessaryClasses(RootbeerClassLoader.java:294)
        at org.trifort.rootbeer.entry.RootbeerCompiler.setupSoot(RootbeerCompiler.java:198)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:219)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:213)
        at org.trifort.rootbeer.entry.Main.run(Main.java:208)
        at org.trifort.rootbeer.entry.Main.main(Main.java:244)
caching package names for: C:\Dir_Rootbeer_Samples\dist\lib\Rootbeer-1.2.3.jar
caching package names for: C:\Program Files\Java\jre1.8.0_20\lib\rt.jar
cpool == null
java.lang.NullPointerException
        at soot.rbclassload.RootbeerClassLoader.loadHierarchySootClasses(RootbeerClassLoader.java:963)
        at soot.rbclassload.RootbeerClassLoader.loadNecessaryClasses(RootbeerClassLoader.java:294)
        at org.trifort.rootbeer.entry.RootbeerCompiler.setupSoot(RootbeerCompiler.java:198)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:219)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:213)
        at org.trifort.rootbeer.entry.Main.run(Main.java:208)
        at org.trifort.rootbeer.entry.Main.main(Main.java:244)
caching package names for: Rootbeer_Samples.jar
cpool == null
java.lang.NullPointerException
        at soot.rbclassload.RootbeerClassLoader.loadHierarchySootClasses(RootbeerClassLoader.java:963)
        at soot.rbclassload.RootbeerClassLoader.loadNecessaryClasses(RootbeerClassLoader.java:294)
        at org.trifort.rootbeer.entry.RootbeerCompiler.setupSoot(RootbeerCompiler.java:198)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:219)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:213)
        at org.trifort.rootbeer.entry.Main.run(Main.java:208)
        at org.trifort.rootbeer.entry.Main.main(Main.java:244)
remapping class: java.util.concurrent.atomic.AtomicLong
java.lang.NullPointerException
        at soot.rbclassload.RootbeerClassLoader.remapClasses(RootbeerClassLoader.java:998)
        at soot.rbclassload.RootbeerClassLoader.loadNecessaryClasses(RootbeerClassLoader.java:295)
        at org.trifort.rootbeer.entry.RootbeerCompiler.setupSoot(RootbeerCompiler.java:198)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:219)
        at org.trifort.rootbeer.entry.RootbeerCompiler.compile(RootbeerCompiler.java:213)
        at org.trifort.rootbeer.entry.Main.run(Main.java:208)
        at org.trifort.rootbeer.entry.Main.main(Main.java:244)

C:\Dir_Rootbeer_Samples\dist>
4

0 回答 0