summaryrefslogtreecommitdiffstats
path: root/test/com/mbien/opencl/JOCLTest.java
blob: 053f22d38dd1c73f913ab7a3bc10d91a535a2c0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.mbien.opencl;

import com.mbien.opencl.impl.CLImpl;
import java.nio.ByteBuffer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Michael Bien
 */
public class JOCLTest {

    public JOCLTest() {
    }

    @Before
    public void setUpClass() throws Exception {
    }

    @After
    public void tearDownClass() throws Exception {
    }

    @Test
    public void basicTest() {
//        System.out.println(0xFFFFFFFF);
//        System.out.println(0xFFFFFFFE);
//        System.out.println(0xFFFFFFFD);

        System.out.print("loading native libs...");
        System.loadLibrary("gluegen-rt");
        System.loadLibrary("jocl");
        System.out.println("done");

        CreateContextCallback cb = new CreateContextCallback() {
            @Override
            public void createContextCallback(String errinfo, ByteBuffer private_info, long cb, Object user_data) {
                throw new RuntimeException(errinfo);
            }
        };

        System.out.println("creating OpenCL context");

        CLImpl impl = new CLImpl();

        long context = impl.clCreateContextFromType(null, CL.CL_DEVICE_TYPE_ALL, cb, null, null);
        System.out.println("context handle: "+context);

        int[] buffer = new int[1];
        impl.clGetContextInfo(context, CL.CL_CONTEXT_NUM_DEVICES, 0, null, buffer, 0);
        System.out.println("CL_CONTEXT_NUM_DEVICES result: "+buffer[0]);


    }


}