| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=optin.mpi.MPI-Checker -analyzer-output=text -verify %s |
| 2 |
|
| 3 |
// MPI-Checker test file to test note diagnostics. |
| 4 |
|
| 5 |
#include "MPIMock.h" |
| 6 |
|
| 7 |
void doubleNonblocking() { |
| 8 |
double buf = 0; |
| 9 |
MPI_Request sendReq; |
| 10 |
MPI_Isend(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // expected-note{{Request is previously used by nonblocking call here.}} |
| 11 |
MPI_Irecv(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // expected-warning{{Double nonblocking on request 'sendReq'.}} expected-note{{Double nonblocking on request 'sendReq'.}} |
| 12 |
MPI_Wait(&sendReq, MPI_STATUS_IGNORE); |
| 13 |
} |
| 14 |
|
| 15 |
void missingWait() { |
| 16 |
double buf = 0; |
| 17 |
MPI_Request sendReq; |
| 18 |
MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, &sendReq); // expected-note{{Request is previously used by nonblocking call here.}} |
| 19 |
} // expected-warning{{Request 'sendReq' has no matching wait.}} expected-note{{Request 'sendReq' has no matching wait.}} |
| 20 |
|
| 21 |
// If more than 2 nonblocking calls are using a request in a sequence, they all |
| 22 |
// point to the first call as the 'previous' call. This is because the |
| 23 |
// BugReporterVisitor only checks for differences in state or existence of an |
| 24 |
// entity. |
| 25 |
void tripleNonblocking() { |
| 26 |
double buf = 0; |
| 27 |
MPI_Request sendReq; |
| 28 |
MPI_Isend(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // expected-note 2{{Request is previously used by nonblocking call here.}} |
| 29 |
MPI_Irecv(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // expected-warning{{Double nonblocking on request 'sendReq'.}} expected-note{{Double nonblocking on request 'sendReq'.}} |
| 30 |
|
| 31 |
MPI_Isend(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // expected-warning{{Double nonblocking on request 'sendReq'.}} expected-note{{Double nonblocking on request 'sendReq'.}} |
| 32 |
|
| 33 |
MPI_Wait(&sendReq, MPI_STATUS_IGNORE); |
| 34 |
} |