Pascal's Weblog
The Grid...



Archives
« December 2009
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today
Click me to subscribe
Search

Links
 

Today's Page Hits: 21

« Previous page | Main
Monday Aug 14, 2006
Mersenne Primes
Mersenne primes are primes of the form: 2^p-1
Mersenne primes are found using the Lucas-Lehmer Test.

A simple Java implementation of this test taking advantage of the BigInteger class is the following:

import java.math.*;
public class Mersenne {

  static final BigInteger one  = new BigInteger("1");
  static final BigInteger two  = new BigInteger("2");
  static final BigInteger four = new BigInteger("4");

  private static boolean LucasLehmerTest(int p) {
    BigInteger s = four;
    BigInteger n = one.shiftLeft(p).subtract(one);
    for (int i = 3; i <= p; i++) {
      s = s.multiply(s).subtract(two).mod(n);
    }
    if (s.bitCount() == 0) {
      return true;
    } else {
      return false;
    }
  }

  public static void main(String[] args) {
    for (int i = 0; i < 5000; i++) {
      if (LucasLehmerTest(i)) {
        System.out.println("2^" + i + "-1 is prime");
      }
    }
  }

}

Ant the output will look like:
2^3-1 is prime
2^5-1 is prime
2^7-1 is prime
2^13-1 is prime
2^17-1 is prime
2^19-1 is prime
2^31-1 is prime
2^61-1 is prime
2^89-1 is prime
2^107-1 is prime
2^127-1 is prime
2^521-1 is prime
2^607-1 is prime
2^1279-1 is prime
2^2203-1 is prime
2^2281-1 is prime
2^3217-1 is prime
2^4253-1 is prime
2^4423-1 is prime

(Of course 2^2-1 is also prime!).
Well, this program does not exactly take advantage of the full power of the Grid (The run took 1.189 hour)! All the computation is done by just one CPU! Let see, if we can rewrite this program to take advantage of the Grid...
Posted at 01:43PM Aug 14, 2006 by Pascal Ledru in Grid Computing  |  Comments[0]

Grid server
Want to actually check what are the underlying servers used by the Grid? Create a small script such as:

cat /etc/release

/usr/sbin/prtconf

/usr/sbin/psrinfo -v

Submit it as a job to the grid. Extract the result from the output zip file. You should get something such as:
                          Solaris 10 3/05 s10_74L2a X86
           Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 22 January 2005
System Configuration:  Sun Microsystems  i86pc
Memory size: 7808 Megabytes
System Peripherals (Software Nodes):

i86pc
    scsi_vhci, instance #0
    ib, instance #0
        rpcib, instance #0
        daplt, instance #0
    isa, instance #0
        motherboard (driver not attached)
        i8042, instance #0
            mouse, instance #0
            keyboard, instance #0
        asy, instance #0
        fdc, instance #0
            fd, instance #0
            fd, instance #1 (driver not attached)
    pci, instance #0
        pci1022,7460, instance #0
            pci17c2,10, instance #0
            pci17c2,10, instance #1
            display, instance #0
        pci17c2,10 (driver not attached)
        pci-ide, instance #0
            ide, instance #0 (driver not attached)
            ide, instance #1
                sd, instance #0
                st, instance #7 (driver not attached)
        pci1022,7450, instance #1
            pci17c2,10, instance #0
            pci17c2,10, instance #1
            pci17c2,10, instance #0
                sd, instance #1 (driver not attached)
                sd, instance #2
                sd, instance #3 (driver not attached)
                sd, instance #4 (driver not attached)
                sd, instance #5 (driver not attached)
                sd, instance #6 (driver not attached)
                sd, instance #7 (driver not attached)
                sd, instance #8 (driver not attached)
                sd, instance #9 (driver not attached)
                sd, instance #10 (driver not attached)
                sd, instance #11 (driver not attached)
                sd, instance #12 (driver not attached)
                sd, instance #13 (driver not attached)
                sd, instance #14 (driver not attached)
                sd, instance #15 (driver not attached)
                sd, instance #16 (driver not attached)
                st, instance #0 (driver not attached)
                st, instance #1 (driver not attached)
                st, instance #2 (driver not attached)
                st, instance #3 (driver not attached)
                st, instance #4 (driver not attached)
                st, instance #5 (driver not attached)
                st, instance #6 (driver not attached)
        pci17c2,10 (driver not attached)
        pci1022,7450, instance #2
            pci15b3,5a46, instance #3
                pci15b3,5a44, instance #0
        pci17c2,10 (driver not attached)
        pci1022,1100 (driver not attached)
        pci1022,1101 (driver not attached)
        pci1022,1102 (driver not attached)
        pci1022,1103 (driver not attached)
        pci1022,1100 (driver not attached)
        pci1022,1101 (driver not attached)
        pci1022,1102 (driver not attached)
        pci1022,1103 (driver not attached)
    pseudo, instance #0
    options, instance #0
    xsvc, instance #0
    objmgr, instance #0 (driver not attached)
    used-resources (driver not attached)
    cpus (driver not attached)
        cpu, instance #0 (driver not attached)
        cpu, instance #1 (driver not attached)
Status of virtual processor 0 as of: 08/14/2006 19:17:29
  on-line since 07/21/2006 17:15:45.
  The i386 processor operates at 2191 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 1 as of: 08/14/2006 19:17:29
  on-line since 07/21/2006 17:15:51.
  The i386 processor operates at 2191 MHz,
        and has an i387 compatible floating point processor.

That indicates that this server is a two processors (2191 MHz) server with 7808 Megabytes of Memory running Solaris 10.
Posted at 12:29PM Aug 14, 2006 by Pascal Ledru in Grid Computing  |  Comments[0]