brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 994ce8e Raw
35 lines · cpp
1// RUN: %clang_analyze_cc1 -analyzer-checker=optin.mpi.MPI-Checker -analyzer-output=text -verify %s2 3// MPI-Checker test file to test note diagnostics.4 5#include "MPIMock.h"6 7void 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 15void 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 all22// point to the first call as the 'previous' call. This is because the23// BugReporterVisitor only checks for differences in state or existence of an24// entity.25void 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}35