diff options
Diffstat (limited to 'src/com')
16 files changed, 190 insertions, 178 deletions
diff --git a/src/com/jogamp/opencl/demos/bandwidth/BandwidthBenchmark.java b/src/com/jogamp/opencl/demos/bandwidth/BandwidthBenchmark.java index 30de54e..d740e36 100644 --- a/src/com/jogamp/opencl/demos/bandwidth/BandwidthBenchmark.java +++ b/src/com/jogamp/opencl/demos/bandwidth/BandwidthBenchmark.java @@ -27,11 +27,11 @@ public class BandwidthBenchmark { private static int MEMCOPY_ITERATIONS = 100; private static int DEFAULT_SIZE = (32 * (1 << 20)); //32 M private static int DEFAULT_INCREMENT = (1 << 22); //4 M - private static int CACHE_CLEAR_SIZE = (1 << 24); //16 M +// private static int CACHE_CLEAR_SIZE = (1 << 24); //16 M //shmoo mode defines private static int SHMOO_MEMSIZE_MAX = (1 << 26); //64 M - private static int SHMOO_MEMSIZE_START = (1 << 10); //1 KB +// private static int SHMOO_MEMSIZE_START = (1 << 10); //1 KB private static int SHMOO_INCREMENT_1KB = (1 << 10); //1 KB private static int SHMOO_INCREMENT_2KB = (1 << 11); //2 KB private static int SHMOO_INCREMENT_10KB = (10 * (1 << 10)); //10KB @@ -248,7 +248,7 @@ public class BandwidthBenchmark { CLContext context = queue.getContext(); //allocate and init host memory, pinned or conventional - if (memMode == memMode.PINNED) { + if (memMode == MEMORY.PINNED) { // Create a host buffer cmPinnedData = context.createBuffer(memSize, Mem.READ_WRITE, Mem.ALLOCATE_BUFFER); @@ -268,7 +268,7 @@ public class BandwidthBenchmark { cmDevData = context.createBuffer(memSize, Mem.READ_WRITE); // initialize device memory - if (memMode == memMode.PINNED) { + if (memMode == MEMORY.PINNED) { // Get a mapped pointer h_data = queue.putMapBuffer(cmPinnedData, WRITE, true); @@ -284,7 +284,7 @@ public class BandwidthBenchmark { long delta = System.nanoTime(); - if (accMode == accMode.DIRECT) { + if (accMode == ACCESS.DIRECT) { // DIRECT: API access to device buffer cmDevData = cmDevData.cloneWith(h_data); for (int i = 0; i < MEMCOPY_ITERATIONS; i++) { @@ -329,7 +329,7 @@ public class BandwidthBenchmark { CLContext context = queue.getContext(); // Allocate and init host memory, pinned or conventional - if (memMode == memMode.PINNED) { + if (memMode == MEMORY.PINNED) { // Create a host buffer cmPinnedData = context.createBuffer(memSize, Mem.READ_WRITE, Mem.ALLOCATE_BUFFER); @@ -355,8 +355,8 @@ public class BandwidthBenchmark { long delta = System.nanoTime(); - if (accMode == accMode.DIRECT) { - if (memMode == memMode.PINNED) { + if (accMode == ACCESS.DIRECT) { + if (memMode == MEMORY.PINNED) { // Get a mapped pointer h_data = queue.putMapBuffer(cmPinnedData, WRITE, true); } @@ -460,14 +460,14 @@ public class BandwidthBenchmark { } else if (kind == COPY.HOST_TO_DEVICE) { System.out.print("Host to Device Bandwidth, "+iNumDevs+" Device(s), "); } - if (memMode == memMode.PAGEABLE) { + if (memMode == MEMORY.PAGEABLE) { System.out.print("Paged memory"); - } else if (memMode == memMode.PINNED) { + } else if (memMode == MEMORY.PINNED) { System.out.print("Pinned memory"); } - if (accMode == accMode.DIRECT) { + if (accMode == ACCESS.DIRECT) { System.out.println(", direct access"); - } else if (accMode == accMode.MAPPED) { + } else if (accMode == ACCESS.MAPPED) { System.out.println(", mapped access"); } } diff --git a/src/com/jogamp/opencl/demos/fft/BlurTest.java b/src/com/jogamp/opencl/demos/fft/BlurTest.java index c08da43..7fb79fe 100644 --- a/src/com/jogamp/opencl/demos/fft/BlurTest.java +++ b/src/com/jogamp/opencl/demos/fft/BlurTest.java @@ -21,13 +21,13 @@ import java.awt.image.BufferedImage; import java.awt.image.DataBufferByte; import java.awt.image.DataBufferInt; import java.io.File; -import java.io.FileInputStream; +//import java.io.FileInputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import java.util.logging.Level; -import java.util.logging.Logger; +//import java.util.logging.Level; +//import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; @@ -86,7 +86,7 @@ public class BlurTest implements Runnable, ChangeListener, ActionListener { try { File file = null; - if (true) { +// if (true) { fc.setDialogTitle("Select Image File"); fc.setPreferredSize(new Dimension(500, 600)); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { @@ -95,9 +95,9 @@ public class BlurTest implements Runnable, ChangeListener, ActionListener { System.exit(0); } - } else { - file = new File("/home/notzed/cat0.jpg"); - } +// } else { +// file = new File("/home/notzed/cat0.jpg"); +// } img = ImageIO.read(file); if (img == null) { JOptionPane.showMessageDialog(null, "Couldn't load file"); @@ -117,7 +117,7 @@ public class BlurTest implements Runnable, ChangeListener, ActionListener { g.dispose(); JFrame win = new JFrame("Blur Demo"); - win.setDefaultCloseOperation(win.EXIT_ON_CLOSE); + win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel main = new JPanel(); main.setLayout(new BorderLayout()); @@ -168,7 +168,7 @@ public class BlurTest implements Runnable, ChangeListener, ActionListener { } }); ButtonGroup opt = new ButtonGroup(); - JToggleButton tb; +// JToggleButton tb; blurButton = new JToggleButton("Blur"); opt.add(blurButton); buttons.add(blurButton); @@ -349,17 +349,17 @@ public class BlurTest implements Runnable, ChangeListener, ActionListener { rGBuffer = cl.createFloatBuffer(width * height * 2, Mem.READ_WRITE); gGBuffer = cl.createFloatBuffer(width * height * 2, Mem.READ_WRITE); bGBuffer = cl.createFloatBuffer(width * height * 2, Mem.READ_WRITE); - if (false) { - try { - CLProgram p = cl.createProgram(new FileInputStream("/home/notzed/cl/fft-512.cl")); - p.build(); - fft512 = p.createCLKernel("fft0"); - } catch (IOException ex) { - Logger.getLogger(BlurTest.class.getName()).log(Level.SEVERE, null, ex); - } - } else { +// if (false) { +// try { +// CLProgram p = cl.createProgram(new FileInputStream("/home/notzed/cl/fft-512.cl")); +// p.build(); +// fft512 = p.createCLKernel("fft0"); +// } catch (IOException ex) { +// Logger.getLogger(BlurTest.class.getName()).log(Level.SEVERE, null, ex); +// } +// } else { fft = new CLFFTPlan(cl, new int[]{width, height}, CLFFTPlan.CLFFTDataFormat.InterleavedComplexFormat); - } +// } //fft.dumpPlan(null); } @@ -406,17 +406,17 @@ public class BlurTest implements Runnable, ChangeListener, ActionListener { kGrey2Plane.setArg(5, width); q.put2DRangeKernel(kGrey2Plane, 0, 0, width, height, 64, 1); - if (true) { +// if (true) { fft.executeInterleaved(q, 1, CLFFTPlan.CLFFTDirection.Forward, tmpBuffer, psfBuffer, null, null); - } else if (true) { - fft512.setArg(0, tmpBuffer); - fft512.setArg(1, psfBuffer); - fft512.setArg(2, -1); - fft512.setArg(3, height); +// } else if (true) { +// fft512.setArg(0, tmpBuffer); +// fft512.setArg(1, psfBuffer); +// fft512.setArg(2, -1); +// fft512.setArg(3, height); //q.put1DRangeKernel(fft512, 0,height*64, 64); - q.put2DRangeKernel(fft512, 0, 0, height * 64, 1, 64, 1); - System.out.println("running kernel " + 64 * height + ", " + 64); - } +// q.put2DRangeKernel(fft512, 0, 0, height * 64, 1, 64, 1); +// System.out.println("running kernel " + 64 * height + ", " + 64); +// } } // g = f x h diff --git a/src/com/jogamp/opencl/demos/fft/CLFFTPlan.java b/src/com/jogamp/opencl/demos/fft/CLFFTPlan.java index 1c8e039..91a9925 100644 --- a/src/com/jogamp/opencl/demos/fft/CLFFTPlan.java +++ b/src/com/jogamp/opencl/demos/fft/CLFFTPlan.java @@ -38,11 +38,11 @@ public class CLFFTPlan { int y; int z; - CLFFTDim3(int x, int y, int z) { +/* CLFFTDim3(int x, int y, int z) { this.x = x; this.y = y; this.z = z; - } + }*/ CLFFTDim3(int[] size) { x = size[0]; @@ -154,11 +154,11 @@ public class CLFFTPlan { // temp buffer if same batch size is used again and again. int last_batch_size; // temporary buffer for interleaved plan - CLMemory tempmemobj; + CLMemory<FloatBuffer> tempmemobj; // temporary buffer for planner plan. Only one of tempmemobj or // (tempmemobj_real, tempmemobj_imag) pair is valid (allocated) depending // data format of plan (plannar or interleaved) - CLMemory tempmemobj_real, tempmemobj_imag; + CLMemory<FloatBuffer> tempmemobj_real, tempmemobj_imag; // Maximum size of signal for which local memory transposed based // fft is sufficient i.e. no global mem transpose (communication) // is needed @@ -178,27 +178,28 @@ public class CLFFTPlan { // e.g. on NVidia it is 16. int num_local_mem_banks; - public class InvalidContextException extends Exception { + @SuppressWarnings("serial") + public class InvalidContextException extends Exception { } /** * Create a new FFT plan. * * Use the matching executeInterleaved() or executePlanar() depending on the dataFormat specified. - * @param context + * @param context Context to create program in and get devices from. * @param sizes Array of sizes for each dimension. The length of array defines how many dimensions there are. * @param dataFormat Data format, InterleavedComplex (array of complex) or SplitComplex (separate planar arrays). - * @throws zephyr.cl.CLFFTPlan.InvalidContextException + * @throws InvalidContextException if we can't find any GPUs. */ public CLFFTPlan(CLContext context, int[] sizes, CLFFTDataFormat dataFormat) throws InvalidContextException { int i; - int err; +// int err; boolean isPow2 = true; - String kString; - int num_devices; +// String kString; +// int num_devices; boolean gpu_found = false; CLDevice[] devices; - int ret_size; +// int ret_size; if (sizes.length < 1 || sizes.length > 3) { throw new IllegalArgumentException("Dimensions must be between 1 and 3"); @@ -297,7 +298,7 @@ public class CLFFTPlan { /** * Calculate FFT on interleaved complex data. - * @param queue + * @param queue Command queue to put kernels into. * @param batchSize How many instances to calculate. Use 1 for a single FFT. * @param dir Direction of calculation, Forward or Inverse. * @param data_in Input buffer. @@ -309,7 +310,7 @@ public class CLFFTPlan { CLBuffer<FloatBuffer> data_in, CLBuffer<FloatBuffer> data_out, CLEventList condition, CLEventList event) { int s; - if (format != format.InterleavedComplexFormat) { + if (format != CLFFTDataFormat.InterleavedComplexFormat) { throw new IllegalArgumentException(); } @@ -320,7 +321,8 @@ public class CLFFTPlan { allocateTemporaryBufferInterleaved(batchSize); - CLMemory[] memObj = new CLMemory[3]; + @SuppressWarnings("rawtypes") + CLMemory[] memObj = new CLMemory[3]; memObj[0] = data_in; memObj[1] = data_out; memObj[2] = tempmemobj; @@ -404,26 +406,26 @@ public class CLFFTPlan { /** * Calculate FFT of planar data. - * @param queue - * @param batchSize - * @param dir - * @param data_in_real - * @param data_in_imag - * @param data_out_real - * @param data_out_imag - * @param contition - * @param event + * @param queue Command queue to put kernels into. + * @param batchSize Undocumented by original author. + * @param dir Undocumented by original author. + * @param data_in_real Undocumented by original author. + * @param data_in_imag Undocumented by original author. + * @param data_out_real Undocumented by original author. + * @param data_out_imag Undocumented by original author. + * @param contition Undocumented by original author. + * @param event Undocumented by original author. */ public void executePlanar(CLCommandQueue queue, int batchSize, CLFFTDirection dir, CLBuffer<FloatBuffer> data_in_real, CLBuffer<FloatBuffer> data_in_imag, CLBuffer<FloatBuffer> data_out_real, CLBuffer<FloatBuffer> data_out_imag, CLEventList contition, CLEventList event) { int s; - if (format != format.SplitComplexFormat) { + if (format != CLFFTDataFormat.SplitComplexFormat) { throw new IllegalArgumentException(); } - int err; +// int err; WorkDimensions wd; boolean inPlaceDone = false; @@ -431,8 +433,10 @@ public class CLFFTPlan { allocateTemporaryBufferPlanar(batchSize); - CLMemory[] memObj_real = new CLMemory[3]; - CLMemory[] memObj_imag = new CLMemory[3]; + @SuppressWarnings("rawtypes") + CLMemory[] memObj_real = new CLMemory[3]; + @SuppressWarnings("rawtypes") + CLMemory[] memObj_imag = new CLMemory[3]; memObj_real[0] = data_in_real; memObj_real[1] = data_out_real; memObj_real[2] = tempmemobj_real; @@ -514,6 +518,7 @@ public class CLFFTPlan { out.printf("Run kernel %s with global dim = {%d*BatchSize}, local dim={%d}\n", kInfo.kernel_name, wd.gWorkItems, wd.lWorkItems); } out.printf("%s\n", kernel_string.toString()); + out.close(); } WorkDimensions getKernelWorkDimensions(CLFFTKernelInfo kernelInfo, int batchSize) { @@ -581,12 +586,12 @@ public class CLFFTPlan { } private void createKernelList() { - CLFFTKernelInfo kern; +// CLFFTKernelInfo kern; for (CLFFTKernelInfo kinfo : this.kernel_list) { kinfo.kernel = program.createCLKernel(kinfo.kernel_name); } - if (format == format.SplitComplexFormat) { + if (format == CLFFTDataFormat.SplitComplexFormat) { twist_kernel = program.createCLKernel("clFFT_1DTwistSplit"); } else { twist_kernel = program.createCLKernel("clFFT_1DTwistInterleaved"); @@ -749,7 +754,7 @@ public class CLFFTPlan { } void formattedLoad(StringBuilder kernelString, int aIndex, int gIndex, CLFFTDataFormat dataFormat) { - if (dataFormat == dataFormat.InterleavedComplexFormat) { + if (dataFormat == CLFFTDataFormat.InterleavedComplexFormat) { kernelString.append(" a[").append(aIndex).append("] = in[").append(gIndex).append("];\n"); } else { kernelString.append(" a[").append(aIndex).append("].x = in_real[").append(gIndex).append("];\n"); @@ -758,7 +763,7 @@ public class CLFFTPlan { } void formattedStore(StringBuilder kernelString, int aIndex, int gIndex, CLFFTDataFormat dataFormat) { - if (dataFormat == dataFormat.InterleavedComplexFormat) { + if (dataFormat == CLFFTDataFormat.InterleavedComplexFormat) { kernelString.append(" out[").append(gIndex).append("] = a[").append(aIndex).append("];\n"); } else { kernelString.append(" out_real[").append(gIndex).append("] = a[").append(aIndex).append("].x;\n"); @@ -767,7 +772,7 @@ public class CLFFTPlan { } int insertGlobalLoadsAndTranspose(StringBuilder kernelString, int N, int numWorkItemsPerXForm, int numXFormsPerWG, int R0, int mem_coalesce_width, CLFFTDataFormat dataFormat) { - int log2NumWorkItemsPerXForm = (int) log2(numWorkItemsPerXForm); + int log2NumWorkItemsPerXForm = log2(numWorkItemsPerXForm); int groupSize = numWorkItemsPerXForm * numXFormsPerWG; int i, j; int lMemSize = 0; @@ -782,7 +787,7 @@ public class CLFFTPlan { kernelString.append(" jj = lId >> ").append(log2NumWorkItemsPerXForm).append(";\n"); kernelString.append(" if( !s || (groupId < get_num_groups(0)-1) || (jj < s) ) {\n"); kernelString.append(" offset = mad24( mad24(groupId, ").append(numXFormsPerWG).append(", jj), ").append(N).append(", ii );\n"); - if (dataFormat == dataFormat.InterleavedComplexFormat) { + if (dataFormat == CLFFTDataFormat.InterleavedComplexFormat) { kernelString.append(" in += offset;\n"); kernelString.append(" out += offset;\n"); } else { @@ -799,7 +804,7 @@ public class CLFFTPlan { kernelString.append(" ii = lId;\n"); kernelString.append(" jj = 0;\n"); kernelString.append(" offset = mad24(groupId, ").append(N).append(", ii);\n"); - if (dataFormat == dataFormat.InterleavedComplexFormat) { + if (dataFormat == CLFFTDataFormat.InterleavedComplexFormat) { kernelString.append(" in += offset;\n"); kernelString.append(" out += offset;\n"); } else { @@ -817,11 +822,11 @@ public class CLFFTPlan { int numOuterIter = numXFormsPerWG / (groupSize / mem_coalesce_width); kernelString.append(" ii = lId & ").append(mem_coalesce_width - 1).append(";\n"); - kernelString.append(" jj = lId >> ").append((int) log2(mem_coalesce_width)).append(";\n"); + kernelString.append(" jj = lId >> ").append(log2(mem_coalesce_width)).append(";\n"); kernelString.append(" lMemStore = sMem + mad24( jj, ").append(N + numWorkItemsPerXForm).append(", ii );\n"); kernelString.append(" offset = mad24( groupId, ").append(numXFormsPerWG).append(", jj);\n"); kernelString.append(" offset = mad24( offset, ").append(N).append(", ii );\n"); - if (dataFormat == dataFormat.InterleavedComplexFormat) { + if (dataFormat == CLFFTDataFormat.InterleavedComplexFormat) { kernelString.append(" in += offset;\n"); kernelString.append(" out += offset;\n"); } else { @@ -882,7 +887,7 @@ public class CLFFTPlan { lMemSize = (N + numWorkItemsPerXForm) * numXFormsPerWG; } else { kernelString.append(" offset = mad24( groupId, ").append(N * numXFormsPerWG).append(", lId );\n"); - if (dataFormat == dataFormat.InterleavedComplexFormat) { + if (dataFormat == CLFFTDataFormat.InterleavedComplexFormat) { kernelString.append(" in += offset;\n"); kernelString.append(" out += offset;\n"); } else { @@ -893,7 +898,7 @@ public class CLFFTPlan { } kernelString.append(" ii = lId & ").append(N - 1).append(";\n"); - kernelString.append(" jj = lId >> ").append((int) log2(N)).append(";\n"); + kernelString.append(" jj = lId >> ").append(log2(N)).append(";\n"); kernelString.append(" lMemStore = sMem + mad24( jj, ").append(N + numWorkItemsPerXForm).append(", ii );\n"); kernelString.append("if((groupId == get_num_groups(0)-1) && s) {\n"); @@ -953,12 +958,12 @@ public class CLFFTPlan { int i, j, k, ind; int lMemSize = 0; int numIter = maxRadix / Nr; - String indent = ""; +// String indent = ""; if (numWorkItemsPerXForm >= mem_coalesce_width) { if (numXFormsPerWG > 1) { kernelString.append(" if( !s || (groupId < get_num_groups(0)-1) || (jj < s) ) {\n"); - indent = (" "); +// indent = (" "); } for (i = 0; i < maxRadix; i++) { j = i % numIter; @@ -975,7 +980,7 @@ public class CLFFTPlan { kernelString.append(" lMemLoad = sMem + mad24( jj, ").append(N + numWorkItemsPerXForm).append(", ii );\n"); kernelString.append(" ii = lId & ").append(mem_coalesce_width - 1).append(";\n"); - kernelString.append(" jj = lId >> ").append((int) log2(mem_coalesce_width)).append(";\n"); + kernelString.append(" jj = lId >> ").append(log2(mem_coalesce_width)).append(";\n"); kernelString.append(" lMemStore = sMem + mad24( jj,").append(N + numWorkItemsPerXForm).append(", ii );\n"); for (i = 0; i < maxRadix; i++) { @@ -1033,7 +1038,7 @@ public class CLFFTPlan { kernelString.append(" lMemLoad = sMem + mad24( jj,").append(N + numWorkItemsPerXForm).append(", ii );\n"); kernelString.append(" ii = lId & ").append(N - 1).append(";\n"); - kernelString.append(" jj = lId >> ").append((int) log2(N)).append(";\n"); + kernelString.append(" jj = lId >> ").append(log2(N)).append(";\n"); kernelString.append(" lMemStore = sMem + mad24( jj,").append(N + numWorkItemsPerXForm).append(", ii );\n"); for (i = 0; i < maxRadix; i++) { @@ -1411,7 +1416,7 @@ public class CLFFTPlan { int maxArrayLen = this.max_radix; int batchSize = this.min_mem_coalesce_width; CLFFTDataFormat dataFormat = this.format; - boolean vertical = (dir == dir.X) ? false : true; + boolean vertical = (dir == CLFFTKernelDir.X) ? false : true; numRadices = getGlobalRadixInfo(n, radixArr, R1Arr, R2Arr); @@ -1432,7 +1437,7 @@ public class CLFFTPlan { //} int N = n; - int m = (int) log2(n); + int m = log2(n); int Rinit = vertical ? BS : 1; batchSize = vertical ? Math.min(BS, batchSize) : batchSize; int passNum; @@ -1504,9 +1509,9 @@ public class CLFFTPlan { insertVariables(localString, R1); if (vertical) { - localString.append("xNum = groupId >> ").append((int) log2(numBlocksPerXForm)).append(";\n"); + localString.append("xNum = groupId >> ").append(log2(numBlocksPerXForm)).append(";\n"); localString.append("groupId = groupId & ").append(numBlocksPerXForm - 1).append(";\n"); - localString.append("indexIn = mad24(groupId, ").append(batchSize).append(", xNum << ").append((int) log2(n * BS)).append(");\n"); + localString.append("indexIn = mad24(groupId, ").append(batchSize).append(", xNum << ").append(log2(n * BS)).append(");\n"); localString.append("tid = mul24(groupId, ").append(batchSize).append(");\n"); localString.append("i = tid >> ").append(lgStrideO).append(";\n"); localString.append("j = tid & ").append(strideO - 1).append(";\n"); @@ -1514,7 +1519,7 @@ public class CLFFTPlan { for (i = 0; i < passNum; i++) { stride *= radixArr[i]; } - localString.append("indexOut = mad24(i, ").append(stride).append(", j + ").append("(xNum << ").append((int) log2(n * BS)).append("));\n"); + localString.append("indexOut = mad24(i, ").append(stride).append(", j + ").append("(xNum << ").append(log2(n * BS)).append("));\n"); localString.append("bNum = groupId;\n"); } else { int lgNumBlocksPerXForm = log2(numBlocksPerXForm); @@ -1540,7 +1545,7 @@ public class CLFFTPlan { localString.append("j = tid >> ").append(lgBatchSize).append(";\n"); localString.append("indexIn += mad24(j, ").append(strideI).append(", i);\n"); - if (dataFormat == dataFormat.SplitComplexFormat) { + if (dataFormat == CLFFTDataFormat.SplitComplexFormat) { localString.append("in_real += indexIn;\n"); localString.append("in_imag += indexIn;\n"); for (j = 0; j < R1; j++) { @@ -1600,7 +1605,7 @@ public class CLFFTPlan { // twiddle if (passNum < (numPasses - 1)) { localString.append("l = ((bNum << ").append(lgBatchSize).append(") + i) >> ").append(lgStrideO).append(";\n"); - localString.append("k = j << ").append((int) log2(R1 / R2)).append(";\n"); + localString.append("k = j << ").append(log2(R1 / R2)).append(";\n"); localString.append("ang1 = dir*(2.0f*M_PI/").append(N).append(")*l;\n"); for (t = 0; t < R1; t++) { localString.append("ang = ang1*(k + ").append((t % R2) * R1 + (t / R2)).append(");\n"); @@ -1612,8 +1617,8 @@ public class CLFFTPlan { // Store Data if (strideO == 1) { - localString.append("lMemStore = sMem + mad24(i, ").append(radix + 1).append(", j << ").append((int) log2(R1 / R2)).append(");\n"); - localString.append("lMemLoad = sMem + mad24(tid >> ").append((int) log2(radix)).append(", ").append(radix + 1).append(", tid & ").append(radix - 1).append(");\n"); + localString.append("lMemStore = sMem + mad24(i, ").append(radix + 1).append(", j << ").append(log2(R1 / R2)).append(");\n"); + localString.append("lMemLoad = sMem + mad24(tid >> ").append(log2(radix)).append(", ").append(radix + 1).append(", tid & ").append(radix - 1).append(");\n"); for (i = 0; i < R1 / R2; i++) { for (j = 0; j < R2; j++) { @@ -1658,7 +1663,7 @@ public class CLFFTPlan { localString.append("barrier(CLK_LOCAL_MEM_FENCE);\n"); localString.append("indexOut += tid;\n"); - if (dataFormat == dataFormat.SplitComplexFormat) { + if (dataFormat == CLFFTDataFormat.SplitComplexFormat) { localString.append("out_real += indexOut;\n"); localString.append("out_imag += indexOut;\n"); for (k = 0; k < R1; k++) { @@ -1676,7 +1681,7 @@ public class CLFFTPlan { } else { localString.append("indexOut += mad24(j, ").append(numIter * strideO).append(", i);\n"); - if (dataFormat == dataFormat.SplitComplexFormat) { + if (dataFormat == CLFFTDataFormat.SplitComplexFormat) { localString.append("out_real += indexOut;\n"); localString.append("out_imag += indexOut;\n"); for (k = 0; k < R1; k++) { @@ -1739,6 +1744,8 @@ public class CLFFTPlan { if (this.size.z > 1) { createGlobalFFTKernelString(this.size.z, this.size.x * this.size.y, dir, 1); } + break; + default: return; } diff --git a/src/com/jogamp/opencl/demos/fft/ImageView.java b/src/com/jogamp/opencl/demos/fft/ImageView.java index c5d07a1..a1bb94e 100644 --- a/src/com/jogamp/opencl/demos/fft/ImageView.java +++ b/src/com/jogamp/opencl/demos/fft/ImageView.java @@ -9,6 +9,7 @@ import javax.swing.JComponent; * Just draws an image. * @author notzed */ +@SuppressWarnings("serial") class ImageView extends JComponent { BufferedImage img; diff --git a/src/com/jogamp/opencl/demos/fft/PaintView.java b/src/com/jogamp/opencl/demos/fft/PaintView.java index 9dea3c8..4a6535a 100644 --- a/src/com/jogamp/opencl/demos/fft/PaintView.java +++ b/src/com/jogamp/opencl/demos/fft/PaintView.java @@ -16,6 +16,7 @@ import java.awt.image.BufferedImage; * Draws an image and lets you draw white dots in it with the mouse. Or big white dots with code. * @author notzed */ +@SuppressWarnings("serial") class PaintView extends ImageView implements MouseListener, MouseMotionListener { Graphics2D imgg; @@ -70,14 +71,14 @@ class PaintView extends ImageView implements MouseListener, MouseMotionListener } public void mousePressed(MouseEvent e) { - if (e.getButton() == e.BUTTON1) { + if (e.getButton() == MouseEvent.BUTTON1) { addMouseMotionListener(this); drawPaint(e.getX(), e.getY()); } } public void mouseReleased(MouseEvent e) { - if (e.getButton() == e.BUTTON1) { + if (e.getButton() == MouseEvent.BUTTON1) { removeMouseMotionListener(this); //drawPaint(e.getX(), e.getY()); } diff --git a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java index 1b44841..ecb014c 100644 --- a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java +++ b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java @@ -29,6 +29,7 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.IOException; import java.nio.IntBuffer; +import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import com.jogamp.opengl.DebugGL2; @@ -52,15 +53,14 @@ import static java.lang.Math.*; /** * Computes the Mandelbrot set with OpenCL using multiple GPUs and renders the result with OpenGL. - * A shared PBO is used as storage for the fractal image.<br/> + * A shared PBO is used as storage for the fractal image.<p> * http://en.wikipedia.org/wiki/Mandelbrot_set * <p> - * controls:<br/> - * keys 1-9 control parallelism level<br/> - * space enables/disables slice seperator<br/> - * 'd' toggles between 32/64bit floatingpoint precision<br/> - * mouse/mousewheel to drag and zoom<br/> - * </p> + * controls:<p> + * keys 1-9 control parallelism level<p> + * space enables/disables slice seperator<p> + * 'd' toggles between 32/64bit floatingpoint precision<p> + * mouse/mousewheel to drag and zoom<p> * @author Michael Bien */ public class MultiDeviceFractal implements GLEventListener { @@ -78,8 +78,8 @@ public class MultiDeviceFractal implements GLEventListener { private CLKernel[] kernels; private CLProgram[] programs; private CLEventList probes; - private CLGLBuffer<?>[] pboBuffers; - private CLBuffer<IntBuffer>[] colorMap; + private ArrayList<CLGLBuffer<?>> pboBuffers; + private ArrayList<CLBuffer<IntBuffer>> colorMap; private int width = 0; private int height = 0; @@ -148,7 +148,8 @@ public class MultiDeviceFractal implements GLEventListener { } } - private void initCL(GLContext glCtx){ +// @SuppressWarnings( "unchecked" ) + private void initCL(GLContext glCtx){ try { CLPlatform platform = CLPlatform.getDefault(); // SLI on NV platform wasn't very fast (or did not work at all -> CL_INVALID_OPERATION) @@ -165,15 +166,15 @@ public class MultiDeviceFractal implements GLEventListener { queues = new CLCommandQueue[slices]; kernels = new CLKernel[slices]; probes = new CLEventList(slices); - colorMap = new CLBuffer[slices]; + colorMap = new ArrayList<CLBuffer<IntBuffer>>(slices); for (int i = 0; i < slices; i++) { - colorMap[i] = clContext.createIntBuffer(32*2, READ_ONLY); - initColorMap(colorMap[i].getBuffer(), 32, Color.BLUE, Color.GREEN, Color.RED); + colorMap.add(clContext.createIntBuffer(32*2, READ_ONLY)); + initColorMap(colorMap.get(i).getBuffer(), 32, Color.BLUE, Color.GREEN, Color.RED); // create command queue and upload color map buffer on each used device - queues[i] = devices[i].createCommandQueue(PROFILING_MODE).putWriteBuffer(colorMap[i], true); // blocking upload + queues[i] = devices[i].createCommandQueue(PROFILING_MODE).putWriteBuffer(colorMap.get(i), true); // blocking upload } @@ -260,20 +261,19 @@ public class MultiDeviceFractal implements GLEventListener { gl.glOrtho(0.0, width, 0.0, height, 0.0, 1.0); } - @SuppressWarnings("unchecked") private void initPBO(GL gl) { if(pboBuffers != null) { - int[] oldPbos = new int[pboBuffers.length]; - for (int i = 0; i < pboBuffers.length; i++) { - CLGLBuffer<?> buffer = pboBuffers[i]; + int[] oldPbos = new int[pboBuffers.size()]; + for (int i = 0; i < pboBuffers.size(); i++) { + CLGLBuffer<?> buffer = pboBuffers.get(i); oldPbos[i] = buffer.GLID; buffer.release(); } gl.glDeleteBuffers(oldPbos.length, oldPbos, 0); } - pboBuffers = new CLGLBuffer[slices]; + pboBuffers = new ArrayList<CLGLBuffer<?>>(slices); int[] pbo = new int[slices]; gl.glGenBuffers(slices, pbo, 0); @@ -286,7 +286,7 @@ public class MultiDeviceFractal implements GLEventListener { gl.glBufferData(GL_PIXEL_UNPACK_BUFFER, size, null, GL_STREAM_DRAW); gl.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); - pboBuffers[i] = clContext.createFromGLBuffer(pbo[i], size, WRITE_ONLY); + pboBuffers.add(clContext.createFromGLBuffer(pbo[i], size, WRITE_ONLY)); } buffersInitialized = true; @@ -342,9 +342,9 @@ public class MultiDeviceFractal implements GLEventListener { private void setKernelConstants() { for (int i = 0; i < slices; i++) { kernels[i].setForce32BitArgs(!doublePrecision || !isDoubleFPAvailable(queues[i].getDevice())) - .setArg(6, pboBuffers[i]) - .setArg(7, colorMap[i]) - .setArg(8, colorMap[i].getBuffer().capacity()) + .setArg(6, pboBuffers.get(i)) + .setArg(7, colorMap.get(i)) + .setArg(8, colorMap.get(i).getBuffer().capacity()) .setArg(9, MAX_ITERATIONS); } } @@ -388,9 +388,9 @@ public class MultiDeviceFractal implements GLEventListener { .rewind(); // aquire GL objects, and enqueue a kernel with a probe from the list - queues[i].putAcquireGLObject(pboBuffers[i]) + queues[i].putAcquireGLObject(pboBuffers.get(i)) .put2DRangeKernel(kernels[i], 0, 0, sliceWidth, height, 0, 0, probes) - .putReleaseGLObject(pboBuffers[i]); + .putReleaseGLObject(pboBuffers.get(i)); } @@ -413,7 +413,7 @@ public class MultiDeviceFractal implements GLEventListener { int seperatorOffset = drawSeperator?i:0; - gl.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboBuffers[i].GLID); + gl.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboBuffers.get(i).GLID); gl.glRasterPos2i(sliceWidth*i + seperatorOffset, 0); gl.glDrawPixels(sliceWidth, height, GL_BGRA, GL_UNSIGNED_BYTE, 0); diff --git a/src/com/jogamp/opencl/demos/hellojocl/HelloJOCL.java b/src/com/jogamp/opencl/demos/hellojocl/HelloJOCL.java index 70900eb..53cdd82 100644 --- a/src/com/jogamp/opencl/demos/hellojocl/HelloJOCL.java +++ b/src/com/jogamp/opencl/demos/hellojocl/HelloJOCL.java @@ -16,7 +16,7 @@ import static java.lang.Math.*; /** * Hello Java OpenCL example. Adds all elements of buffer A to buffer B - * and stores the result in buffer C.<br/> + * and stores the result in buffer C.<p> * Sample was inspired by the Nvidia VectorAdd example written in C/C++ * which is bundled in the Nvidia OpenCL SDK. * @author Michael Bien diff --git a/src/com/jogamp/opencl/demos/julia3d/Julia3d.java b/src/com/jogamp/opencl/demos/julia3d/Julia3d.java index 1118c2d..3f141db 100644 --- a/src/com/jogamp/opencl/demos/julia3d/Julia3d.java +++ b/src/com/jogamp/opencl/demos/julia3d/Julia3d.java @@ -52,7 +52,8 @@ public class Julia3d { updateCamera(); //setup, prefere GPUs - CLDevice device = CLPlatform.getDefault(type(GPU)).getMaxFlopsDevice(); + @SuppressWarnings("unchecked") + CLDevice device = CLPlatform.getDefault(type(GPU)).getMaxFlopsDevice(); if(device == null) { device = CLPlatform.getDefault().getMaxFlopsDevice(); } diff --git a/src/com/jogamp/opencl/demos/julia3d/UserSceneController.java b/src/com/jogamp/opencl/demos/julia3d/UserSceneController.java index 17b8956..ebceb15 100644 --- a/src/com/jogamp/opencl/demos/julia3d/UserSceneController.java +++ b/src/com/jogamp/opencl/demos/julia3d/UserSceneController.java @@ -175,7 +175,8 @@ public class UserSceneController { .setZ(orig.getZ()+zoom); } - private void rotateLightX(float k) { + @SuppressWarnings("unused") + private void rotateLightX(float k) { float[] light = model.getLight(); float y = light[1]; float z = light[2]; @@ -184,7 +185,8 @@ public class UserSceneController { model.setLight(light); } - private void rotateLightY(float k) { + @SuppressWarnings("unused") + private void rotateLightY(float k) { float[] light = model.getLight(); float x = light[0]; float z = light[2]; diff --git a/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig32.java b/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig32.java index 27f40e6..7364704 100644 --- a/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig32.java +++ b/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig32.java @@ -16,84 +16,84 @@ class RenderingConfig32 extends RenderingConfig { public RenderingConfig setWidth(int val) { - accessor.setIntAt(0, val); + accessor.setIntAt(4*0, val); return this; } public int getWidth() { - return accessor.getIntAt(0); + return accessor.getIntAt(4*0); } public RenderingConfig setHeight(int val) { - accessor.setIntAt(1, val); + accessor.setIntAt(4*1, val); return this; } public int getHeight() { - return accessor.getIntAt(1); + return accessor.getIntAt(4*1); } public RenderingConfig setSuperSamplingSize(int val) { - accessor.setIntAt(2, val); + accessor.setIntAt(4*2, val); return this; } public int getSuperSamplingSize() { - return accessor.getIntAt(2); + return accessor.getIntAt(4*2); } public RenderingConfig setActvateFastRendering(int val) { - accessor.setIntAt(3, val); + accessor.setIntAt(4*3, val); return this; } public int getActvateFastRendering() { - return accessor.getIntAt(3); + return accessor.getIntAt(4*3); } public RenderingConfig setEnableShadow(int val) { - accessor.setIntAt(4, val); + accessor.setIntAt(4*4, val); return this; } public int getEnableShadow() { - return accessor.getIntAt(4); + return accessor.getIntAt(4*4); } public RenderingConfig setMaxIterations(int val) { - accessor.setIntAt(5, val); + accessor.setIntAt(4*5, val); return this; } public int getMaxIterations() { - return accessor.getIntAt(5); + return accessor.getIntAt(4*5); } public RenderingConfig setEpsilon(float val) { - accessor.setFloatAt(6, val); + accessor.setFloatAt(4*6, val); return this; } public float getEpsilon() { - return accessor.getFloatAt(6); + return accessor.getFloatAt(4*6); } public RenderingConfig setMu(float[] val) { - accessor.setFloatsAt(8, val); + accessor.setFloatsAt(4*8, val); return this; } public float[] getMu() { - return accessor.getFloatsAt(8, new float[4]); + return accessor.getFloatsAt(4*8, new float[4]); } public RenderingConfig setLight(float[] val) { - accessor.setFloatsAt(12, val); + accessor.setFloatsAt(4*12, val); return this; } public float[] getLight() { - return accessor.getFloatsAt(12, new float[3]); + return accessor.getFloatsAt(4*12, new float[3]); } public Camera getCamera() { diff --git a/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig64.java b/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig64.java index e60987e..3396e42 100644 --- a/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig64.java +++ b/src/com/jogamp/opencl/demos/julia3d/structs/RenderingConfig64.java @@ -19,84 +19,84 @@ class RenderingConfig64 extends RenderingConfig { public RenderingConfig setWidth(int val) { - accessor.setIntAt(0, val); + accessor.setIntAt(4*0, val); return this; } public int getWidth() { - return accessor.getIntAt(0); + return accessor.getIntAt(4*0); } public RenderingConfig setHeight(int val) { - accessor.setIntAt(1, val); + accessor.setIntAt(4*1, val); return this; } public int getHeight() { - return accessor.getIntAt(1); + return accessor.getIntAt(4*1); } public RenderingConfig setSuperSamplingSize(int val) { - accessor.setIntAt(2, val); + accessor.setIntAt(4*2, val); return this; } public int getSuperSamplingSize() { - return accessor.getIntAt(2); + return accessor.getIntAt(4*2); } public RenderingConfig setActvateFastRendering(int val) { - accessor.setIntAt(3, val); + accessor.setIntAt(4*3, val); return this; } public int getActvateFastRendering() { - return accessor.getIntAt(3); + return accessor.getIntAt(4*3); } public RenderingConfig setEnableShadow(int val) { - accessor.setIntAt(4, val); + accessor.setIntAt(4*4, val); return this; } public int getEnableShadow() { - return accessor.getIntAt(4); + return accessor.getIntAt(4*4); } public RenderingConfig setMaxIterations(int val) { - accessor.setIntAt(5, val); + accessor.setIntAt(4*5, val); return this; } public int getMaxIterations() { - return accessor.getIntAt(5); + return accessor.getIntAt(4*5); } public RenderingConfig setEpsilon(float val) { - accessor.setFloatAt(6, val); + accessor.setFloatAt(4*6, val); return this; } public float getEpsilon() { - return accessor.getFloatAt(6); + return accessor.getFloatAt(4*6); } public RenderingConfig setMu(float[] val) { - accessor.setFloatsAt(7, val); + accessor.setFloatsAt(4*7, val); return this; } public float[] getMu() { - return accessor.getFloatsAt(7, new float[4]); + return accessor.getFloatsAt(4*7, new float[4]); } public RenderingConfig setLight(float[] val) { - accessor.setFloatsAt(11, val); + accessor.setFloatsAt(4*11, val); return this; } public float[] getLight() { - return accessor.getFloatsAt(11, new float[3]); + return accessor.getFloatsAt(4*11, new float[3]); } public Camera getCamera() { diff --git a/src/com/jogamp/opencl/demos/julia3d/structs/Vec32.java b/src/com/jogamp/opencl/demos/julia3d/structs/Vec32.java index e7668ac..09ea0d9 100644 --- a/src/com/jogamp/opencl/demos/julia3d/structs/Vec32.java +++ b/src/com/jogamp/opencl/demos/julia3d/structs/Vec32.java @@ -16,29 +16,29 @@ class Vec32 extends Vec { public Vec setX(float val) { - accessor.setFloatAt(0, val); + accessor.setFloatAt(4*0, val); return this; } public float getX() { - return accessor.getFloatAt(0); + return accessor.getFloatAt(4*0); } public Vec setY(float val) { - accessor.setFloatAt(1, val); + accessor.setFloatAt(4*1, val); return this; } public float getY() { - return accessor.getFloatAt(1); + return accessor.getFloatAt(4*1); } public Vec setZ(float val) { - accessor.setFloatAt(2, val); + accessor.setFloatAt(4*2, val); return this; } public float getZ() { - return accessor.getFloatAt(2); + return accessor.getFloatAt(4*2); } } diff --git a/src/com/jogamp/opencl/demos/julia3d/structs/Vec64.java b/src/com/jogamp/opencl/demos/julia3d/structs/Vec64.java index 60750a4..8731491 100644 --- a/src/com/jogamp/opencl/demos/julia3d/structs/Vec64.java +++ b/src/com/jogamp/opencl/demos/julia3d/structs/Vec64.java @@ -16,29 +16,29 @@ class Vec64 extends Vec { public Vec setX(float val) { - accessor.setFloatAt(0, val); + accessor.setFloatAt(4*0, val); return this; } public float getX() { - return accessor.getFloatAt(0); + return accessor.getFloatAt(4*0); } public Vec setY(float val) { - accessor.setFloatAt(1, val); + accessor.setFloatAt(4*1, val); return this; } public float getY() { - return accessor.getFloatAt(1); + return accessor.getFloatAt(4*1); } public Vec setZ(float val) { - accessor.setFloatAt(2, val); + accessor.setFloatAt(4*2, val); return this; } public float getZ() { - return accessor.getFloatAt(2); + return accessor.getFloatAt(4*2); } } diff --git a/src/com/jogamp/opencl/demos/radixsort/RadixSort.java b/src/com/jogamp/opencl/demos/radixsort/RadixSort.java index ceb9310..abfd621 100644 --- a/src/com/jogamp/opencl/demos/radixsort/RadixSort.java +++ b/src/com/jogamp/opencl/demos/radixsort/RadixSort.java @@ -62,7 +62,7 @@ public class RadixSort implements CLResource { program = context.createProgram(getClass().getResourceAsStream("RadixSort.cl")) .build(ENABLE_MAD, define("WARP_SIZE", WARP_SIZE)); -// out.println(program.getBuildLog()); +// System.out.println(program.getBuildLog()); ckRadixSortBlocksKeysOnly = program.createCLKernel("radixSortBlocksKeysOnly"); ckFindRadixOffsets = program.createCLKernel("findRadixOffsets"); diff --git a/src/com/jogamp/opencl/demos/radixsort/Scan.java b/src/com/jogamp/opencl/demos/radixsort/Scan.java index d5e158d..7fa1f09 100644 --- a/src/com/jogamp/opencl/demos/radixsort/Scan.java +++ b/src/com/jogamp/opencl/demos/radixsort/Scan.java @@ -21,11 +21,11 @@ import static com.jogamp.opencl.CLProgram.CompilerOptions.*; public class Scan implements CLResource { private final static int MAX_WORKGROUP_INCLUSIVE_SCAN_SIZE = 1024; - private final static int MAX_LOCAL_GROUP_SIZE = 256; +// private final static int MAX_LOCAL_GROUP_SIZE = 256; private final static int WORKGROUP_SIZE = 256; private final static int MAX_BATCH_ELEMENTS = 64 * 1048576; - private final static int MIN_SHORT_ARRAY_SIZE = 4; - private final static int MAX_SHORT_ARRAY_SIZE = 4 * WORKGROUP_SIZE; +// private final static int MIN_SHORT_ARRAY_SIZE = 4; +// private final static int MAX_SHORT_ARRAY_SIZE = 4 * WORKGROUP_SIZE; private final static int MIN_LARGE_ARRAY_SIZE = 8 * WORKGROUP_SIZE; private final static int MAX_LARGE_ARRAY_SIZE = 4 * WORKGROUP_SIZE * WORKGROUP_SIZE; diff --git a/src/com/jogamp/opencl/util/ExceptionReporter.java b/src/com/jogamp/opencl/util/ExceptionReporter.java index 17b92cc..d1c9c07 100644 --- a/src/com/jogamp/opencl/util/ExceptionReporter.java +++ b/src/com/jogamp/opencl/util/ExceptionReporter.java @@ -38,6 +38,7 @@ import javax.swing.WindowConstants; * * @author Michael Bien */ +@SuppressWarnings("serial") public class ExceptionReporter extends JDialog { public ExceptionReporter(Frame parent, boolean modal) { @@ -65,7 +66,6 @@ public class ExceptionReporter extends JDialog { * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { JLabel icon = new JLabel(); |