summaryrefslogtreecommitdiffstats
path: root/test/com/mbien/opencl/TestUtils.java
blob: 70bade8a8f355f399bf3e069bc9db9b5ee748d11 (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
package com.mbien.opencl;

import java.nio.ByteBuffer;
import java.util.Random;

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

    public static final void fillBuffer(ByteBuffer buffer, int seed) {

        Random rnd = new Random(seed);

        while(buffer.remaining() != 0)
            buffer.putInt(rnd.nextInt());

        buffer.rewind();
    }

    public static final int roundUp(int groupSize, int globalSize) {
        int r = globalSize % groupSize;
        if (r == 0) {
            return globalSize;
        } else {
            return globalSize + groupSize - r;
        }
    }
}