[mpich] MPICH primary repository branch, master, updated. v3.1rc1-16-g40c6fda
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "MPICH primary repository". The branch, master has been updated via 40c6fda95428adbaf8938d33031d24b160af9539 (commit) via 85e4a5072e3b1edd3651357601e9e72c18f887b6 (commit) via ad44b6b335b1b07b4ef9c4baf22341ad6d76710e (commit) from 120bff0671e8d034262af5060a33cb7836a2513c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://git.mpich.org/mpich.git/commitdiff/40c6fda95428adbaf8938d33031d24b160... commit 40c6fda95428adbaf8938d33031d24b160af9539 Author: Huiwei Lu <[email protected]> Date: Wed Nov 13 10:01:25 2013 -0600 Fix #1879 - fix test script fix testlist Signed-off-by: Junchao Zhang <[email protected]> diff --git a/test/mpi/threads/pt2pt/testlist b/test/mpi/threads/pt2pt/testlist index ce8fc9c..b6ab43e 100644 --- a/test/mpi/threads/pt2pt/testlist +++ b/test/mpi/threads/pt2pt/testlist @@ -8,4 +8,4 @@ multisend3 5 multisend4 5 greq_wait 1 greq_test 1 -ibtest 2 +ibsend 2 http://git.mpich.org/mpich.git/commitdiff/85e4a5072e3b1edd3651357601e9e72c18... commit 85e4a5072e3b1edd3651357601e9e72c18f887b6 Author: Huiwei Lu <[email protected]> Date: Mon Nov 11 11:28:22 2013 -0600 Fix #1879 - false alarm, bug is in user code First, this ticket is caused in the user code of ibsend.c where multiple pthreads are created using the same pthread variable. This leads to unexpected behaviors where detached threads screw up with MPI_Comm_free when both of them calls ALLFUNC lock in unexpected order, thus leads to the assertion failure in initthread.c:213. Second, BSEND lock in the proposed patch in trac is unnecessary. Basically the patch is to create a new lock, BSEND, to lock the function of MPIR_Bsend_isend for thread safety; however, MPIR_Bsend_isend is already called inside a ALLFUNC lock both in MPI_Bsend and MPI_Ibsend. See attached test/mpi/threads/pt2pt/ibsend.c for correct use of pthread_create and pthread_join diff --git a/test/mpi/threads/pt2pt/ibsend.c b/test/mpi/threads/pt2pt/ibsend.c index 168c2fd..c21fd69 100644 --- a/test/mpi/threads/pt2pt/ibsend.c +++ b/test/mpi/threads/pt2pt/ibsend.c @@ -1,19 +1,19 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* - This program performs a short test of MPI_BSEND in a - multithreaded environment. + This program performs a short test of MPI_BSEND in a + multithreaded environment. - It starts a single receiver thread that expects - NUMSENDS messages and NUMSENDS sender threads, that - use MPI_Bsend to send a message of size MSGSIZE - to its right neigbour or rank 0 if (my_rank==comm_size-1), i.e. - target_rank = (my_rank+1)%size . + It starts a single receiver thread that expects + NUMSENDS messages and NUMSENDS sender threads, that + use MPI_Bsend to send a message of size MSGSIZE + to its right neigbour or rank 0 if (my_rank==comm_size-1), i.e. + target_rank = (my_rank+1)%size . - After all messages have been received, the - receiver thread prints a message, the threads - are joined into the main thread and the application - terminates. -*/ + After all messages have been received, the + receiver thread prints a message, the threads + are joined into the main thread and the application + terminates. + */ #include <stdio.h> #include <stdlib.h> @@ -37,7 +37,7 @@ void *receiver(void *ptr) MPI_Recv(buf, MSGSIZE, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - return NULL; + pthread_exit(NULL); } @@ -46,7 +46,8 @@ void *sender_bsend(void *ptr) char buffer[MSGSIZE]; MPI_Bsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD); - return NULL; + + pthread_exit(NULL); } void *sender_ibsend(void *ptr) @@ -57,7 +58,7 @@ void *sender_ibsend(void *ptr) MPI_COMM_WORLD, &req); MPI_Wait(&req, MPI_STATUS_IGNORE); - return NULL; + pthread_exit(NULL); } void *sender_isend(void *ptr) @@ -67,7 +68,8 @@ void *sender_isend(void *ptr) MPI_Isend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD, &req); MPI_Wait(&req, MPI_STATUS_IGNORE); - return NULL; + + pthread_exit(NULL); } void *sender_send(void *ptr) @@ -75,16 +77,19 @@ void *sender_send(void *ptr) char buffer[MSGSIZE]; MPI_Send(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD); - return NULL; + + pthread_exit(NULL); } int main(int argc, char *argv[]) { int provided, i[2], k; - char *buffer; + char *buffer, *ptr_dt; + buffer = (char *) malloc(BUFSIZE * sizeof(char)); MPI_Status status; - pthread_t receiver_thread, sender_thread; + pthread_t receiver_thread, sender_thread[NUMSENDS]; + pthread_attr_t attr; MPI_Comm communicator; int bs; @@ -95,7 +100,7 @@ int main(int argc, char *argv[]) MPI_Abort(911, MPI_COMM_WORLD); } - MPI_Buffer_attach(malloc(BUFSIZE), BUFSIZE); + MPI_Buffer_attach(buffer, BUFSIZE); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); @@ -104,43 +109,48 @@ int main(int argc, char *argv[]) If the MPI_Comm_dup() call is commented out, it is still evident but does not appear that often (don't know why) */ - pthread_create(&receiver_thread, NULL, &receiver, NULL); + /* Initialize and set thread detached attribute */ + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + + pthread_create(&receiver_thread, &attr, &receiver, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_create(&sender_thread, NULL, &sender_bsend, NULL); + pthread_create(&sender_thread[k], &attr, &sender_bsend, NULL); pthread_join(receiver_thread, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_join(sender_thread, NULL); + pthread_join(sender_thread[k], NULL); MPI_Barrier(MPI_COMM_WORLD); - pthread_create(&receiver_thread, NULL, &receiver, NULL); + pthread_create(&receiver_thread, &attr, &receiver, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_create(&sender_thread, NULL, &sender_ibsend, NULL); + pthread_create(&sender_thread[k], &attr, &sender_ibsend, NULL); pthread_join(receiver_thread, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_join(sender_thread, NULL); + pthread_join(sender_thread[k], NULL); MPI_Barrier(MPI_COMM_WORLD); - pthread_create(&receiver_thread, NULL, &receiver, NULL); + pthread_create(&receiver_thread, &attr, &receiver, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_create(&sender_thread, NULL, &sender_isend, NULL); + pthread_create(&sender_thread[k], &attr, &sender_isend, NULL); pthread_join(receiver_thread, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_join(sender_thread, NULL); + pthread_join(sender_thread[k], NULL); MPI_Barrier(MPI_COMM_WORLD); - pthread_create(&receiver_thread, NULL, &receiver, NULL); + pthread_create(&receiver_thread, &attr, &receiver, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_create(&sender_thread, NULL, &sender_send, NULL); + pthread_create(&sender_thread[k], &attr, &sender_send, NULL); pthread_join(receiver_thread, NULL); for (k = 0; k < NUMSENDS; k++) - pthread_join(sender_thread, NULL); + pthread_join(sender_thread[k], NULL); MPI_Barrier(MPI_COMM_WORLD); + pthread_attr_destroy(&attr); if (!rank) printf( " No Errors\n" ); MPI_Comm_free(&communicator); - MPI_Buffer_detach(&buffer, &bs); + MPI_Buffer_detach(&ptr_dt, &bs); free(buffer); MPI_Finalize(); } http://git.mpich.org/mpich.git/commitdiff/ad44b6b335b1b07b4ef9c4baf22341ad6d... commit ad44b6b335b1b07b4ef9c4baf22341ad6d76710e Author: Huiwei Lu <[email protected]> Date: Wed Nov 6 18:06:02 2013 -0600 Fix #1879 - Adds a test case for ibsend Adds a test case for ibsend/bsend/isend/send in threading execution. diff --git a/test/mpi/threads/pt2pt/Makefile.am b/test/mpi/threads/pt2pt/Makefile.am index efa573b..7030260 100644 --- a/test/mpi/threads/pt2pt/Makefile.am +++ b/test/mpi/threads/pt2pt/Makefile.am @@ -10,5 +10,5 @@ include $(top_srcdir)/threads/Makefile_threads.mtest EXTRA_DIST = testlist noinst_PROGRAMS = threads threaded_sr alltoall sendselfth greq_wait greq_test \ - multisend multisend2 multisend3 multisend4 + multisend multisend2 multisend3 multisend4 ibsend diff --git a/test/mpi/threads/pt2pt/ibsend.c b/test/mpi/threads/pt2pt/ibsend.c new file mode 100644 index 0000000..168c2fd --- /dev/null +++ b/test/mpi/threads/pt2pt/ibsend.c @@ -0,0 +1,146 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + This program performs a short test of MPI_BSEND in a + multithreaded environment. + + It starts a single receiver thread that expects + NUMSENDS messages and NUMSENDS sender threads, that + use MPI_Bsend to send a message of size MSGSIZE + to its right neigbour or rank 0 if (my_rank==comm_size-1), i.e. + target_rank = (my_rank+1)%size . + + After all messages have been received, the + receiver thread prints a message, the threads + are joined into the main thread and the application + terminates. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <mpi.h> +#include <string.h> +#include "mpitest.h" +#include "mpithreadtest.h" + +#define NUMSENDS 32 +#define BUFSIZE 10000000 +#define MSGSIZE 1024 + +int rank, size; + +void *receiver(void *ptr) +{ + int k; + char buf[MSGSIZE]; + + for (k = 0; k < NUMSENDS; k++) + MPI_Recv(buf, MSGSIZE, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, + MPI_COMM_WORLD, MPI_STATUS_IGNORE); + + return NULL; +} + + +void *sender_bsend(void *ptr) +{ + char buffer[MSGSIZE]; + MPI_Bsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, + MPI_COMM_WORLD); + return NULL; +} + +void *sender_ibsend(void *ptr) +{ + char buffer[MSGSIZE]; + MPI_Request req; + MPI_Ibsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, + MPI_COMM_WORLD, &req); + MPI_Wait(&req, MPI_STATUS_IGNORE); + + return NULL; +} + +void *sender_isend(void *ptr) +{ + char buffer[MSGSIZE]; + MPI_Request req; + MPI_Isend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, + MPI_COMM_WORLD, &req); + MPI_Wait(&req, MPI_STATUS_IGNORE); + return NULL; +} + +void *sender_send(void *ptr) +{ + char buffer[MSGSIZE]; + MPI_Send(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, + MPI_COMM_WORLD); + return NULL; +} + +int main(int argc, char *argv[]) +{ + + int provided, i[2], k; + char *buffer; + MPI_Status status; + pthread_t receiver_thread, sender_thread; + MPI_Comm communicator; + int bs; + + MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); + + if (provided != MPI_THREAD_MULTIPLE) { + printf("Error\n"); + MPI_Abort(911, MPI_COMM_WORLD); + } + + MPI_Buffer_attach(malloc(BUFSIZE), BUFSIZE); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_dup(MPI_COMM_WORLD, &communicator); /* We do not use this communicator in this program, but + with this call, the problem appears more reliably. + If the MPI_Comm_dup() call is commented out, it is still + evident but does not appear that often (don't know why) */ + + pthread_create(&receiver_thread, NULL, &receiver, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_create(&sender_thread, NULL, &sender_bsend, NULL); + pthread_join(receiver_thread, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_join(sender_thread, NULL); + MPI_Barrier(MPI_COMM_WORLD); + + pthread_create(&receiver_thread, NULL, &receiver, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_create(&sender_thread, NULL, &sender_ibsend, NULL); + pthread_join(receiver_thread, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_join(sender_thread, NULL); + MPI_Barrier(MPI_COMM_WORLD); + + pthread_create(&receiver_thread, NULL, &receiver, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_create(&sender_thread, NULL, &sender_isend, NULL); + pthread_join(receiver_thread, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_join(sender_thread, NULL); + MPI_Barrier(MPI_COMM_WORLD); + + pthread_create(&receiver_thread, NULL, &receiver, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_create(&sender_thread, NULL, &sender_send, NULL); + pthread_join(receiver_thread, NULL); + for (k = 0; k < NUMSENDS; k++) + pthread_join(sender_thread, NULL); + MPI_Barrier(MPI_COMM_WORLD); + + if (!rank) + printf( " No Errors\n" ); + + MPI_Comm_free(&communicator); + MPI_Buffer_detach(&buffer, &bs); + free(buffer); + MPI_Finalize(); +} diff --git a/test/mpi/threads/pt2pt/testlist b/test/mpi/threads/pt2pt/testlist index 760238f..ce8fc9c 100644 --- a/test/mpi/threads/pt2pt/testlist +++ b/test/mpi/threads/pt2pt/testlist @@ -8,3 +8,4 @@ multisend3 5 multisend4 5 greq_wait 1 greq_test 1 +ibtest 2 ----------------------------------------------------------------------- Summary of changes: test/mpi/threads/pt2pt/Makefile.am | 2 +- test/mpi/threads/pt2pt/ibsend.c | 156 ++++++++++++++++++++++++++++++++++++ test/mpi/threads/pt2pt/testlist | 1 + 3 files changed, 158 insertions(+), 1 deletions(-) create mode 100644 test/mpi/threads/pt2pt/ibsend.c hooks/post-receive -- MPICH primary repository
participants (1)
-
noreply@mpich.org