23 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
27 char const * test_strings[] = {
30 "This is a longer test string to check packing and unpacking "
34 NUM_TEST_STRINGS =
sizeof(test_strings) /
sizeof(test_strings[0])};
36 for (
size_t str_idx = 0; str_idx < NUM_TEST_STRINGS; ++str_idx) {
37 for (
int allow_null = 0; allow_null <= 1; ++allow_null) {
39 const char *test_str = test_strings[str_idx];
42 void *
buffer = malloc(pack_size);
45 "test", test_str,
buffer, (
int)pack_size, &pos, MPI_COMM_WORLD,
52 if (!unpacked || strcmp(unpacked, test_str) != 0) {
53 PUT_ERR(
"Normal string pack/unpack");
66 void *
buffer = malloc(pack_size);
69 "test", NULL,
buffer, (
int)pack_size, &pos, MPI_COMM_WORLD, allow_null);
74 if (unpacked != NULL) {
75 PUT_ERR(
"FAILED: NULL string pack/unpack");
size_t yac_string_get_pack_size(char const *caller, char const *string, MPI_Comm comm, int allow_null)
Compute number of bytes required to pack a string for MPI transport.
char * yac_string_unpack(void const *buffer, int buffer_size, int *position, MPI_Comm comm)
Unpack a C string from a buffer packed with yac_string_pack.
void yac_string_pack(char const *caller, char const *string, void *buffer, int buffer_size, int *position, MPI_Comm comm, int allow_null)
Pack a C string into a provided buffer using MPI_Pack semantics.