Move MDModules initialization earlier
[gromacs.git] / cmake / TestAtomics.cpp
blobb5679569c8b75666c7a4e567a657ef17f133ea77
2 #define TMPI_CHECK_ATOMICS
3 #include "thread_mpi/atomic.h"
5 int main(void)
7 int i;
8 void *ptr;
9 tMPI_Atomic_t some_atomic;
10 tMPI_Atomic_ptr_t *some_atomic_ptr = NULL;
11 tMPI_Spinlock_t some_spinlock;
13 /* Make the compiler actually emit code for these functions, so
14 that things like inability to emit inline assembly get
15 tested. It is not expected that the code below can run. */
16 tMPI_Atomic_memory_barrier();
17 tMPI_Atomic_memory_barrier_acq();
18 tMPI_Atomic_memory_barrier_rel();
19 i = tMPI_Atomic_get(&some_atomic);
20 tMPI_Atomic_set(&some_atomic, 0);
21 ptr = tMPI_Atomic_ptr_get(some_atomic_ptr);
22 tMPI_Atomic_ptr_set(some_atomic_ptr, ptr);
23 tMPI_Atomic_add_return(&some_atomic, 0);
24 tMPI_Atomic_fetch_add(&some_atomic, 0);
25 tMPI_Atomic_cas(&some_atomic, 0, 1);
26 tMPI_Atomic_ptr_cas(some_atomic_ptr, ptr, ptr);
27 tMPI_Atomic_swap(&some_atomic, 0);
28 tMPI_Atomic_ptr_swap(some_atomic_ptr, ptr);
29 tMPI_Spinlock_init(&some_spinlock);
30 tMPI_Spinlock_lock(&some_spinlock);
31 tMPI_Spinlock_trylock(&some_spinlock);
32 tMPI_Spinlock_unlock(&some_spinlock);
33 tMPI_Spinlock_islocked(&some_spinlock);
34 tMPI_Spinlock_wait(&some_spinlock);
35 return 0;