-
Notifications
You must be signed in to change notification settings - Fork 22
/
Chap_API_Data_Mgmt.tex
630 lines (475 loc) · 24.5 KB
/
Chap_API_Data_Mgmt.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chapter: Data Packing and Unpacking
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Data Packing and Unpacking}
\label{chap:api_data_mgmt}
\ac{PMIx} intentionally does not include support for internode communications in the standard, instead relying on its host \ac{SMS} environment to transfer any needed data and/or requests between nodes. These operations frequently involve PMIx-defined public data structures that include binary data. Many \ac{HPC} clusters are homogeneous, and so transferring the structures can be done rather simply. However, greater effort is required in heterogeneous environments to ensure binary data is correctly transferred. \ac{PMIx} buffer manipulation functions are provided for this purpose via standardized interfaces to ease adoption.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Data Buffer Type}
\declarestruct{pmix_data_buffer_t}
The \refstruct{pmix_data_buffer_t} structure describes a data buffer used for packing and unpacking.
\copySignature{pmix_data_buffer_t}{2.0}{
typedef struct pmix_data_buffer \{ \\
\hspace*{4\sigspace}/** Start of my memory */ \\
\hspace*{4\sigspace}char *base_ptr; \\
\hspace*{4\sigspace}/** Where the next data will be packed to \\
\hspace*{8\sigspace}(within the allocated memory starting \\
\hspace*{8\sigspace}at base_ptr) */ \\
\hspace*{4\sigspace}char *pack_ptr; \\
\hspace*{4\sigspace}/** Where the next data will be unpacked \\
\hspace*{8\sigspace}from (within the allocated memory \\
\hspace*{8\sigspace}starting as base_ptr) */ \\
\hspace*{4\sigspace}char *unpack_ptr; \\
\hspace*{4\sigspace}/** Number of bytes allocated (starting \\
\hspace*{8\sigspace}at base_ptr) */ \\
\hspace*{4\sigspace}size_t bytes_allocated; \\
\hspace*{4\sigspace}/** Number of bytes used by the buffer \\
\hspace*{8\sigspace}(i.e., amount of data -- including \\
\hspace*{8\sigspace}overhead -- packed in the buffer) */ \\
\hspace*{4\sigspace}size_t bytes_used; \\
\} pmix_data_buffer_t;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Support Macros}
\label{chap:datamgt:macros}
\ac{PMIx} provides a set of convenience macros for creating, initiating, and releasing data buffers.
%%%%
\littleheader{Static initializer for the data buffer structure}
\declaremacroProvisional{PMIX_DATA_BUFFER_STATIC_INIT}
Provide a static initializer for the \refstruct{pmix_data_buffer_t} fields.
\versionMarker{5.0}
\cspecificstart
\begin{codepar}
PMIX_DATA_BUFFER_STATIC_INIT
\end{codepar}
\cspecificend
%%%%%%%%%%%
\littleheader{\code{PMIX_DATA_BUFFER_CREATE}}
\declaremacro{PMIX_DATA_BUFFER_CREATE}
Allocate memory for a \refstruct{pmix_data_buffer_t} object and initialize it.
This macro uses \textit{calloc} to allocate memory for the buffer and initialize all fields in it
\copySignature{PMIX_DATA_BUFFER_CREATE}{2.0}{
PMIX_DATA_BUFFER_CREATE(buffer);
}
\begin{arglist}
\argout{buffer}{Variable to be assigned the pointer to the allocated \refstruct{pmix_data_buffer_t} (handle)}
\end{arglist}
%%%%%%%%%%%
\littleheader{\code{PMIX_DATA_BUFFER_RELEASE}}
\declaremacro{PMIX_DATA_BUFFER_RELEASE}
Free a \refstruct{pmix_data_buffer_t} object and the data it contains.
Free's the data contained in the buffer, and then free's the buffer itself
\copySignature{PMIX_DATA_BUFFER_RELEASE}{2.0}{
PMIX_DATA_BUFFER_RELEASE(buffer);
}
\begin{arglist}
\argin{buffer}{Pointer to the \refstruct{pmix_data_buffer_t} to be released (handle)}
\end{arglist}
%%%%%%%%%%%
\littleheader{\code{PMIX_DATA_BUFFER_CONSTRUCT}}
\declaremacro{PMIX_DATA_BUFFER_CONSTRUCT}
Initialize a statically declared \refstruct{pmix_data_buffer_t} object.
\copySignature{PMIX_DATA_BUFFER_CONSTRUCT}{2.0}{
PMIX_DATA_BUFFER_CONSTRUCT(buffer);
}
\begin{arglist}
\argin{buffer}{Pointer to the allocated \refstruct{pmix_data_buffer_t} that is to be initialized (handle)}
\end{arglist}
%%%%%%%%%%%
\littleheader{\code{PMIX_DATA_BUFFER_DESTRUCT}}
\declaremacro{PMIX_DATA_BUFFER_DESTRUCT}
Release the data contained in a \refstruct{pmix_data_buffer_t} object.
\copySignature{PMIX_DATA_BUFFER_DESTRUCT}{2.0}{
PMIX_DATA_BUFFER_DESTRUCT(buffer);
}
\begin{arglist}
\argin{buffer}{Pointer to the \refstruct{pmix_data_buffer_t} whose data is to be released (handle)}
\end{arglist}
%%%%%%%%%%%
\littleheader{\code{PMIX_DATA_BUFFER_LOAD}}
\declaremacro{PMIX_DATA_BUFFER_LOAD}
Load a blob into a \refstruct{pmix_data_buffer_t} object.
Load the given data into the provided \refstruct{pmix_data_buffer_t} object, usually done in preparation for unpacking the provided data. Note that the data is \textit{not} copied into the buffer - thus, the blob must not be released until after operations on the buffer have completed.
\copySignature{PMIX_DATA_BUFFER_LOAD}{2.0}{
PMIX_DATA_BUFFER_LOAD(buffer, data, size);
}
\begin{arglist}
\argin{buffer}{Pointer to a pre-allocated \refstruct{pmix_data_buffer_t} (handle)}
\argin{data}{Pointer to a blob (\code{char*})}
\argin{size}{Number of bytes in the blob {\code{size_t}}}
\end{arglist}
%%%%%%%%%%%
\littleheader{\code{PMIX_DATA_BUFFER_UNLOAD}}
\declaremacro{PMIX_DATA_BUFFER_UNLOAD}
Unload the data from a \refstruct{pmix_data_buffer_t} object.
Extract the data in a buffer, assigning the pointer to the data (and the number of bytes in the blob) to the provided variables, usually done to transmit the blob to a remote process for unpacking. The buffer's internal pointer will be set to NULL to protect the data upon buffer destruct or release - thus, the user is responsible for releasing the blob when done with it.
\copySignature{PMIX_DATA_BUFFER_UNLOAD}{2.0}{
PMIX_DATA_BUFFER_UNLOAD(buffer, data, size);
}
\begin{arglist}
\argin{buffer}{Pointer to the \refstruct{pmix_data_buffer_t} whose data is to be extracted (handle)}
\argout{data}{Variable to be assigned the pointer to the extracted blob (\code{void*})}
\argout{size}{Variable to be assigned the number of bytes in the blob {\code{size_t}}}
\end{arglist}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{General Routines}
\label{chap:data_mgmt:general}
The following routines are provided to support internode transfers in heterogeneous environments.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_pack}}
\declareapi{PMIx_Data_pack}
%%%%
\summary
Pack one or more values of a specified type into a buffer, usually for transmission to another process.
%%%%
\format
\copySignature{PMIx_Data_pack}{2.0}{
pmix_status_t \\
PMIx_Data_pack(const pmix_proc_t *target, \\
\hspace*{15\sigspace}pmix_data_buffer_t *buffer, \\
\hspace*{15\sigspace}void *src, int32_t num_vals, \\
\hspace*{15\sigspace}pmix_data_type_t type);
}
\begin{arglist}
\argin{target}{Pointer to a \refstruct{pmix_proc_t} containing the nspace/rank of the process that will be unpacking the final buffer. A NULL value may be used to indicate that the target is based on the same \ac{PMIx} version as the caller. Note that only the target's nspace is relevant. (handle)}
\argin{buffer}{Pointer to a \refstruct{pmix_data_buffer_t} where the packed data is to be stored (handle)}
\argin{src}{Pointer to a location where the data resides. Strings are to be passed as (char **) --- i.e., the caller must pass the address of the pointer to the string as the (void*). This allows the caller to pass multiple strings in a single call. (memory reference)}
\argin{num_vals}{Number of elements pointed to by the \refarg{src} pointer. A string value is counted as a single value regardless of length. The values must be contiguous in memory. Arrays of pointers (e.g., string arrays) should be contiguous, although the data pointed to need not be contiguous across array entries.(\code{int32_t})}
\argin{type}{The type of the data to be packed (\refstruct{pmix_data_type_t})}
\end{arglist}
\returnstart
\begin{constantdesc}
\item \refconst{PMIX_ERR_BAD_PARAM} The provided buffer or src is \code{NULL}
\item \refconst{PMIX_ERR_UNKNOWN_DATA_TYPE} The specified data type is not known to this implementation
\item \refconst{PMIX_ERR_OUT_OF_RESOURCE} Not enough memory to support the operation
\end{constantdesc}
\returnend
%%%%
\descr
The pack function packs one or more values of a specified type into the specified buffer. The buffer must have already been
initialized via the \refmacro{PMIX_DATA_BUFFER_CREATE} or \refmacro{PMIX_DATA_BUFFER_CONSTRUCT}
macros --- otherwise, \refapi{PMIx_Data_pack} will return an error.
Providing an unsupported type flag will likewise be reported as an error.
Note that any data to be packed that is not hard type cast (i.e.,
not type cast to a specific size) may lose precision when unpacked
by a non-homogeneous recipient. The \refapi{PMIx_Data_pack} function will do its best to deal
with heterogeneity issues between the packer and unpacker in such
cases. Sending a number larger than can be handled by the recipient
will return an error code (generated upon unpacking) ---
the error cannot be detected during packing.
The namespace of the intended recipient of the packed buffer (i.e., the
process that will be unpacking it) is used solely to resolve any data type
differences between \ac{PMIx} versions. The recipient must, therefore, be
known to the user prior to calling the pack function so that the
\ac{PMIx} library is aware of the version the recipient is using. Note that
all processes in a given namespace are \textit{required} to use the same \ac{PMIx}
version --- thus, the caller must only know at least one process from the
target's namespace.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_unpack}}
\declareapi{PMIx_Data_unpack}
%%%%
\summary
Unpack values from a \refstruct{pmix_data_buffer_t}
%%%%
\format
\copySignature{PMIx_Data_unpack}{2.0}{
pmix_status_t \\
PMIx_Data_unpack(const pmix_proc_t *source, \\
\hspace*{17\sigspace}pmix_data_buffer_t *buffer, void *dest, \\
\hspace*{17\sigspace}int32_t *max_num_values, \\
\hspace*{17\sigspace}pmix_data_type_t type); \\
}
\begin{arglist}
\argin{source}{Pointer to a \refstruct{pmix_proc_t} structure containing the nspace/rank of the process that packed the provided buffer. A NULL value may be used to indicate that the source is based on the same \ac{PMIx} version as the caller. Note that only the source's nspace is relevant. (handle)}
\argin{buffer}{A pointer to the buffer from which the value will be extracted. (handle)}
\arginout{dest}{A pointer to the memory location into which the data is to be stored. Note that these values will be stored contiguously in memory. For strings, this pointer must be to (char**) to provide a means of supporting multiple string operations. The unpack function will allocate memory for each string in the array - the caller must only provide adequate memory for the array of pointers. (\code{void*})}
\arginout{max_num_values}{The number of values to be unpacked --- upon completion, the parameter will be set to the actual number of values unpacked. In most cases, this should match the maximum number provided in the parameters --- but in no case will it exceed the value of this parameter. Note that unpacking fewer values than are actually available will leave the buffer in an unpackable state --- the function will return an error code to warn of this condition.(\code{int32_t})}
\argin{type}{The type of the data to be unpacked --- must be one of the \ac{PMIx} defined data types (\refstruct{pmix_data_type_t})}
\end{arglist}
\returnstart
\begin{constantdesc}
\item \refconst{PMIX_ERR_BAD_PARAM} The provided buffer or dest is \code{NULL}
\item \refconst{PMIX_ERR_UNKNOWN_DATA_TYPE} The specified data type is not known to this implementation
\item \refconst{PMIX_ERR_OUT_OF_RESOURCE} Not enough memory to support the operation
\end{constantdesc}
\returnend
%%%%
\descr
The unpack function unpacks the next value (or values) of a specified type from the given buffer. The buffer must have already been initialized via an \refmacro{PMIX_DATA_BUFFER_CREATE} or \refmacro{PMIX_DATA_BUFFER_CONSTRUCT} call (and assumedly filled with some data) --- otherwise, the unpack_value function will return an error. Providing an unsupported type flag will likewise be reported as an error, as will specifying a data type that \textit{does not} match the type of the next item in the buffer. An attempt to read beyond the end of the stored data held in the buffer will also return an error.
Note that it is possible for the buffer to be corrupted and that \ac{PMIx} will \textit{think} there is a proper variable type at the beginning of an unpack region --- but that the value is bogus (e.g., just a byte field in a string array that so happens to have a value that matches the specified data type flag). Therefore, the data type error check is \textit{not} completely safe.
Unpacking values is a "nondestructive" process --- i.e., the values are not removed from the buffer. It is therefore possible for the caller to re-unpack a value from the same buffer by resetting the unpack_ptr.
Warning: The caller is responsible for providing adequate memory storage for the requested data. The user must provide a parameter indicating the maximum number of values that can be unpacked into the allocated memory. If more values exist in the buffer than can fit into the memory storage, then the function will unpack what it can fit into that location and return an error code indicating that the buffer was only partially unpacked.
Note that any data that was not hard type cast (i.e., not type cast to a specific size) when packed may lose precision when unpacked by a non-homogeneous recipient. \ac{PMIx} will do its best to deal with heterogeneity issues between the packer and unpacker in such cases. Sending a number larger than can be handled by the recipient will return an error code generated upon unpacking --- these errors cannot be detected during packing.
The namespace of the process that packed the buffer is used solely to resolve any data type
differences between \ac{PMIx} versions. The packer must, therefore, be
known to the user prior to calling the pack function so that the
\ac{PMIx} library is aware of the version the packer is using. Note that
all processes in a given namespace are \textit{required} to use the same \ac{PMIx}
version --- thus, the caller must only know at least one process from the
packer's namespace.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_copy}}
\declareapi{PMIx_Data_copy}
%%%%
\summary
Copy a data value from one location to another.
%%%%
\format
\copySignature{PMIx_Data_copy}{2.0}{
pmix_status_t \\
PMIx_Data_copy(void **dest, void *src, \\
\hspace*{15\sigspace}pmix_data_type_t type);
}
\begin{arglist}
\argin{dest}{The address of a pointer into which the address of the resulting data is to be stored. (\code{void**})}
\argin{src}{A pointer to the memory location from which the data is to be copied (handle)}
\argin{type}{The type of the data to be copied --- must be one of the PMIx defined data types. (\refstruct{pmix_data_type_t})}
\end{arglist}
\returnstart
\begin{constantdesc}
\item \refconst{PMIX_ERR_BAD_PARAM} The provided src or dest is \code{NULL}
\item \refconst{PMIX_ERR_UNKNOWN_DATA_TYPE} The specified data type is not known to this implementation
\item \refconst{PMIX_ERR_OUT_OF_RESOURCE} Not enough memory to support the operation
\end{constantdesc}
\returnend
%%%%
\descr
Since registered data types can be complex structures, the system needs some way to know how to copy the data from one location to another (e.g., for storage in the registry). This function, which can call other copy functions to build up complex data types, defines the method for making a copy of the specified data type.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_print}}
\declareapi{PMIx_Data_print}
%%%%
\summary
Pretty-print a data value.
%%%%
\format
\copySignature{PMIx_Data_print}{2.0}{
pmix_status_t \\
PMIx_Data_print(char **output, const char *prefix, \\
\hspace*{16\sigspace}void *src, pmix_data_type_t type);
}
\begin{arglist}
\argin{output}{The address of a pointer into which the address of the resulting output is to be stored. (\code{char**})}
\argin{prefix}{String to be prepended to the resulting output (\code{const char*})}
\argin{src}{A pointer to the memory location of the data value to be printed (handle)}
\argin{type}{The type of the data value to be printed --- must be one of the PMIx defined data types. (\refstruct{pmix_data_type_t})}
\end{arglist}
\returnstart
\begin{constantdesc}
\item \refconst{PMIX_ERR_BAD_PARAM} The provided data type is not recognized.
\end{constantdesc}
\returnend
%%%%
\descr
Since registered data types can be complex structures, the system needs some way to know how to print them (i.e., convert them to a string representation). Primarily for debug purposes.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_copy_payload}}
\declareapi{PMIx_Data_copy_payload}
%%%%
\summary
Copy a payload from one buffer to another
%%%%
\format
\copySignature{PMIx_Data_copy_payload}{2.0}{
pmix_status_t \\
PMIx_Data_copy_payload(pmix_data_buffer_t *dest, \\
\hspace*{23\sigspace}pmix_data_buffer_t *src);
}
\begin{arglist}
\argin{dest}{Pointer to the destination \refstruct{pmix_data_buffer_t} (handle)}
\argin{src}{Pointer to the source \refstruct{pmix_data_buffer_t} (handle)}
\end{arglist}
Returns one of the following:
\begin{constantdesc}
\item \refconst{PMIX_SUCCESS} The data has been copied as requested
\item \refconst{PMIX_ERR_BAD_PARAM} The src and dest \refstruct{pmix_data_buffer_t} types do not match
\item \refconst{PMIX_ERR_NOT_SUPPORTED} The \ac{PMIx} implementation does not support this function.
\end{constantdesc}
%%%%
\descr
This function will append a copy of the payload in one buffer into another buffer. Note that this is \textit{not} a destructive procedure --- the source buffer's payload will remain intact, as will any pre-existing payload in the destination's buffer. Only the unpacked portion of the source payload will be copied.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_load}}
\declareapi{PMIx_Data_load}
%%%%
\summary
Load a buffer with the provided payload
%%%%
\format
\versionMarkerProvisional{4.1}
\cspecificstart
\begin{codepar}
pmix_status_t
PMIx_Data_load(pmix_data_buffer_t *dest,
pmix_byte_object_t *src);
\end{codepar}
\cspecificend
\begin{arglist}
\argin{dest}{Pointer to the destination \refstruct{pmix_data_buffer_t} (handle)}
\argin{src}{Pointer to the source \refstruct{pmix_byte_object_t} (handle)}
\end{arglist}
Returns one of the following:
\begin{constantdesc}
\item \refconst{PMIX_SUCCESS} The data has been loaded as requested
\item \refconst{PMIX_ERR_BAD_PARAM} The \refarg{dest} structure pointer is \code{NULL}
\item \refconst{PMIX_ERR_NOT_SUPPORTED} The \ac{PMIx} implementation does not support this function.
\end{constantdesc}
%%%%
\descr
The load function allows the caller to transfer the contents of the \refarg{src}
\refstruct{pmix_byte_object_t} to the \refarg{dest} target buffer. If a payload
already exists in the buffer, the function will "free" the existing data to
release it, and then replace the data payload with the one provided
by the caller.
\adviceuserstart
The buffer must be allocated or constructed in advance - failing to do so
will cause the load function to return an error code.
The caller is responsible for pre-packing the provided
payload. For example, the load function cannot convert to network byte order
any data contained in the provided payload.
\adviceuserend
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_unload}}
\declareapi{PMIx_Data_unload}
%%%%
\summary
Unload a buffer into a byte object
%%%%
\format
\versionMarkerProvisional{4.1}
\cspecificstart
\begin{codepar}
pmix_status_t
PMIx_Data_unload(pmix_data_buffer_t *src,
pmix_byte_object_t *dest);
\end{codepar}
\cspecificend
\begin{arglist}
\argin{src}{Pointer to the source \refstruct{pmix_data_buffer_t} (handle)}
\argin{dest}{Pointer to the destination \refstruct{pmix_byte_object_t} (handle)}
\end{arglist}
\returnstart
\begin{constantdesc}
\item \refconst{PMIX_ERR_BAD_PARAM} The destination and/or source pointer is \code{NULL}
\end{constantdesc}
\returnend
%%%%
\descr
The unload function provides the caller with a pointer to the
portion of the data payload within the buffer that has not yet been
unpacked, along with the size of that region. Any portion of
the payload that was previously unpacked using the \refapi{PMIx_Data_unpack}
routine will be ignored. This allows the user to directly access the payload.
\adviceuserstart
This is a destructive operation. While the payload returned in the
destination \refstruct{pmix_byte_object_t} is
undisturbed, the function will clear the \refarg{src}'s pointers to the
payload. Thus, the \refarg{src} and the payload are completely separated,
leaving the caller able to free or destruct the \refarg{src}.
\adviceuserend
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_compress}}
\declareapi{PMIx_Data_compress}
%%%%
\summary
Perform a lossless compression on the provided data
%%%%
\format
\versionMarkerProvisional{4.1}
\cspecificstart
\begin{codepar}
bool
PMIx_Data_compress(const uint8_t *inbytes, size_t size,
uint8_t **outbytes, size_t *nbytes);
\end{codepar}
\cspecificend
\begin{arglist}
\argin{inbytes}{Pointer to the source data (handle)}
\argin{size}{Number of bytes in the source data region (\code{size_t})}
\argout{outbytes}{Address where the pointer to the compressed data region is to be returned (handle)}
\argout{nbytes}{Address where the number of bytes in the compressed data region is to be returned (handle)}
\end{arglist}
Returns one of the following:
\begin{itemize}
\item \code{True} The data has been compressed as requested
\item \code{False} The data has not been compressed
\end{itemize}
%%%%
\descr
Compress the provided data block. Destination memory
will be allocated if operation is successfully concluded. Caller
is responsible for release of the allocated region. The input
data block will remain unaltered.
Note: the compress function will return \code{False} if the operation
would not result in a smaller data block.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_decompress}}
\declareapi{PMIx_Data_decompress}
%%%%
\summary
Decompress the provided data
%%%%
\format
\versionMarkerProvisional{4.1}
\cspecificstart
\begin{codepar}
bool
PMIx_Data_decompress(const uint8_t *inbytes, size_t size,
uint8_t **outbytes, size_t *nbytes);
\end{codepar}
\cspecificend
\begin{arglist}
\argout{outbytes}{Address where the pointer to the decompressed data region is to be returned (handle)}
\argout{nbytes}{Address where the number of bytes in the decompressed data region is to be returned (handle)}
\argin{inbytes}{Pointer to the source data (handle)}
\argin{size}{Number of bytes in the source data region (\code{size_t})}
\end{arglist}
Returns one of the following:
\begin{itemize}
\item \code{True} The data has been decompressed as requested
\item \code{False} The data has not been decompressed
\end{itemize}
%%%%
\descr
Decompress the provided data block. Destination memory
will be allocated if operation is successfully concluded. Caller
is responsible for release of the allocated region. The input
data block will remain unaltered.
Only data compressed by the \refapi{PMIx_Data_compress} \ac{API}
can be decompressed by this function. Passing data that has not
been compressed by \refapi{PMIx_Data_compress} will lead to
unexpected and potentially catastrophic results.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\code{PMIx_Data_embed}}
\declareapiProvisional{PMIx_Data_embed}
%%%%
\summary
Embed a data payload into a buffer
%%%%
\format
\versionMarker{5.0}
\cspecificstart
\begin{codepar}
pmix_status_t
PMIx_Data_embed(pmix_data_buffer_t *buffer,
const pmix_byte_object_t *payload);
\end{codepar}
\cspecificend
\begin{arglist}
\argout{buffer}{Address of the buffer where the payload is to be embedded (handle)}
\argin{payload}{Address of the \refstruct{pmix_byte_object_t} structure containing the data to be embedded into the buffer (handle)}
\end{arglist}
Returns one of the following:
\begin{constantdesc}
\item \refconst{PMIX_SUCCESS} The data has been embedded as requested
\item \refconst{PMIX_ERR_BAD_PARAM} The destination and/or source pointer is \code{NULL}
\item \refconst{PMIX_ERR_NOT_SUPPORTED} The \ac{PMIx} implementation does not support this function.
\end{constantdesc}
%%%%
\descr
The embed function is identical in operation to \refapi{PMIx_Data_load}
except that it does \emph{not} clear the payload object upon completion.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%