HPMC User Guide v 1.00
© 2022 Bassem W. Jamaleddine
HPMC calculators that are fabric capable can be interconnected together to take advange of RDMA via DAPL (direct access programming library) to execute programs and distribute the processing on neighboring HPMCs.
It is possible to interconnect two or more HPMCs DMA using switched network cards, called infinibands. An application that is executed on the MIC of an HPMC can also be executed on the MIC of another HPMC system. This parallel programming is possible with MPI.
Parallel programming with MPI, Message Passing Interface, can be performed on your HPMC calculator. If you have two or more HPMC calculators interconnected with fabric wiring, then you can scale the execution of your MPI program by allocating more threads.
In MPI, the programmer does not need to focus on shared memory as each processor has its own private memory. Processors communicate between each other by explcitly sending messages (trhough communicators). Each process within a communicator has a unique rank identified by an integer starting at zero. When running the MPI program, one can specify a number for the ranks. The message passing between processes permits the exchange of data, while the sending of messages can contain buffers of data specifying the receiving process rank.
The core (* not CPU core) of such execution is laid through RDMA basic and essential components, all known to be stacked in what is called rdma-core. Message passing across the RDMA is essentially what allows the software application to be executed on a group (* we will avoid using cluster or clustering) of HPMC. The Message Passing Interface (MPI) is a set of RFC protocol (open or not open) that allows the execution of a program to be distributed on many HPMCs. While MPI is a monotonic interface that explores the RDMA and IPoIB switching (subject of DAPL) its execution benefits from leaving the Central Processing Unit (CPU) alone, hence it is asynchronous and fully duplexed depending on the Net-InfiniBand.
Consider the following trap_offload.c program that we will be running to test the MPI execution on our HPMCs.
1. #include <math.h> 2. #include <mpi.h> 3. #include <stdio.h> 4. #include <unistd.h> 5. #define NUM_TRAPEZOIDS 10000000000 6. __attribute__((target(mic))) inline double f(double x) { 7. return 1.00*x*x*exp(-(x-0.0)*(x-0.0)/(2.0*0.25*0.25)) 8. + 0.50*x*x*exp(-(x-0.2)*(x-0.2)/(2.0*0.50*0.50)) 9. + 0.50*x*x*exp(-(x+0.2)*(x+0.2)/(2.0*0.50*0.50)) 10. + 0.25*x*x*exp(-(x-0.4)*(x-0.4)/(2.0*1.00*1.00)) 11. + 0.25*x*x*exp(-(x+0.4)*(x+0.4)/(2.0*1.00*1.00)); 12. } 13. 14. int main (int argc, char *argv[]) { 15. int namelen, rank, size; 16. char name[MPI_MAX_PROCESSOR_NAME]; 17. double upper_bound = 5.0, lower_bound = -5.0; 18. double x0, x1, width; 19. double integral = 0; 20. double compute_time, total_time; 21. int chunk_size; 22. MPI_Init(&argc, &argv); 23. MPI_Comm_size(MPI_COMM_WORLD, &size); 24. MPI_Comm_rank(MPI_COMM_WORLD, &rank); 25. MPI_Get_processor_name(name, &namelen); 26. chunk_size = NUM_TRAPEZOIDS / size; 27. x0 = lower_bound+(upper_bound-lower_bound)*rank/size; 28. x1 = x0 + (upper_bound - lower_bound)/size; 29. width = (x1-x0)/chunk_size; 30. MPI_Barrier(MPI_COMM_WORLD); 31. compute_time = total_time = MPI_Wtime(); 32. #pragma offload target(mic) 33. #pragma omp parallel 34. #pragma omp for reduction(+:integral) 35. for (int i = 0; i < chunk_size ; i++) { 36. integral += 0.5*width *(f(x0+width*i)+f(x0+width*(i+1))); 37. } 38. compute_time = MPI_Wtime() - compute_time; 39. MPI_Allreduce(MPI_IN_PLACE, &integral, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); 40. total_time = MPI_Wtime() - total_time; 41. printf("rank %d of %d on %s: %f seconds\n", rank, size, name, compute_time); 42. if (rank == 0) { 43. printf("integral = %f, time = %f\n", integral, total_time); 44. } 45. MPI_Finalize(); 46. return(0); 47. }
■ Offloading to MIC
We run the MPI program trap_offload by offloading it to the MIC. The following command shows how to run trap_offload using eight threads and two ranks. The command is executed on HPMC9.
13:36 root@HPMC9: /mm03fs/MPI # OMP_NUM_THREADS=8 I_MPI_FABRICS=ofa mpirun -n 2 ./trap_offload
13:36 root@HPMC9: /mm03fs/MPI # OMP_NUM_THREADS=8 I_MPI_FABRICS=ofa mpirun -n 2 ./trap_offload rank 0 of 2 on HPMC9: 22.342904 seconds integral = 1.856399, time = 22.342928 rank 1 of 2 on HPMC9: 22.163031 seconds
This section is not included in the SAMPLE PREVIEW.
13:17 root@HPMC9: /mm03fs/MPI # I_MPI_FABRICS=ofa mpirun -n 8 ./trap_offload
13:17 root@HPMC9: /mm03fs/MPI # I_MPI_FABRICS=ofa mpirun -n 8 ./trap_offload rank 0 of 8 on HPMC9: 10.728176 seconds integral = 1.856399, time = 13.593669 rank 1 of 8 on HPMC9: 9.398290 seconds rank 2 of 8 on HPMC9: 12.958419 seconds rank 3 of 8 on HPMC9: 11.538105 seconds rank 4 of 8 on HPMC9: 13.529295 seconds rank 5 of 8 on HPMC9: 13.593640 seconds rank 6 of 8 on HPMC9: 13.218497 seconds rank 7 of 8 on HPMC9: 13.058236 seconds
■ Behind the Scene when Offloading to MIC
On HPMC we will issue the command, let's call it mpi-hydra command, so that it run on HPMC7's MIC. While the program is executing, we will capture the processes on HPMC7 and its MIC.
From HPMC we can ping HPMC7: From HPMC we can ping HPMC7's MIC, to make sure it is up:
This section is not included in the SAMPLE PREVIEW.
├─mpssd(17299)─┬─{mpssd}(17300)
│ ├─{mpssd}(17301)
│ ├─{mpssd}(17302)
│ └─{mpssd}(17375)
├─mpxyd(16747)
├─opensm-launch(15637)───opensm(15638)─┬─{opensm}(15666)
│ ├─{opensm}(15670)
│ ├─{opensm}(15671)
│ ├─{opensm}(15672)
│ ├─{opensm}(15673)
│ ├─{opensm}(15674)
... x 278 opensm for 278 cores on HPMC7
│ ├─{opensm}(15942)
│ ├─{opensm}(15943)
│ ├─{opensm}(15944)
│ ├─{opensm}(15945)
│ └─{opensm}(15946)
├─polkitd(16061,polkitd)─┬─{polkitd}(16076)
│ ├─{polkitd}(16077)
│ ├─{polkitd}(16078)
│ ├─{polkitd}(16080)
│ ├─{polkitd}(16081)
│ └─{polkitd}(16095)
├─rdma-ndd(15523)
├─rngd(16060)
├─rpc.idmapd(15953)
├─rpc.mountd(16773)
├─rpc.statd(16756,rpcuser)
├─rpcbind(16716,rpc)
├─rsyslogd(16681)─┬─{rsyslogd}(16706)
│ └─{rsyslogd}(16709)
├─smartd(15991)
├─sshd(16675)─┬─sshd(17194)───bash(17197)───pstree(35532)
│ ├─sshd(17392)───bash(17395)───ssh(26996)
│ └─sshd(35484)───pmi_proxy(35486)─┬─trap_offload(35514)─┬─{trap_offload}(35523)
│ │ ├─{trap_offload}(35529)
│ │ ├─{trap_offload}(35552)
│ │ └─{trap_offload}(35554)
│ ├─trap_offload(35515)─┬─{trap_offload}(35524)
│ │ ├─{trap_offload}(35526)
│ │ ├─{trap_offload}(35534)
│ │ └─{trap_offload}(35536)
│ ├─trap_offload(35516)─┬─{trap_offload}(35522)
│ │ ├─{trap_offload}(35527)
│ │ ├─{trap_offload}(35540)
│ │ └─{trap_offload}(35542)
│ └─trap_offload(35517)─┬─{trap_offload}(35525)
│ ├─{trap_offload}(35528)
│ ├─{trap_offload}(35546)
│ └─{trap_offload}(35548)
├─systemd-journal(11373)
├─systemd-logind(15981)
├─systemd-udevd(11431)
└─xinetd(16674)
The first rank (0 of 4) is managed by HPMC7; hence there are four processed, and each process has four sibling.
On the MIC, ranks 2, 3, and 4 are executed, each with 60 cores.
(HPMC7) 00:30 root@mic0: ~ # pstree -up
init(1)-+-coi_daemon(4610,micuser)-+-trap_offloadMIC(14405)-+-{trap_offloadMIC}(14410)
| | |-{trap_offloadMIC}(14412)
| | |-{trap_offloadMIC}(14413)
| | |-{trap_offloadMIC}(14414)
| | |-{trap_offloadMIC}(14415)
| | |-{trap_offloadMIC}(14417)
... x 60 (Tuncated for 60 total)
| | |-{trap_offloadMIC}(14470)
| | |-{trap_offloadMIC}(14471)
| | |-{trap_offloadMIC}(14472)
| | |-{trap_offloadMIC}(14473)
| | `-{trap_offloadMIC}(14474)
| |-trap_offloadMIC(14416)-+-{trap_offloadMIC}(14478)
| | |-{trap_offloadMIC}(14482)
| | |-{trap_offloadMIC}(14483)
| | |-{trap_offloadMIC}(14484)
| | |-{trap_offloadMIC}(14485)
... x 60 (Tuncated for 60 total)
| | |-{trap_offloadMIC}(14537)
| | |-{trap_offloadMIC}(14538)
| | |-{trap_offloadMIC}(14539)
| | |-{trap_offloadMIC}(14540)
| | `-{trap_offloadMIC}(14541)
| |-trap_offloadMIC(14475)-+-{trap_offloadMIC}(14543)
| | |-{trap_offloadMIC}(14545)
| | |-{trap_offloadMIC}(14548)
| | |-{trap_offloadMIC}(14549)
| | |-{trap_offloadMIC}(14550)
| | |-{trap_offloadMIC}(14551)
| | |-{trap_offloadMIC}(14552)
| | |-{trap_offloadMIC}(14553)
... x 60 (Tuncated for 60 total)
| | |-{trap_offloadMIC}(14603)
| | |-{trap_offloadMIC}(14604)
| | |-{trap_offloadMIC}(14605)
| | |-{trap_offloadMIC}(14606)
| | `-{trap_offloadMIC}(14607)
| |-{coi_daemon}(4612)
| `-{coi_daemon}(14407)
|-getty(4625)
|-klogd(4589)
|-mpssd(4594)-+-{mpssd}(4597)
| `-{mpssd}(4598)
|-portmap(4546,1)
|-sshd(4578)---sshd(14398)---bash(14400)---pstree(14479)
|-syslogd(4586)
`-udevd(4369)-+-udevd(4398)
`-udevd(4402)
Specifying more threads than the core available may cause high context switching. However, this should not be an issue, see Appendix MPI Threads and Ranks and Context Switching.
■ DAPL is Provided by the Switch
Let's turn off (or unplug) the switch to completely disable DAPL, then run the command. The command displays: dapl fabric is not available and fallback fabric is not enabled as shown below.
18:59 root@HPMC: /mm03fs/MPI # OMP_NUM_THREADS=220 I_MPI_DAPL_PROVIDER_LIST=ofa-v2-mlx4_0-1u I_MPI_PERHOST=1 I_MPI_DEBUG=5 I_MPI_FABRICS=shm:dapl I_MPI_FALLBACK=0 /opt/INTEL-XE-2017-update7/compilers_and_libraries_2017.7.259/linux/mpi/intel64/bin/mpiexec.hydra -n 8 -hosts hpmc7,hpmc9 ./trap_offload
[0] MPI startup(): Multi-threaded optimized library [3] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [5] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [1] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [7] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [0] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [2] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [4] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [6] DAPL startup(): trying to open DAPL provider from I_MPI_DAPL_PROVIDER: ofa-v2-mlx4_0-1u [5] DAPL startup(): failed to open DAPL provider ofa-v2-mlx4_0-1u [5] MPI startup(): dapl fabric is not available and fallback fabric is not enabled [3] DAPL startup(): failed to open DAPL provider ofa-v2-mlx4_0-1u [3] MPI startup(): dapl fabric is not available and fallback fabric is not enabled [7] DAPL startup(): failed to open DAPL provider ofa-v2-mlx4_0-1u
■ Running the MPI Program on Distributed HPMC's MIC
Both hpmc9 and hpmc7 are interconnected by infiniband.
Running the MPI program to be executed by hundreds of threads, by offloading through the library provider ofa (Open Fabrics Alliance), eg. I_MPI_FABRICS=ofa. Even can be dispatched to be completely executed on multiple HPMC's MIC RDMA via DAPL (direct access programming library), eg. I_MPI_DAPL_PROVIDER_LIST=ofa-v2-mlx4_0-1u MPI_FABRICS=shm:dapl, where shm means shared memory transport (used for intra-node communication only).
This section is not included in the SAMPLE PREVIEW.
On HPMC7's MIC we display the processes:
(uos/HPMC7) 01:11 root@mic0: ~ # pstree -up
(HPMC7) 01:11 root@mic0: ~ # pstree -up
init(1)-+-coi_daemon(4610,micuser)-+-trap_offloadMIC(31521)-+-{trap_offloadMIC}(31526)
| | |-{trap_offloadMIC}(31528)
| | |-{trap_offloadMIC}(31529)
| | |-{trap_offloadMIC}(31530)
| | |-{trap_offloadMIC}(31531)
| | |-{trap_offloadMIC}(31533)
... x 220 (Tuncated for 220 total)
| | |-{trap_offloadMIC}(31855)
| | |-{trap_offloadMIC}(31858)
| | |-{trap_offloadMIC}(31860)
| | |-{trap_offloadMIC}(31863)
| | `-{trap_offloadMIC}(31865)
| |-trap_offloadMIC(31532)-+-{trap_offloadMIC}(31621)
| | |-{trap_offloadMIC}(31630)
| | |-{trap_offloadMIC}(31661)
| | |-{trap_offloadMIC}(31663)
| | |-{trap_offloadMIC}(31666)
| | |-{trap_offloadMIC}(31669)
| | |-{trap_offloadMIC}(31671)
... x 220 (Tuncated for 220 total)
| | |-{trap_offloadMIC}(31994)
| | |-{trap_offloadMIC}(31995)
| | |-{trap_offloadMIC}(31996)
| | |-{trap_offloadMIC}(31997)
| | `-{trap_offloadMIC}(31998)
| |-trap_offloadMIC(31664)-+-{trap_offloadMIC}(31864)
| | |-{trap_offloadMIC}(31878)
| | |-{trap_offloadMIC}(31951)
| | |-{trap_offloadMIC}(31952)
| | |-{trap_offloadMIC}(31955)
| | |-{trap_offloadMIC}(31959)
... x 220 (Tuncated for 220 total)
| | |-{trap_offloadMIC}(32198)
| | |-{trap_offloadMIC}(32199)
| | |-{trap_offloadMIC}(32200)
| | |-{trap_offloadMIC}(32201)
| | |-{trap_offloadMIC}(32202)
| | `-{trap_offloadMIC}(32203)
| |-{coi_daemon}(4612)
| `-{coi_daemon}(31523)
|-getty(4625)
|-klogd(4589)
|-mpssd(4594)-+-{mpssd}(4597)
| `-{mpssd}(4598)
|-portmap(4546,1)
|-sshd(4578)---sshd(14398)---bash(14400)---pstree(31742)
|-syslogd(4586)
`-udevd(4369)-+-udevd(4398)
`-udevd(4402)
This section is not included in the SAMPLE PREVIEW.
What happens when a participant host is taken off line while the program is executing? As an exercise, we can test the persistence of the DAPL command by disconnecting one of the node. For example, disconnecting the hpmc7 from the switch is simply realized by pulling out the connector from its HCA as shown in Figure 6.2.1. In this case, since hpmc9 is still connected, the MPI command will run on hpmc9.
■ Running the MPI Program Using One Single Thread
Finally, to compare the efficiency of MPI execution using threads, we will run the same program using one single core by setting OMP_NUM_THREADS=1 and using one single rank -n 1.
This section is not included in the SAMPLE PREVIEW.
On HPMC7 host only one process with four siblings are started for the rank 0 of 1.
00:50 root@HPMC7: ~ # pstree -up
├─sshd(16702)─┬─sshd(24515)───bash(24517)───pstree(61956)
│ ├─sshd(25707)───bash(25709)───ssh(25769)
│ └─sshd(61915)───pmi_proxy(61917)───trap_offload(61944)─┬─{trap_offload}(61946)
│ ├─{trap_offload}(61947)
│ ├─{trap_offload}(61952)
│ └─{trap_offload}(61954)
├─systemd-journal(11323)
├─systemd-logind(16007)
├─systemd-udevd(11394)
└─xinetd(16728)
On HPMC7's MIC only one thread used.
(uos/HPMC7) 23:50 root@mic0: ~ # pstree -up
(HPMC7) 00:50 root@mic0: ~ # pstree -up
init(1)-+-coi_daemon(4610,micuser)-+-trap_offloadMIC(28824)-+-{trap_offloadMIC}(28829)
| | `-{trap_offloadMIC}(28831)
| |-{coi_daemon}(4612)
| `-{coi_daemon}(28826)
|-getty(4625)
|-klogd(4589)
|-mpssd(4595)-+-{mpssd}(4597)
| `-{mpssd}(4598)
|-portmap(4545,1)
|-sshd(4578)---sshd(5555)---bash(5557)---pstree(28832)
|-syslogd(4586)
`-udevd(4369)-+-udevd(4399)
`-udevd(4592)