home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / fortran / library / library / libry7.doc < prev    next >
Text File  |  1989-11-10  |  7KB  |  131 lines

  1. .pa
  2.                               VECTOR EMULATIONS
  3.  
  4. Vector emulations are software procedures that mimic the operation  of  vector
  5. processing  hardware.   Of  course,  the  software  is  not  based on the same
  6. principle as the hardware;  but the concept is the same:   specific  procedure
  7. designed  to most efficiently perform similar repetitive tasks on contiguously
  8. stored real numbers.  No, I won't tell you how I do  it,  so  don't  ask.   My
  9. vector  emulations  are  completely  compatible  with Hewlett-Packard's Vector
  10. Instruction Set (VIS).  They have the same calling syntax and function (that's
  11. why  I  developed  them  in  the  first  place  - downloading programs from an
  12. HP-1000F).  HP has a very nice manual with examples.  If you  are  interested,
  13. perhaps  they  would  sell  you  one (I wouldn't even hazard a guess as to the
  14. cost).
  15.  
  16.                Vector Instruction Set (VIS) User's Manual
  17.                Part No. 12824-90001
  18.                Hewlett-Packard Company
  19.                Data Systems Division
  20.                11000 Wolfe Road
  21.                Cupertino, CA 95014
  22.  
  23. If you are using a PC you don't need a math coprocessor (Intel 8087/80287)  in
  24. order  to  run  a  program  linked  with  LIBRY;   but  it  makes a TREMENDOUS
  25. difference (a factor of 120 or so for floating point operations).  The  vector
  26. emulations  will  run  even  without a math coprocessor;  but in that case the
  27. speed is already so slow that nothing will help.   The  improvement  in  speed
  28. with  the  vector  emulations  varies  depending on the relative speed of your
  29. processor and coprocessor (not MHz speed but MIPS and FLOPS - a 5MHz-80286  is
  30. quite  a  bit  faster  than a 5MHz-8088 while a 5MHz-8087 is just as fast as a
  31. 5MHz  80287).   The  greatest  improvement  is  realized  on  a  PC   with   a
  32. 5MHz-8088/5MHz-8087 pair;  and the least improvement is realized on an AT with
  33. an 8MHz-80286/5MHz-80287 pair.
  34.  
  35. Note that the increments (INCR1,INCR2,INCR3),index (M), and the count (N)  are
  36. of  the  type  INTEGER*2.   Reals  are of the type REAL*4 and double precision
  37. reals are of the type REAL*8.  There can be no mixing  of  REAL*4  and  REAL*8
  38. types  in  the  same emulation.  To get double precision use "CALL DVABS(...)"
  39. rather than "CALL VABS(...)".
  40.  
  41. It is very important to BE SURE THAT NO  VECTOR  CROSSES  A  SEGMENT  BOUNDARY
  42. (refer to Microsoft FORTRAN manual section 8).  What this means to the machine
  43. is that a vector must reside within a single segment (65536 bytes) or  it  can
  44. not address all of the elements as a group.  In order to assure this to be the
  45. case, NEVER use the $LARGE metacommand.  If you have no COMMON then you  never
  46. have  to  worry  about this.  If you do have COMMON make sure that each COMMON
  47. contains no more than 65536 bytes.  Of course,  you  can  have  several  named
  48. COMMONs  so  this  is  not too restrictive a limit on your programs.  Also, if
  49. there is more than one vector passed to the emulator they need not  reside  in
  50. the  same  segment.   For  instance,  you  can  add one real vector with 16384
  51. elements to another with 16384 elements and store the result in a third  -  as
  52. long as they are all in different COMMONs.  Of course, you can add two vectors
  53. in the same COMMON provided their total number of  elements  does  not  exceed
  54. 16384.   There  is  a  way  of getting around this;  but it is too involved to
  55. explain here.
  56.  
  57. A word of warning...  vector emulations do not like being  interrupted.   This
  58. is  the  whole  point of "speed at any cost" procedures.  For this reason, the
  59. emulations may interfere with the operation of some "pop-up" programs and such
  60. things  as  windowing and multitasking.  This is regrettably unpredictable.  I
  61. can say that the emulations don't interfere with any of the "pop-up"  programs
  62. that  I  have  developed  (like  my  DOS  command stack full-screen editor and
  63. improved scroller) that "lurk" in the background;  but I don't know about such
  64. programs that others have developed.
  65. .pa
  66.                   SAMPLE FORTRAN EQUIVALENT OF A VECTOR ADD
  67.  
  68.  
  69.       SUBROUTINE VADD(V1,INCR1,V2,INCR2,V3,INCR3,N)
  70. C
  71. C  VECTOR V3=V1+V2
  72. C
  73.       IMPLICIT INTEGER*2(I-N),REAL*4(A-H,O-Z)
  74.       DIMENSION V1(N),V2(N),V3(N)
  75. C
  76.       IF(N.LT.1) GO TO 999
  77.       I1=1
  78.       I2=1
  79.       I3=1
  80. C
  81.       DO 100 I=1,N
  82.       V3(I3)=V1(I1)+V2(I2)
  83.       I1=I1+INCR1
  84.       I2=I2+INCR2
  85.   100 I3=I3+INCR3
  86. C
  87.   999 RETURN
  88.       END
  89. .pa
  90.                       SUMMARY OF VECTOR INSTRUCTION SET
  91. ------------------------------------------------------------------------------
  92. calling syntax                                operation
  93. ------------------------------------------------------------------------------
  94. CALL VABS(V1,INCR1,V2,INCR2,N)                (V2(I)=ABS(V1(I)),I=1,N)
  95. CALL VADD(V1,INCR1,V2,INCR2,V3,INCR3,N)       (V3(I)=V1(I)+V2(I),I=1,N)
  96. CALL VDIV(V1,INCR1,V2,INCR2,V3,INCR3,N)       (V3(I)=V1(I)/V2(I),I=1,N)
  97. CALL VDOT(S,V1,INCR1,V2,INCR2,N)              S=SUM(V1(I)*V2(I),I=1,N)
  98. CALL VMAB(M,V1,INCR1,N)                       V1(M)=AMAX1(ABS(V1(I)),I=1,N)
  99. CALL VMAX(M,V1,INCR1,N)                       V1(M)=AMAX1(V1(I),I=1,N)
  100. CALL VMIB(M,V1,INCR1,N)                       V1(M)=AMIN1(ABS(V1(I)),I=1,N)
  101. CALL VMIN(M,V1,INCR1,N)                       V1(M)=AMIN1(V1(I),I=1,N)
  102. CALL VMOV(V1,INCR1,V2,INCR2,N)                (V2(I)=V1(I),I=1,N)
  103. CALL VMPY(V1,INCR1,V2,INCR2,V3,INCR3,N)       (V3(I)=V1(I)*V2(I),I=1,N)
  104. CALL VNRM(S,V1,INCR1,N)                       S=SUM(ABS(V1(I)),I=1,N)
  105. CALL VPIV(S,V1,INCR1,V2,INCR2,V3,INCR3,N)     (V3(I)=S*V1(I)+V2(I),I=1,N)
  106. CALL VSAD(S,V1,INCR1,V2,INCR2,N)              (V2(I)=S+V1(I),I=1,N)
  107. CALL VSDV(S,V1,INCR1,V2,INCR2,N)              (V2(I)=S/V1(I),I=1,N)
  108. CALL VSMY(S,V1,INCR1,V2,INCR2,N)              (V2(I)=S*V1(I),I=1,N)
  109. CALL VSSB(S,V1,INCR1,V2,INCR2,N)              (V2(I)=S-V1(I),I=1,N)
  110. CALL VSUB(V1,INCR1,V2,INCR2,V3,INCR3,N)       (V3(I)=V1(I)-V2(I),I=1,N)
  111. CALL VSUM(S,V1,INCR1,N)                       S=SUM(V1(I),I=1,N)
  112. CALL VSWP(V1,INCR1,V2,INCR2,N)                (V1(I)<->V2(I),I=1,N)
  113. CALL VMIX(INDEX,V1,V2,N)                      (V2(I)=V1(INDEX(I)),I=1,N)
  114. CALL VMXI(INDEX,V1,V2,N)                      (V2(INDEX(I))=V1(I),I=1,N)
  115. CALL CLAMP(VMIN,VMAX,V,N)                     (V1(I)=AMAX1(VMIN,AMIN1(VMAX,
  116.                                                      V(I))),I=1,N)
  117. H=HORNER(C,X,N)                               H=SUM(C(I)*X**(I-1),I=1,N)
  118. ------------------------------------------------------------------------------
  119.  
  120. Note 1: There is little or no improvement for n<5 and runtimes may increase
  121.         for n<3.
  122. Note 2: For double precision add a "D" prefix (e.g.  DVABS, DVADD, ...,
  123.         DCLAMP, DHORNE).
  124. Note 3: Vectors  must not cross a segment boundary (see section 8 of Microsoft
  125.         FORTRAN user's guide).
  126. Note 4: All integers (e.g.  INCR1,INCR2,INCR3,n...) are of the INTEGER*2
  127.         type.
  128. Note 5: Increments (viz.  INCR1,INCR2,INCR3) can be positive, negative, or
  129.         zero.
  130. .ad LIBRY7A.DOC
  131.