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 byte[] randomByteArray(int len) {
   byte t[] = new byte[len];
   random.nextBytes(t);
   in1DAlloc.copyFrom(t);
   in2DAlloc.copyFrom(t);
   in3DAlloc.copyFrom(t);
   return t;
 }
Example #3
0
 private double[] randomDoubleArray(int len) {
   double t[] = new double[len];
   for (int i = 0; i < t.length; i++) {
     t[i] = random.nextDouble();
   }
   in1DAlloc.copyFrom(t);
   in2DAlloc.copyFrom(t);
   in3DAlloc.copyFrom(t);
   return t;
 }
Example #4
0
 private float[] randomFloatArray(int len) {
   float t[] = new float[len];
   for (int i = 0; i < t.length; i++) {
     t[i] = random.nextFloat();
   }
   in1DAlloc.copyFrom(t);
   in2DAlloc.copyFrom(t);
   in3DAlloc.copyFrom(t);
   return t;
 }
Example #5
0
 private long[] randomLongArray(int len) {
   long t[] = new long[len];
   for (int i = 0; i < t.length; i++) {
     t[i] = random.nextLong();
   }
   in1DAlloc.copyFrom(t);
   in2DAlloc.copyFrom(t);
   in3DAlloc.copyFrom(t);
   return t;
 }
Example #6
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 #7
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;
 }
Example #8
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   random.setSeed(10);
   script = new ScriptC_getset(mRS);
   scriptRelaxed = new ScriptC_getset_relaxed(mRS);
   script.set_gWidth(gWidth);
   script.set_gHeight(gHeight);
   scriptRelaxed.set_gWidth(gWidth);
   scriptRelaxed.set_gHeight(gHeight);
 }