private void updateInfos() { if (testBuffer == null && clContext != null && !bufferCreated) { try { testBuffer = clContext.createBuffer(1024).register(); LOG.info("Test buffer created"); } catch (OpenCLException ex) { LOG.log(Level.SEVERE, "Unable to create buffer", ex); } bufferCreated = true; } Context c = context.getOpenCLContext(); if (c == clContext) { return; } clContext = c; LOG.info("context changed"); testBuffer = null; bufferCreated = false; StringBuilder text = new StringBuilder(); text.append("Current context:\n"); text.append(" Platform: ").append(clContext.getDevices().get(0).getPlatform().getName()).append("\n"); text.append(" Device: ").append(clContext.getDevices().get(0).getName()).append("\n"); text.append(" Profile: ").append(clContext.getDevices().get(0).getProfile()).append("\n"); text.append(" Memory: ").append(clContext.getDevices().get(0).getGlobalMemorySize()).append(" B\n"); text.append(" Compute Units: ").append(clContext.getDevices().get(0).getComputeUnits()).append("\n"); infoLabel.setText(text.toString()); }
private void changePlatform(String platform) { selectedPlatform = platform; Platform p = null; for (Platform p2 : availabePlatforms) { if (p2.getName().equals(selectedPlatform)) { p = p2; break; } } deviceListBox.clear(); if (p == null) { return; } for (Device d : p.getDevices()) { deviceListBox.addItem(d.getName()); } deviceListBox.selectItem(selectedDevice); }
.append(clContext.getDevices().get(0).getPlatform().getName()) .append("\n Devices: ").append(clContext.getDevices()); str.append("\nTests:");
.append(clContext.getDevices().get(0).getPlatform().getName()) .append("\n Devices: ").append(clContext.getDevices()); str.append("\nTests:");
@Override @SuppressWarnings("unchecked") public void bind(Nifty nifty, Screen screen) { applyButton = screen.findNiftyControl("ApplyButton", Button.class); platformListBox = screen.findNiftyControl("PlatformListBox", ListBox.class); deviceListBox = screen.findNiftyControl("DeviceListBox", ListBox.class); infoLabel = screen.findNiftyControl("InfoLabel", Label.class); updateInfos(); platformListBox.clear(); for (Platform p : availabePlatforms) { platformListBox.addItem(p.getName()); } platformListBox.selectItem(selectedPlatform); changePlatform(selectedPlatform); }