Examples of AtomicIntegerArray


Examples of java.util.concurrent.atomic.AtomicIntegerArray

                out.writeNull();
            }
            return;
        }

        AtomicIntegerArray array = (AtomicIntegerArray) object;
        int len = array.length();
        out.append('[');
        for (int i = 0; i < len; ++i) {
            int val = array.get(i);
            if (i != 0) {
                out.write(',');
            }
            out.writeInt(val);
        }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

        drainedOrder = Integer.MIN_VALUE;
        evictionLock = new ReentrantLock();
        evictionDeque = new LinkedDeque<Node>();
        drainStatus = new AtomicReference<DrainStatus>(IDLE);

        bufferLengths = new AtomicIntegerArray(NUMBER_OF_BUFFERS);
        buffers = (Queue<Task>[]) new Queue[NUMBER_OF_BUFFERS];
        for (int i = 0; i < NUMBER_OF_BUFFERS; i++) {
            buffers[i] = new ConcurrentLinkedQueue<Task>();
        }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    }
    System.out.println("PASSED");
  }

  static int test(boolean test_only) {
    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
    // Initialize
    for (int i=0; i<ARRLEN; i++) {
      a1.set(i, -1);
      a2.set(i, -1);
    }
    System.out.println("Warmup");
    for (int i=0; i<ITERS; i++) {
      test_ci(a1);
      test_vi(a2, 123, -1);
      test_cp(a1, a2);
      test_2ci(a1, a2);
      test_2vi(a1, a2, 123, 103);
      test_ci_neg(a1, 123);
      test_vi_neg(a2, 123, 103);
      test_cp_neg(a1, a2);
      test_2ci_neg(a1, a2);
      test_2vi_neg(a1, a2, 123, 103);
      test_ci_oppos(a1, 123);
      test_vi_oppos(a2, 123, 103);
      test_cp_oppos(a1, a2);
      test_2ci_oppos(a1, a2);
      test_2vi_oppos(a1, a2, 123, 103);
      test_ci_off(a1, 123);
      test_vi_off(a2, 123, 103);
      test_cp_off(a1, a2);
      test_2ci_off(a1, a2);
      test_2vi_off(a1, a2, 123, 103);
      test_ci_inv(a1, OFFSET, 123);
      test_vi_inv(a2, 123, OFFSET, 103);
      test_cp_inv(a1, a2, OFFSET);
      test_2ci_inv(a1, a2, OFFSET);
      test_2vi_inv(a1, a2, 123, 103, OFFSET);
      test_ci_scl(a1, 123);
      test_vi_scl(a2, 123, 103);
      test_cp_scl(a1, a2);
      test_2ci_scl(a1, a2);
      test_2vi_scl(a1, a2, 123, 103);
      test_cp_alndst(a1, a2);
      test_cp_alnsrc(a1, a2);
      test_2ci_aln(a1, a2);
      test_2vi_aln(a1, a2, 123, 103);
      test_cp_unalndst(a1, a2);
      test_cp_unalnsrc(a1, a2);
      test_2ci_unaln(a1, a2);
      test_2vi_unaln(a1, a2, 123, 103);
    }
    // Initialize
    for (int i=0; i<ARRLEN; i++) {
      a1.set(i, -1);
      a2.set(i, -1);
    }
    // Test and verify results
    System.out.println("Verification");
    int errn = 0;
    {
      test_ci(a1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_ci: a1", i, a1.get(i), -123);
      }
      test_vi(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_vi: a2", i, a2.get(i), 123);
      }
      test_cp(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_cp: a1", i, a1.get(i), 123);
      }
      test_2ci(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2ci: a1", i, a1.get(i), -123);
        errn += verify("test_2ci: a2", i, a2.get(i), -103);
      }
      test_2vi(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2vi: a1", i, a1.get(i), 123);
        errn += verify("test_2vi: a2", i, a2.get(i), 103);
      }
      // Reset for negative stride
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_neg(a1, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
      }
      test_vi_neg(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
      }
      test_cp_neg(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
      }
      test_2ci_neg(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
      }
      test_2vi_neg(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
      }
      // Reset for opposite stride
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_oppos(a1, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
      }
      test_vi_oppos(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
      }
      test_cp_oppos(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
      }
      test_2ci_oppos(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
      }
      test_2vi_oppos(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
      }
      // Reset for indexing with offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_off(a1, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
      }
      test_vi_off(a2, 123, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
      }
      test_cp_off(a1, a2);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
      }
      test_2ci_off(a1, a2);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
      }
      test_2vi_off(a1, a2, 123, 103);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
      }
      for (int i=0; i<OFFSET; i++) {
        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
      }
      // Reset for indexing with invariant offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_inv(a1, OFFSET, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
      }
      test_vi_inv(a2, 123, OFFSET, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
      }
      test_cp_inv(a1, a2, OFFSET);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
      }
      test_2ci_inv(a1, a2, OFFSET);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
      }
      test_2vi_inv(a1, a2, 123, 103, OFFSET);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
      }
      for (int i=0; i<OFFSET; i++) {
        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
      }
      // Reset for indexing with scale
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_scl(a1, -1);
      for (int i=0; i<ARRLEN; i++) {
        int val = (i%SCALE != 0) ? -1 : -123;
        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
      }
      test_vi_scl(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        int val = (i%SCALE != 0) ? -1 : 123;
        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
      }
      test_cp_scl(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        int val = (i%SCALE != 0) ? -1 : 123;
        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
      }
      test_2ci_scl(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        if (i%SCALE != 0) {
          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
        }
        if (i%SCALE != 0) {
          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
        }
      }
      test_2vi_scl(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        if (i%SCALE != 0) {
          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
        }
        if (i%SCALE != 0) {
          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
        }
      }
      // Reset for 2 arrays with relative aligned offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_vi(a2, 123, -1);
      test_cp_alndst(a1, a2);
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
      }
      for (int i=0; i<ALIGN_OFF; i++) {
        a1.set(i, 123);
      }
      test_vi(a2, -123, 123);
      test_cp_alnsrc(a1, a2);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2ci_aln(a1, a2);
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2vi_aln(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
      }
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
      }

      // Reset for 2 arrays with relative unaligned offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_vi(a2, 123, -1);
      test_cp_unalndst(a1, a2);
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
      }
      test_vi(a2, -123, 123);
      test_cp_unalnsrc(a1, a2);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2ci_unaln(a1, a2);
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2vi_unaln(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
      }
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
      }

      // Reset for aligned overlap initialization
      for (int i=0; i<ALIGN_OFF; i++) {
        a1.set(i, i);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_cp_alndst(a1, a1);
      for (int i=0; i<ARRLEN; i++) {
        int v = i%ALIGN_OFF;
        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<ALIGN_OFF; i++) {
        a1.set((i+ALIGN_OFF), -1);
      }
      test_cp_alnsrc(a1, a1);
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        int v = i%ALIGN_OFF;
        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2ci_aln(a1, a1);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2vi_aln(a1, a1, 123, 103);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
      }

      // Reset for unaligned overlap initialization
      for (int i=0; i<UNALIGN_OFF; i++) {
        a1.set(i, i);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_cp_unalndst(a1, a1);
      for (int i=0; i<ARRLEN; i++) {
        int v = i%UNALIGN_OFF;
        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<UNALIGN_OFF; i++) {
        a1.set((i+UNALIGN_OFF), -1);
      }
      test_cp_unalnsrc(a1, a1);
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        int v = i%UNALIGN_OFF;
        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2ci_unaln(a1, a1);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2vi_unaln(a1, a1, 123, 103);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
      }

    }

    if (errn > 0 || test_only)
      return errn;

    // Initialize
    for (int i=0; i<ARRLEN; i++) {
      a1.set(i, -1);
      a2.set(i, -1);
    }
    System.out.println("Time");
    long start, end;
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    }
    System.out.println("PASSED");
  }

  static int test(boolean test_only) {
    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
    // Initialize
    for (int i=0; i<ARRLEN; i++) {
      a1.set(i, -1);
      a2.set(i, -1);
    }
    System.out.println("Warmup");
    for (int i=0; i<ITERS; i++) {
      test_ci(a1);
      test_vi(a2, 123, -1);
      test_cp(a1, a2);
      test_2ci(a1, a2);
      test_2vi(a1, a2, 123, 103);
      test_ci_neg(a1, 123);
      test_vi_neg(a2, 123, 103);
      test_cp_neg(a1, a2);
      test_2ci_neg(a1, a2);
      test_2vi_neg(a1, a2, 123, 103);
      test_ci_oppos(a1, 123);
      test_vi_oppos(a2, 123, 103);
      test_cp_oppos(a1, a2);
      test_2ci_oppos(a1, a2);
      test_2vi_oppos(a1, a2, 123, 103);
      test_ci_off(a1, 123);
      test_vi_off(a2, 123, 103);
      test_cp_off(a1, a2);
      test_2ci_off(a1, a2);
      test_2vi_off(a1, a2, 123, 103);
      test_ci_inv(a1, OFFSET, 123);
      test_vi_inv(a2, 123, OFFSET, 103);
      test_cp_inv(a1, a2, OFFSET);
      test_2ci_inv(a1, a2, OFFSET);
      test_2vi_inv(a1, a2, 123, 103, OFFSET);
      test_ci_scl(a1, 123);
      test_vi_scl(a2, 123, 103);
      test_cp_scl(a1, a2);
      test_2ci_scl(a1, a2);
      test_2vi_scl(a1, a2, 123, 103);
      test_cp_alndst(a1, a2);
      test_cp_alnsrc(a1, a2);
      test_2ci_aln(a1, a2);
      test_2vi_aln(a1, a2, 123, 103);
      test_cp_unalndst(a1, a2);
      test_cp_unalnsrc(a1, a2);
      test_2ci_unaln(a1, a2);
      test_2vi_unaln(a1, a2, 123, 103);
    }
    // Initialize
    for (int i=0; i<ARRLEN; i++) {
      a1.set(i, -1);
      a2.set(i, -1);
    }
    // Test and verify results
    System.out.println("Verification");
    int errn = 0;
    {
      test_ci(a1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_ci: a1", i, a1.get(i), -123);
      }
      test_vi(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_vi: a2", i, a2.get(i), 123);
      }
      test_cp(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_cp: a1", i, a1.get(i), 123);
      }
      test_2ci(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2ci: a1", i, a1.get(i), -123);
        errn += verify("test_2ci: a2", i, a2.get(i), -103);
      }
      test_2vi(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2vi: a1", i, a1.get(i), 123);
        errn += verify("test_2vi: a2", i, a2.get(i), 103);
      }
      // Reset for negative stride
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_neg(a1, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
      }
      test_vi_neg(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
      }
      test_cp_neg(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
      }
      test_2ci_neg(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
      }
      test_2vi_neg(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
      }
      // Reset for opposite stride
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_oppos(a1, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
      }
      test_vi_oppos(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
      }
      test_cp_oppos(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
      }
      test_2ci_oppos(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
      }
      test_2vi_oppos(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
      }
      // Reset for indexing with offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_off(a1, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
      }
      test_vi_off(a2, 123, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
      }
      test_cp_off(a1, a2);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
      }
      test_2ci_off(a1, a2);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
      }
      test_2vi_off(a1, a2, 123, 103);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
      }
      for (int i=0; i<OFFSET; i++) {
        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
      }
      // Reset for indexing with invariant offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_inv(a1, OFFSET, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
      }
      test_vi_inv(a2, 123, OFFSET, -1);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
      }
      test_cp_inv(a1, a2, OFFSET);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
      }
      test_2ci_inv(a1, a2, OFFSET);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
      }
      test_2vi_inv(a1, a2, 123, 103, OFFSET);
      for (int i=OFFSET; i<ARRLEN; i++) {
        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
      }
      for (int i=0; i<OFFSET; i++) {
        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
      }
      // Reset for indexing with scale
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_ci_scl(a1, -1);
      for (int i=0; i<ARRLEN; i++) {
        int val = (i%SCALE != 0) ? -1 : -123;
        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
      }
      test_vi_scl(a2, 123, -1);
      for (int i=0; i<ARRLEN; i++) {
        int val = (i%SCALE != 0) ? -1 : 123;
        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
      }
      test_cp_scl(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        int val = (i%SCALE != 0) ? -1 : 123;
        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
      }
      test_2ci_scl(a1, a2);
      for (int i=0; i<ARRLEN; i++) {
        if (i%SCALE != 0) {
          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
        }
        if (i%SCALE != 0) {
          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
        }
      }
      test_2vi_scl(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN; i++) {
        if (i%SCALE != 0) {
          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
        }
        if (i%SCALE != 0) {
          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
        } else if (i*SCALE < ARRLEN) {
          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
        }
      }
      // Reset for 2 arrays with relative aligned offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_vi(a2, 123, -1);
      test_cp_alndst(a1, a2);
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
      }
      for (int i=0; i<ALIGN_OFF; i++) {
        a1.set(i, 123);
      }
      test_vi(a2, -123, 123);
      test_cp_alnsrc(a1, a2);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2ci_aln(a1, a2);
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2vi_aln(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
      }
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
      }

      // Reset for 2 arrays with relative unaligned offset
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_vi(a2, 123, -1);
      test_cp_unalndst(a1, a2);
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
      }
      test_vi(a2, -123, 123);
      test_cp_unalnsrc(a1, a2);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2ci_unaln(a1, a2);
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
        a2.set(i, -1);
      }
      test_2vi_unaln(a1, a2, 123, 103);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
      }
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
      }

      // Reset for aligned overlap initialization
      for (int i=0; i<ALIGN_OFF; i++) {
        a1.set(i, i);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_cp_alndst(a1, a1);
      for (int i=0; i<ARRLEN; i++) {
        int v = i%ALIGN_OFF;
        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<ALIGN_OFF; i++) {
        a1.set((i+ALIGN_OFF), -1);
      }
      test_cp_alnsrc(a1, a1);
      for (int i=0; i<ALIGN_OFF; i++) {
        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
      }
      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
        int v = i%ALIGN_OFF;
        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2ci_aln(a1, a1);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2vi_aln(a1, a1, 123, 103);
      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
      }

      // Reset for unaligned overlap initialization
      for (int i=0; i<UNALIGN_OFF; i++) {
        a1.set(i, i);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_cp_unalndst(a1, a1);
      for (int i=0; i<ARRLEN; i++) {
        int v = i%UNALIGN_OFF;
        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<UNALIGN_OFF; i++) {
        a1.set((i+UNALIGN_OFF), -1);
      }
      test_cp_unalnsrc(a1, a1);
      for (int i=0; i<UNALIGN_OFF; i++) {
        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
      }
      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
        int v = i%UNALIGN_OFF;
        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2ci_unaln(a1, a1);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
      }
      for (int i=0; i<ARRLEN; i++) {
        a1.set(i, -1);
      }
      test_2vi_unaln(a1, a1, 123, 103);
      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
      }
      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
      }

    }

    if (errn > 0 || test_only)
      return errn;

    // Initialize
    for (int i=0; i<ARRLEN; i++) {
      a1.set(i, -1);
      a2.set(i, -1);
    }
    System.out.println("Time");
    long start, end;
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

public class AtomicBitSet {
    private final AtomicIntegerArray array;

    public AtomicBitSet(int length) {
        int intLength = (length + 31) / 32;
        array = new AtomicIntegerArray(intLength);
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    drainedOrder = Integer.MIN_VALUE;
    evictionLock = new ReentrantLock();
    evictionDeque = new LinkedDeque<Node>();
    drainStatus = new AtomicReference<DrainStatus>(IDLE);

    bufferLengths = new AtomicIntegerArray(NUMBER_OF_BUFFERS);
    buffers = (Queue<Task>[]) new Queue[NUMBER_OF_BUFFERS];
    for (int i = 0; i < NUMBER_OF_BUFFERS; i++) {
      buffers[i] = new ConcurrentLinkedQueue<Task>();
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    atomicIntegers = new AtomicInteger[THREAD_COUNT];
    for (int i = 0; i < atomicIntegers.length; ++i) {
      atomicIntegers[i] = new AtomicInteger(0);
    }

    atomicIntegerArray = new AtomicIntegerArray(new int[THREAD_COUNT]);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.