public void cluster() { prepareOpenCl(); for (int iteration = 0; iteration < noIterations; iteration++) { Arrays.fill(clustersUpdates, 0); memUpdates.copyHtoD(); for (int batch = 0; batch < images.size() / batchItems; batch++) { for (int i = 0; i < batchItems; i++) { System.arraycopy( images.get(batch * batchItems + i).getDataShort(), 0, inputImages, i * imageSize, imageSize); } memImages.copyHtoD(); updateCenters.run(batchItems, 256); program.finish(); } System.out.println(iteration); memUpdates.copyDtoH(); reduceCenters(); subtractMeanClusters(); memClusters.copyHtoD(); } releaseOpenCl(); constructImageClusters(); }