|
Workshops differ in how this is done. The instructor will go over this beforehand.
In your home directory, create a pthreads subdirectory for the example codes, copy the example codes and then cd into your pthreads subdirectory:
mkdir pthreads
cp /usr/global/docs/training/blaise/pthreads/* ~/pthreads
cd pthreads
You should notice a number of files as shown in the table below.
File Name | Description | |
---|---|---|
arrayloops.c arrayloops.f |
Data decomposition by loop distribution. Fortran example only works under IBM AIX: see comments in source code for compilation instructions. | |
condvar.c | ||
detached.c |
Demonstrates how to explicitly create pthreads in a detached state. | |
dotprod_mutex.c dotprod_serial.c |
Mutex variable example using a dot product program. Both a serial and pthreads version of the code are available. | |
hello.c |
Simple "Hello World" example | |
hello32.c |
"Hello World" pthreads program demonstrating thread scheduling behavior. | |
hello_arg1.c |
One correct way of passing the pthread_create() argument. | |
hello_arg2.c |
Another correct method of passing the pthread_create() argument, this time using a structure to pass multiple arguments. | |
join.c |
Demonstrates how to explicitly create pthreads in a joinable state for portability purposes. Also shows how to use the pthread_exit status parameter. | |
mpithreads_serial.c mpithreads_threads.c mpithreads_mpi.c mpithreads_both.c mpithreads.makefile |
A "series" of programs which demonstrate the progression for a serial dot product code to a hybrid MPI/Pthreads implementation. Files include the serial version, Pthreads version, MPI version, hybrid version and a makefile. | |
Bug Code | Bug Behavior | Hints/Notes |
bug1.c bug1fix.c |
Hangs | |
bug2.c bug2fix.c |
Seg fault/coredump | |
bug3.c |
Wrong answers | |
bug4.c bug4fix.c |
Hangs (usually) | |
bug5.c |
Threads die and never get to do their work | |
bug6.c bug6fix.c |
Wrong answer - run it several times to prove this |
If you need help, see the provided file.
icc -pthread -o hello myhello.c
pgcc -lpthread -o hello myhello.c
gcc -pthread -o hello myhello.c
When you get a clean compile, proceed.
mpithreads_serial.c
mpithreads_threads.c
mpithreads_mpi.c
mpithreads_both.c
mpithreads.makefile
These codes implement a dot product calculation and are designed to show the progression of developing a hybrid MPI / Pthreads program from a a serial code. The problem size increases as the examples go from serial, to threads/mpi to mpi with threads.
Suggestion: simply making and running this series of codes is rather unremarkable. Using the available lab time to understand what is actually happening is the intent. The instructor is available for your questions.
make -f mpithreads.makefile
Execution command | Description |
---|---|
mpithreads_serial |
Serial version - no threads or MPI |
mpithreads_threads |
Threads only version of the code using 8 threads |
srun -n8 -ppReserved mpithreads_mpi |
MPI only version with 8 tasks running on a single node in the special workshop pool |
srun -N4 -ppReserved mpithreads_both |
MPI with threads using 4 tasks running on 4 different nodes, each of which spawns 8 threads, running in special workshop pool |
This completes the exercise.
![]() |
Please complete the online evaluation form if you have not already done so for this tutorial. |
Where would you like to go now?