Changeset 2a658e9


Ignore:
Timestamp:
Sep 23, 2020, 12:56:32 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4ab3cf9b
Parents:
305cd5c
Message:

Updated java benchmarks to support repetitions beyond 232

Location:
benchmark
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • benchmark/creation/JavaThread.java

    r305cd5c r2a658e9  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("10000") ;
     28        static private long times = Long.parseLong("10000") ;
    2929
    3030        public static class MyThread extends Thread {
     
    3333        }
    3434        public static void helper() throws InterruptedException {
    35                 for(int i = 1; i <= times; i += 1) {
     35                for(long i = 1; i <= times; i += 1) {
    3636                        MyThread m = new MyThread();
    3737                        x = nextRandom( x );
     
    4848        public static void main(String[] args) throws InterruptedException {
    4949                if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     50                if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
    5151
    52                 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 
     52                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
    5353                        InnerMain();
    5454                        Thread.sleep(2000);             // 2 seconds
  • benchmark/ctxswitch/JavaThread.java

    r305cd5c r2a658e9  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000");
     28        static private long times = Long.parseLong("100000");
    2929
    3030        public static void helper() {
    31                 for(int i = 1; i <= times; i += 1) {
     31                for(long i = 1; i <= times; i += 1) {
    3232                        Thread.yield();
    3333                }
     
    4141        public static void main(String[] args) throws InterruptedException {
    4242                if ( args.length > 2 ) System.exit( 1 );
    43                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     43                if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
    4444
    4545                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
  • benchmark/mutex/JavaThread.java

    r305cd5c r2a658e9  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000000");
     28        static private long times = Long.parseLong("100000000");
    2929
    3030        public synchronized void noop() {
     
    3434                JavaThread j = new JavaThread();
    3535                // Inhibit biased locking ...
    36                 x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;     
    37                 for(int i = 1; i <= times; i += 1) {
     36                x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;
     37                for(long i = 1; i <= times; i += 1) {
    3838                        x = nextRandom(x);
    3939                        j.noop();
     
    4848        public static void main(String[] args) throws InterruptedException {
    4949                if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     50                if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
    5151
    52                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 
     52                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    5353                        InnerMain();
    5454                        Thread.sleep(2000);     // 2 seconds
  • benchmark/mutexC/JavaThread.java

    r305cd5c r2a658e9  
    11class Noop {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        public static int nextRandom( int x ) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626}
     
    4747        static int x = 2;
    4848
    49         static private int times = Integer.parseInt("10000000");
     49        static private long times = Long.parseLong("10000000");
    5050
    5151        public static void call( Monitor m ) throws InterruptedException {
     
    5353                m.go = true;
    5454                //while ( ! m.go2 );
    55                 for ( int i = 0; i < times; i += 1 ) {
     55                for ( long i = 0; i < times; i += 1 ) {
    5656                        m.call();
    5757                        x = Noop.nextRandom( x );
     
    7171        public static void main( String[] args ) throws InterruptedException {
    7272                if ( args.length > 2 ) System.exit( 1 );
    73                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     73                if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
    7474
    75                 if ( args.length > 2 ) System.exit( 1 );
    76                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
    77 
    78                 for ( int i = Integer.parseInt("5"); --i >= 0 ; ) {
     75                for ( int i = Integer.parseInt("5"); --i >= 0 ; ) {
    7976                        InnerMain();
    8077                        // Thread.sleep(2000);  // 2 seconds
  • benchmark/schedint/JavaThread.java

    r305cd5c r2a658e9  
    2424public class JavaThread {
    2525        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    26         // Bijective   
     26        // Bijective
    2727        // Cycle length for non-zero values is 4G-1.
    2828        // 0 is absorbing and should be avoided -- fixed point.
    2929        // The returned value is typically masked to produce a positive value.
    30         static volatile int Ticket = 0 ; 
     30        static volatile int Ticket = 0 ;
    3131
    3232        private static int nextRandom (int x) {
    33                 if (x == 0) { 
     33                if (x == 0) {
    3434                        // reseed the PRNG
    35                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    36                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    37                         // If the race is a concern switch to an AtomicInteger. 
    38                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    39                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    40                         // nextRandom() invocations. 
    41                         x = ++Ticket ; 
    42                         if (x == 0) x = 1 ; 
     35                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     36                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     37                        // If the race is a concern switch to an AtomicInteger.
     38                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     39                        // (readily) predictable at compile-time so the JIT will not be able to elide
     40                        // nextRandom() invocations.
     41                        x = ++Ticket ;
     42                        if (x == 0) x = 1 ;
    4343                }
    4444                x ^= x << 6;
    4545                x ^= x >>> 21;
    4646                x ^= x << 7;
    47                 return x ;   
     47                return x ;
    4848        }
    4949        static int x = 2;
    5050
    51         static private int times = Integer.parseInt("1000000");
     51        static private long times = Long.parseLong("1000000");
    5252
    5353        public static void helper( Monitor m ) throws InterruptedException {
    54                 for(int i = 1; i <= times; i += 1) {
     54                for(long i = 1; i <= times; i += 1) {
    5555                        m.wait();               // relase monitor lock
    5656                        m.next = true;
     
    7676        public static void main(String[] args) throws InterruptedException {
    7777                if ( args.length > 2 ) System.exit( 1 );
    78                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     78                if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
    7979
    80                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 
     80                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    8181                        InnerMain();
    8282                        Thread.sleep(2000);     // 2 seconds
Note: See TracChangeset for help on using the changeset viewer.