private static void initCL(CLDevice.Type clType) throws Exception { /** * Hole OpenCL-Plattformen z.B. AMD APP, NVIDIA CUDA ** */ platforms = JavaCL.listPlatforms(); /** * Hole OpenCL-Device des geforderten Typs z.B. GPU, CPU ** */ EnumSet<CLDevice.Type> types = EnumSet.of(clType); devices = new ArrayList<CLDevice>(); CLDevice[] devTmp; for (CLPlatform platform : platforms) { devTmp = platform.listDevices(types, true); devices.addAll(Arrays.asList(devTmp)); } /** * Erstelle OpenCL-Context und CommandQueue ** */ devTmp = new CLDevice[devices.size()]; context = JavaCL.createContext(null, devices.toArray(devTmp)); cmdQ = context.createDefaultQueue(QueueProperties.ProfilingEnable); /** * OpenCL-Quellcode einlesen ** */ String src = readFile(KERNEL_PATH); // String src = KERNEL_SRC; /** * OpenCL-Programm aus Quellcode erstellen ** */ program = context.createProgram(src); try { program.build(); } catch (CLBuildException err) { Logger.logError(CLAZZ, "Build log for \"" + devices.get(0) + "\n" + err.getMessage()); throw err; } /** * OpenCL-Kernel laden ** */ kernel = program.createKernel("addVec"); }