| 467 | ==== Examples ==== |
| 468 | |
| 469 | {{{ |
| 470 | MPI_Info_create(&info); |
| 471 | MPI_Info_set(info, "psnam_manifestation", "psnam_manifestation_libnam"); |
| 472 | MPI_Info_set(info, "psnam_consistency", "psnam_consistency_volatile"); |
| 473 | |
| 474 | // Allocate a "raw_and_flat" window: |
| 475 | MPI_Info_set(win, "psnam_structure", "psnam_structure_raw_and_flat"); |
| 476 | MPI_Win_allocate(rank ? 0 : win_size, 1, info, comm, NULL, &win_flat); |
| 477 | |
| 478 | // Put some data into the "raw_and_flat" window: |
| 479 | MPI_Win_fence(0, win_flat); |
| 480 | if (rank == 0) |
| 481 | MPI_Put(data_ptr, win_size, MPI_BYTE, 0 /*=target*/, 0 /*=offset*/, win_size, MPI_BYTE, win_flat); |
| 482 | MPI_Win_fence(0, win_flat); |
| 483 | … |
| 484 | |
| 485 | // Allocate a "managed_distributed" window: |
| 486 | MPI_Info_set(win, "psnam_structure", "psnam_structure_ managed_distributed"); |
| 487 | MPI_Win_allocate(my_region_size * sizeof(int), sizeof(int) , info, comm, NULL, &win_dist); |
| 488 | |
| 489 | // Put some data into the "managed_distributed" window: |
| 490 | MPI_Win_fence(0, win_dist); |
| 491 | MPI_Put(data_ptr, my_region_size, MPI_INT, my_rank, 0 /*=offset*/, my_region_size, MPI_INT, win_dist); |
| 492 | MPI_Win_fence(0, win_dist); |
| 493 | … |
| 494 | }}} |
| 495 | |
| 496 | |
| 497 | === Persistent MPI Windows === |
| 498 | |
| 499 | ==== General Semantics ==== |
| 500 | |
| 501 | A central use-case for the NAM in DEEP-EST is the idea of facilitating workflows between different applications and/or application steps. |
| 502 | For doing so, the data once put into NAM memory shall later be re-usable by other MPI applications and/or sessions. |
| 503 | Of course, this requires that NAM regions--and hence also their related MPI windows--can somehow be denoted as "persistent" so that their content gets not be wiped when the window is freed. |
| 504 | In fact, this can be achieved by setting the above mentioned `psnam_consistency_persistent` MPI info key when calling `MPI_Win_allocate()`. |
| 505 | |
| 506 | ==== Window Names ==== |
| 507 | |
| 508 | If the creation of the persistent NAM window was successful, the related NAM regions become addressable as a joint entity by means of a logical name that is system-wide unique. |
| 509 | This window name can then in turn be retrieved by querying the info object attached to that window afterwards via the info key `psnam_window_name`. |
| 510 | If an MPI application wants to pass data via such a persistent window to a subsequent MPI application, it merely has to pass this window name somehow to its successor so that this other MPI session can then re-attach to the respective window. |
| 511 | The passing of this window name could, for example, be done via standard I/O, via command line arguments, or even via MPI-based name publishing. |
| 512 | As the knowledge about this string allows other MPI sessions to attach and to modify the data within the persistent window, it is the responsibility of the application programmer to ensure that data races are avoided—for example, by locally releasing the window via `MPI_Win_free()` before publishing the window name. |
| 513 | |
| 514 | |
| 515 | ==== Example ==== |
| 516 | |
| 517 | {{{ |
| 518 | MPI_Info_create(&info); |
| 519 | MPI_Info_set(info, "psnam_consistency", "psnam_consistency_persistent"); |
| 520 | MPI_Win_allocate(sizeof(int) * ELEMENTS_PER_PROC, sizeof(int), info, comm, NULL, &win); |
| 521 | MPI_Info_free(&info); |
| 522 | |
| 523 | MPI_Win_get_info(win, &info); |
| 524 | MPI_Info_get(info, "psnam_window_name", INFO_VALUE_LEN, info_value, &flag); |
| 525 | if(flag) { strcpy(window_name, info_value); |
| 526 | printf("The window's name is: %s\n", window_name); |
| 527 | } else { printf("No psnam window name found!\n"); |
| 528 | MPI_Abort(MPI_COMM_WORLD, -1); |
| 529 | } |
| 530 | … |
| 531 | // Work on window... |
| 532 | … |
| 533 | |
| 534 | MPI_Win_free(&win); |
| 535 | if(comm_rank == 0) { |
| 536 | sprintf(service_name, "%s:my-peristent-psnam-window", argv[0]); |
| 537 | MPI_Publish_name(service_name, MPI_INFO_NULL, window_name); |
| 538 | } |
| 539 | }}} |