2727
2828#include "pdc_public.h"
2929#include "pdc_obj.h"
30+
3031#ifdef ENABLE_MPI
3132#include "mpi.h"
3233#endif
3334
35+ #define DIM_MAX 4
36+
3437/**************************/
3538/* Library Public Struct */
3639/**************************/
@@ -46,6 +49,13 @@ struct pdc_region_info {
4649 size_t unit ;
4750};
4851
52+ // Similar structure PDC_region_info_t defined in pdc_obj_pkg.h
53+ typedef struct region_info_transfer_t {
54+ size_t ndim ;
55+ uint64_t start [DIM_MAX ];
56+ uint64_t count [DIM_MAX ];
57+ } region_info_transfer_t ;
58+
4959typedef enum {
5060 PDC_TRANSFER_STATUS_COMPLETE = 0 ,
5161 PDC_TRANSFER_STATUS_PENDING = 1 ,
@@ -253,4 +263,129 @@ perr_t PDCreg_obtain_lock(pdcid_t obj_id, pdcid_t reg_id, pdc_access_t access_ty
253263 */
254264perr_t PDCreg_release_lock (pdcid_t obj_id , pdcid_t reg_id , pdc_access_t access_type );
255265
266+ /**
267+ * @brief Check if two region info transfers are identical.
268+ *
269+ * Compares two region info transfer structures (`reg1` and `reg2`) to determine if they
270+ * are equal. The comparison checks if all bytes within the structures match.
271+ *
272+ * @param reg1 [IN] Pointer to the first region info transfer to compare.
273+ * @param reg2 [IN] Pointer to the second region info transfer to compare.
274+ *
275+ * @return 1 if the region info transfers are identical, -1 otherwise.
276+ */
277+ pbool_t PDC_region_info_transfer_t_is_equal (const region_info_transfer_t * reg1 ,
278+ const region_info_transfer_t * reg2 );
279+
280+ /**
281+ * @brief Copy a region info transfer to another region.
282+ *
283+ * Copies the data from one region info transfer structure (`src_reg`) to another (`dest_reg`).
284+ *
285+ * @param src_reg [IN] Pointer to the source region info transfer to copy from.
286+ * @param dest_reg [OUT] Pointer to the destination region info transfer to copy to.
287+ *
288+ * @return Non-negative on success, negative on failure.
289+ */
290+ perr_t PDC_copy_region_info_transfer_t (const region_info_transfer_t * src_reg ,
291+ region_info_transfer_t * dest_reg );
292+
293+ /**
294+ * @brief Calculate the size of a region descriptor in bytes.
295+ *
296+ * This function computes the size of the region described by `src_reg` in bytes by
297+ * multiplying the size of each dimension by the element size (`unit`).
298+ * The size in bytes is computed as the product of all dimensions, scaled by `unit`.
299+ *
300+ * @param src_reg [IN] Pointer to the source region descriptor (in elements)
301+ * @param unit [IN] Size of each element in bytes
302+ * @param ndim [IN] Number of dimensions in the region descriptor
303+ *
304+ * @return The size of the region in bytes.
305+ */
306+ uint64_t PDC_get_region_desc_size_bytes (uint64_t * src_reg , int unit , int ndim );
307+
308+ /**
309+ * @brief Calculate the size of a region descriptor in elements from region desccriptor in bytes.
310+ *
311+ * This function computes the size of the region described by `src_reg` in terms of the
312+ * number of elements by dividing the given byte size by the element size (`unit`).
313+ *
314+ * @param src_reg [IN] Pointer to the source region descriptor (in bytes)
315+ * @param unit [IN] Size of each element in bytes
316+ * @param ndim [IN] Number of dimensions in the region descriptor
317+ *
318+ * @return The size of the region in terms of the number of elements.
319+ */
320+ uint64_t PDC_get_region_desc_size_from_bytes_to_elements (const uint64_t * src_reg , int unit , int ndim );
321+
322+ /**
323+ * @brief Calculate the total size of a region descriptor in elements.
324+ *
325+ * This function computes the total size of the region described by `src_reg`,
326+ * by multiplying the dimensions of the region. The size is returned in terms
327+ * of the number of elements, not bytes.
328+ *
329+ * @param src_reg [IN] Pointer to the source region descriptor (in elements)
330+ * @param ndim [IN] Number of dimensions in the region descriptor
331+ *
332+ * @return The total size of the region in terms of the number of elements.
333+ */
334+ uint64_t PDC_get_region_desc_size (const uint64_t * src_reg , int ndim );
335+
336+ /**
337+ * @brief Convert a region descriptor from byte units to element units.
338+ *
339+ * Copies the region dimensions from the source descriptor to the destination descriptor,
340+ * converting each dimension from bytes to elements by dividing by the element size.
341+ * For each dimension i:
342+ * dest_reg[i] = src_reg[i] / unit
343+ *
344+ * Both source and destination pointers must be non-null.
345+ *
346+ * @param src_reg [IN] Pointer to the source region descriptor (in bytes)
347+ * @param dest_reg [OUT] Pointer to the destination region descriptor (in elements)
348+ * @param unit [IN] Size of each element in bytes
349+ * @param ndim [IN] Number of dimensions in the region
350+ *
351+ * @return Non-negative on success, negative on failure.
352+ */
353+ perr_t PDC_copy_region_desc_bytes_to_elements (const uint64_t * src_reg , uint64_t * dest_reg , int unit ,
354+ int ndim );
355+
356+ /**
357+ * @brief Copy a region descriptor from source to destination without unit scaling.
358+ *
359+ * Copies each dimension from the source region descriptor to the destination region
360+ * descriptor without applying any scaling. The number of dimensions may differ between
361+ * source and destination, in which case only the common number of dimensions is copied.
362+ *
363+ * Validates that both source and destination pointers are not NULL.
364+ *
365+ * @param src_reg [IN] Pointer to the source region descriptor
366+ * @param dest_reg [OUT] Pointer to the destination region descriptor
367+ * @param src_ndim [IN] Number of dimensions in the source region
368+ * @param dest_ndim [IN] Number of dimensions in the destination region
369+ *
370+ * @return Non-negative on success, negative on failure.
371+ */
372+ perr_t PDC_copy_region_desc (const uint64_t * src_reg , uint64_t * dest_reg , int src_ndim , int dest_ndim );
373+
374+ /**
375+ * @brief Copy a region descriptor from element units to byte units.
376+ *
377+ * Sets each dimension of the destination region descriptor equal to the
378+ * corresponding dimension of the source descriptor multiplied by the element size in bytes.
379+ * For the i-th dimension: dest_reg[i] = src_reg[i] * unit
380+ *
381+ * @param src_reg [IN] Pointer to the source region descriptor (in elements)
382+ * @param dest_reg [OUT] Pointer to the destination region descriptor (in bytes)
383+ * @param unit [IN] Size of each element in bytes
384+ * @param dest_ndim [IN] Number of dimensions in the destination region
385+ *
386+ * @return Non-negative on success, negative on failure.
387+ */
388+ perr_t PDC_copy_region_desc_elements_to_bytes (const uint64_t * src_reg , uint64_t * dest_reg , int unit ,
389+ int dest_ndim );
390+
256391#endif /* PDC_REGION_H */
0 commit comments