54 INTEGER,
PARAMETER :: num_iterations = 128
56 INTEGER :: dest, expected, iter, nthreads, &
57 recv_value, send_value, source, tag, &
60 thread_id = omp_get_thread_num()
61 nthreads = omp_get_num_threads()
62 cpassert(nthreads == 2)
63 cpassert(thread_id >= 0 .AND. thread_id < nthreads)
65 dest =
modulo(comm%mepos + 1, comm%num_pe)
66 source =
modulo(comm%mepos - 1, comm%num_pe)
68 DO iter = 1, num_iterations
69 tag = (iter - 1)*nthreads + thread_id
70 send_value = (comm%num_pe*(iter - 1) + comm%mepos)*nthreads + thread_id
71 CALL comm%sendrecv(send_value, dest, recv_value, source, tag=tag)
72 expected = (comm%num_pe*(iter - 1) + source)*nthreads + thread_id
73 cpassert(recv_value == expected)
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....