source: CIVL/examples/mpi/abstract_array2.cvl@ e2570cd

main test-branch
Last change on this file since e2570cd was 5514bd7, checked in by Stephen Siegel <siegel@…>, 15 months ago

Adding a few more tests and examples: 2 for MPI using lambdas, and one LanguageFeatureTest
using a bad lambda expression that should result in an error message but instead crashes.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5953 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 499 bytes
RevLine 
[5514bd7]1#include <mpi.h>
2
3int main(void) {
4 int nproc, rank;
5 MPI_Init(NULL, NULL);
6 MPI_Comm_size(MPI_COMM_WORLD, &nproc);
7 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
8 $assert(nproc >= 2);
9 int a[] = (int[2]) $lambda(int i) rank;
10 if (rank == 0) {
11 int b[2*nproc];
12 MPI_Gather(a, 2, MPI_INT, b, 2, MPI_INT, 0, MPI_COMM_WORLD);
13 $assert($forall (int i:0..nproc-1) (b[2*i]==i && b[2*i+1]==i));
14 } else {
15 MPI_Gather(a, 2, MPI_INT, NULL, 0, MPI_INT, 0, MPI_COMM_WORLD);
16 }
17 MPI_Finalize();
18}
Note: See TracBrowser for help on using the repository browser.