PROGRAM M7 c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c Benchmark #7 -- Bit Twiddle c c c The Problem: c c Given {A(i)}, a binary stream of length L, let {B(i)} and c {C(i)} be binary streams formed as follows: c {B(i)} = A(0),A(1),A(2),A(3),A(4),A(11),A(12),...etc. c {C(i)} = A(5),A(6),A(7),A(8),A(9),A(16),A(17),...etc. c c i.e., to form the {B(i)} stream, take 5 from {A(i)}, drop 6, c take 5, drop 6, etc., c and to form the {C(i)} stream, drop 5 from {A(i)}, take 5, c drop 6, take 5, drop 6, and so on (dropping 5 only on the c first instance). c c Calculate the stream {D(i)} defined as c c D(i) = (C(i) ^ B(i+1)) + (~C(i) ^ B(i-1)) c c where c ~X = the complement of X c XOR = exclusive "or" function c ^ = "and" function c + = can be integer add, exclusive "or", or inclusive "or". c They are all equivalent here. c c Then calculate {E(i)} where c c E(i) = C(i) XOR D(i) XOR C(i+37) XOR D(i+37) XOR c C(i+100) XOR D(i+100). c c Now locate all sequences of zeros of length greater than 100 in bit c stream {E(i)}, and output for each sequence of zeros, the c starting position of the sequence in the E stream and the c length of the sequence. c c Parameter: L = 6.0E10 c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c Main Program for Benchmark #7 c c Call time parameters: c c L = Length of the A bit stream, as a fp number c Maximum = Default = 6.0E10 bits c Other permissible value = largest system can do that c is less than 6.0E10 c (Note: maximum value check routine verifies is 6.0E10) c c NAME = Name of secondary storage file to hold data c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c USE LIMITS USE POP_N_LEADZ IMPLICIT INTEGER (A-Z) C--CVS variable declaration TYPE CVS sequence character( 160 ) string integer stringend END TYPE CVS C--CVS initilaize variables TYPE( CVS ),save :: CVS_INFO = \$ CVS("BMARKGRP \$Date: 2005/01/10 20:45:00 \$ \$Revision: 1.2 \$" // \$ "\$RCSfile: m7.f,v \$ \$Name: rel_5 \$", 0) c c Variables for timing purposes REAL CPUTIME,CSET,CRUN,CVRFY,X0,Y0 REAL WALL,WSET,WRUN,WVRFY c c Maximum length of the A stream buffer in 64 bit words c NOTE: Changing this buffer size may result in errors in c the check routine C7 as the answers may not be in expected c locations with a different buffer size. PARAMETER (MLW = B7_MLW) c c Number of buffers to use PARAMETER (NBUF = 2) c c Minimum length of zeros to report. The following code assumes c that NZ > 74. See the notes in routine P7 on the relationship c between the offsets and NZ. PARAMETER (NZ = 100) INTEGER A(MLW,NBUF) c Arrays to hold answers INTEGER START(1000), LENGTH(1000) c c Error flag arrayc INTEGER IER(2) c Array for run time parameters CHARACTER*80 ARG, NAME REAL AL INTEGER NAMELEN EXTERNAL IRAND c c c Cc Uncomment the following for machines without the LEADZ intrinsic. Cc Also uncomment the code for INITZ in the UTIL routine Cc and the corresponding COMMON statement in P7 (and P7OP). c CALL INITLZ_COM c c c Cc Uncomment the following for machines without the POPCNT intrinsic. Cc Also uncomment the code for INITPC and POPCNT in the UTIL routine Cc and the corresponding COMMON statement in P7 (and P7OP). c CALL INITPC_COM c c c c Get input parameters c Get A stream length c NAMELEN=GETARG_COM(1,ARG) READ(ARG,55) AL 55 FORMAT(F15.6) CSB IF(AL .LE. 0.0) AL = 6.0E10 IF(AL .LE. 0.0) AL = 6.0E9 L = AL LW = (L-1)/64 + 1 c c Get secondary memory file name NAMELEN=GETARG_COM(2,NAME) IF (NAME .EQ. '') THEN NAME = 'f7.tmp' ENDIF c c Initialize the random number generator I = IRAND(-99907) c c Initialize timing variables CSET=0.0 WSET=0.0 CRUN=0.0 WRUN=0.0 CVRFY=0.0 WVRFY=0.0 c c Generate bitstream A X0 = CPUTIME() Y0 = WALL() CALL S7(LW, NAME, A) c CSET = CPUTIME() - X0 WSET = WALL() - Y0 c c Time the actual work being done in subroutine P7 X0 = CPUTIME() Y0 = WALL() CALL P7(A,LW,NZ,START,LENGTH,NN,OVER) CRUN = CPUTIME() - X0 WRUN = WALL() -Y0 c c Check the results CALL C7(START,LENGTH,NN,LW,LB,IER) CALL UNLINK(NAME) c c Output results CALL R7(LW*64,LB,NZ,CSET,WSET,CRUN,WRUN,NN,START,LENGTH,IER, \$ OVER) c STOP END