| Cray T3ETM Fortran Optimization Guide - 004-2518-002 | ||
|---|---|---|
| Prev Section | Chapter 2. Parallel Virtual Machine (PVM) | Next Section |
Passing 32-bit data can be almost twice as fast as sending 64-bit data. If, however, your data is not aligned on a 64-bit word and you are using PvmDataInPlace for packing, your code will probably slow down.
In the following example, data is sent in the REAL(KIND=4) format:
Example 2-1. Transferring 32-bit data
1. PROGRAM COMPARE2 2. C 3. C PVM version 4. C 5. INCLUDE 'fpvm3.h' 6. INTEGER ME 7. INTEGER ISTAT, SENDER, RECEIVER 8. PARAMETER(N=1000) 9. PARAMETER(SENDER = 0) 10. PARAMETER(RECEIVER = 1) 11. PARAMETER(MTAG = 2) 12. REAL (KIND=4) D_SEND(N), D_RECV(N) 13. C 14. C Get PE info 15. CALL PVMFMYTID(MYTID) 16. CALL PVMFGETPE(MYTID, ME) 17. C 18. C Initialize data 19. DO I=1,N 20. D_SEND(I) = I * 1.0 21. END DO 22. 23. IF (ME .EQ. SENDER) THEN 24. C 25. C Send data 26. CALL PVMFINITSEND(PvmDataRaw, ISTAT) 27. CALL PVMFPACK(REAL4, D_SEND, N, 1, ISTAT) 28. CALL PVMFSEND(RECEIVER, MTAG, ISTAT) 29. ELSE IF (ME .EQ. RECEIVER) THEN 30. C 31. C Receive data 32. CALL PVMFRECV(SENDER, MTAG, ISTAT) 33. CALL PVMFUNPACK(REAL4, D_RECV, N, 1, ISTAT) 34. C 35. C Print results 36. WRITE(*,*) 'Receiver=',ME,' D_RECV=', D_RECV(1), D_RECV(2) 37. 1 ,D_RECV(3),D_RECV(4),D_RECV(5),D_RECV(6),D_RECV(7) 38. ENDIF 39. END |
The program in this example has the following output:
Receiver=1 D_RECV=1., 2., 3., 4., 5., 6., 7. |
To move on to the next optimization topic, go to Section 2.4. For a brief description of the above program, continue with this section.
Line 5 references the PVM INCLUDE file. See your system administrator for the actual location of the INCLUDE file on your system. You must also either load the Message Passing Toolkit (MPT) module with the module(1) command or specify the location of the INCLUDE file with the -I option on the f90(1) command line.
5. INCLUDE 'fpvm3.h' |
Lines 9 and 10 define the sending PE as PE 0 and the receiving PE as PE 1.
9. PARAMETER(SENDER = 0) 10. PARAMETER(RECEIVER = 1) |
Line 12 defines the sizes of the sending and receiving arrays. The (KIND=4) specification defines 32-bit data.
12. REAL (KIND=4) D_SEND(N), D_RECV(N) |
The fastest of the data encoding arguments to PVMFINITSEND, in this case, is PvmDataRaw because data conversion is not needed. If the program were transferring 32-bit integer data, PvmDataDefault would be faster (see Section 2.2). Because the sending and receiving arrays both begin with the first element and use a stride-1 increment, the 32-bit values will be packed and unpacked two data items per 64-bit word.
Lines 26 through 28 initialize the send buffer, pack the 32-bit data, and send the data:
26. CALL PVMFINITSEND(PvmDataRaw, ISTAT) 27. CALL PVMFPACK(REAL4, D_SEND, N, 1, ISTAT) 28. CALL PVMFSEND(RECEIVER, MTAG, ISTAT) |
Lines 32 and 33 receive and unpack the 32-bit data:
32. CALL PVMFRECV(SENDER, MTAG, ISTAT) 33. CALL PVMFUNPACK(REAL4, D_RECV, N, 1, ISTAT) |
| Prev Section | Table of Contents | Title Page | Next Section |
| Allocating Send Buffers | Up one level | Sending and Receiving Stride-1 Data |