Example #1
0
  protected void createWalk(int vsize) {
    // We do a random copy order to attempt to get multiple threads
    // reading and writing the same cache line
    // We could do this as a simple walk but that would likely miss
    // some caching issues.
    final int tw = gCount / vsize;
    int tmp[] = new int[tw];
    boolean b[] = new boolean[tw];
    int toCopy = tw;
    int i = 0;

    while (toCopy > 0) {
      int x = random.nextInt(tw);

      while ((x < tw) && b[x]) {
        x++;
        if (x >= tw) {
          x = 0;
        }
      }

      b[x] = true;
      toCopy--;

      // android.util.Log.v("rs", "walk  " + i + ", " + x);
      tmp[i++] = x;
    }

    walkAlloc = Allocation.createSized(mRS, Element.I32(mRS), tw);
    walkAlloc.copy1DRangeFrom(0, tw, tmp);
  }
Example #2
0
 private int[] randomIntArray(int len) {
   int t[] = new int[len];
   for (int i = 0; i < t.length; i++) {
     t[i] = random.nextInt();
   }
   in1DAlloc.copyFrom(t);
   in2DAlloc.copyFrom(t);
   in3DAlloc.copyFrom(t);
   return t;
 }
Example #3
0
 private short[] randomShortArray(int len) {
   short t[] = new short[len];
   for (int i = 0; i < t.length; i++) {
     t[i] = (short) (random.nextInt() & 0xffff);
   }
   in1DAlloc.copyFrom(t);
   in2DAlloc.copyFrom(t);
   in3DAlloc.copyFrom(t);
   return t;
 }