Esempio n. 1
0
    /*
    ** Perform the transcendental/trigonometric portion of the
    ** benchmark.  This benchmark calculates the first n
    ** fourier coefficients of the function (x+1)^x defined
    ** on the interval 0,2.
    */
    public override double Run()
    {
        double[] abase;         /* Base of A[] coefficients array */
        double[] bbase;         /* Base of B[] coefficients array */
        long     accumtime;     /* Accumulated time in ticks */
        double   iterations;    /* # of iterations */

        /*
        ** See if we need to do self-adjustment code.
        */
        if (this.adjust == 0)
        {
            this.arraysize = 100; /* Start at 100 elements */
            while (true)
            {
                abase = new double[this.arraysize];
                bbase = new double[this.arraysize];

                /*
                ** Do an iteration of the tests.  If the elapsed time is
                ** less than or equal to the permitted minimum, re-allocate
                ** larger arrays and try again.
                */
                if (DoFPUTransIteration(abase, bbase, this.arraysize) > global.min_ticks)
                {
                    break;
                }
                this.arraysize += 50;
            }
        }
        else
        {
            /*
            ** Don't need self-adjustment.  Just allocate the
            ** arrays, and go.
            */
            abase = new double[this.arraysize];
            bbase = new double[this.arraysize];
        }

        accumtime  = 0L;
        iterations = 0.0;
        do
        {
            accumtime  += DoFPUTransIteration(abase, bbase, this.arraysize);
            iterations += (double)this.arraysize * (double)2.0 - (double)1.0;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        if (this.adjust == 0)
        {
            this.adjust = 1;
        }

        return(iterations / (double)ByteMark.TicksToFracSecs(accumtime));
    }
Esempio n. 2
0
    public override double Run()
    {
        double[][]   a;
        double[]     b;
        double[][][] abase = null;
        double[][]   bbase = null;
        int          n;
        int          i;
        long         accumtime;
        double       iterations;

        /*
        ** Our first step is to build a "solvable" problem.  This
        ** will become the "seed" set that all others will be
        ** derived from. (I.E., we'll simply copy these arrays
        ** into the others.
        */
        a = new double[global.LUARRAYROWS][];
        for (int j = 0; j < global.LUARRAYROWS; j++)
        {
            a[j] = new double[global.LUARRAYCOLS];
        }
        b = new double[global.LUARRAYROWS];
        n = global.LUARRAYROWS;

        s_LUtempvv = new double[global.LUARRAYROWS];

        build_problem(a, n, b);

        if (this.adjust == 0)
        {
            for (i = 1; i <= MAXLUARRAYS; i++)
            {
                abase = new double[i + 1][][];
                for (int j = 0; j < i + 1; j++)
                {
                    abase[j] = new double[global.LUARRAYROWS][];
                    for (int k = 0; k < global.LUARRAYROWS; k++)
                    {
                        abase[j][k] = new double[global.LUARRAYCOLS];
                    }
                }

                bbase = new double[i + 1][];
                for (int j = 0; j < i + 1; j++)
                {
                    bbase[j] = new double[global.LUARRAYROWS];
                }

                if (DoLUIteration(a, b, abase, bbase, i) > global.min_ticks)
                {
                    this.numarrays = i;
                    break;
                }
            }

            if (this.numarrays == 0)
            {
                throw new Exception("FPU:LU -- Array limit reached");
            }
        }
        else
        {
            abase = new double[this.numarrays][][];
            for (int j = 0; j < this.numarrays; j++)
            {
                abase[j] = new double[global.LUARRAYROWS][];
                for (int k = 0; k < global.LUARRAYROWS; k++)
                {
                    abase[j][k] = new double[global.LUARRAYCOLS];
                }
            }
            bbase = new double[this.numarrays][];
            for (int j = 0; j < this.numarrays; j++)
            {
                bbase[j] = new double[global.LUARRAYROWS];
            }
        }

        accumtime  = 0;
        iterations = 0.0;

        do
        {
            accumtime  += DoLUIteration(a, b, abase, bbase, this.numarrays);
            iterations += (double)this.numarrays;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        if (this.adjust == 0)
        {
            this.adjust = 1;
        }

        return(iterations / ByteMark.TicksToFracSecs(accumtime));
    }
Esempio n. 3
0
    public override double Run()
    {
        string[][] arraybase;   /* Base pointers of array */
        long       accumtime;   /* Accumulated time */
        double     iterations;  /* Iteration counter */

        /*
        ** See if we need to do self adjustment code.
        */
        if (this.adjust == 0)
        {
            /*
            ** Self-adjustment code.  The system begins by sorting 1
            ** array.  If it does that in no time, then two arrays
            ** are built and sorted.  This process continues until
            ** enough arrays are built to handle the tolerance.
            */
            this.numarrays = 1;
            while (true)
            {
                /*
                ** Allocate space for arrays
                */
                arraybase = new string[this.numarrays][];
                for (int i = 0; i < this.numarrays; i++)
                {
                    arraybase[i] = new string[this.arraysize];
                }

                /*
                ** Do an iteration of the string sort.  If the
                ** elapsed time is less than or equal to the permitted
                ** minimum, then allocate for more arrays and
                ** try again.
                */
                if (DoStringSortIteration(arraybase,
                                          this.numarrays,
                                          this.arraysize) > global.min_ticks)
                {
                    break;          /* We're ok...exit */
                }
                if (this.numarrays++ > global.NUMSTRARRAYS)
                {
                    throw new Exception("CPU:SSORT -- NUMSTRARRAYS hit.");
                }
            }
        }
        else
        {
            /*
            ** Allocate space for arrays
            */
            arraybase = new string[this.numarrays][];
            for (int i = 0; i < this.numarrays; i++)
            {
                arraybase[i] = new string[this.arraysize];
            }
        }

        /*
        ** All's well if we get here.  Repeatedly perform sorts until the
        ** accumulated elapsed time is greater than # of seconds requested.
        */
        accumtime  = 0L;
        iterations = (double)0.0;

        do
        {
            accumtime += DoStringSortIteration(arraybase,
                                               this.numarrays,
                                               this.arraysize);
            iterations += (double)this.numarrays;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        if (this.adjust == 0)
        {
            this.adjust = 1;
        }

        /*
        ** Clean up, calculate results, and go home.
        ** Set flag to show we don't need to rerun adjustment code.
        */

        return(iterations * (double)this.numarrays / ByteMark.TicksToFracSecs(accumtime));
    }
Esempio n. 4
0
    double DoNNET(NNetStruct locnnetstruct)
    {
        //    string errorcontext = "CPU:NNET";
        //    int systemerror = 0;
        long   accumtime  = 0;
        double iterations = 0.0;

        /*
        ** Init random number generator.
        ** NOTE: It is important that the random number generator
        **  be re-initialized for every pass through this test.
        **  The NNET algorithm uses the random number generator
        **  to initialize the net.  Results are sensitive to
        **  the initial neural net state.
        */
        ByteMark.randnum(3);

        /*
        ** Read in the input and output patterns.  We'll do this
        ** only once here at the beginning.  These values don't
        ** change once loaded.
        */
        read_data_file();

        /*
        ** See if we need to perform self adjustment loop.
        */
        if (locnnetstruct.adjust == 0)
        {
            /*
            ** Do self-adjustment.  This involves initializing the
            ** # of loops and increasing the loop count until we
            ** get a number of loops that we can use.
            */
            for (locnnetstruct.loops = 1;
                 locnnetstruct.loops < MAXNNETLOOPS;
                 locnnetstruct.loops++)
            {
                ByteMark.randnum(3);
                if (DoNNetIteration(locnnetstruct.loops) > global.min_ticks)
                {
                    break;
                }
            }
        }

        /*
        ** All's well if we get here.  Do the test.
        */
        accumtime  = 0L;
        iterations = (double)0.0;

        do
        {
            ByteMark.randnum(3);    /* Gotta do this for Neural Net */
            accumtime  += DoNNetIteration(locnnetstruct.loops);
            iterations += (double)locnnetstruct.loops;
        } while (ByteMark.TicksToSecs(accumtime) < locnnetstruct.request_secs);

        /*
        ** Clean up, calculate results, and go home.  Be sure to
        ** show that we don't have to rerun adjustment code.
        */
        locnnetstruct.iterspersec = iterations / ByteMark.TicksToFracSecs(accumtime);

        if (locnnetstruct.adjust == 0)
        {
            locnnetstruct.adjust = 1;
        }


        return(locnnetstruct.iterspersec);
    }
Esempio n. 5
0
    /*
    ** emfloat.c
    ** Source for emulated floating-point routines.
    ** BYTEmark (tm)
    ** BYTE's Native Mode Benchmarks
    ** Rick Grehan, BYTE Magazine.
    **
    ** Created:
    ** Last update: 3/95
    **
    ** DISCLAIMER
    ** The source, executable, and documentation files that comprise
    ** the BYTEmark benchmarks are made available on an "as is" basis.
    ** This means that we at BYTE Magazine have made every reasonable
    ** effort to verify that the there are no errors in the source and
    ** executable code.  We cannot, however, guarantee that the programs
    ** are error-free.  Consequently, McGraw-HIll and BYTE Magazine make
    ** no claims in regard to the fitness of the source code, executable
    ** code, and documentation of the BYTEmark.
    **  Furthermore, BYTE Magazine, McGraw-Hill, and all employees
    ** of McGraw-Hill cannot be held responsible for any damages resulting
    ** from the use of this code or the results obtained from using
    ** this code.
    */

    /*
    ** Floating-point emulator.
    ** These routines are only "sort of" IEEE-compliant.  All work is
    ** done using an internal representation.  Also, the routines do
    ** not check for many of the exceptions that might occur.
    ** Still, the external formats produced are IEEE-compatible,
    ** with the restriction that they presume a low-endian machine
    ** (though the endianism will not effect the performance).
    **
    ** Some code here was based on work done by Steve Snelgrove of
    ** Orem, UT.  Other code comes from routines presented in
    ** the long-ago book: "Microprocessor Programming for
    ** Computer Hobbyists" by Neill Graham.
    */

    /*****************************
    ** FLOATING-POINT EMULATION **
    *****************************/

    /**************
    ** DoEmFloat **
    ***************
    ** Perform the floating-point emulation routines portion of the
    ** CPU benchmark.  Returns the operations per second.
    */
    public override double Run()
    {
        InternalFPF[] abase;          /* Base of A array */
        InternalFPF[] bbase;          /* Base of B array */
        InternalFPF[] cbase;          /* Base of C array */
        long          accumtime;      /* Accumulated time in ticks */
        double        iterations;     /* # of iterations */
        long          tickcount;      /* # of ticks */
        int           loops;          /* # of loops */

        /*
        ** Test the emulation routines.
        */

        abase = new InternalFPF[this.arraysize];
        bbase = new InternalFPF[this.arraysize];
        cbase = new InternalFPF[this.arraysize];

        for (int i = 0; i < this.arraysize; i++)
        {
            abase[i] = new InternalFPF();
            bbase[i] = new InternalFPF();
            cbase[i] = new InternalFPF();
        }

        /*
         * for (int i = 0; i < this.arraysize; i++)
         * {
         *  abase[i].type = IFPF.IFPF_IS_ZERO;
         *  abase[i].sign = (byte)0;
         *  abase[i].exp = (short)0;
         *  abase[i].mantissa = new char[INTERNAL_FPF_PRECISION];
         *
         *  bbase[i].type = IFPF.IFPF_IS_ZERO;
         *  bbase[i].sign = (byte)0;
         *  bbase[i].exp = (short)0;
         *  bbase[i].mantissa = new char[INTERNAL_FPF_PRECISION];
         *
         *  cbase[i].type = IFPF.IFPF_IS_ZERO;
         *  cbase[i].sign = (byte)0;
         *  cbase[i].exp = (short)0;
         *  cbase[i].mantissa = new char[INTERNAL_FPF_PRECISION];
         * }
         */

        /*
        ** Set up the arrays
        */
        SetupCPUEmFloatArrays(abase, bbase, cbase, this.arraysize);

        /*
        ** See if we need to do self-adjusting code.
        */
        if (this.adjust == 0)
        {
            this.loops = 0;

            /*
            ** Do an iteration of the tests.  If the elapsed time is
            ** less than minimum, increase the loop count and try
            ** again.
            */
            for (loops = 1; loops < global.CPUEMFLOATLOOPMAX; loops += loops)
            {
                tickcount = DoEmFloatIteration(abase, bbase, cbase,
                                               this.arraysize,
                                               loops);
                if (tickcount > global.min_ticks)
                {
                    this.loops = loops;
                    break;
                }
            }
        }

        /*
        ** Verify that selft adjustment code worked.
        */
        if (this.loops == 0)
        {
            throw new Exception("CPU:EMFPU -- CMPUEMFLOATLOOPMAX limit hit\n");
        }

        /*
        ** All's well if we get here.  Repeatedly perform floating
        ** tests until the accumulated time is greater than the
        ** # of seconds requested.
        ** Each iteration performs arraysize * 3 operations.
        */
        accumtime  = 0L;
        iterations = (double)0.0;
        do
        {
            accumtime += DoEmFloatIteration(abase, bbase, cbase,
                                            this.arraysize,
                                            this.loops);
            iterations += (double)1.0;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        /*
        ** Clean up, calculate results, and go home.
        ** Also, indicate that adjustment is done.
        */

        if (this.adjust == 0)
        {
            this.adjust = 1;
        }
        double emflops = (iterations * (double)this.loops) /
                         (double)ByteMark.TicksToFracSecs(accumtime);

        return(emflops);
    }
Esempio n. 6
0
    /**************
    ** DoHuffman **
    ***************
    ** Execute a huffman compression on a block of plaintext.
    ** Note that (as with IDEA encryption) an iteration of the
    ** Huffman test includes a compression AND a decompression.
    ** Also, the compression cycle includes building the
    ** Huffman tree.
    */
    public override double Run()
    {
        huff_node[] hufftree;
        long        accumtime;
        double      iterations;

        byte[] comparray;
        byte[] decomparray;
        byte[] plaintext;

        InitWords();

        /*
        ** Allocate memory for the plaintext and the compressed text.
        ** We'll be really pessimistic here, and allocate equal amounts
        ** for both (though we know...well, we PRESUME) the compressed
        ** stuff will take less than the plain stuff.
        ** Also note that we'll build a 3rd buffer to decompress
        ** into, and we preallocate space for the huffman tree.
        ** (We presume that the Huffman tree will grow no larger
        ** than 512 bytes.  This is actually a super-conservative
        ** estimate...but, who cares?)
        */
        plaintext   = new byte[this.arraysize];
        comparray   = new byte[this.arraysize];
        decomparray = new byte[this.arraysize];

        hufftree = new huff_node[512];

        /*
        ** Build the plaintext buffer.  Since we want this to
        ** actually be able to compress, we'll use the
        ** wordcatalog to build the plaintext stuff.
        */
        create_text_block(plaintext, this.arraysize - 1, 500);
        //		for (int i = 0; i < this.arraysize-1; i++) {
        //			Console.Write((char)plaintext[i]);
        //		}
        plaintext[this.arraysize - 1] = (byte)'\0';
        // plaintextlen=this.arraysize;

        /*
        ** See if we need to perform self adjustment loop.
        */
        if (this.adjust == 0)
        {
            /*
            ** Do self-adjustment.  This involves initializing the
            ** # of loops and increasing the loop count until we
            ** get a number of loops that we can use.
            */

            for (this.loops = 100;
                 this.loops < global.MAXHUFFLOOPS;
                 this.loops += 10)
            {
                if (DoHuffIteration(plaintext,
                                    comparray,
                                    decomparray,
                                    this.arraysize,
                                    this.loops,
                                    hufftree) > global.min_ticks)
                {
                    break;
                }
            }
        }

        /*
        ** All's well if we get here.  Do the test.
        */
        accumtime  = 0L;
        iterations = (double)0.0;

        do
        {
            accumtime += DoHuffIteration(plaintext,
                                         comparray,
                                         decomparray,
                                         this.arraysize,
                                         this.loops,
                                         hufftree);
            iterations += (double)this.loops;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        /*
        ** Clean up, calculate results, and go home.  Be sure to
        ** show that we don't have to rerun adjustment code.
        */
        //this.iterspersec=iterations / TicksToFracSecs(accumtime);

        if (this.adjust == 0)
        {
            this.adjust = 1;
        }

        return(iterations / ByteMark.TicksToFracSecs(accumtime));
    }
Esempio n. 7
0
    public override double Run()
    {
        int i;

        char[] Z       = new char[global.KEYLEN];
        char[] DK      = new char[global.KEYLEN];
        char[] userkey = new char[8];
        long   accumtime;
        double iterations;

        byte[] plain1;               /* First plaintext buffer */
        byte[] crypt1;               /* Encryption buffer */
        byte[] plain2;               /* Second plaintext buffer */

        /*
        ** Re-init random-number generator.
        */
        ByteMark.randnum(3);

        /*
        ** Build an encryption/decryption key
        */
        for (i = 0; i < 8; i++)
        {
            userkey[i] = (char)(ByteMark.abs_randwc(60000) & 0xFFFF);
        }
        for (i = 0; i < global.KEYLEN; i++)
        {
            Z[i] = (char)0;
        }

        /*
        ** Compute encryption/decryption subkeys
        */
        en_key_idea(userkey, Z);
        de_key_idea(Z, DK);

        /*
        ** Allocate memory for buffers.  We'll make 3, called plain1,
        ** crypt1, and plain2.  It works like this:
        **   plain1 >>encrypt>> crypt1 >>decrypt>> plain2.
        ** So, plain1 and plain2 should match.
        ** Also, fill up plain1 with sample text.
        */
        plain1 = new byte[this.arraysize];
        crypt1 = new byte[this.arraysize];
        plain2 = new byte[this.arraysize];

        /*
        ** Note that we build the "plaintext" by simply loading
        ** the array up with random numbers.
        */
        for (i = 0; i < this.arraysize; i++)
        {
            plain1[i] = (byte)(ByteMark.abs_randwc(255) & 0xFF);
        }

        /*
        ** See if we need to perform self adjustment loop.
        */
        if (this.adjust == 0)
        {
            /*
            ** Do self-adjustment.  This involves initializing the
            ** # of loops and increasing the loop count until we
            ** get a number of loops that we can use.
            */
            for (this.loops = 100;
                 this.loops < global.MAXIDEALOOPS;
                 this.loops += 10)
            {
                if (DoIDEAIteration(plain1, crypt1, plain2,
                                    this.arraysize,
                                    this.loops,
                                    Z, DK) > global.min_ticks)
                {
                    break;
                }
            }
        }

        /*
        ** All's well if we get here.  Do the test.
        */
        accumtime  = 0;
        iterations = (double)0.0;

        do
        {
            accumtime += DoIDEAIteration(plain1, crypt1, plain2,
                                         this.arraysize,
                                         this.loops, Z, DK);
            iterations += (double)this.loops;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        /*
        ** Clean up, calculate results, and go home.  Be sure to
        ** show that we don't have to rerun adjustment code.
        */

        if (this.adjust == 0)
        {
            this.adjust = 1;
        }

        return(iterations / ByteMark.TicksToFracSecs(accumtime));
    }
Esempio n. 8
0
    public override double Run()
    {
        int[][,] arraybase;
        long   accumtime;
        double iterations;

        /*
        ** See if we need to do self adjustment code.
        */
        if (this.adjust == 0)
        {
            /*
            ** Self-adjustment code.  The system begins by working on 1
            ** array.  If it does that in no time, then two arrays
            ** are built.  This process continues until
            ** enough arrays are built to handle the tolerance.
            */
            this.numarrays = 1;
            while (true)
            {
                /*
                ** Allocate space for arrays
                */
                arraybase = new int[this.numarrays][, ];
                for (int i = 0; i < this.numarrays; i++)
                {
                    arraybase[i] = new int[global.ASSIGNROWS, global.ASSIGNCOLS];
                }

                /*
                ** Do an iteration of the assignment alg.  If the
                ** elapsed time is less than or equal to the permitted
                ** minimum, then allocate for more arrays and
                ** try again.
                */
                if (DoAssignIteration(arraybase,
                                      this.numarrays) > global.min_ticks)
                {
                    break;          /* We're ok...exit */
                }
                this.numarrays++;
            }
        }
        else
        {       /*
                ** Allocate space for arrays
                */
            arraybase = new int[this.numarrays][, ];
            for (int i = 0; i < this.numarrays; i++)
            {
                arraybase[i] = new int[global.ASSIGNROWS, global.ASSIGNCOLS];
            }
        }


        /*
        ** All's well if we get here.  Do the tests.
        */
        accumtime  = 0;
        iterations = (double)0.0;

        do
        {
            accumtime  += DoAssignIteration(arraybase, this.numarrays);
            iterations += (double)1.0;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        if (this.adjust == 0)
        {
            this.adjust = 1;
        }



        return(iterations * (double)this.numarrays
               / ByteMark.TicksToFracSecs(accumtime));
    }
Esempio n. 9
0
    public override double Run()
    {
        int[]  bitarraybase;            /* Base of bitmap array */
        int[]  bitoparraybase;          /* Base of bitmap operations array */
        int    nbitops = 0;             /* # of bitfield operations */
        long   accumtime;               /* Accumulated time in ticks */
        double iterations;              /* # of iterations */

        /*
        ** See if we need to run adjustment code.
        */
        if (this.adjust == 0)
        {
            bitarraybase = new int[this.bitfieldarraysize];

            /*
            ** Initialize bitfield operations array to [2,30] elements
            */
            this.bitoparraysize = 30;

            while (true)
            {
                /*
                ** Allocate space for operations array
                */
                bitoparraybase = new int[this.bitoparraysize * 2];

                /*
                ** Do an iteration of the bitmap test.  If the
                ** elapsed time is less than or equal to the permitted
                ** minimum, then de-allocate the array, reallocate a
                ** larger version, and try again.
                */
                if (DoBitfieldIteration(bitarraybase,
                                        bitoparraybase,
                                        this.bitoparraysize,
                                        ref nbitops) > global.min_ticks)
                {
                    break;          /* We're ok...exit */
                }
                this.bitoparraysize += 100;
            }
        }
        else
        {
            /*
            ** Don't need to do self adjustment, just allocate
            ** the array space.
            */
            bitarraybase   = new int[this.bitfieldarraysize];
            bitoparraybase = new int[this.bitoparraysize * 2];
        }

        /*
        ** All's well if we get here.  Repeatedly perform bitops until the
        ** accumulated elapsed time is greater than # of seconds requested.
        */
        accumtime  = 0;
        iterations = (double)0.0;

        do
        {
            accumtime += DoBitfieldIteration(bitarraybase,
                                             bitoparraybase,
                                             this.bitoparraysize,
                                             ref nbitops);
            iterations += (double)nbitops;
        } while (ByteMark.TicksToSecs(accumtime) < this.request_secs);

        /*
        ** Clean up, calculate results, and go home.
        ** Also, set adjustment flag to show that we don't have
        ** to do self adjusting in the future.
        */
        if (this.adjust == 0)
        {
            this.adjust = 1;
        }

        return(iterations / ByteMark.TicksToFracSecs(accumtime));
    }