X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.2 Date: Tue, 09 Jan 2001 13:35:50 -0600 To: mpi-core@XXXXXXXXXXX From: William Gropp Subject: Are attribute copy functions synchronized? Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-mpi-core@XXXXXXXXXXXXX Precedence: bulk Consider the following case: two threads belonging to the same process both execute MPI_COMM_DUP on different communicators at the same time. In addition, both of these communicators have an attribute for a particular keyval whose copy function looks something like this: int attr_copy( MPI_Comm oldcomm, int keyval, void *extra_state, void *attribute_val_in, void *attribute_val_out, int *flag ) { int *tag_p = (int *)extra_state; int *aval_p; aval_p = (int *)malloc( sizeof(int) ); if (!aval_p) MPI_Abort(MPI_COMM_WORLD,0); *aval_p = *tag_p; *tag_p = *tag_p + 1; *(void **)attribute_val_out = aval_p; *flag = 1; return MPI_SUCCESS; } This attribute is intended to provide an integer sequence number to each communicator, based on a single, global value maintained in the keyval's extra_state. In the multithreaded case, it is possible for both threads to read the same value from *tag_p. Is this a user error? Should a multithreaded MPI ensure that only one thread at a time invokes an attribute copy (or delete) function? From a user's perspective, I'd answer yes to both - it is a user error, but I'd like the MPI implementation to handle this for me. A related question is: Is it erroneous for an MPI implementation to ensure that only one thread at a time invokes an attribute copy or delete function? Bill