Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/com/jogamp/opencl/demos/bitonicsort/BitonicSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.jogamp.opencl.CLCommandQueue;
import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLDevice;
import com.jogamp.opencl.CLDevice.Type;
import com.jogamp.opencl.CLKernel;
import com.jogamp.opencl.CLProgram;
import java.io.IOException;
Expand All @@ -21,7 +22,9 @@
/**
* Bitonic sort optimized for GPUs.
* Uses NVIDIA's bitonic merge sort kernel.
*
* @author Michael Bien
* @author rexguo (bug fix for OSX)
*/
public class BitonicSort {

Expand All @@ -46,9 +49,24 @@ public BitonicSort() throws IOException {

try{

context = CLContext.create();
/**
* It is possible that a CPU context is created on
* machines with under-powered GPUs. So we explicitly
* ask for a GPU device.
*
* On CPU devices on OSX 10.6.8, Core 2 Duo 3GHz, trying
* to setup the workgroup size results in:
* Exception in thread "main" java.lang.RuntimeException:
* Minimum work-group size 512 required by this application
* is not supported on this device.
*/
context = CLContext.create(Type.GPU);
CLCommandQueue queue = context.getMaxFlopsDevice().createCommandQueue();

out.println(context);
out.println(context.getMaxFlopsDevice());
out.println();

out.println("Initializing OpenCL bitonic sorter...");
kernels = initBitonicSort(queue);

Expand Down