Locking seems to be broken if the lock variable is runtime-allocated. #9
Open
Description
I'm running Fedora 33 with system packages openmpi-4.0.5, ucx-1.10.1, gcc-10.3.1
Reproducer (slight modification of the OpenSHMEM 1.5 spec document):
#include <shmem.h>
#include <stdio.h>
int main(void) {
static int count = 0;
shmem_init();
#if 0
static long _lock = 0;
long *lock = &_lock;
#else
long *lock = shmem_malloc(sizeof(long));
*lock = 0;
shmem_barrier_all();
#endif
int mype = shmem_my_pe();
shmem_set_lock(lock);
int val = shmem_g(&count, 0); /* get count value on PE 0 */
printf("%d: count is %d\n", mype, val);
val++; /* incrementing and updating count on PE 0 */
shmem_p(&count, val, 0);
shmem_clear_lock(lock); /* ensures count update completes before clearing the lock */
shmem_finalize();
return 0;
}
$ oshcc tmp2.c
$ oshrun -n 5 ./a.out
0: count is 0
2: count is 1
3: count is 2
4: count is 1
1: count is 3
$ oshrun -n 5 ./a.out
1: count is 0
3: count is 0
4: count is 0
0: count is 1
2: count is 2
Note: If you switch #if 0
-> #if 1
, then things work as expected:
$ oshrun -n 5 ./a.out
2: count is 2
4: count is 0
0: count is 1
1: count is 3
3: count is 4
Metadata
Assignees
Labels
No labels