From 422b8ddd66fe536f5051a9b8fe18f043a495d940 Mon Sep 17 00:00:00 2001 From: adash Date: Mon, 15 Jun 2009 21:08:55 +0000 Subject: [PATCH] files modified for Bayes benchmark --- .../Benchmarks/SingleTM/Genome/Genome.java | 2 +- .../Benchmarks/SingleTM/common/BitMap.java | 28 +++++++------------ .../Benchmarks/SingleTM/common/QuickSort.java | 14 ++++++---- .../Benchmarks/SingleTM/common/Vector_t.java | 7 +++-- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/Genome/Genome.java b/Robust/src/Benchmarks/SingleTM/Genome/Genome.java index 4fa26000..b44620e0 100644 --- a/Robust/src/Benchmarks/SingleTM/Genome/Genome.java +++ b/Robust/src/Benchmarks/SingleTM/Genome/Genome.java @@ -91,7 +91,7 @@ public class Genome extends Thread { System.out.println("Number threads = " + g.numThread); - Barrier.setBarrier((int)g.numThread); + Barrier.setBarrier(g.numThread); /* Create and Start Threads */ diff --git a/Robust/src/Benchmarks/SingleTM/common/BitMap.java b/Robust/src/Benchmarks/SingleTM/common/BitMap.java index 7bc2f922..25cb8fe7 100644 --- a/Robust/src/Benchmarks/SingleTM/common/BitMap.java +++ b/Robust/src/Benchmarks/SingleTM/common/BitMap.java @@ -7,8 +7,8 @@ * Copyright (C) Stanford University, 2006. All Rights Reserved. * Author: Chi Cao Minh * - * Ported to Java: - * Author:Alokika dash + * Ported to Java June 2009 Alokika Dash + * adash@uci.edu * University of California, Irvine * * ============================================================================= @@ -105,10 +105,9 @@ public class BitMap { * ============================================================================= */ public void - bitmap_free (BitMap bitmapPtr) + bitmap_free () { - bitmapPtr.bits = null; - bitmapPtr = null; + bits = null; //free(bitmapPtr.bits); //free(bitmapPtr); } @@ -195,8 +194,9 @@ public class BitMap { public boolean bitmap_isSet (int i) { + int val = bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD)); if ((i >= 0) && (i < numBit) && - (bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD)))) { + (val != 0)) { return true; } @@ -218,8 +218,9 @@ public class BitMap { int[] tmp_bits = bits; //uint_t* bits = bitmapPtr.bits; - for (int i = MAX(startIndex, 0); i < tmp_numBit; i++) { - if (!(tmp_bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD)))) { + for (int i = Math.imax(startIndex, 0); i < tmp_numBit; i++) { + int val = tmp_bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD)); + if(val == 0) { return i; } } @@ -243,7 +244,7 @@ public class BitMap { int numBit = bitmapPtr.numBit; uint_t* bits = bitmapPtr.bits; - for (i = MAX(startIndex, 0); i < numBit; i++) { + for (i = Math.imax(startIndex, 0); i < numBit; i++) { if (bits[i/NUM_BIT_PER_WORD] & (1UL << (i % NUM_BIT_PER_WORD))) { return i; } @@ -322,15 +323,6 @@ public class BitMap { } } */ - - /** - * ====================================== - * MAX(a.b) - * ====================================== - **/ - public int MAX(int a, int b) { - return (a > b) ? a : b; - } } /* ============================================================================= diff --git a/Robust/src/Benchmarks/SingleTM/common/QuickSort.java b/Robust/src/Benchmarks/SingleTM/common/QuickSort.java index 1e5e10dc..4ee8271a 100644 --- a/Robust/src/Benchmarks/SingleTM/common/QuickSort.java +++ b/Robust/src/Benchmarks/SingleTM/common/QuickSort.java @@ -4,7 +4,7 @@ public class QuickSort { } - public static void swap (int A[], int x, int y) + public void swap (int A[], int x, int y) { int temp = A[x]; A[x] = A[y]; @@ -13,7 +13,7 @@ public class QuickSort { // Reorganizes the given list so all elements less than the first are // before it and all greater elements are after it. - public static int partition(int A[], int left, int right) + public int partition(int a[], int left, int right) { int i = left - 1; int j = right; @@ -29,11 +29,15 @@ public class QuickSort { return i; } - public static void Quicksort(int A[], int f, int l) + public void sort(int A[], int f, int l) { if (f >= l) return; int pivot_index = partition(A, f, l); - Quicksort(A, f, pivot_index); - Quicksort(A, pivot_index+1, l); + sort(A, f, pivot_index); + sort(A, pivot_index+1, l); + } + + boolean less(int x, int y) { + return(x